Skip to content Skip to sidebar Skip to footer

Three.js: Attach Object To Camera But Not Make It Rotate With It

I currently have a SphereGeometry attached to a Perspective Camera. But when I rotate the camera, the Sphere rotates with the camera which is normal but in my case I do not want th

Solution 1:

One approach is to define an onBeforeRender() method for your sphere mesh. For example:

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 );
};

three.js r.86

Post a Comment for "Three.js: Attach Object To Camera But Not Make It Rotate With It"