Skip to content
Snippets Groups Projects
Unverified Commit 2145762c authored by Kevin Lee's avatar Kevin Lee Committed by GitHub
Browse files

Merge pull request #298 from mozilla/feature/duck-spawner-updates

Feature/duck spawner updates
parents 6457f5ef aa5c1c50
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@ AFRAME.registerComponent("super-spawner", {
template: { default: "" },
useCustomSpawnPosition: { default: false },
spawnPosition: { type: "vec3" },
useCustomSpawnRotation: { default: false },
spawnRotation: { type: "vec4" },
events: { default: ["cursor-grab", "action_grab"] },
spawnCooldown: { default: 1 }
},
......@@ -10,7 +12,6 @@ AFRAME.registerComponent("super-spawner", {
init: function() {
this.entities = new Map();
this.timeout = null;
this.defaultScale = this.el.getAttribute("scale").clone();
},
play: function() {
......@@ -21,10 +22,12 @@ AFRAME.registerComponent("super-spawner", {
pause: function() {
this.el.removeEventListener("grab-start", this.handleGrabStart);
clearTimeout(this.timeout);
this.timeout = null;
this.el.setAttribute("visible", true);
this.el.setAttribute("scale", this.defaultScale);
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
this.el.setAttribute("visible", true);
this.el.classList.add("interactable");
}
},
remove: function() {
......@@ -61,14 +64,16 @@ AFRAME.registerComponent("super-spawner", {
const pos = this.data.useCustomSpawnPosition ? this.data.spawnPosition : this.el.getAttribute("position");
entity.setAttribute("position", pos);
const rot = this.data.useCustomSpawnRotation ? this.data.spawnRotation : this.el.getAttribute("rotation");
entity.setAttribute("rotation", rot);
this.el.sceneEl.appendChild(entity);
if (this.data.spawnCooldown > 0) {
this.el.setAttribute("visible", false);
this.el.setAttribute("scale", { x: 0.0001, y: 0.0001, z: 0.0001 });
this.el.classList.remove("interactable");
this.timeout = setTimeout(() => {
this.el.setAttribute("visible", true);
this.el.setAttribute("scale", this.defaultScale);
this.el.classList.add("interactable");
this.timeout = null;
}, this.data.spawnCooldown * 1000);
}
......
......@@ -62,7 +62,7 @@
<a-asset-item id="botwoody" response-type="arraybuffer" src="https://asset-bundles-prod.reticulum.io/bots/BotWoody_Avatar-0140485a23.gltf"></a-asset-item>
<a-asset-item id="watch-model" response-type="arraybuffer" src="./assets/hud/watch.glb"></a-asset-item>
<a-asset-item id="interactable-duck" response-type="arraybuffer" src="./assets/interactables/duck/DuckyMesh.glb"></a-asset-item>
<a-asset-item id="interactable-duck" response-type="arraybuffer" src="https://asset-bundles-prod.reticulum.io/interactables/Ducky/DuckyMesh-438ff8e022.gltf"></a-asset-item>
<a-asset-item id="quack" src="./assets/sfx/quack.mp3" response-type="arraybuffer" preload="auto"></a-asset-item>
<a-asset-item id="specialquack" src="./assets/sfx/specialquack.mp3" response-type="arraybuffer" preload="auto"></a-asset-item>
......@@ -164,7 +164,6 @@
<template id="interactable-template">
<a-entity
gltf-model-plus="src: #interactable-duck; inflate: true;"
scale="2 2 2"
class="interactable"
super-networked-interactable="counter: #counter; mass: 1;"
body="type: dynamic; shape: none; mass: 1;"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment