Lor*_*ick 1 javascript three.js
我目前有一个附加到透视相机的SphereGeometry.但是当我旋转相机时,球体会随着相机旋转,这是正常的但在我的情况下我不希望这样.
这是我有的:
camera.add(Sphere);
Sphere.position.set (0, -100, 0);
Run Code Online (Sandbox Code Playgroud)
我想要的是将球体连接到相机的底部,但保持在那个位置.目前,当我旋转相机时,球体似乎随之旋转,所以我看不到它.如何以不随相机旋转的方式附加子对象?谢谢.
一种方法是onBeforeRender()
为球体网格定义方法.例如:
scene.add( sphere ); // add it as a child of the scene, not the camera
sphere.onBeforeRender = function( renderer, scene, camera, geometry, material, group ) {
var pos = camera.position;
this.position.set( pos.x, pos.y - 100, pos.z );
};
Run Code Online (Sandbox Code Playgroud)
three.js r.86