CubeCamera.js呈现黑色/无

时间:2014-07-25 06:47:36

标签: javascript three.js

我几乎尝试了一切,代码似乎完全有效。我已经尝试更改threejs版本,从MeshPhongMaterial更改为MeshBasicMaterial并返回,并尝试从在线复制粘贴代码。但是我仍然得到相同的结果。 CubeCamemra.js对我来说非常适合 - >>> http://blog.romanliutikov.com/post/58910953451/dynamic-reflections-in-three-js,但是当我尝试在本地实现它时,它呈现黑色。请告诉我,如果我错过任何重要的事情。提前谢谢!

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

var renderer = new THREE.WebGLRenderer();
camera.position.z = 5;
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var controls = new THREE.TrackballControls(camera);
var cubeCamera = new THREE.CubeCamera(0.1, 1000, 256); // parameters: near, far, resolution
cubeCamera.renderTarget.minFilter = THREE.LinearMipMapLinearFilter; // mipmap filter

scene.add(cubeCamera);


var sphere = new THREE.Mesh(
  new THREE.SphereGeometry(0.5, 30, 30),
  new THREE.MeshBasicMaterial({
    envMap: cubeCamera.renderTarget,
    color: 0x00ffff
  })
);
//sphere.position.y = 3;
scene.add(sphere);
var cube = new THREE.Mesh(new THREE.CubeGeometry(1,1,1),new THREE.MeshNormalMaterial());
scene.add(cube);
cube.position.y = 3;
function render() {

  requestAnimationFrame(render);

  sphere.visible = false;
  cubeCamera.updateCubeMap(renderer, scene);
  sphere.visible = true;

  renderer.render(scene,camera);

  controls.update();

}
render();

http://puu.sh/aqcib/6c2b15d6ca.png - 发生什么事情

0 个答案:

没有答案