Remove a mesh's pointOverTrigger but keep Pickable

i create too much point by thinInstance;
and then

     scene.onPointerDown = function (evt, pickResult) {
        if (pickResult.hit && ~pickResult.thinInstanceIndex) {
          console.log('onPointerDown---------------')
          const worldMat = instance.thinInstanceGetWorldMatrices()
          const thinInstanceMatrix = worldMat[pickResult.thinInstanceIndex]
          callback && callback(pickResult.thinInstanceIndex, thinInstanceMatrix)
        }
      }

but i found that,when i use mouse hover them,not click them;
some computation function is running , because the fps number going down really fast;
when the mouse stay away from them , fps number back to normal;

so,i wonder whether mouse movement detection can be removed for this, and onPointerDown events are not affected

thanks for your answer :slight_smile: !

Could you share a repro in the playground ? so it might help us find the best config ?

1 Like

https://playground.babylonjs.com/#RC2IAH

I wrote my code according to this case,I can’t copy all the configuration for my project (it is too long and it is too hard to write on PG),but I can provide the code of create instance:

 createInstance(instance: BABYLON.Mesh, matricesData: Float32Array, isPickable: boolean, callback?: Function) {
    instance.thinInstanceSetBuffer('matrix', matricesData, 16, false)
    instance.isPickable = isPickable
    instance.thinInstanceEnablePicking = isPickable
    if (isPickable) {
      BabylonService.getScene().onPointerDown = function (evt, pickResult) {
        if (pickResult.hit && ~pickResult.thinInstanceIndex) {
          console.log('onPointerDown---------------')
          const worldMat = instance.thinInstanceGetWorldMatrices()
          const thinInstanceMatrix = worldMat[pickResult.thinInstanceIndex]
          callback && callback(pickResult.thinInstanceIndex, thinInstanceMatrix)
        }
      }
    }
  }

em…maybe i find the reason…

    ball.actionManager.registerAction(
      new BABYLON.ExecuteCodeAction(
        {
          trigger: BABYLON.ActionManager.OnPickTrigger,
        },
        (e: BABYLON.ActionEvent) => {
          if (this.pickable) {
            BabylonEvent.triggerEvent({
              action: 'clickThePoint',
              mesh: ball,
            })
          }
        }
      )
    )

Maybe I wrote the if statement in the wrong place

finally,I replaced the above code,it is useful,and this problem has also been solved

  public setPickable(bool: boolean) {
    if (bool) {
      this.ball.actionManager = new BABYLON.ActionManager(this.scene)
      this.ball.actionManager.registerAction(
        new BABYLON.ExecuteCodeAction(
          {
            trigger: BABYLON.ActionManager.OnPickTrigger,
          },
          (e: BABYLON.ActionEvent) => {
            BabylonEvent.triggerEvent({
              action: 'clickThePoint',
              mesh: this.getBall,
            })
          }
        )
      )
    }
  }

thanks :slight_smile:

1 Like