Преглед на файлове

Add target setup for directional-spot lights when loading from glTF

Michael Bond преди 7 години
родител
ревизия
f22daf7e6d
променени са 2 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. 4 0
      examples/js/loaders/GLTFLoader.js
  2. 2 3
      examples/webgl_loader_gltf_extensions.html

+ 4 - 0
examples/js/loaders/GLTFLoader.js

@@ -244,6 +244,8 @@ THREE.GLTFLoader = ( function () {
 
 				case 'directional':
 					lightNode = new THREE.DirectionalLight( color );
+					lightNode.target.position.set( 0, 0, 1 );
+					lightNode.add( lightNode.target );
 					break;
 
 				case 'point':
@@ -258,6 +260,8 @@ THREE.GLTFLoader = ( function () {
 					var outerConeAngle = spot.outerConeAngle !== undefined ? spot.outerConeAngle : Math.PI / 4.0;
 					lightNode.angle = outerConeAngle;
 					lightNode.penumbra = 1.0 - innerConeAngle / outerConeAngle;
+					lightNode.target.position.set( 0, 0, 1 );
+					lightNode.add( lightNode.target );
 					break;
 
 				case 'ambient':

+ 2 - 3
examples/webgl_loader_gltf_extensions.html

@@ -145,14 +145,13 @@
 					var ambient = new THREE.AmbientLight( 0x222222 );
 					scene.add( ambient );
 
-					var directionalLight = new THREE.DirectionalLight( 0xdddddd );
+					var directionalLight = new THREE.DirectionalLight( 0xdddddd, 4 );
 					directionalLight.position.set( 0, 0, 1 ).normalize();
 					scene.add( directionalLight );
 
-					spot1   = new THREE.SpotLight( 0xffffff, 1 );
+					spot1   = new THREE.SpotLight( 0xffffff, 2 );
 					spot1.position.set( 10, 20, 10 );
 					spot1.angle = 0.25;
-					spot1.distance = 1024;
 					spot1.penumbra = 0.75;
 
 					if ( sceneInfo.shadows ) {