-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Pen tool #524
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
Merged
Merged
Pen tool #524
Changes from 58 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
23732f3
WIP - drawing/pen tool, initial commit
InfiniteLee 24da819
Added drawing of "caps" to the start/end of each line drawn; cleaned …
InfiniteLee 592d252
seperate pen and networked-drawing components
InfiniteLee e345c7e
Merge branch 'master' into feature/drawing
InfiniteLee 4a0d90b
first pass at networking drawings (unoptimzied)
InfiniteLee a49be34
bug fixes and optimizations; testing with 6-dof controller
InfiniteLee 240fc1f
fixes
InfiniteLee 3d29c8c
update networking to not rely on networked-aframe's default attribute…
InfiniteLee 1209809
adding chunking on inital drawBuffer sync
InfiniteLee 4c512b5
colors work now (but they don't network correctly yet).
InfiniteLee 2bc4fa2
Colors are now network synced properly; slightly improved how the mat…
InfiniteLee 13038ef
Adding pen interactable
InfiniteLee 763a446
Merge branch 'master' into feature/drawing
InfiniteLee d4e0a5b
Adding pen interactable
InfiniteLee 776dc76
activatable component and sticky behavior
InfiniteLee 56baef3
use meshBasicMaterial for now since normals arent calculated correctly
InfiniteLee 5bfaf0e
Merge branch 'master' into feature/drawing
InfiniteLee 6158c6c
fix lint issues
InfiniteLee 7039d64
one more lint fix
InfiniteLee 3588a27
more fixes...
InfiniteLee 0a1545d
enable sticky behavior for mouse
InfiniteLee 3067dfe
sticky and activatable work with cursor now.
InfiniteLee da40d65
refactoring input for 6dof hands + cursor
InfiniteLee 74d69cc
fix hand switching
InfiniteLee f413ccb
unused var
InfiniteLee 6830075
merge master
InfiniteLee a103f9f
fix lint
InfiniteLee 9aeff16
fixed faceculling order on geometry for lines and caps, both even and…
InfiniteLee 35e962a
calculate vertex normals better so that lines have correct lighting w…
InfiniteLee 869de4c
cleanup sharedbuffergeometry
InfiniteLee 645e576
Merge branch 'master' into feature/drawing
InfiniteLee 57c857a
add color changing for 6-dof and fixing oculus go input
InfiniteLee bd2509a
fixed networking
InfiniteLee 7dd8003
change grabbable-toggle into a full replacement for grabbable reactio…
InfiniteLee 4e9946d
lint fixes
InfiniteLee 783768c
networked pen color
InfiniteLee af54f91
limit length of individual lines; limit how many lines can persist be…
InfiniteLee 53d6257
lint fixes
InfiniteLee d8ebdb5
more lint fixes
InfiniteLee 7d8247f
change color by scrolling touchpad
InfiniteLee 92a44ac
fix race condition
InfiniteLee fad6c17
need to send color with every line
InfiniteLee 59b8cfe
Merge branch 'master' into feature/drawing
InfiniteLee 74d6ef6
fix bug where single point lines were not being ended correctly
InfiniteLee 543cce9
fix bugs that occur if users are drawing when a new user enters the room
InfiniteLee 7d15850
remove logging
InfiniteLee 145e538
remove velocity based haptics on interactables
InfiniteLee a0989de
add functionality to change pen radius
InfiniteLee f7e4d80
encode radius of pen on the direction vector.
InfiniteLee c1eeb51
allow changing color and scale via mouse when holding alt or shift ke…
InfiniteLee a560ecc
fix color changing on oculus go
InfiniteLee 735acfa
enable color and radius to be changed mid-line, update networking to …
InfiniteLee 35ccfc4
clean up/update how scrolling is handled
InfiniteLee 0221433
Merge branch 'master' into feature/drawing
InfiniteLee e0a428d
cleanup
InfiniteLee c2a6cad
rename sticky class to toggle so it doesn't get confused with sticky-…
InfiniteLee a576031
get rid of added actions on vive trackpad because now they are redundant
InfiniteLee 2d44166
get rid of "tertiary" input events since they're handled by scrolling…
InfiniteLee de9919a
add back in preventDefault in case of scrolling while holding alt key
InfiniteLee 4abeda6
various updates to support moving the duck and pen into the gltf-comp…
InfiniteLee 830d51d
various cleanup; fix issue with swapping hands with toggle interactables
InfiniteLee e206702
Merge branch 'master' into feature/drawing
InfiniteLee f5b845b
fix bug where grabbing state was not properly removed from grabbable-…
InfiniteLee afa0ea4
cleanup; fixing bugs around how line endings are networked
InfiniteLee f92e189
Merge branch 'master' into feature/drawing
InfiniteLee c762b1d
cleanup
InfiniteLee 4302686
fix issue with teleporting on 3-dof
InfiniteLee bec4321
add ability to spawn pen from hud (replacing the space bubble toggle)…
InfiniteLee 1505cae
update pen icons
InfiniteLee fff303a
lint fixes
InfiniteLee 8e00551
update spawn_pen icons again
InfiniteLee 4ae6f00
fix bug where normal was being modified incorrectly
InfiniteLee 9ae9d1f
fix spawn_pen-hover icon
InfiniteLee 28438d4
fix issue with pen not drawing until second primary_grab; fix spawn_p…
InfiniteLee 73e2cc6
Merge branch 'master' into feature/drawing
InfiniteLee 7d23549
fix issue where spawning pen in hud was frame behind causing issues.
InfiniteLee c9e47d7
fix bug where joystick input in rift would drop objects; fix bug wher…
InfiniteLee daa99a0
fix issues were multiple networked-drawings could interfere with each…
InfiniteLee 7ff3f47
Merge branch 'master' into feature/drawing
InfiniteLee 8520817
fix bug that occur because clients were assuming mutual dataChannel c…
InfiniteLee db345bc
fix lint
InfiniteLee cf511a7
reduce how often sharedBuffer.update() is called to improve performan…
InfiniteLee bf8d8b6
allow scaling of interactable-media via scrolling events
InfiniteLee 3173532
Merge branch 'feature/remove_velocity_haptics' into feature/drawing
InfiniteLee 36d5dd2
spawn pen near hand when user is determined to be using 6-dof
InfiniteLee 6a4e0bd
fixes for lint; update pen gltf
InfiniteLee 484b05e
fix issue where camera look would be enabled the second time you grab…
InfiniteLee 9c201bc
fix issue where scroll-scaling wasn't updating its local scale value;…
InfiniteLee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| /* global AFRAME, THREE */ | ||
| const inherit = AFRAME.utils.extendDeep; | ||
| const physicsCore = require("super-hands/reaction_components/prototypes/physics-grab-proto.js"); | ||
| const buttonsCore = require("super-hands/reaction_components/prototypes/buttons-proto.js"); | ||
| // new object with all core modules | ||
| const base = inherit({}, physicsCore, buttonsCore); | ||
| AFRAME.registerComponent( | ||
| "grabbable-toggle", | ||
| inherit(base, { | ||
| schema: { | ||
| maxGrabbers: { type: "int", default: NaN }, | ||
| invert: { default: false }, | ||
| suppressY: { default: false }, | ||
| primaryReleaseEvents: { default: ["primary_hand_release"] }, | ||
| secondaryReleaseEvents: { default: ["secondary_hand_release"] } | ||
| }, | ||
| init: function() { | ||
| this.GRABBED_STATE = "grabbed"; | ||
| this.GRAB_EVENT = "grab-start"; | ||
| this.UNGRAB_EVENT = "grab-end"; | ||
| this.grabbed = false; | ||
| this.grabbers = []; | ||
| this.constraints = new Map(); | ||
| this.deltaPositionIsValid = false; | ||
| this.grabDistance = undefined; | ||
| this.grabDirection = { x: 0, y: 0, z: -1 }; | ||
| this.grabOffset = { x: 0, y: 0, z: 0 }; | ||
| // persistent object speeds up repeat setAttribute calls | ||
| this.destPosition = { x: 0, y: 0, z: 0 }; | ||
| this.deltaPosition = new THREE.Vector3(); | ||
| this.targetPosition = new THREE.Vector3(); | ||
| this.physicsInit(); | ||
|
|
||
| this.el.addEventListener(this.GRAB_EVENT, e => this.start(e)); | ||
| this.el.addEventListener(this.UNGRAB_EVENT, e => this.end(e)); | ||
| this.el.addEventListener("mouseout", e => this.lostGrabber(e)); | ||
|
|
||
| this.toggle = false; | ||
| this.lastGrabber = null; | ||
| }, | ||
| update: function() { | ||
| this.physicsUpdate(); | ||
| this.xFactor = this.data.invert ? -1 : 1; | ||
| this.zFactor = this.data.invert ? -1 : 1; | ||
| this.yFactor = (this.data.invert ? -1 : 1) * !this.data.suppressY; | ||
| }, | ||
| tick: (function() { | ||
| const q = new THREE.Quaternion(); | ||
| const v = new THREE.Vector3(); | ||
|
|
||
| return function() { | ||
| let entityPosition; | ||
| if (this.grabber) { | ||
| // reflect on z-axis to point in same direction as the laser | ||
| this.targetPosition.copy(this.grabDirection); | ||
| this.targetPosition | ||
| .applyQuaternion(this.grabber.object3D.getWorldQuaternion(q)) | ||
| .setLength(this.grabDistance) | ||
| .add(this.grabber.object3D.getWorldPosition(v)) | ||
| .add(this.grabOffset); | ||
| if (this.deltaPositionIsValid) { | ||
| // relative position changes work better with nested entities | ||
| this.deltaPosition.sub(this.targetPosition); | ||
| entityPosition = this.el.getAttribute("position"); | ||
| this.destPosition.x = entityPosition.x - this.deltaPosition.x * this.xFactor; | ||
| this.destPosition.y = entityPosition.y - this.deltaPosition.y * this.yFactor; | ||
| this.destPosition.z = entityPosition.z - this.deltaPosition.z * this.zFactor; | ||
| this.el.setAttribute("position", this.destPosition); | ||
| } else { | ||
| this.deltaPositionIsValid = true; | ||
| } | ||
| this.deltaPosition.copy(this.targetPosition); | ||
| } | ||
| }; | ||
| })(), | ||
| remove: function() { | ||
| this.el.removeEventListener(this.GRAB_EVENT, this.start); | ||
| this.el.removeEventListener(this.UNGRAB_EVENT, this.end); | ||
| this.physicsRemove(); | ||
| }, | ||
| start: function(evt) { | ||
| if (evt.defaultPrevented || !this.startButtonOk(evt)) { | ||
| return; | ||
| } | ||
| // room for more grabbers? | ||
| let grabAvailable = !Number.isFinite(this.data.maxGrabbers) || this.grabbers.length < this.data.maxGrabbers; | ||
| if (Number.isFinite(this.data.maxGrabbers) && !grabAvailable && this.grabbed) { | ||
| this.grabbers[0].components["super-hands"].onGrabEndButton(); | ||
| grabAvailable = true; | ||
| } | ||
| if (this.grabbers.indexOf(evt.detail.hand) === -1 && grabAvailable) { | ||
| if (!evt.detail.hand.object3D) { | ||
| console.warn("grabbable entities must have an object3D"); | ||
| return; | ||
| } | ||
| this.grabbers.push(evt.detail.hand); | ||
| // initiate physics if available, otherwise manual | ||
| if (!this.physicsStart(evt) && !this.grabber) { | ||
| this.grabber = evt.detail.hand; | ||
| this.resetGrabber(); | ||
| } | ||
| // notify super-hands that the gesture was accepted | ||
| if (evt.preventDefault) { | ||
| evt.preventDefault(); | ||
| } | ||
| this.grabbed = true; | ||
| this.el.addState(this.GRABBED_STATE); | ||
| } | ||
| }, | ||
| end: function(evt) { | ||
| const handIndex = this.grabbers.indexOf(evt.detail.hand); | ||
| if (evt.defaultPrevented || !this.endButtonOk(evt)) { | ||
| return; | ||
| } | ||
|
|
||
| const type = evt.detail && evt.detail.buttonEvent ? evt.detail.buttonEvent.type : null; | ||
|
|
||
| if (this.toggle && this.lastGrabber !== this.grabbers[0]) { | ||
| this.toggle = false; | ||
| this.lastGrabber = null; | ||
| } | ||
|
|
||
| if (handIndex !== -1) { | ||
| this.grabbers.splice(handIndex, 1); | ||
| this.grabber = this.grabbers[0]; | ||
| } | ||
|
|
||
| if ((this.isPrimaryRelease(type) && !this.toggle) || this.isSecondaryRelease(type)) { | ||
| this.toggle = true; | ||
| this.lastGrabber = this.grabbers[0]; | ||
| return; | ||
| } else if (this.toggle && this.isPrimaryRelease(type)) { | ||
| this.toggle = false; | ||
| this.lastGrabber = null; | ||
| } | ||
|
|
||
| this.physicsEnd(evt); | ||
| if (!this.resetGrabber()) { | ||
| this.grabbed = false; | ||
| this.el.removeState(this.GRABBED_STATE); | ||
| } | ||
| if (evt.preventDefault) { | ||
| evt.preventDefault(); | ||
| } | ||
| }, | ||
| resetGrabber: (() => { | ||
| const objPos = new THREE.Vector3(); | ||
| const grabPos = new THREE.Vector3(); | ||
| return function() { | ||
| if (!this.grabber) { | ||
| return false; | ||
| } | ||
| const raycaster = this.grabber.getAttribute("raycaster"); | ||
| this.deltaPositionIsValid = false; | ||
| this.grabDistance = this.el.object3D | ||
| .getWorldPosition(objPos) | ||
| .distanceTo(this.grabber.object3D.getWorldPosition(grabPos)); | ||
| if (raycaster) { | ||
| this.grabDirection = raycaster.direction; | ||
| this.grabOffset = raycaster.origin; | ||
| } | ||
| return true; | ||
| }; | ||
| })(), | ||
| lostGrabber: function(evt) { | ||
| const i = this.grabbers.indexOf(evt.relatedTarget); | ||
| // if a queued, non-physics grabber leaves the collision zone, forget it | ||
| if (i !== -1 && evt.relatedTarget !== this.grabber && !this.physicsIsConstrained(evt.relatedTarget)) { | ||
| this.grabbers.splice(i, 1); | ||
| } | ||
| }, | ||
|
|
||
| isPrimaryRelease(type) { | ||
| return this.data.primaryReleaseEvents.indexOf(type) !== -1; | ||
| }, | ||
|
|
||
| isSecondaryRelease(type) { | ||
| return this.data.secondaryReleaseEvents.indexOf(type) !== -1; | ||
| } | ||
| }) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * Drawing Manager | ||
| * @component drawing-manager | ||
| */ | ||
| AFRAME.registerComponent("drawing-manager", { | ||
| schema: { | ||
| drawing: { type: "string" } | ||
| }, | ||
|
|
||
| init() { | ||
| this.handleDrawingInitialized = this.handleDrawingInitialized.bind(this); | ||
|
|
||
| // this.drawingEl = document.querySelector(this.data.drawing); | ||
| this.drawingToPen = new Map(); | ||
|
|
||
| // if (this.drawingEl.hasLoaded) { | ||
|
||
| // this.drawing = this.drawingEl.components["networked-drawing"]; | ||
| // } else { | ||
| // this.drawingEl.addEventListener("componentinitialized", this.handleDrawingInitialized); | ||
| // } | ||
| }, | ||
|
|
||
| remove() { | ||
| // this.drawingEl.removeEventListener("componentinitialized", this.handleDrawingInitialized); | ||
| }, | ||
|
|
||
| play() { | ||
| this.drawing = document.querySelector(this.data.drawing).components["networked-drawing"]; | ||
| }, | ||
|
|
||
| pause() {}, | ||
|
|
||
| handleDrawingInitialized(e) { | ||
| if (e.detail.name === "networked-drawing") { | ||
| this.drawing = this.drawingEl.components["networked-drawing"]; | ||
| } | ||
| }, | ||
|
|
||
| getDrawing(pen) { | ||
| //TODO: future handling of multiple drawings | ||
| if (this.drawing && (!this.drawingToPen.has(this.drawing) || this.drawingToPen.get(this.drawing) === pen)) { | ||
| this.drawingToPen.set(this.drawing, pen); | ||
| return this.drawing; | ||
| } | ||
|
|
||
| return null; | ||
| }, | ||
|
|
||
| returnDrawing(pen) { | ||
| if (this.drawingToPen.has(this.drawing) && this.drawingToPen.get(this.drawing) === pen) { | ||
| this.drawingToPen.delete(this.drawing); | ||
| } | ||
| } | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Change
useCustomSpawnRotationtouseCustomSpawnScale.