Trying to place a cube halfway between a camera and the look target of the camera floating directly between them always distance based. Really struggling with this for some reason!
by user 103054507105067008
Trying to place a cube halfway between a camera and the look target of the camera floating directly between them always distance based. Really struggling with this for some reason!
by user 103054507105067008
means you have the two positions
camPos:vec3;
targetPos:vec3;
wouldn’t the cube position be just (the distance of cam to target)/ 2?
cube.position.set((camPos-targetPos/2))
by user 367081956959322114
Three.js seemed to get upset when I tried to divide the vetcor3 by 2, I’ll try again tomorrow
by user 103054507105067008
if that was not possible, just take each number separately
like this:
`let distance = camPos - targetPos;
let x = distance.x/2;
let y = distance.y/2;
let z = distance.z/2;
cube.position.set(x,y,z);`
by user 367081956959322114
It makes perfect sense and I did that yet the positions weren’t right, I’ll post back code and a gif tomorrow. Made sure to grab world position of the camera and camera target but I think something funky was going on under the hood with the Orbit Cam script from the Needle Samples
by user 103054507105067008
You could also just lerp (myVector.lerp(myTargetVector, .5)
)
Note that this will change the value of myVector
you can also use lerpVectors
three.js docs
I’ll ping back here when I give it another shot for sure, thanks!
by user 103054507105067008