|
37 | 37 | container = document.createElement( 'div' );
|
38 | 38 | document.body.appendChild( container );
|
39 | 39 |
|
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 ); |
49 | 41 | camera.position.z = 1000;
|
50 | 42 |
|
51 | 43 | scene = new THREE.Scene();
|
52 | 44 |
|
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 ); |
54 | 48 | light.position.set( 0, 500, 2000 );
|
55 | 49 | light.castShadow = true;
|
56 | 50 | scene.addLight( light );
|
|
77 | 71 |
|
78 | 72 | }
|
79 | 73 |
|
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 ); |
81 | 76 | plane.visible = false;
|
82 | 77 | scene.addObject( plane );
|
83 | 78 |
|
84 | 79 | projector = new THREE.Projector();
|
85 | 80 |
|
86 |
| - renderer = new THREE.WebGLRenderer( { antialias: true } ); |
| 81 | + renderer = new THREE.WebGLRenderer( { antialias : true } ); |
87 | 82 | renderer.sortObjects = false;
|
88 | 83 | renderer.setSize( window.innerWidth, window.innerHeight );
|
89 | 84 |
|
| 85 | + renderer.shadowMapEnabled = true; |
| 86 | + renderer.shadowMapSoft = true; |
| 87 | + |
90 | 88 | renderer.shadowCameraNear = 3;
|
91 | 89 | renderer.shadowCameraFar = camera.far;
|
92 |
| - renderer.shadowCameraFov = 30; |
| 90 | + renderer.shadowCameraFov = 50; |
93 | 91 |
|
94 |
| - renderer.shadowMapBias = 0.00389; |
| 92 | + renderer.shadowMapBias = 0.0039; |
95 | 93 | renderer.shadowMapDarkness = 0.5;
|
96 | 94 | renderer.shadowMapWidth = 1024;
|
97 | 95 | renderer.shadowMapHeight = 1024;
|
98 | 96 |
|
99 |
| - renderer.shadowMapEnabled = true; |
100 |
| - renderer.shadowMapSoft = true; |
| 97 | + container.appendChild( renderer.domElement ); |
101 | 98 |
|
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 ); |
103 | 106 |
|
104 | 107 | stats = new Stats();
|
105 | 108 | stats.domElement.style.position = 'absolute';
|
106 | 109 | stats.domElement.style.top = '0px';
|
107 | 110 | container.appendChild( stats.domElement );
|
108 | 111 |
|
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 ); |
112 | 115 |
|
113 | 116 | }
|
114 | 117 |
|
|
186 | 189 | container.style.cursor = 'move';
|
187 | 190 |
|
188 | 191 | }
|
| 192 | + |
189 | 193 | }
|
190 | 194 |
|
191 | 195 | function onDocumentMouseUp( event ) {
|
|
0 commit comments