-
Notifications
You must be signed in to change notification settings - Fork 1.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
Better 2D cursor #75
Better 2D cursor #75
Conversation
…on; look-controls are paused when an interactable is grabbed; colors changed; cursor no longer appears to be in "hovered" state when moused over the floor or table;
# Conflicts: # src/room.css # src/room.html
src/components/super-cursor.js
Outdated
} | ||
}, | ||
|
||
_handleMouseDown: function(e) { | ||
this.mouseDown = true; |
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.
This flag appears to be unused.
src/components/super-cursor.js
Outdated
this.el.setAttribute("raycaster", { origin: this.origin, direction: this.direction }); | ||
|
||
let className = null; | ||
|
||
if (!this.isGrabbing) { | ||
const intersections = this.el.components.raycaster.intersections; | ||
if (intersections.length > 0 && intersections[0].distance <= this.data.maxDistance) { | ||
isIntersecting = true; |
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.
Instead of storing isIntersecting
, className
, point
and currentDistance
I would probably just store the interesection itself.
@@ -62,49 +86,70 @@ AFRAME.registerComponent("super-cursor", { | |||
} | |||
|
|||
if (this.isGrabbing || !isIntersecting) { | |||
const head = this.el.object3D; | |||
head.getWorldPosition(this.origin); | |||
head.getWorldDirection(this.direction); | |||
const distance = Math.min( | |||
Math.max(this.data.minDistance, this.currentDistance - this.currentDistanceMod), | |||
this.data.maxDistance | |||
); | |||
this.currentDistanceMod = this.currentDistance - distance; |
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.
bit confused what this is doing here?
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.
this is the logic that allows you to scroll the mouse wheel to move the object closer or farther from you.
# Conflicts: # src/room.js
no more cursor lock; super-cursor follows around cursor screen position; look-controls are paused when an interactable is grabbed; colors changed; cursor no longer appears to be in "hovered" state when moused over the floor or table; system cursor is hidden.