Javascript three.js将点光源添加到相机
这是我的代码,我试图在相机上添加两个灯光,以便它们随着轨道控制的使用而移动。由于我不知道的原因,灯光/球体不可见。有人能指出我做错了什么吗Javascript three.js将点光源添加到相机,javascript,three.js,Javascript,Three.js,这是我的代码,我试图在相机上添加两个灯光,以便它们随着轨道控制的使用而移动。由于我不知道的原因,灯光/球体不可见。有人能指出我做错了什么吗 var sphere1 = new THREE.Mesh( new THREE.SphereGeometry( 2000, 16, 16), new THREE.MeshBasicMaterial({color:0xff0000}) ); var cameraLight1 = new THREE.PointLight( this.options.lights
var sphere1 = new THREE.Mesh( new THREE.SphereGeometry( 2000, 16, 16), new THREE.MeshBasicMaterial({color:0xff0000}) );
var cameraLight1 = new THREE.PointLight( this.options.lights.lightColor, this.options.lights.lightIntensity * 1.2, this.options.lights.lightRadious );
sphere1.add( cameraLight1 );
sphere1.position.set( -5000, -5000, -5000 );
this.camera.add( sphere1 );
var sphere2 = new THREE.Mesh( new THREE.SphereGeometry( 2000, 16, 16), new THREE.MeshBasicMaterial({color:0xff0000}) );
var cameraLight2 = new THREE.PointLight( this.options.lights.lightColor, this.options.lights.lightIntensity * 1.2, this.options.lights.lightRadious );
sphere2.add( cameraLight2 );
sphere2.position.set( -5000, -5000, -5000 );
this.camera.add( sphere2 );
如果我在场景中添加球体/灯光,它们看起来很好。
不知道为什么这样不行
附言:
摄像机初始位置:{x:0,y:5.510910596163089e-12,z:90000}
更新
这也不起作用:
var cameraLight1 = new THREE.PointLight( this.options.lights.lightColor, this.options.lights.lightIntensity * 1.2, this.options.lights.lightRadious );
this.camera.add( cameraLight1 );
cameraLight1.position.set( 0,0,-5000 );
var cameraLight2 = new THREE.PointLight( this.options.lights.lightColor, this.options.lights.lightIntensity * 1.2, this.options.lights.lightRadious );
this.camera.add( cameraLight2 );
cameraLight2.position.set( 0,0,-5000 );
如果将子对象添加到摄影机,则还必须将摄影机添加到场景中。否则,子对象将不会是场景图的一部分
scene.add( camera ); // this is required...
camera.add( light ); // ... whenever you do this
three.js r.69在将任何灯光或球体添加到场景之前,将摄影机添加到场景中。