From cb53f9b16faad17d5b81aff57cfa951c1eeeac91 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 12 Jan 2023 16:05:59 +0100 Subject: [PATCH] Sound --- protocols/schemas/shapes.prs | 4 +++- scene/lobby.pr | 13 +++++++------ src/shapes.ts | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/protocols/schemas/shapes.prs b/protocols/schemas/shapes.prs index 9059430..f848a68 100644 --- a/protocols/schemas/shapes.prs +++ b/protocols/schemas/shapes.prs @@ -2,7 +2,7 @@ version 1 . Sprite = . -Shape = Mesh / Light / Scale / Move / Rotate / @many [Shape ...] / Texture / Color / Name / Floor / Nonphysical / Touchable / CSG / Skybox . +Shape = Mesh / Light / Scale / Move / Rotate / @many [Shape ...] / Texture / Color / Sound / Name / Floor / Nonphysical / Touchable / CSG / Skybox . Mesh = Sphere / Box / Ground / Plane / External . @@ -34,6 +34,8 @@ Color = / @transparent . +Sound = . + Name = . Floor = . diff --git a/scene/lobby.pr b/scene/lobby.pr index af1a01f..eec7181 100644 --- a/scene/lobby.pr +++ b/scene/lobby.pr @@ -76,12 +76,13 @@ ] - >>> - >>> - ]> - > + >>> + >>> + ]> + >> >>> ; diff --git a/src/shapes.ts b/src/shapes.ts index d5b0ad9..ea361c8 100644 --- a/src/shapes.ts +++ b/src/shapes.ts @@ -12,6 +12,7 @@ import { Quaternion, Scene, SceneLoader, + Sound, StandardMaterial, Texture, TransformNode, @@ -252,6 +253,27 @@ export function build(name: string, scene: Scene, shape: Shapes.Shape, customize }); } + case "Sound": { + const sound = new Sound( + name + ".sound", + shape.value.url, + scene, + null, + { + distanceModel: "inverse", + loop: true, + rolloffFactor: 0.25, + autoplay: true, + streaming: true, + skipCodecCheck: true, + }); + console.log(sound); + return build(name + ".inner", scene, shape.value.shape, { + ... customize, + sound: async m => sound.attachToMesh(m.rootnode), + }); + } + case "Name": return build(name + '.' + shape.value.base, scene, shape.value.shape, customize);