Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 7 additions & 13 deletions src/ray-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default class RayController extends EventEmitter {

onMouseDown_(e) {
this.startDragging_(e);
this.emit('raydown');
this.emit('raydown', e);
}

onMouseMove_(e) {
Expand All @@ -167,7 +167,7 @@ export default class RayController extends EventEmitter {
}

onMouseUp_(e) {
this.endDragging_();
this.endDragging_(e);
}

onTouchStart_(e) {
Expand All @@ -177,10 +177,7 @@ export default class RayController extends EventEmitter {
this.updateTouchPointer_(e);

this.emit('pointermove', this.pointerNdc);
this.emit('raydown');

// Prevent synthetic mouse event from being created.
e.preventDefault();
this.emit('raydown', e);
}

onTouchMove_(e) {
Expand All @@ -192,10 +189,8 @@ export default class RayController extends EventEmitter {
}

onTouchEnd_(e) {
this.endDragging_();
this.endDragging_(e);

// Prevent synthetic mouse event from being created.
e.preventDefault();
this.isTouchActive = false;
}

Expand All @@ -222,8 +217,6 @@ export default class RayController extends EventEmitter {
this.dragDistance += distance;
this.lastPointer.copy(this.pointer);


//console.log('dragDistance', this.dragDistance);
if (this.dragDistance > DRAG_DISTANCE_PX) {
this.emit('raycancel');
this.isDragging = false;
Expand All @@ -233,12 +226,13 @@ export default class RayController extends EventEmitter {

startDragging_(e) {
this.isDragging = true;
this.dragDistance = 0;
this.lastPointer.set(e.clientX, e.clientY);
}

endDragging_() {
endDragging_(e) {
if (this.dragDistance < DRAG_DISTANCE_PX) {
this.emit('rayup');
this.emit('rayup', e);
}
this.dragDistance = 0;
this.isDragging = false;
Expand Down
13 changes: 10 additions & 3 deletions src/ray-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,22 @@ export default class RayInput extends EventEmitter {
// Force the renderer to raycast.
this.renderer.update();
let mesh = this.renderer.getSelectedMesh();

this.rayDownMesh = mesh;
this.emit('raydown', mesh);

this.renderer.setActive(true);
}

onRayUp_(e) {
//console.log('onRayUp_');
let mesh = this.renderer.getSelectedMesh();
this.emit('rayup', mesh);
// console.log('onRayUp_', e && this.rayDownMesh);

if (e && this.rayDownMesh) {
e.preventDefault();
}

this.emit('rayup', this.rayDownMesh);
this.rayDownMesh = null;

this.renderer.setActive(false);
}
Expand Down