我使用three.js中的mirror.js创建镜像平面。 现在我想在那架飞机上施加重力。我试过这段代码却收到错误
var planeGeo = new THREE.PlaneBufferGeometry( 300, 300 );
var groundMirror = new THREE.Mirror( renderer, camera, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT, color: 0x777777 } );
var Material = new Physijs.createMaterial(groundMirror);
var cube = new Physijs.BoxMesh(planeGeo,Material,0 );
cube.add( groundMirror );
scene.add(cube);
答案 0 :(得分:0)
CubeCamera对于单个飞机来说有点浪费,您可以随时使用单个透视摄像头并将其与您的飞机对齐。基本思路是使平面垂直,将摄像机放置在平面后面,在通过平面中心的法线上对齐,并将其定向(旋转)以与法线对齐。确保将摄像机的近似值设置为与摄像机和平面之间的距离相同,以便可以在到达接触点时捕获反射。通过确保您的视口在飞机上的大小相同来解决比例问题。
供参考,看看他的CubeCamera源代码: https://github.com/mrdoob/three.js/blob/master/src/cameras/CubeCamera.js
再次查看示例后,我发现Slayvin已经实现了: http://threejs.org/examples/webgl_mirror.html
这是一个相关的片段:
var planeGeo = new THREE.PlaneBufferGeometry( 100.1, 100.1 );
// MIRORR planes
groundMirror = new THREE.Mirror( renderer, camera, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT, color: 0x777777 } );
var mirrorMesh = new THREE.Mesh( planeGeo, groundMirror.material );
mirrorMesh.add( groundMirror );
mirrorMesh.rotateX( - Math.PI / 2 );
scene.add( mirrorMesh );
答案 1 :(得分:0)
通过更改
来纠正它
var Material = new Physijs.createMaterial(groundMirror.material);
var planeGeo = new THREE.PlaneGeometry( 300, 300 );
var groundMirror = new THREE.Mirror( renderer, camera, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT, color: 0x777777 } );
var Material = new Physijs.createMaterial(groundMirror.material);
var cube = new Physijs.BoxMesh(planeGeo,Material,0 );
cube.rotateX( - Math.PI / 2 );
cube.add( groundMirror );