Jump to content

THREE.Sprite getting position and scale right


Sebi
 Share

Recommended Posts

Hello guys,

 

I have a question. Above my models, I want to display the respective character name.

 

First I create a canvas for each name and use it as texture for my sprite.

 

var name = new THREE.Sprite(new THREE.SpriteMaterial({
  map: new THREE.Texture(canvas),
  useScreenCoordinates: false,
  transparent: true
}));
 
Then I add it to my models mesh.
 
So far so good.
 
Now I have the problem that the Sprite is affected by the camera's distance.
name .scale.set(canvas.width, canvas.height, 1.0);
name.position.set(0, 10, 0);
 
This is stretching my sprite instead of displaying it at the canvas width and height.
Is there an option to display my sprite at exactly the canvas width/height ignoring camera perspective and distance?
Link to comment
Share on other sites

I think I have found a solution for my problem.

I will just add a new function to my entity system and calculate the screen position of my entity mesh. Then use screen coordination to display my sprite.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...