Mesh disapears on vector.project

camera
mesh

#1

Hi, I have a mesh and a text, and i want to move the mesh around with its text. The issue am facing is that each time i call the toScreenPosition function, it hides the mesh. (I think both of them move but i cant see mesh)

This is my sample
https://jsfiddle.net/8cmeLs1o/1/

commenting out toScreenPosition brings back the box mesh.


#2

There is no toScreenPosition() function in the provided fiddle.


#3

Yes am sorry wrong link, i will make a new fiddle and update, wanted to delete but cant.


#4

Hi, i updated my fiddle link.


#5

Did you try to log to console the result of .project()?


#6

for the first call in init i get Object { x: NaN, y: -Infinity, z: -Infinity }


#7

Hi, is there no solution to this.


#8

see

Adding camera.updateMatrixWorld(); seems to solve the issue: https://jsfiddle.net/nutkbrgy/


#9

No, i initial box is still hidden, what i mean if you comment out the line in init().

// removing this shows mesh but wont set texts inital position.
toScreenPosition(mesh.position);

#10

The problem is right now that the project changes the position value of your cube. Try to clone the position vector before you pass it to toScreenPosition(). https://jsfiddle.net/ak8f2dLb/