Hi, I’m new to Three.js, and I have a problem about directional light.
The code is as follows:
//Model loader
const loader = new GLTFLoader().setPath( 'models/gltf/' );
loader.setKTX2Loader( ktx2Loader );
loader.setMeshoptDecoder( MeshoptDecoder );
loader.load( 'cpt0826.glb', function ( gltf ) {
gltf.scene.position.x = 0;
gltf.scene.position.y = 0;
gltf.scene.position.z = 0;
gltf.scene.scale.set(10, 10, 10);
scene.add( gltf.scene );
// Directioal light
directionalLight = new THREE.DirectionalLight(0x999999,0.8);
// directionalLight.castShadow = true;
directionalLight.position.set(500, 1100, 500);
directionalLight.target = gltf.scene;
directionalLight.shadow.radius = 0.5;
directionalLight.shadow.camera.near = 100;
directionalLight.shadow.camera.far = 3000;
directionalLight.shadow.camera.left = -500;
directionalLight.shadow.camera.right = 500;
directionalLight.shadow.camera.top = 500;
directionalLight.shadow.camera.bottom = -500;
directionalLight.visible = true;
scene.add(directionalLight);
let helper = new THREE.CameraHelper( directionalLight.shadow.camera );
scene.add( helper );
}
generally speaking, Directional light start position is (500, 1100, 500), but the position is set at original point, so I don’t know why.
And does there are other ways to load GLTF/GLB model without gltf.scene?