Skip to content
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
23732f3
WIP - drawing/pen tool, initial commit
InfiniteLee Jun 27, 2018
24da819
Added drawing of "caps" to the start/end of each line drawn; cleaned …
InfiniteLee Jun 29, 2018
592d252
seperate pen and networked-drawing components
InfiniteLee Jun 30, 2018
e345c7e
Merge branch 'master' into feature/drawing
InfiniteLee Jul 2, 2018
4a0d90b
first pass at networking drawings (unoptimzied)
InfiniteLee Jul 3, 2018
a49be34
bug fixes and optimizations; testing with 6-dof controller
InfiniteLee Jul 6, 2018
240fc1f
fixes
InfiniteLee Jul 6, 2018
3d29c8c
update networking to not rely on networked-aframe's default attribute…
InfiniteLee Jul 11, 2018
1209809
adding chunking on inital drawBuffer sync
InfiniteLee Jul 12, 2018
4c512b5
colors work now (but they don't network correctly yet).
InfiniteLee Jul 12, 2018
2bc4fa2
Colors are now network synced properly; slightly improved how the mat…
InfiniteLee Jul 12, 2018
13038ef
Adding pen interactable
InfiniteLee Jul 13, 2018
763a446
Merge branch 'master' into feature/drawing
InfiniteLee Jul 13, 2018
d4e0a5b
Adding pen interactable
InfiniteLee Jul 16, 2018
776dc76
activatable component and sticky behavior
InfiniteLee Jul 19, 2018
56baef3
use meshBasicMaterial for now since normals arent calculated correctly
InfiniteLee Jul 19, 2018
5bfaf0e
Merge branch 'master' into feature/drawing
InfiniteLee Jul 19, 2018
6158c6c
fix lint issues
InfiniteLee Jul 19, 2018
7039d64
one more lint fix
InfiniteLee Jul 19, 2018
3588a27
more fixes...
InfiniteLee Jul 19, 2018
0a1545d
enable sticky behavior for mouse
InfiniteLee Jul 20, 2018
3067dfe
sticky and activatable work with cursor now.
InfiniteLee Jul 24, 2018
da40d65
refactoring input for 6dof hands + cursor
InfiniteLee Jul 26, 2018
74d69cc
fix hand switching
InfiniteLee Jul 27, 2018
f413ccb
unused var
InfiniteLee Jul 27, 2018
6830075
merge master
InfiniteLee Jul 27, 2018
a103f9f
fix lint
InfiniteLee Jul 27, 2018
9aeff16
fixed faceculling order on geometry for lines and caps, both even and…
InfiniteLee Aug 7, 2018
35e962a
calculate vertex normals better so that lines have correct lighting w…
InfiniteLee Aug 8, 2018
869de4c
cleanup sharedbuffergeometry
InfiniteLee Aug 8, 2018
645e576
Merge branch 'master' into feature/drawing
InfiniteLee Aug 8, 2018
57c857a
add color changing for 6-dof and fixing oculus go input
InfiniteLee Aug 10, 2018
bd2509a
fixed networking
InfiniteLee Aug 11, 2018
7dd8003
change grabbable-toggle into a full replacement for grabbable reactio…
InfiniteLee Aug 14, 2018
4e9946d
lint fixes
InfiniteLee Aug 14, 2018
783768c
networked pen color
InfiniteLee Aug 14, 2018
af54f91
limit length of individual lines; limit how many lines can persist be…
InfiniteLee Aug 15, 2018
53d6257
lint fixes
InfiniteLee Aug 15, 2018
d8ebdb5
more lint fixes
InfiniteLee Aug 15, 2018
7d8247f
change color by scrolling touchpad
InfiniteLee Aug 16, 2018
92a44ac
fix race condition
InfiniteLee Aug 16, 2018
fad6c17
need to send color with every line
InfiniteLee Aug 16, 2018
59b8cfe
Merge branch 'master' into feature/drawing
InfiniteLee Aug 16, 2018
74d6ef6
fix bug where single point lines were not being ended correctly
InfiniteLee Aug 17, 2018
543cce9
fix bugs that occur if users are drawing when a new user enters the room
InfiniteLee Aug 20, 2018
7d15850
remove logging
InfiniteLee Aug 20, 2018
145e538
remove velocity based haptics on interactables
InfiniteLee Aug 20, 2018
a0989de
add functionality to change pen radius
InfiniteLee Aug 21, 2018
f7e4d80
encode radius of pen on the direction vector.
InfiniteLee Aug 21, 2018
c1eeb51
allow changing color and scale via mouse when holding alt or shift ke…
InfiniteLee Aug 21, 2018
a560ecc
fix color changing on oculus go
InfiniteLee Aug 22, 2018
735acfa
enable color and radius to be changed mid-line, update networking to …
InfiniteLee Aug 22, 2018
35ccfc4
clean up/update how scrolling is handled
InfiniteLee Aug 23, 2018
0221433
Merge branch 'master' into feature/drawing
InfiniteLee Aug 23, 2018
e0a428d
cleanup
InfiniteLee Aug 23, 2018
c2a6cad
rename sticky class to toggle so it doesn't get confused with sticky-…
InfiniteLee Aug 23, 2018
a576031
get rid of added actions on vive trackpad because now they are redundant
InfiniteLee Aug 23, 2018
2d44166
get rid of "tertiary" input events since they're handled by scrolling…
InfiniteLee Aug 23, 2018
de9919a
add back in preventDefault in case of scrolling while holding alt key
InfiniteLee Aug 23, 2018
4abeda6
various updates to support moving the duck and pen into the gltf-comp…
InfiniteLee Aug 23, 2018
830d51d
various cleanup; fix issue with swapping hands with toggle interactables
InfiniteLee Aug 24, 2018
e206702
Merge branch 'master' into feature/drawing
InfiniteLee Aug 27, 2018
f5b845b
fix bug where grabbing state was not properly removed from grabbable-…
InfiniteLee Aug 27, 2018
afa0ea4
cleanup; fixing bugs around how line endings are networked
InfiniteLee Aug 28, 2018
f92e189
Merge branch 'master' into feature/drawing
InfiniteLee Aug 28, 2018
c762b1d
cleanup
InfiniteLee Aug 29, 2018
4302686
fix issue with teleporting on 3-dof
InfiniteLee Aug 29, 2018
bec4321
add ability to spawn pen from hud (replacing the space bubble toggle)…
InfiniteLee Aug 30, 2018
1505cae
update pen icons
InfiniteLee Aug 30, 2018
fff303a
lint fixes
InfiniteLee Aug 30, 2018
8e00551
update spawn_pen icons again
InfiniteLee Aug 30, 2018
4ae6f00
fix bug where normal was being modified incorrectly
InfiniteLee Aug 30, 2018
9ae9d1f
fix spawn_pen-hover icon
InfiniteLee Aug 30, 2018
28438d4
fix issue with pen not drawing until second primary_grab; fix spawn_p…
InfiniteLee Aug 30, 2018
73e2cc6
Merge branch 'master' into feature/drawing
InfiniteLee Aug 30, 2018
7d23549
fix issue where spawning pen in hud was frame behind causing issues.
InfiniteLee Aug 31, 2018
c9e47d7
fix bug where joystick input in rift would drop objects; fix bug wher…
InfiniteLee Aug 31, 2018
daa99a0
fix issues were multiple networked-drawings could interfere with each…
InfiniteLee Sep 4, 2018
7ff3f47
Merge branch 'master' into feature/drawing
InfiniteLee Sep 5, 2018
8520817
fix bug that occur because clients were assuming mutual dataChannel c…
InfiniteLee Sep 6, 2018
db345bc
fix lint
InfiniteLee Sep 6, 2018
cf511a7
reduce how often sharedBuffer.update() is called to improve performan…
InfiniteLee Sep 6, 2018
bf8d8b6
allow scaling of interactable-media via scrolling events
InfiniteLee Sep 6, 2018
3173532
Merge branch 'feature/remove_velocity_haptics' into feature/drawing
InfiniteLee Sep 6, 2018
36d5dd2
spawn pen near hand when user is determined to be using 6-dof
InfiniteLee Sep 6, 2018
6a4e0bd
fixes for lint; update pen gltf
InfiniteLee Sep 7, 2018
484b05e
fix issue where camera look would be enabled the second time you grab…
InfiniteLee Sep 7, 2018
9c201bc
fix issue where scroll-scaling wasn't updating its local scale value;…
InfiniteLee Sep 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 220 additions & 111 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"react-dom": "^16.1.1",
"react-intl": "^2.4.0",
"screenfull": "^3.3.2",
"super-hands": "github:mozillareality/aframe-super-hands-component#f8f9781d8b4c487bb544b3986000e85ed5f82fcc",
"super-hands": "github:mozillareality/aframe-super-hands-component#feature/drawing",
"three": "github:mozillareality/three.js#8b1886c384371c3e6305b757d1db7577c5201a9b",
"three-pathfinding": "^0.7.0",
"three-to-cannon": "1.3.0",
Expand Down
Binary file added src/assets/hud/spawn_pen-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/hud/spawn_pen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/assets/stylesheets/2d-hud.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
background-image: url(../hud/bubble_on-hover.png);
}

:local(.iconButton.spawn_pen) {
background-image: url(../hud/spawn_pen.png);
}
:local(.iconButton.spawn_pen:hover) {
background-image: url(../hud/spawn_pen-hover.png);
}

:local(.iconButton.freeze) {
background-image: url(../hud/freeze_off.png);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/css-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AFRAME.registerComponent("css-class", {
schema: {
type: "string"
},
multiple: true,
init() {
this.el.classList.add(this.data);
},
Expand Down
10 changes: 8 additions & 2 deletions src/components/cursor-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ AFRAME.registerComponent("cursor-controller", {
this.updateRay();
}

const isGrabbing = this.data.cursor.components["super-hands"].state.has("grab-start");
const isGrabbing = this.isInteracting();
if (isGrabbing) {
const distance = Math.min(
this.data.maxDistance,
Expand Down Expand Up @@ -153,6 +153,10 @@ AFRAME.registerComponent("cursor-controller", {
this.data.cursor.components["static-body"].syncToPhysics();
},

isInteracting: function() {
return this.data.cursor.components["super-hands"].state.has("grab-start");
},

startInteraction: function() {
if (this._isTargetOfType(TARGET_TYPE_INTERACTABLE_OR_UI)) {
this.data.cursor.emit("cursor-grab", {});
Expand All @@ -174,9 +178,11 @@ AFRAME.registerComponent("cursor-controller", {
const targetDistanceMod = this.currentDistanceMod + delta;
const moddedDistance = this.currentDistance - targetDistanceMod;
if (moddedDistance > maxDistance || moddedDistance < minDistance) {
return;
return false;
}

this.currentDistanceMod = targetDistanceMod;
return true;
},

_handleCursorLoaded: function() {
Expand Down
185 changes: 185 additions & 0 deletions src/components/grabbable-toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/* 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.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;
}

if (handIndex !== -1) {
this.grabbers.splice(handIndex, 1);
this.grabber = this.grabbers[0];
}

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;
}
})
);
16 changes: 8 additions & 8 deletions src/components/in-world-hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ AFRAME.registerComponent("in-world-hud", {
init() {
this.mic = this.el.querySelector(".mic");
this.freeze = this.el.querySelector(".freeze");
this.bubble = this.el.querySelector(".bubble");
this.pen = this.el.querySelector(".pen");
this.background = this.el.querySelector(".bg");
const renderOrder = window.APP.RENDER_ORDER;
this.mic.object3DMap.mesh.renderOrder = renderOrder.HUD_ICONS;
this.freeze.object3DMap.mesh.renderOrder = renderOrder.HUD_ICONS;
this.bubble.object3DMap.mesh.renderOrder = renderOrder.HUD_ICONS;
this.pen.object3DMap.mesh.renderOrder = renderOrder.HUD_ICONS;
this.background.object3DMap.mesh.renderORder = renderOrder.HUD_BACKGROUND;

this.updateButtonStates = () => {
this.mic.setAttribute("icon-button", "active", this.el.sceneEl.is("muted"));
this.freeze.setAttribute("icon-button", "active", this.el.sceneEl.is("frozen"));
this.bubble.setAttribute("icon-button", "active", this.el.sceneEl.is("spacebubble"));
this.pen.setAttribute("icon-button", "active", this.el.sceneEl.is("pen"));
};
this.updateButtonStates();

this.onStateChange = evt => {
if (!(evt.detail === "muted" || evt.detail === "frozen" || evt.detail === "spacebubble")) return;
if (!(evt.detail === "muted" || evt.detail === "frozen" || evt.detail === "pen")) return;
this.updateButtonStates();
};

Expand All @@ -39,8 +39,8 @@ AFRAME.registerComponent("in-world-hud", {
this.el.emit("action_freeze");
};

this.onBubbleClick = () => {
this.el.emit("action_space_bubble");
this.onPenClick = () => {
this.el.emit("spawn_pen");
};
},

Expand All @@ -50,7 +50,7 @@ AFRAME.registerComponent("in-world-hud", {

this.mic.addEventListener("click", this.onMicClick);
this.freeze.addEventListener("click", this.onFreezeClick);
this.bubble.addEventListener("click", this.onBubbleClick);
this.pen.addEventListener("mousedown", this.onPenClick);
},

pause() {
Expand All @@ -59,6 +59,6 @@ AFRAME.registerComponent("in-world-hud", {

this.mic.removeEventListener("click", this.onMicClick);
this.freeze.removeEventListener("click", this.onFreezeClick);
this.bubble.removeEventListener("click", this.onBubbleClick);
this.pen.removeEventListener("mousedown", this.onPenClick);
}
});
2 changes: 1 addition & 1 deletion src/components/input-configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ AFRAME.registerComponent("input-configurator", {
this.cursor.el.setAttribute("cursor-controller", { rayObject: this.data.gazeCursorRayObject });
}

if (this.actionEventHandler) {
if (this.actionEventHandler && this.controller) {
this.actionEventHandler.setHandThatAlsoDrivesCursor(this.controller);
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/components/media-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ AFRAME.registerComponent("media-loader", {
this.onError = this.onError.bind(this);
this.showLoader = this.showLoader.bind(this);
this.clearLoadingTimeout = this.clearLoadingTimeout.bind(this);
this.shapeAdded = false;
},

setShapeAndScale(resize) {
const mesh = this.el.getObject3D("mesh");
const box = getBox(this.el, mesh);
const scaleCoefficient = resize ? getScaleCoefficient(0.5, box) : 1;
this.el.object3DMap.mesh.scale.multiplyScalar(scaleCoefficient);
if (this.el.body && this.el.body.shapes.length > 1) {
if (this.el.body && this.shapeAdded && this.el.body.shapes.length > 1) {
this.el.removeAttribute("shape");
} else {
this.shapeAdded = false;
} else if (this.el.body.shapes.length === 0) {
const center = new THREE.Vector3();
const { min, max } = box;
const halfExtents = {
Expand All @@ -43,6 +45,7 @@ AFRAME.registerComponent("media-loader", {
shape: "box",
halfExtents: halfExtents
});
this.shapeAdded = true;
}
},

Expand Down
Loading