Scene.onPointerObservable's POINTERWHEEL events create event.ray to pick, but do not set event.pickedMesh

Hi, I’m noob here.

I made a mesh behavior with the intent of creating a “mouse wheel to zoom” feature. I want the behavior to update it’s attached mesh when 1) the pointer is over the mesh and 2) the mouse wheel scrolls.

Here’s my class:

export class PointerInputBehavior implements Behavior<AbstractMesh> {
  public attachedNode?: AbstractMesh
  private _scene?: Scene
  private _pointerObserver?: Nullable<Observer<PointerInfo>>

  // ...

  /**
   * @param target The mesh that will emit inputs when under the pointer
   */
  public attach(target: AbstractMesh): void {
    this._scene = target.getScene()
    this.attachedNode = target

    this._pointerObserver = this._scene.onPointerObservable.add((pointerInfo) => {
      console.log(pointerInfo)
      if (this.attachedNode != pointerInfo.pickInfo?.pickedMesh) return
      switch (pointerInfo.type) {
        case PointerEventTypes.POINTERWHEEL:
          console.log('POINTER WHEEL')
          break
      }
      // ...
    })
  }

When I mouse over the mesh and mouse wheel up/down, I don’t get “POINTER WHEEL” in the output. I do get pointerInfo’s and they look like this:

These two PointerInfo’s are two mouse wheel events at different places on the mesh. Notice the Ray’s origin is different, which makes me think it’s finding the picked mesh, but not setting pickInfo.pickedMesh or pickedPoint as I expected.

This code seems relevant.

Like I said, I’m noob, it seems like a bug, but maybe there’s a simpler way that I’m overlooking. Thank you,

Michael

cc @PolygonalSun can you review ?

Hey @FunAndFriendly, I looked over how a wheel event would populate the pickingInfo and I also checked out that line you referenced in your link. For the code in the link, anything within lines 225-227 would probably not have any effect on whether or not the pickedPoint or pickedMesh populating, at least if I’m tracing this correctly. I believe that it’s by design that pickInfo isn’t populated with a mesh on move or wheel events so you may need to manually try to pick a mesh when you get a wheel event using cursor information and scene.pick to build your pickingInfo. Usually pickingInfo would be populated by a pointerup event as that’s when we also fire PointerEventTypes.POINTERPICK.

It’s possible that I’m missing part of the picture here though but I don’t know that I’m seeing a bug here.

Hi @PolygonalSun thanks for looking at it. I’m a bit noob here. I poked around in Ray and it might already be there:

I’ll try it my next session. Thanks for your help!

Hello @FunAndFriendly just checking in, are you still having issues?

@carolhmj Thanks for asking! I had a message in the chat room buffer here: “Hmmm… that didn’t work.”

To be honest, I put the project aside because it was too ambitious and I wasn’t getting anywhere. I just booted up the code and it’s not working :frowning:

If I get some time I’ll take another look. Thanks for checking in!

Michael

1 Like