Replies: 1 comment
|
The hotspots aren't capturing your gestures — they're in a different subtree from the listeners, so the events never reach the camera code at all.
element.addEventListener('pointerdown', this.onPointerDown);
element.addEventListener('wheel', this.onWheel);Hotspots live somewhere else. this.element.shadowRoot!.querySelector('.default')!.appendChild(domElement);and in That accounts for all four of your symptoms, and your pinch observation is the proof of it: with one finger on a hotspot, The page-scroll half has the same root. const {style} = this.element;
...
style.touchAction = touchAction!;Your hotspots are outside that element, so the browser's default touch-action governs there and it pans the page. Likewise the wheel: no handler runs, so nothing calls Worth noting what is not the cause: the CSS2D container is explicitly transparent — .pointer-tumbling .annotation-wrapper ::slotted(*) {
pointer-events: none;
}so a drag that begins on the canvas is never interrupted by a hotspot passing under the cursor. The only gap is a gesture that begins on a hotspot. The fix for rotate/pinch is to stop the hotspot from being a hit target and re-enable only the part that must be tappable: [slot^="hotspot"] { pointer-events: none; }
[slot^="hotspot"] .dot { pointer-events: auto; }You don't need The fix for the wheel is nicer, because there's a public method for exactly this. zoom(keyPresses: number) {
const event = new WheelEvent('wheel', {deltaY: -30 * keyPresses});
this[$userInputElement].dispatchEvent(event);
}So on the hotspot itself: hotspot.addEventListener('wheel', (e) => {
e.preventDefault();
modelViewer.zoom(-e.deltaY / 30);
}, {passive: false});and the wheel zooms the model even with the cursor parked on a label, without touching the shadow DOM. Two approaches I'd skip:
|
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I'm facing an issue with hotspots interfering with the default gestures of .
Normally, on desktop I can rotate the model by dragging with the left mouse button and zoom with the mouse wheel. On mobile, I can rotate by dragging with one finger and zoom using the pinch gesture.
However, when my cursor (or finger) is positioned on a hotspot, the behavior changes unexpectedly:
On desktop:
On mobile:
It seems like the hotspots are capturing the pointer/touch events and preventing them from reaching the underlying model-viewer gestures.
I'm looking for advice on how to allow the default model-viewer gestures (rotate, zoom) to still work even when interacting over a hotspot. Ideally, I want the hotspots to respond to taps/clicks, but otherwise let pointer events pass through so that zooming and rotating still works as expected.
Any guidance on how to solve this would be much appreciated.
Thank you in advance!
All reactions