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