diff --git a/src/assets/interactables/duck/DuckyMesh.glb b/src/assets/interactables/duck/DuckyMesh.glb new file mode 100644 index 0000000000000000000000000000000000000000..5bb10e0cd79c623f72f87d438f6eddbe1d0dc250 Binary files /dev/null and b/src/assets/interactables/duck/DuckyMesh.glb differ diff --git a/src/components/event-repeater.js b/src/components/event-repeater.js new file mode 100644 index 0000000000000000000000000000000000000000..d6f396766cd82cf42548d93f0808256a1e4891cd --- /dev/null +++ b/src/components/event-repeater.js @@ -0,0 +1,16 @@ +AFRAME.registerComponent("event-repeater", { + schema: { + target: {type: "selector"}, + events: {type: "array"} + }, + + init: function() { + let events = this.data.events; + for (let i = 0; i < events.length; i++) { + this.data.target.addEventListener(events[i], e => { + this.el.emit(events[i], e.details); + }); + } + } + +}); \ No newline at end of file diff --git a/src/room.html b/src/room.html index 2f45bd2ea2190db333f28268a2ccc45fed8614bd..eef387bc25ea88f937d6e951d8b9e697de17567e 100644 --- a/src/room.html +++ b/src/room.html @@ -34,6 +34,7 @@ <a-asset-item id="outdoor-facade-mesh" response-type="arraybuffer" src="./assets/environments/OutdoorFacade_mesh.glb"></a-asset-item> <a-asset-item id="floor-nav-mesh" response-type="arraybuffer" src="./assets/environments/FloorNav_mesh.glb"></a-asset-item> <a-asset-item id="cliff-vista-mesh" response-type="arraybuffer" src="./assets/environments/CliffVista_mesh.glb"></a-asset-item> + <a-asset-item id="interactable-duck" response-type="arraybuffer" src="./assets/interactables/duck/DuckyMesh.glb"></a-asset-item> <img id="water-normal-map" src="./assets/waternormals.jpg"></a-asset-item> @@ -88,15 +89,15 @@ <template id="interactable-template"> <a-entity - geometry="primitive: box" + gltf-model="#interactable-duck" + scale="2 2 2" class="collidable" remote-dynamic-body="counter: #counter; mass: 5;" - scale="0.25 0.25 0.25" - material="color: green" - body="type: dynamic; mass: 5;" + body="type: dynamic; mass: 5; shape: box;" grabbable stretchable - ></a-entity> + > + </a-entity> </template> <a-mixin id="super-hands" @@ -115,17 +116,14 @@ <a-entity id="counter" networked-counter="max: 3; ttl: 120"></a-entity> <a-entity - id="cube-spawner" + gltf-model="#interactable-duck" + scale="2 2 2" + class="collidable" + class="collidable" super-spawner="template: #interactable-template; spawn_position: 2.5 1.2 0;" position="2.5 1.2 0" - > - <a-box - material="color: blue" - class="collidable" - scale="0.25 0.25 0.25" - body="mass: 0; type: static;" - ></a-box> - </a-entity> + body="mass: 0; type: static; shape: box;" + ></a-entity> <a-sphere id="3d-cursor" @@ -154,9 +152,10 @@ look-controls="pointerLockEnabled: true;" > <a-entity + id="cursor-hand" cursor-hand="cursor: #3d-cursor" position="0 0 0" - raycaster="objects: .collidable; direction: 0 0 -1; recursive: false;" + raycaster="objects: .collidable; direction: 0 0 -1;" ></a-entity> </a-entity> @@ -167,8 +166,6 @@ tracked-controls teleport-controls="cameraRig: #player-rig; teleportOrigin: #player-camera; button: action_teleport_" haptic-feedback - static-body="shape: sphere; sphereRadius: 0.02" - mixin="super-hands" ></a-entity> <a-entity @@ -178,8 +175,6 @@ tracked-controls teleport-controls="cameraRig: #player-rig; teleportOrigin: #player-camera; button: action_teleport_" haptic-feedback - static-body="shape: sphere; sphereRadius: 0.02" - mixin="super-hands" ></a-entity> <a-gltf-entity src="#bot-skinned-mesh" inflate="true" ik-controller> @@ -203,8 +198,26 @@ rotation="0 -90 90" position="0 -0.04 0" ></a-gltf-entity> + <a-entity + event-repeater="events: action_grab, action_release; target: #player-left-controller" + static-body="shape: sphere; sphereRadius: 0.02" + mixin="super-hands" + position="0 0.05 0" + ></a-entity> </a-entity> </template> + + <template data-selector=".RightHand"> + <a-entity> + <a-entity + event-repeater="events: action_grab, action_release; target: #player-right-controller" + static-body="shape: sphere; sphereRadius: 0.02" + mixin="super-hands" + position="0 -0.05 0" + ></a-entity> + </a-entity> + </template> + </a-gltf-entity> </a-entity> diff --git a/src/room.js b/src/room.js index f8dd6580f38e6f3ac155ae056fa7b9a889953420..4e6a569b1aaaf1df73c4f3b7d2b2197c71d63fff 100644 --- a/src/room.js +++ b/src/room.js @@ -50,6 +50,7 @@ import "./components/remote-dynamic-body"; import "./components/networked-counter"; import "./components/super-spawner"; import "./components/cursor-hand"; +import "./components/event-repeater"; import { promptForName, getCookie, parseJwt } from "./utils/identity"; import registerNetworkSchemas from "./network-schemas";