Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript three.js将点光源添加到相机_Javascript_Three.js - Fatal编程技术网

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

在将任何灯光或球体添加到场景之前,将摄影机添加到场景中。