examples/FBXLoader.js
function ( relationships ) {

			var model;
			var lightAttribute;

			relationships.children.forEach( function ( child ) {

				var attr = fbxTree.Objects.NodeAttribute[ child.ID ];

				if ( attr !== undefined ) {

					lightAttribute = attr;

				}

			} );

			if ( lightAttribute === undefined ) {

				model = new THREE.Object3D();

			} else {

				var type;

				// LightType can be undefined for Point lights
				if ( lightAttribute.LightType === undefined ) {

					type = 0;

				} else {

					type = lightAttribute.LightType.value;

				}

				var color = 0xffffff;

				if ( lightAttribute.Color !== undefined ) {

					color = new THREE.Color().fromArray( lightAttribute.Color.value );

				}

				var intensity = ( lightAttribute.Intensity === undefined ) ? 1 : lightAttribute.Intensity.value / 100;

				// light disabled
				if ( lightAttribute.CastLightOnObject !== undefined && lightAttribute.CastLightOnObject.value === 0 ) {

					intensity = 0;

				}

				var distance = 0;
				if ( lightAttribute.FarAttenuationEnd !== undefined ) {

					if ( lightAttribute.EnableFarAttenuation !== undefined && lightAttribute.EnableFarAttenuation.value === 0 ) {

						distance = 0;

					} else {

						distance = lightAttribute.FarAttenuationEnd.value;

					}

				}

				// TODO: could this be calculated linearly from FarAttenuationStart to FarAttenuationEnd?
				var decay = 1;

				switch ( type ) {

					case 0: // Point
						model = new THREE.PointLight( color, intensity, distance, decay );
						break;

					case 1: // Directional
						model = new THREE.DirectionalLight( color, intensity );
						break;

					case 2: // Spot
						var angle = Math.PI / 3;

						if ( lightAttribute.InnerAngle !== undefined ) {

							angle = THREE.Math.degToRad( lightAttribute.InnerAngle.value );

						}

						var penumbra = 0;
						if ( lightAttribute.OuterAngle !== undefined ) {

						// TODO: this is not correct - FBX calculates outer and inner angle in degrees
						// with OuterAngle > InnerAngle && OuterAngle <= Math.PI
						// while three.js uses a penumbra between (0, 1) to attenuate the inner angle
							penumbra = THREE.Math.degToRad( lightAttribute.OuterAngle.value );
							penumbra = Math.max( penumbra, 1 );

						}

						model = new THREE.SpotLight( color, intensity, distance, angle, penumbra, decay );
						break;

					default:
						console.warn( 'THREE.FBXLoader: Unknown light type ' + lightAttribute.LightType.value + ', defaulting to a THREE.PointLight.' );
						model = new THREE.PointLight( color, intensity );
						break;

				}

				if ( lightAttribute.CastShadows !== undefined && lightAttribute.CastShadows.value === 1 ) {

					model.castShadow = true;

				}

			}

			return model;

		}
function ( relationships ) {

			var model;
			var lightAttribute;

			relationships.children.forEach( function ( child ) {

				var attr = fbxTree.Objects.NodeAttribute[ child.ID ];

				if ( attr !== undefined ) {

					lightAttribute = attr;

				}

			} );

			if ( lightAttribute === undefined ) {

				model = new THREE.Object3D();

			} else {

				var type;

				// LightType can be undefined for Point lights
				if ( lightAttribute.LightType === undefined ) {

					type = 0;

				} else {

					type = lightAttribute.LightType.value;

				}

				var color = 0xffffff;

				if ( lightAttribute.Color !== undefined ) {

					color = new THREE.Color().fromArray( lightAttribute.Color.value );

				}

				var intensity = ( lightAttribute.Intensity === undefined ) ? 1 : lightAttribute.Intensity.value / 100;

				// light disabled
				if ( lightAttribute.CastLightOnObject !== undefined && lightAttribute.CastLightOnObject.value === 0 ) {

					intensity = 0;

				}

				var distance = 0;
				if ( lightAttribute.FarAttenuationEnd !== undefined ) {

					if ( lightAttribute.EnableFarAttenuation !== undefined && lightAttribute.EnableFarAttenuation.value === 0 ) {

						distance = 0;

					} else {

						distance = lightAttribute.FarAttenuationEnd.value;

					}

				}

				// TODO: could this be calculated linearly from FarAttenuationStart to FarAttenuationEnd?
				var decay = 1;

				switch ( type ) {

					case 0: // Point
						model = new THREE.PointLight( color, intensity, distance, decay );
						break;

					case 1: // Directional
						model = new THREE.DirectionalLight( color, intensity );
						break;

					case 2: // Spot
						var angle = Math.PI / 3;

						if ( lightAttribute.InnerAngle !== undefined ) {

							angle = THREE.Math.degToRad( lightAttribute.InnerAngle.value );

						}

						var penumbra = 0;
						if ( lightAttribute.OuterAngle !== undefined ) {

						// TODO: this is not correct - FBX calculates outer and inner angle in degrees
						// with OuterAngle > InnerAngle && OuterAngle <= Math.PI
						// while three.js uses a penumbra between (0, 1) to attenuate the inner angle
							penumbra = THREE.Math.degToRad( lightAttribute.OuterAngle.value );
							penumbra = Math.max( penumbra, 1 );

						}

						model = new THREE.SpotLight( color, intensity, distance, angle, penumbra, decay );
						break;

					default:
						console.warn( 'THREE.FBXLoader: Unknown light type ' + lightAttribute.LightType.value + ', defaulting to a THREE.PointLight.' );
						model = new THREE.PointLight( color, intensity );
						break;

				}

				if ( lightAttribute.CastShadows !== undefined && lightAttribute.CastShadows.value === 1 ) {

					model.castShadow = true;

				}

			}

			return model;

		}
function ( relationships ) { var model ; var lightAttribute ; relationships . children . forEach ( function ( child ) { var attr = fbxTree . Objects . NodeAttribute [ child . ID ] ; if ( attr !== undefined ) { lightAttribute = attr ; } } ) ; if ( lightAttribute === undefined ) { model = new THREE . Object3D ( ) ; } else { var type ; // LightType can be undefined for Point lights if ( lightAttribute . LightType === undefined ) { type = 0 ; } else { type = lightAttribute . LightType . value ; } var color = 0xffffff ; if ( lightAttribute . Color !== undefined ) { color = new THREE . Color ( ) . fromArray ( lightAttribute . Color . value ) ; } var intensity = ( lightAttribute . Intensity === undefined ) ? 1 : lightAttribute . Intensity . value / 100 ; // light disabled if ( lightAttribute . CastLightOnObject !== undefined && lightAttribute . CastLightOnObject . value === 0 ) { intensity = 0 ; } var distance = 0 ; if ( lightAttribute . FarAttenuationEnd !== undefined ) { if ( lightAttribute . EnableFarAttenuation !== undefined && lightAttribute . EnableFarAttenuation . value === 0 ) { distance = 0 ; } else { distance = lightAttribute . FarAttenuationEnd . value ; } } // TODO: could this be calculated linearly from FarAttenuationStart to FarAttenuationEnd? var decay = 1 ; switch ( type ) { case 0 : // Point model = new THREE . PointLight ( color , intensity , distance , decay ) ; break ; case 1 : // Directional model = new THREE . DirectionalLight ( color , intensity ) ; break ; case 2 : // Spot var angle = Math . PI / 3 ; if ( lightAttribute . InnerAngle !== undefined ) { angle = THREE . Math . degToRad ( lightAttribute . InnerAngle . value ) ; } var penumbra = 0 ; if ( lightAttribute . OuterAngle !== undefined ) { // TODO: this is not correct - FBX calculates outer and inner angle in degrees // with OuterAngle > InnerAngle && OuterAngle <= Math.PI // while three.js uses a penumbra between (0, 1) to attenuate the inner angle penumbra = THREE . Math . degToRad ( lightAttribute . OuterAngle . value ) ; penumbra = Math . max ( penumbra , 1 ) ; } model = new THREE . SpotLight ( color , intensity , distance , angle , penumbra , decay ) ; break ; default : console . warn ( 'THREE.FBXLoader: Unknown light type ' + lightAttribute . LightType . value + ', defaulting to a THREE.PointLight.' ) ; model = new THREE . PointLight ( color , intensity ) ; break ; } if ( lightAttribute . CastShadows !== undefined && lightAttribute . CastShadows . value === 1 ) { model . castShadow = true ; } } return model ; }
Create a THREE.DirectionalLight, THREE.PointLight or THREE.SpotLight
Create a THREE . DirectionalLight THREE . PointLight or THREE . SpotLight