Mesh disapears on vector.project

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.

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

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

Hi, i updated my fiddle link.

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

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

Hi, is there no solution to this.

see

Adding camera.updateMatrixWorld(); seems to solve the issue: Edit fiddle - JSFiddle - Code Playground

1 Like

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);

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/

1 Like