forked from nxxcxx/Neural-Network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.js
86 lines (71 loc) · 2.08 KB
/
scene.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
74
75
76
77
78
79
80
81
82
83
84
85
86
// Scene --------------------------------------------------------
/* exported updateHelpers */
if ( !Detector.webgl ) {
Detector.addGetWebGLMessage();
}
var container, stats;
var scene, light, camera, cameraCtrl, renderer;
var WIDTH = window.innerWidth;
var HEIGHT = window.innerHeight;
var pixelRatio = window.devicePixelRatio || 1;
var screenRatio = WIDTH / HEIGHT;
var clock = new THREE.Clock();
var FRAME_COUNT = 0;
// ---- Settings
var sceneSettings = {
pause: false,
bgColor: 0x111115,
enableGridHelper: false,
enableAxisHelper: false
};
// ---- Scene
container = document.getElementById( 'canvas-container' );
scene = new THREE.Scene();
// ---- Camera
camera = new THREE.PerspectiveCamera( 75, screenRatio, 10, 5000 );
// camera orbit control
cameraCtrl = new THREE.OrbitControls( camera, container );
cameraCtrl.object.position.y = 500;
cameraCtrl.object.position.x = 50;
cameraCtrl.object.position.z = 150;
cameraCtrl.update();
// ---- Renderer
renderer = new THREE.WebGLRenderer( {
antialias: true,
alpha: true
} );
renderer.setSize( WIDTH, HEIGHT );
renderer.setPixelRatio( pixelRatio );
renderer.setClearColor( sceneSettings.bgColor, 1 );
renderer.autoClear = false;
// container.appendChild( renderer.domElement );
// ---- Stats
stats = new Stats();
// container.appendChild( stats.domElement );
// ---- grid & axis helper
var gridHelper = new THREE.GridHelper( 600, 50 );
gridHelper.setColors( 0x00bbff, 0xffffff );
gridHelper.material.opacity = 0.1;
gridHelper.material.transparent = true;
gridHelper.position.y = -300;
scene.add( gridHelper );
var axisHelper = new THREE.AxisHelper( 50 );
scene.add( axisHelper );
function updateHelpers() {
axisHelper.visible = sceneSettings.enableAxisHelper;
gridHelper.visible = sceneSettings.enableGridHelper;
}
/*
// ---- Lights
// back light
light = new THREE.DirectionalLight( 0xffffff, 0.8 );
light.position.set( 100, 230, -100 );
scene.add( light );
// hemi
light = new THREE.HemisphereLight( 0x00ffff, 0x29295e, 1 );
light.position.set( 370, 200, 20 );
scene.add( light );
// ambient
light = new THREE.AmbientLight( 0x111111 );
scene.add( light );
*/