我的对象场景中的光线有问题。
我无法在我的场景中定位我的灯光并选择哪一个。
在这里,我选择了几个 directionalLights 和一个ambientLight,但我的对象并没有真正改变。
你能帮我吗?:)
我的 HTML 代码是:
<script src="three.min.js"></script>
<script src="OrbitControls.js"></script>
<script src="GLTFLoader.js"></script>
<script src="script.js"></script>
我的脚本代码是:
var scene = new THREE.Scene();
scene.background = new THREE.Color(0x000000);
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var loader = new THREE.GLTFLoader();
loader.load( 'scene.glb', function ( gltf ) {
var mesh = gltf.scene;
mesh.position.set(0,-0.07,0.2);
scene.add( gltf.scene );
}, undefined, function ( error ) {
console.onerror( error );
} );
camera.position.z = 1;
var ambientLight = new THREE.AmbientLight(0xFFFFFF, 1.5);
scene.add(ambientLight);
var light = new THREE.DirectionalLight(0xFFFFFF,3);
light.position.set(0,1,0);
var helper = new THREE.DirectionalLightHelper( light);
scene.add(light);
var light1 = new THREE.DirectionalLight(0xFFFFFF,3);
light1.position.set(1,0,0);
var helper1 = new THREE.DirectionalLightHelper( light1);
scene.add(light1);
var light2 = new THREE.DirectionalLight(0xFFFFFF,3);
light2.position.set(0,0,1);
var helper2 = new THREE.DirectionalLightHelper( light2);
scene.add(light2);
var light3 = new THREE.DirectionalLight(0xFFFFFF,3);
light3.position.set(0,0,-1);
var helper3 = new THREE.DirectionalLightHelper( light3 );
scene.add(light3);
var light4 = new THREE.DirectionalLight(0xFFFFFF,3);
light4.position.set(0,-1,0);
var helper4 = new THREE.DirectionalLightHelper( light4);
scene.add(light4);
var light5 = new THREE.DirectionalLight(0xFFFFFF,3);
light5.position.set(-1,0,0);
var helper5 = new THREE.DirectionalLightHelper( light5);
scene.add(light5);
var controls = new THREE.OrbitControls(camera,renderer.domElement);
animate();
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}