-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
73 lines (64 loc) · 1.84 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var THREE = require('three');
window.THREE = THREE;
var ManagedView = require('./');
var loadAndRunScripts = require('loadandrunscripts');
var Resize = require('input-resize');
loadAndRunScripts(
[
'lib/stats.min.js',
'lib/threex.rendererstats.js'
],
function() {
var containerDiv = document.createElement('div');
containerDiv.id = 'threejsContainer';
document.getElementsByTagName('body')[0].appendChild(containerDiv);
console.log(containerDiv);
containerDiv.style.position = 'absolute';
containerDiv.style.left = '25%';
containerDiv.style.top = '25%';
containerDiv.style.width = '50%';
containerDiv.style.height = '50%';
Resize.minWidth = 600;
Resize.minHeight = 400;
var view = new ManagedView.View({
stats: true,
canvasContainer: containerDiv,
adaptiveResolution: false,
adaptiveResolutionSettings: {
upgradeWhen: 55,
degradeWhen: 50
},
useRafPolyfill: false
});
view.camera.position.y = 0;
view.camera.lookAt(new THREE.Vector3());
var cols = 30;
var rows = 30;
var minX = -6;
var minY = -6;
var rangeX = 12;
var rangeY = 12;
var geom = new THREE.SphereGeometry(.1, 16, 16);
var mat = new THREE.MeshBasicMaterial();
for (var ix = cols - 1; ix > 0; ix--) {
var ratioX = ix / cols;
for (var iy = rows - 1; iy > 0; iy--) {
var ratioY = iy / rows;
var mesh = new THREE.Mesh(geom, mat);
mesh.position.x = minX + ratioX * rangeX;
mesh.position.y = minY + ratioY * rangeX;
view.scene.add(mesh);
};
};
// setTimeout(function() {
// var format = 'jpeg';
// var imageData = view.captureImageData({
// width: 1920,
// height: 1080,
// format: format
// });
// var image = imageData.replace("image/"+format, "image/octet-stream"); //Convert image to 'octet-stream' (Just a download, really)
// window.location.href = image;
// });
}
)