diff --git a/src/components/super-spawner.js b/src/components/super-spawner.js index 41e2d7aeabbe77f2dc0ba9b3821170fab9724db5..7bd554f5a5ae07026896c45f0a837f5fb7467be3 100644 --- a/src/components/super-spawner.js +++ b/src/components/super-spawner.js @@ -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); } diff --git a/src/hub.html b/src/hub.html index bfdf831d5d7e7d5221b2d8d13afcf15e8032c601..f3cf9e74cafbe3534906c63ab4480b08135088bd 100644 --- a/src/hub.html +++ b/src/hub.html @@ -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;"