我有一个非常简单的CubeCamera /反射示例(从Stemkoski的反射示例中提升了大小)。代码如下所示:
var sphereGeom = new THREE.SphereGeometry( 2, 32, 32 );
mirrorSphereCamera = new THREE.CubeCamera( 0.1, 5000, 512 );
scene.add( mirrorSphereCamera );
var mirrorSphereMaterial = new THREE.MeshBasicMaterial( { envMap: mirrorSphereCamera.renderTarget } );
mirrorSphere = new THREE.Mesh( sphereGeom, mirrorSphereMaterial );
mirrorSphere.position.set(0, 2, 0);
mirrorSphereCamera.position = mirrorSphere.position;
scene.add(mirrorSphere)
渲染代码如下所示
mirrorSphere.visible = false;
mirrorSphereCamera.updateCubeMap( renderer, scene );
mirrorSphere.visible = true;
renderer.render( scene, camera );
使用three.js 60,虽然我收到了这些警告但它仍能正常工作:
[.Offscreen-For-WebGL-0x7f80b4013200]RENDER WARNING: there is no texture bound to the unit 0
[.Offscreen-For-WebGL-0x7f80b4013200]RENDER WARNING: there is no texture bound to the unit 0
[.Offscreen-For-WebGL-0x7f80b4013200]RENDER WARNING: there is no texture bound to the unit 0
Wth three.js 75我收到此错误:
WebGL: INVALID_OPERATION: bindTexture: textures can not be used with multiple targets
使用最新的版本82,我收到了这些警告:
THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.
THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead.
在75和82中,反射都不起作用。尽管来自82的警告,the example at threejs.org仍然使用renderTarget(AFAICT):
我还在调查,但欢迎任何建议。