Hi again! i’ve a quick question/double on scene.pick, i’m slightly confused.
I’m implementing a mouse-follow, my mesh is a sphere, centered is 0,0,0.
my onBeforeRenderLoop is
updatePosition () {
this.pickResult = this.scene.pick(this.scene.pointerX, this.scene.pointerY, mesh => { return mesh === this.mesh }, true, this.camera)
if (this.pickResult.hit) {
const p = this.pickResult.pickedPoint
const d0x = 0 - this.mesh.position.x
const d0y = 0 - this.mesh.position.y
const d0 = Math.sqrt(d0x * d0x + d0y * d0y)
const newx = p.x * (1.3 - d0)
const newy = p.y * (1.3 - d0)
this.mesh.position.x = this.lerp2(this.mesh.position.x, newx, 0.15)
this.mesh.position.y = this.lerp2(this.mesh.position.y, newy, 0.15)
}
}
}
-
scene.pickedPoint coordinates are the intersect coordinates between the ray of the freeCamera and the surface of the sphere?
-
do the coordinates of the sphere added to the scene refer to its center?
-
How can I get the coordinates of the center of the sphere by knowing the coordinates of the pickedPoint?
thanks in advance!