javascript3dthree.jsspine

Three.js How to make Object3D looks at near of view frustum not a point or render like sprite?


I'm a newbie about 3D programming.

I'm trying to use three.js and Spine to render 2D-Characters on 3D-Space.

And I want to render Mesh as Sprite. It means objects look at near view with parallel always not a camera's point with lookAt() function.

Spine has SkeletonMesh which is inherited by Mesh. So It shows like 3D Objects even if it has only one face.

Is there any simple way? or please advice mathematical method.

Thanks.


Solution

  • If you want an object face the camera, but look in a direction that is parallel to the look direction of the camera, you can use this pattern:

    object.quaternion.copy( camera.quaternion );
    

    You can't assign the quaternion, you must copy it every frame in the animation loop -- or at least when the camera changes its orientation.

    This approach is an alternative to using

    object.lookAt( camera.position );
    

    three.js r.84