|
@@ -36,7 +36,7 @@
|
|
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
|
|
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
|
|
|
|
|
|
var camera, scene, renderer, stats;
|
|
var camera, scene, renderer, stats;
|
|
- var dirLight, pointLight;
|
|
|
|
|
|
+ var pointLight, pointLight2;
|
|
var torusKnot;
|
|
var torusKnot;
|
|
var cubeMaterial;
|
|
var cubeMaterial;
|
|
var wallMaterial;
|
|
var wallMaterial;
|
|
@@ -67,40 +67,34 @@
|
|
var ambient = new THREE.AmbientLight( 0x404040 );
|
|
var ambient = new THREE.AmbientLight( 0x404040 );
|
|
scene.add( ambient );
|
|
scene.add( ambient );
|
|
|
|
|
|
- pointLight = new THREE.PointLight( 0xffffff );
|
|
|
|
- pointLight.castShadow = true;
|
|
|
|
- pointLight.shadowCameraNear = 1;
|
|
|
|
- pointLight.shadowCameraFar = 30;
|
|
|
|
- pointLight.shadowDarkness = 0.5;
|
|
|
|
- // pointLight.shadowCameraVisible = true;
|
|
|
|
- pointLight.shadowMapWidth = 2048;
|
|
|
|
- pointLight.shadowMapHeight = 1024;
|
|
|
|
- pointLight.shadowBias = 0.01;
|
|
|
|
- scene.add( pointLight );
|
|
|
|
|
|
+ function createLight( color ) {
|
|
|
|
|
|
- var geometry = new THREE.SphereGeometry( 0.3, 32, 32 );
|
|
|
|
- var material = new THREE.MeshBasicMaterial( { color: 0xffffff } );
|
|
|
|
- var sphere = new THREE.Mesh( geometry, material );
|
|
|
|
- sphere.castShadow = false;
|
|
|
|
- sphere.receiveShadow = false;
|
|
|
|
- pointLight.add( sphere );
|
|
|
|
|
|
+ var pointLight = new THREE.PointLight( color );
|
|
|
|
+ pointLight.castShadow = true;
|
|
|
|
+ pointLight.shadowCameraNear = 1;
|
|
|
|
+ pointLight.shadowCameraFar = 30;
|
|
|
|
+ pointLight.shadowDarkness = 0.5;
|
|
|
|
+ // pointLight.shadowCameraVisible = true;
|
|
|
|
+ pointLight.shadowMapWidth = 2048;
|
|
|
|
+ pointLight.shadowMapHeight = 1024;
|
|
|
|
+ pointLight.shadowBias = 0.01;
|
|
|
|
|
|
- /*
|
|
|
|
- dirLight = new THREE.DirectionalLight( 0xffffff, 1 );
|
|
|
|
- dirLight.position.set( 0, 50, 0 );
|
|
|
|
- dirLight.castShadow = true;
|
|
|
|
- dirLight.shadowCameraNear = 1;
|
|
|
|
- dirLight.shadowCameraFar = 100;
|
|
|
|
- dirLight.shadowCameraRight = 15;
|
|
|
|
- dirLight.shadowCameraLeft = -15;
|
|
|
|
- dirLight.shadowCameraTop = 15;
|
|
|
|
- dirLight.shadowCameraBottom = -15;
|
|
|
|
- dirLight.shadowDarkness = 0.5;
|
|
|
|
- dirLight.shadowCameraVisible = true;
|
|
|
|
- dirLight.shadowMapWidth = 1024;
|
|
|
|
- dirLight.shadowMapHeight = 1024;
|
|
|
|
- scene.add( dirLight );
|
|
|
|
- */
|
|
|
|
|
|
+ var geometry = new THREE.SphereGeometry( 0.3, 32, 32 );
|
|
|
|
+ var material = new THREE.MeshBasicMaterial( { color: color } );
|
|
|
|
+ var sphere = new THREE.Mesh( geometry, material );
|
|
|
|
+ sphere.castShadow = false;
|
|
|
|
+ sphere.receiveShadow = false;
|
|
|
|
+ pointLight.add( sphere );
|
|
|
|
+
|
|
|
|
+ return pointLight
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pointLight = createLight( 0xffffff );
|
|
|
|
+ scene.add( pointLight );
|
|
|
|
+
|
|
|
|
+ pointLight2 = createLight( 0xff0000 );
|
|
|
|
+ scene.add( pointLight2 );
|
|
|
|
|
|
cubeMaterial = new THREE.MeshPhongMaterial( {
|
|
cubeMaterial = new THREE.MeshPhongMaterial( {
|
|
color: 0xff0000,
|
|
color: 0xff0000,
|
|
@@ -227,6 +221,12 @@
|
|
pointLight.position.y = Math.sin( time * 1.1 ) * 9 + 5;
|
|
pointLight.position.y = Math.sin( time * 1.1 ) * 9 + 5;
|
|
pointLight.position.z = Math.sin( time * 1.2 ) * 9;
|
|
pointLight.position.z = Math.sin( time * 1.2 ) * 9;
|
|
|
|
|
|
|
|
+ time += 10000;
|
|
|
|
+
|
|
|
|
+ pointLight2.position.x = Math.sin( time ) * 9;
|
|
|
|
+ pointLight2.position.y = Math.sin( time * 1.1 ) * 9 + 5;
|
|
|
|
+ pointLight2.position.z = Math.sin( time * 1.2 ) * 9;
|
|
|
|
+
|
|
renderScene();
|
|
renderScene();
|
|
|
|
|
|
torusKnot.rotation.y = time * 0.1;
|
|
torusKnot.rotation.y = time * 0.1;
|