Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

THREE js: Disable auto rotate of sprite

I used sprites in Three js to display 2d images, the problem that I faced with sprites that they rotate to face the camera.

I am trying to use it to fake a shadow for the 3d object. When I rotate the camera the 3d object tilt with the camera until it makes a 30-degree angle with the horizontal but it's shadow (2d sprite) still at 0 degrees.

How to disable the auto rotation of sprite, or is there another solution to preview 2d images in three js to look like a 3d object?

like image 952
Bilal Sehwail Avatar asked Sep 19 '18 10:09

Bilal Sehwail


1 Answers

How to disable the auto rotation of sprite, or is there another solution to preview 2d images in three js to look like a 3d object?

It's not possible to disable the orientation towards the camera with a flag or configuration. You would have to modify the shader code of SpriteMaterial for this.

I suggest you use a mesh instead based on a PlaneBufferGeometry and a MeshBasicMaterial. Alternatively, you write a custom billboard shader with ShaderMaterial or RawShaderMaterial.

like image 165
Mugen87 Avatar answered Oct 20 '22 03:10

Mugen87