0 The solution to this question made me recall trigonometry and vector algebra. Problem statement: when creating, change the object after the mouse movement. What we have: cursor coordinates in screen coordinates, camera viewing angle, aspect ratio. It is necessary to determine: how much the scale of the view in world coordinates at a given moment of time differs from the scale of the screen, find the distance from the position of the object in screen coordinates and multiply it by the scale of the view at the current time. To look at the camera from the side (above), I created a third render and placed it in the second canvas. When you click on canvas, it increases to full screen. Later I will make an orthogonal camera there. The first thing we will do is determine the position of the object in screen coordinates. To do this, project the position vector of the object onto the screen. Three.js provides a project () function. We clone the position vector of the object, otherwise the function will change the position of the object. Translation to screen coordinates: In the video, the first yellow ball shows the position of the created object.
Continue reading