Pointer follow sphere, scene.pick

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! :slight_smile:

Hi s… I just sent you a PM about this… could be correct, could be wrong. :slight_smile:

Other forum helpers, you might wish to hold-off on answering here… until we determine how miserably wrong I was… in PM. In general, I think S is correct… pickedMesh.position needs to be added to pickedPoint, to get worldspace position of actual point-of-impact. (a nice value to use as a particleSystem emitter, for a .manualEmitCount point-of-impact “puff”) :slight_smile:

Save your fingers for a little while, fellow forum helpers… let’s see if spleen is already fixed-up.

1 Like

i’ve created this PG to make the idea :slight_smile:

Oh, I was kind-of off-topic, huh? Sorry. Thx for the pg - nice one. Is your issue solved, or do we still have something wonky?