Please find below a Playground link:
Note that the player is intentionally spawned below the camera (since this bug deals with the vertical offset of meshes relative to ArcRotateCamera’s radius), so please click inside the Playground and either:
- Hold down the Up arrow key
- Click and drag the left mouse button from up to down
Please refer to the lines:
// BUG: If radius <= 3, gun points one way. If radius >= 4, gun points other way. const radius = 3;
Note that when
radius = 3, the gun points outwards.
radius = 4, the gun points inwards.
Some may suggest to remove the first forced render after initializing the player model and setting its parent to the green rectangular prism:
scene.render(); // Force updates by rendering
However, this won’t solve the issue I’m facing in development, since there will be situations where a new gun mesh is attached to a player model after the first
scene.render() call with the player model in the scene (for example: a player picking up a new gun).
This first forced
scene.render() is an attempt to make a gun’s rotation consistent regardless of whether the gun was attached to a player model during initialization or several minutes into a game.
Thank you for your time and help