A-Frame mouse and touch controls don't work when <a-scene> z-index is negative
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17.6k
- Forks
- 4.4k
- PR merge metrics
- No merged PRs in 30d
Description
Description:
- A-Frame Version: 1.2.0
- Platform / Device: Chrome on Windows, but suspect it's universal
- Reproducible Code Snippet or URL: Glitch here: https://adaptable-quick-dedication.glitch.me/
A-Frame help here discusses the use of z-index as a way to layer 2D UI elements over an A-Frame scene.
https://aframe.io/docs/1.2.0/components/embedded.html#integration-with-the-2d-page
However based on this advice there is a chance that someone might be inspired to set the z-index of their to a negative value (which is exactly what I did).
Having done that, they will then discover the unfortunate side-effect that mouse & touch controls can no longer be detected in the A-Frame scene, as demonstrated in this glitch.
https://adaptable-quick-dedication.glitch.me/
(press the button 3 times to get to negative z-index values).
I don't understand the root cause, but have observed that when "a-scene" z-index is 0 or higher, then setting a breakpoint onto mouse or touch events in the Chrome debugger reveals various events being triggered on CANVAS. And when z-index is < 0, no events are triggered on CANVAS.
I doubt anyone has a genuine reason to need their "a-scene" to have a negative z-index, but at a minimum this issue should be documented at the docs link above.
It would be nice to have a fix, as even with documentation it will be easy to stumble across this, and the consequences might not be obvious (for me, I was trying to troubleshoot why raycasting wasn't working, and after several hours I finally realized that it was down to this).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Glitch reproduction and verify mouse and touch behavior while changing the a-scene z-index from 0 to a negative value. Read the linked embedded-scene documentation and investigate why canvas events stop firing; done means either the controls work with a negative z-index or the limitation is clearly documented there.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100