Alex
April 10, 2023, 3:14am
1
Hello,

I am trying to draw an rectangle that is horizontal always to the eyes. I mean not follow the orbit control

Please take a look at the picture.

This is my rectangle tilted

I am getting this with this formula

getRectPoints = (startPoint, endPoint) => {
const sPoint = new THREE.Vector3(startPoint.x, 0.002, startPoint.z)
const ePoint = new THREE.Vector3(endPoint.x, 0.002, endPoint.z)
const subVec = new THREE.Vector3().subVectors(ePoint, sPoint)
const p1 = new THREE.Vector3().copy(sPoint)
p1.x += subVec.x
const p2 = new THREE.Vector3().copy(sPoint)
p2.z += subVec.z

return {p1: p1, p2: p2, sPoint: sPoint, ePoint: ePoint}
}

I want it horizontal always irrespective of that cube view that is using orbit control

I need it like this

Thanks

Adding the rectangle mesh to the camera should do the trick - it should then not be affected by the controls

Alex
April 10, 2023, 5:39am
3
u mean camera.add(mesh)

If yes so than how it will reflect in scene , because camera is not the child of scene

Hello! Maybe you mean rotating like into games bullet trace always look to camera by rotating aroung one axe.

makc3d
April 10, 2023, 7:24am
5
well make it one then? scene.add(camera)

1 Like

Dat_Le
April 11, 2023, 7:56am
6

Alex:

Hello,

I am trying to draw an rectangle that is horizontal always to the Download GTA 5 Mobile APK + Data . I mean not follow the orbit control

Please take a look at the picture.

This is my rectangle tilted

I am getting this with this formula

getRectPoints = (startPoint, endPoint) => {
const sPoint = new THREE.Vector3(startPoint.x, 0.002, startPoint.z)
const ePoint = new THREE.Vector3(endPoint.x, 0.002, endPoint.z)
const subVec = new THREE.Vector3().subVectors(ePoint, sPoint)
const p1 = new THREE.Vector3().copy(sPoint)
p1.x += subVec.x
const p2 = new THREE.Vector3().copy(sPoint)
p2.z += subVec.z

return {p1: p1, p2: p2, sPoint: sPoint, ePoint: ePoint}
}

I want it horizontal always irrespective of that cube view that is using orbit control

I need it like this

Thanks

To keep your rectangle horizontal and not follow the orbit control, you need to ensure that its orientation is always aligned with the world’s XY plane. One way to achieve this is to use the `lookAt`

method to point your rectangle towards the camera’s position