From 830d51d9f2195e728ffeb70ce691f55ae25e882f Mon Sep 17 00:00:00 2001 From: Kevin Lee <kevin@infinite-lee.com> Date: Thu, 23 Aug 2018 18:32:21 -0700 Subject: [PATCH] various cleanup; fix issue with swapping hands with toggle interactables --- src/components/grabbable-toggle.js | 5 ++++- src/components/super-spawner.js | 2 +- src/components/tools/drawing-manager.js | 13 ------------- src/hub.html | 4 ++-- src/hub.js | 8 ++++---- src/utils/sharedbuffergeometry.js | 6 +++--- 6 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/components/grabbable-toggle.js b/src/components/grabbable-toggle.js index f3d4bc7e7..d7e978e8c 100644 --- a/src/components/grabbable-toggle.js +++ b/src/components/grabbable-toggle.js @@ -121,7 +121,6 @@ AFRAME.registerComponent( } if (handIndex !== -1) { - this.grabbers.splice(handIndex, 1); this.grabber = this.grabbers[0]; } @@ -134,6 +133,10 @@ AFRAME.registerComponent( this.lastGrabber = null; } + if (handIndex !== -1) { + this.grabbers.splice(handIndex, 1); + } + this.physicsEnd(evt); if (!this.resetGrabber()) { this.grabbed = false; diff --git a/src/components/super-spawner.js b/src/components/super-spawner.js index f2b43e281..a7fa520ba 100644 --- a/src/components/super-spawner.js +++ b/src/components/super-spawner.js @@ -103,7 +103,7 @@ AFRAME.registerComponent("super-spawner", { entity.object3D.rotation.copy( this.data.useCustomSpawnRotation ? this.data.spawnRotation : this.el.object3D.rotation ); - entity.object3D.scale.copy(this.data.useCustomSpawnRotation ? this.data.spawnScale : this.el.object3D.scale); + entity.object3D.scale.copy(this.data.useCustomSpawnScale ? this.data.spawnScale : this.el.object3D.scale); this.activateCooldown(); diff --git a/src/components/tools/drawing-manager.js b/src/components/tools/drawing-manager.js index 34d8f6488..31f7c490e 100644 --- a/src/components/tools/drawing-manager.js +++ b/src/components/tools/drawing-manager.js @@ -10,26 +10,13 @@ AFRAME.registerComponent("drawing-manager", { 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"]; diff --git a/src/hub.html b/src/hub.html index 856919280..65787209d 100644 --- a/src/hub.html +++ b/src/hub.html @@ -170,7 +170,7 @@ super-networked-interactable="counter: #pen-counter; mass: 1;" body="type: dynamic; shape: none; mass: 1;" sticky-object="autoLockOnRelease: true; autoLockOnLoad: true;" - grabbable-toggle="maxGrabbers: 1; maxGrabBehavior: drop;" + grabbable-toggle="maxGrabbers: 1;" hoverable activatable__draw-hand="buttonStartEvents: secondary_hand_grab; buttonEndEvents: secondary_hand_release;" activatable__draw-cursor="buttonStartEvents: secondary-cursor-grab; buttonEndEvents: secondary-cursor-release;" @@ -438,7 +438,7 @@ <!-- TODO: remove this once the pens are added into the environments --> <a-entity - gltf-model-plus="src: https://asset-bundles-prod.reticulum.io/interactables/DrawingPen/DrawingPen-484ae5682f.gltf" + media-loader="src: https://asset-bundles-prod.reticulum.io/interactables/DrawingPen/DrawingPen-484ae5682f.gltf" class="interactable toggle" super-spawner="template: #pen-interactable; src: https://asset-bundles-prod.reticulum.io/interactables/DrawingPen/DrawingPen-484ae5682f.gltf;" position="-1 1.2 -5.5" diff --git a/src/hub.js b/src/hub.js index a22c09680..17ef7acf4 100644 --- a/src/hub.js +++ b/src/hub.js @@ -134,6 +134,10 @@ import "./components/cursor-controller"; import "./components/nav-mesh-helper"; +import "./components/tools/pen"; +import "./components/tools/networked-drawing"; +import "./components/tools/drawing-manager"; + import registerNetworkSchemas from "./network-schemas"; import { inGameActions, config as inputConfig } from "./input-mappings"; import registerTelemetry from "./telemetry"; @@ -141,10 +145,6 @@ import registerTelemetry from "./telemetry"; import { getAvailableVREntryTypes, VR_DEVICE_AVAILABILITY } from "./utils/vr-caps-detect.js"; import ConcurrentLoadDetector from "./utils/concurrent-load-detector.js"; -import "./components/tools/pen"; -import "./components/tools/networked-drawing"; -import "./components/tools/drawing-manager"; - import qsTruthy from "./utils/qs_truthy"; const isBotMode = qsTruthy("bot"); diff --git a/src/utils/sharedbuffergeometry.js b/src/utils/sharedbuffergeometry.js index 189176ffd..0b044be87 100644 --- a/src/utils/sharedbuffergeometry.js +++ b/src/utils/sharedbuffergeometry.js @@ -66,9 +66,9 @@ export default class SharedBufferGeometry { mesh.frustumCulled = false; mesh.vertices = vertices; - this.object3D = new THREE.Object3D(); - this.drawing.add(this.object3D); - this.object3D.add(mesh); + const object3D = new THREE.Object3D(); + this.drawing.add(object3D); + object3D.add(mesh); geometry.setDrawRange(0, 0); geometry.addAttribute("position", new THREE.BufferAttribute(vertices, 3).setDynamic(true)); -- GitLab