World To Screen Help #210
Closed
CodyRelish
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to get the Camera.main.worldToScreen method to work for me. I have a cube that is spawned in at 0,0,0 & I have a standard sprite being created using PIXI. I'll get the converted world position of the cube to screen position and apply an offset from the size of the renderer and use that to set the sprites position.
const cube = PIXI3D.Mesh3D.createCube();
cube.material = new Shaders.TestMaterial();
this.addChild(cube);
const worldPosition = cube.position.clone(); // Get the world position of the cube
const screenPosition = PIXI3D.Camera.main.worldToScreen(worldPosition.x, worldPosition.y, worldPosition.z); // Convert to screen position
const newPos = new Point(screenPosition.x - this._size.x * 0.5, screenPosition.x - this._size.y * 0.5);
sprite.position.copyFrom(screenPosition);
What I'm getting:
Beta Was this translation helpful? Give feedback.
All reactions