Now I have a project must set a obj in word always same size. Use PerspectiveCamera. I do not want use OrthographicCamera
Asked
Active
Viewed 2,587 times
0
-
See if this pattern works for you: `var vec = new THREE.Vector3(); sprite.scale.x = sprite.scale.y = vec.setFromMatrixPosition( sprite.matrixWorld ).sub( camera.position ).length() / defaultDepth;` Update scale whenever sprite or camera move. – WestLangley Feb 20 '17 at 04:26
-
@WestLangley thansk I think it is ok – Wooden man Feb 20 '17 at 10:26
1 Answers
3
If you want to prevent size attenuation with sprites, and you are using a perspective camera, you can set the sizeAttenuation
property of your material to false:
var material = new THREE.SpriteMaterial( {
color: 0xffffff,
map: texture,
sizeAttenuation: false
} );
EDIT: Updated to three.js r.96

WestLangley
- 102,557
- 10
- 276
- 276
-
If I have many sprite can I add to an container. And set the container scale? – Wooden man Feb 20 '17 at 15:38
-
1
-
-
This is a guess: To get the sprite size in pixels, you first need to calculate the [visible height in world units](https://stackoverflow.com/questions/13350875/three-js-width-of-view/13351534#13351534) and compare that to the sprite size in world units. That will give you a fraction. Multiply that fraction by the drawing size height in pixels. – WestLangley Mar 21 '18 at 16:46