Skip to content

Commit 89079b9

Browse files
committed
Fixed mouse listeners on draggable cubes example, also reverted to previous aesthetic (sorry @alteredq).
1 parent aac9143 commit 89079b9

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

examples/webgl_interactive_draggablecubes.html

+24-20
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,14 @@
3737
container = document.createElement( 'div' );
3838
document.body.appendChild( container );
3939

40-
var info = document.createElement( 'div' );
41-
info.style.position = 'absolute';
42-
info.style.top = '10px';
43-
info.style.width = '100%';
44-
info.style.textAlign = 'center';
45-
info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> webgl - draggable cubes';
46-
container.appendChild( info );
47-
48-
camera = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 5000 );
40+
camera = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 10000 );
4941
camera.position.z = 1000;
5042

5143
scene = new THREE.Scene();
5244

53-
var light = new THREE.SpotLight( 0xffffff, 2 );
45+
scene.addLight( new THREE.AmbientLight( 0x505050 ) );
46+
47+
var light = new THREE.SpotLight( 0xffffff, 1.5 );
5448
light.position.set( 0, 500, 2000 );
5549
light.castShadow = true;
5650
scene.addLight( light );
@@ -77,38 +71,47 @@
7771

7872
}
7973

80-
plane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.5, wireframe: true } ) );
74+
plane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.25, transparent: true, wireframe: true } ) );
75+
plane.lookAt( camera.position );
8176
plane.visible = false;
8277
scene.addObject( plane );
8378

8479
projector = new THREE.Projector();
8580

86-
renderer = new THREE.WebGLRenderer( { antialias: true } );
81+
renderer = new THREE.WebGLRenderer( { antialias : true } );
8782
renderer.sortObjects = false;
8883
renderer.setSize( window.innerWidth, window.innerHeight );
8984

85+
renderer.shadowMapEnabled = true;
86+
renderer.shadowMapSoft = true;
87+
9088
renderer.shadowCameraNear = 3;
9189
renderer.shadowCameraFar = camera.far;
92-
renderer.shadowCameraFov = 30;
90+
renderer.shadowCameraFov = 50;
9391

94-
renderer.shadowMapBias = 0.00389;
92+
renderer.shadowMapBias = 0.0039;
9593
renderer.shadowMapDarkness = 0.5;
9694
renderer.shadowMapWidth = 1024;
9795
renderer.shadowMapHeight = 1024;
9896

99-
renderer.shadowMapEnabled = true;
100-
renderer.shadowMapSoft = true;
97+
container.appendChild( renderer.domElement );
10198

102-
container.appendChild(renderer.domElement);
99+
var info = document.createElement( 'div' );
100+
info.style.position = 'absolute';
101+
info.style.top = '10px';
102+
info.style.width = '100%';
103+
info.style.textAlign = 'center';
104+
info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> webgl - draggable cubes';
105+
container.appendChild( info );
103106

104107
stats = new Stats();
105108
stats.domElement.style.position = 'absolute';
106109
stats.domElement.style.top = '0px';
107110
container.appendChild( stats.domElement );
108111

109-
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
110-
document.addEventListener( 'mousedown', onDocumentMouseDown, false );
111-
document.addEventListener( 'mouseup', onDocumentMouseUp, false );
112+
renderer.domElement.addEventListener( 'mousemove', onDocumentMouseMove, false );
113+
renderer.domElement.addEventListener( 'mousedown', onDocumentMouseDown, false );
114+
renderer.domElement.addEventListener( 'mouseup', onDocumentMouseUp, false );
112115

113116
}
114117

@@ -186,6 +189,7 @@
186189
container.style.cursor = 'move';
187190

188191
}
192+
189193
}
190194

191195
function onDocumentMouseUp( event ) {

0 commit comments

Comments
 (0)