-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OrbitControls: Set certain event listeners to non-passive #19782
Conversation
Nice :)
|
How can I trigger this warning? I don't see it in the production link right now. |
What's your chrome version? (Ellipsis menu, Help, About) Mine is Version 83.0.4103.116 (Official Build) (64-bit). Also you must refresh the page after opening it. console does not show these messages if you open it after pageload. |
Um, I still don't see it 🤔 . I'm using Chrome 83.0.4103.116 on macOS. |
I observe it on my macOS as well. Perhaps check if you have console filters activated. |
Yeah... looks like it is a debug-level warning and only shows if you set all levels... just to the right of your screenshot i guess itll say "3 hidden". Hey thanks for the screenshot, I'm gonna go check out the three.js dev tools! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to allow event options to be passed in, which would override (merge with) the default options.
Also, how does orbit controls work if rendering more than one scene or camera within the same WebGL context? For this reason, it may be also good to allow the DOM element to be optionally passed in, to give more optional control (f.e. cover the canvas with elements to handle events for different portions of the canvas). |
@@ -1125,11 +1125,11 @@ THREE.OrbitControls = function ( object, domElement ) { | |||
scope.domElement.addEventListener( 'contextmenu', onContextMenu, false ); | |||
|
|||
scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); | |||
scope.domElement.addEventListener( 'wheel', onMouseWheel, false ); | |||
scope.domElement.addEventListener( 'wheel', onMouseWheel, { capture: false, passive: false } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find on the internets if capture
is false
by default...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, useCapture
(the third parameter) is supposed to be false
by default, but Firefox used to error a decade ago if it was not specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this spec, but the relevant section is non-normative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
capture (a boolean, initially false)
I guess I can remove it from the options
object then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since non-normative means the specifications in that section are recommendations, not requirements, I think it would be best if we specify the value we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reading a different section than you were.
When set to true, options’s capture prevents callback from being invoked when the event’s eventPhase attribute value is BUBBLING_PHASE. When false (or not present), ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess it should just be this?
scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
PS: I realised I didn't explain the useCapture
issue property. Firefox used to crash because the third parameter was not passed.
I think this is already the case. That’s what |
This is easily reverted. Let's try it early in the dev cycle so we can get feedback. |
This PR eliminates the Chrome warnings if there is no DAT.GUI -- but not if there is one... |
Hmmm... I can't see any warnings on Chrome 84.0.4147.135... https://threejs.org/examples/misc_controls_orbit.html Took a screenshot after scrolling on the view: |
Try #19782 (comment). |
@WestLangley Yeah! As you can see in the screenshot I have all levels selected. Including verbose. |
Oh wait, I can reproduce it from the examples page: |
When the console sidebar is visible in Chrome 85, 'verbose' appears to be hardwired, and the warnings appear. My current workaround to avoid the warnings is to hide the console sidebar and toggle-off 'verbose'. |
It doesn't appear there is interest in this, so closing... |
Um, this is pretty weird. I found this page looking for PRs that would fix the [Violation] warnings that are pretty annoying, only to find that this has been... dropped? I mean, it's a trivial change, what's preventing this from being merged in? |
... similar to the suggestion by @unphased in #10373 (comment).
It does seem to prevent the following warning in Chrome:
ref: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener