@webspatial/core-sdk 1.7.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +10 -0
- package/dist/JSBCommand.d.ts +398 -0
- package/dist/JSBCommand.js +668 -0
- package/dist/JSBCommand.js.map +1 -0
- package/dist/Spatial.d.ts +63 -0
- package/dist/Spatial.js +60 -0
- package/dist/Spatial.js.map +1 -0
- package/dist/SpatialObject.d.ts +19 -0
- package/dist/SpatialObject.js +44 -0
- package/dist/SpatialObject.js.map +1 -0
- package/dist/SpatialScene.d.ts +51 -0
- package/dist/SpatialScene.js +74 -0
- package/dist/SpatialScene.js.map +1 -0
- package/dist/SpatialSession.d.ts +143 -0
- package/dist/SpatialSession.js +173 -0
- package/dist/SpatialSession.js.map +1 -0
- package/dist/SpatialWebEvent.d.ts +8 -0
- package/dist/SpatialWebEvent.js +18 -0
- package/dist/SpatialWebEvent.js.map +1 -0
- package/dist/SpatialWebEventCreator.d.ts +11 -0
- package/dist/SpatialWebEventCreator.js +11 -0
- package/dist/SpatialWebEventCreator.js.map +1 -0
- package/dist/Spatialized2DElement.d.ts +42 -0
- package/dist/Spatialized2DElement.js +47 -0
- package/dist/Spatialized2DElement.js.map +1 -0
- package/dist/SpatializedDynamic3DElement.d.ts +7 -0
- package/dist/SpatializedDynamic3DElement.js +43 -0
- package/dist/SpatializedDynamic3DElement.js.map +1 -0
- package/dist/SpatializedElement.d.ts +7 -0
- package/dist/SpatializedElement.js +206 -0
- package/dist/SpatializedElement.js.map +1 -0
- package/dist/SpatializedElementCreator.d.ts +15 -0
- package/dist/SpatializedElementCreator.js +47 -0
- package/dist/SpatializedElementCreator.js.map +1 -0
- package/dist/SpatializedStatic3DElement.d.ts +195 -0
- package/dist/SpatializedStatic3DElement.js +327 -0
- package/dist/SpatializedStatic3DElement.js.map +1 -0
- package/dist/WebMsgCommand.d.ts +7 -0
- package/dist/WebMsgCommand.js +23 -0
- package/dist/WebMsgCommand.js.map +1 -0
- package/dist/index.d.ts +35 -1251
- package/dist/index.js +21 -3650
- package/dist/index.js.map +1 -1
- package/dist/install-polyfills.d.ts +2 -0
- package/dist/install-polyfills.js +13 -0
- package/dist/install-polyfills.js.map +1 -0
- package/dist/isSSREnv.d.ts +3 -0
- package/dist/isSSREnv.js +6 -0
- package/dist/isSSREnv.js.map +1 -0
- package/dist/motion/AnimationObject.d.ts +7 -0
- package/dist/motion/AnimationObject.js +140 -0
- package/dist/motion/AnimationObject.js.map +1 -0
- package/dist/motion/compute/index.d.ts +10 -0
- package/dist/motion/compute/index.js +19 -0
- package/dist/motion/compute/index.js.map +1 -0
- package/dist/motion/compute/motionPropertyValues.d.ts +19 -0
- package/dist/motion/compute/motionPropertyValues.js +50 -0
- package/dist/motion/compute/motionPropertyValues.js.map +1 -0
- package/dist/motion/compute/normalize.d.ts +31 -0
- package/dist/motion/compute/normalize.js +201 -0
- package/dist/motion/compute/normalize.js.map +1 -0
- package/dist/motion/compute/validate.d.ts +22 -0
- package/dist/motion/compute/validate.js +103 -0
- package/dist/motion/compute/validate.js.map +1 -0
- package/dist/motion/index.d.ts +8 -0
- package/dist/motion/index.js +6 -0
- package/dist/motion/index.js.map +1 -0
- package/dist/motion/native/serializeMotionTimeline.d.ts +12 -0
- package/dist/motion/native/serializeMotionTimeline.js +21 -0
- package/dist/motion/native/serializeMotionTimeline.js.map +1 -0
- package/dist/physicalMetrics-W5uZ5xKb.d.ts +48 -0
- package/dist/physicalMetrics.d.ts +1 -0
- package/dist/physicalMetrics.js +58 -0
- package/dist/physicalMetrics.js.map +1 -0
- package/dist/platform-adapter/CommandResultUtils.d.ts +12 -0
- package/dist/platform-adapter/CommandResultUtils.js +21 -0
- package/dist/platform-adapter/CommandResultUtils.js.map +1 -0
- package/dist/platform-adapter/createPlatformSync.d.ts +16 -0
- package/dist/platform-adapter/createPlatformSync.js +30 -0
- package/dist/platform-adapter/createPlatformSync.js.map +1 -0
- package/dist/platform-adapter/index.d.ts +12 -0
- package/dist/platform-adapter/index.js +10 -0
- package/dist/platform-adapter/index.js.map +1 -0
- package/dist/platform-adapter/interface.d.ts +7 -0
- package/dist/platform-adapter/interface.js +1 -0
- package/dist/platform-adapter/interface.js.map +1 -0
- package/dist/platform-adapter/pico-os/PicoOSPlatform.d.ts +25 -0
- package/dist/platform-adapter/pico-os/PicoOSPlatform.js +168 -0
- package/dist/platform-adapter/pico-os/PicoOSPlatform.js.map +1 -0
- package/dist/platform-adapter/puppeteer/PuppeteerPlatform.d.ts +66 -0
- package/dist/platform-adapter/puppeteer/PuppeteerPlatform.js +372 -0
- package/dist/platform-adapter/puppeteer/PuppeteerPlatform.js.map +1 -0
- package/dist/platform-adapter/spatialRequestMetadata.d.ts +6 -0
- package/dist/platform-adapter/spatialRequestMetadata.js +39 -0
- package/dist/platform-adapter/spatialRequestMetadata.js.map +1 -0
- package/dist/platform-adapter/spatialSceneQuery.d.ts +12 -0
- package/dist/platform-adapter/spatialSceneQuery.js +12 -0
- package/dist/platform-adapter/spatialSceneQuery.js.map +1 -0
- package/dist/platform-adapter/vision-os/VisionOSPlatform.d.ts +19 -0
- package/dist/platform-adapter/vision-os/VisionOSPlatform.js +77 -0
- package/dist/platform-adapter/vision-os/VisionOSPlatform.js.map +1 -0
- package/dist/platform-runtime.d.ts +12 -0
- package/dist/platform-runtime.js +14 -0
- package/dist/platform-runtime.js.map +1 -0
- package/dist/reality/Attachment.d.ts +19 -0
- package/dist/reality/Attachment.js +39 -0
- package/dist/reality/Attachment.js.map +1 -0
- package/dist/reality/component/ModelComponent.d.ts +14 -0
- package/dist/reality/component/ModelComponent.js +11 -0
- package/dist/reality/component/ModelComponent.js.map +1 -0
- package/dist/reality/component/SpatialComponent.d.ts +8 -0
- package/dist/reality/component/SpatialComponent.js +19 -0
- package/dist/reality/component/SpatialComponent.js.map +1 -0
- package/dist/reality/component/index.d.ts +8 -0
- package/dist/reality/component/index.js +3 -0
- package/dist/reality/component/index.js.map +1 -0
- package/dist/reality/entity/SpatialEntity.d.ts +7 -0
- package/dist/reality/entity/SpatialEntity.js +291 -0
- package/dist/reality/entity/SpatialEntity.js.map +1 -0
- package/dist/reality/entity/SpatialModelEntity.d.ts +17 -0
- package/dist/reality/entity/SpatialModelEntity.js +17 -0
- package/dist/reality/entity/SpatialModelEntity.js.map +1 -0
- package/dist/reality/entity/index.d.ts +8 -0
- package/dist/reality/entity/index.js +3 -0
- package/dist/reality/entity/index.js.map +1 -0
- package/dist/reality/geometry/SpatialBoxGeometry.d.ts +16 -0
- package/dist/reality/geometry/SpatialBoxGeometry.js +13 -0
- package/dist/reality/geometry/SpatialBoxGeometry.js.map +1 -0
- package/dist/reality/geometry/SpatialConeGeometry.d.ts +16 -0
- package/dist/reality/geometry/SpatialConeGeometry.js +13 -0
- package/dist/reality/geometry/SpatialConeGeometry.js.map +1 -0
- package/dist/reality/geometry/SpatialCylinderGeometry.d.ts +16 -0
- package/dist/reality/geometry/SpatialCylinderGeometry.js +13 -0
- package/dist/reality/geometry/SpatialCylinderGeometry.js.map +1 -0
- package/dist/reality/geometry/SpatialGeometry.d.ts +7 -0
- package/dist/reality/geometry/SpatialGeometry.js +13 -0
- package/dist/reality/geometry/SpatialGeometry.js.map +1 -0
- package/dist/reality/geometry/SpatialPlaneGeometry.d.ts +16 -0
- package/dist/reality/geometry/SpatialPlaneGeometry.js +13 -0
- package/dist/reality/geometry/SpatialPlaneGeometry.js.map +1 -0
- package/dist/reality/geometry/SpatialSphereGeometry.d.ts +16 -0
- package/dist/reality/geometry/SpatialSphereGeometry.js +13 -0
- package/dist/reality/geometry/SpatialSphereGeometry.js.map +1 -0
- package/dist/reality/geometry/index.d.ts +12 -0
- package/dist/reality/geometry/index.js +7 -0
- package/dist/reality/geometry/index.js.map +1 -0
- package/dist/reality/index.d.ts +18 -0
- package/dist/reality/index.js +7 -0
- package/dist/reality/index.js.map +1 -0
- package/dist/reality/material/SpatialMaterial.d.ts +7 -0
- package/dist/reality/material/SpatialMaterial.js +13 -0
- package/dist/reality/material/SpatialMaterial.js.map +1 -0
- package/dist/reality/material/SpatialUnlitMaterial.d.ts +16 -0
- package/dist/reality/material/SpatialUnlitMaterial.js +16 -0
- package/dist/reality/material/SpatialUnlitMaterial.js.map +1 -0
- package/dist/reality/material/index.d.ts +8 -0
- package/dist/reality/material/index.js +3 -0
- package/dist/reality/material/index.js.map +1 -0
- package/dist/reality/realityCreator.d.ts +22 -0
- package/dist/reality/realityCreator.js +89 -0
- package/dist/reality/realityCreator.js.map +1 -0
- package/dist/reality/resource/SpatialModelAsset.d.ts +15 -0
- package/dist/reality/resource/SpatialModelAsset.js +12 -0
- package/dist/reality/resource/SpatialModelAsset.js.map +1 -0
- package/dist/reality/resource/SpatialTextureResource.d.ts +16 -0
- package/dist/reality/resource/SpatialTextureResource.js +16 -0
- package/dist/reality/resource/SpatialTextureResource.js.map +1 -0
- package/dist/reality/resource/index.d.ts +9 -0
- package/dist/reality/resource/index.js +3 -0
- package/dist/reality/resource/index.js.map +1 -0
- package/dist/runtime/WebSpatialRuntimeError.d.ts +10 -0
- package/dist/runtime/WebSpatialRuntimeError.js +14 -0
- package/dist/runtime/WebSpatialRuntimeError.js.map +1 -0
- package/dist/runtime/capability-data.d.ts +12 -0
- package/dist/runtime/capability-data.js +134 -0
- package/dist/runtime/capability-data.js.map +1 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/jsbAdapterPlatform.d.ts +9 -0
- package/dist/runtime/jsbAdapterPlatform.js +38 -0
- package/dist/runtime/jsbAdapterPlatform.js.map +1 -0
- package/dist/runtime/keys.d.ts +34 -0
- package/dist/runtime/keys.js +122 -0
- package/dist/runtime/keys.js.map +1 -0
- package/dist/runtime/semver.d.ts +8 -0
- package/dist/runtime/semver.js +32 -0
- package/dist/runtime/semver.js.map +1 -0
- package/dist/runtime/supports.d.ts +22 -0
- package/dist/runtime/supports.js +78 -0
- package/dist/runtime/supports.js.map +1 -0
- package/dist/runtime/types.d.ts +12 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/userAgent.d.ts +20 -0
- package/dist/runtime/userAgent.js +41 -0
- package/dist/runtime/userAgent.js.map +1 -0
- package/dist/scene-polyfill.d.ts +18 -0
- package/dist/scene-polyfill.js +480 -0
- package/dist/scene-polyfill.js.map +1 -0
- package/dist/spatial-host.d.ts +13 -0
- package/dist/spatial-host.js +18 -0
- package/dist/spatial-host.js.map +1 -0
- package/dist/spatial-window-polyfill.d.ts +3 -0
- package/dist/spatial-window-polyfill.js +155 -0
- package/dist/spatial-window-polyfill.js.map +1 -0
- package/dist/spatializedElementMotion-_0XWPQCE.d.ts +1009 -0
- package/dist/types/animation.d.ts +7 -0
- package/dist/types/animation.js +1 -0
- package/dist/types/animation.js.map +1 -0
- package/dist/types/global.d.ts +38 -0
- package/dist/types/global.js +1 -0
- package/dist/types/global.js.map +1 -0
- package/dist/types/internal.d.ts +7 -0
- package/dist/types/internal.js +12 -0
- package/dist/types/internal.js.map +1 -0
- package/dist/types/motion/index.d.ts +7 -0
- package/dist/types/motion/index.js +3 -0
- package/dist/types/motion/index.js.map +1 -0
- package/dist/types/motion/spatializedElementMotion.d.ts +7 -0
- package/dist/types/motion/spatializedElementMotion.js +1 -0
- package/dist/types/motion/spatializedElementMotion.js.map +1 -0
- package/dist/types/motion/spatializedMotion.d.ts +7 -0
- package/dist/types/motion/spatializedMotion.js +16 -0
- package/dist/types/motion/spatializedMotion.js.map +1 -0
- package/dist/types/motion/spatializedPlayback.d.ts +11 -0
- package/dist/types/motion/spatializedPlayback.js +1 -0
- package/dist/types/motion/spatializedPlayback.js.map +1 -0
- package/dist/types/motion/spatializedVisual.d.ts +35 -0
- package/dist/types/motion/spatializedVisual.js +1 -0
- package/dist/types/motion/spatializedVisual.js.map +1 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/types.js +117 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils.d.ts +44 -0
- package/dist/utils.js +86 -0
- package/dist/utils.js.map +1 -0
- package/package.json +20 -4
- package/src/JSBCommand.ts +132 -5
- package/src/SpatialObject.ts +10 -0
- package/src/Spatialized2DElement.ts +5 -0
- package/src/SpatializedDynamic3DElement.ts +5 -0
- package/src/SpatializedElement.ts +29 -0
- package/src/SpatializedStatic3DElement.ts +42 -3
- package/src/WebMsgCommand.ts +40 -0
- package/src/coverage-boost.test.ts +239 -216
- package/src/index.ts +25 -11
- package/src/install-polyfills.ts +38 -0
- package/src/jsbcommand.coverage.test.ts +23 -0
- package/src/motion/AnimationObject.test.ts +421 -0
- package/src/motion/AnimationObject.ts +208 -0
- package/src/motion/compute/index.ts +10 -0
- package/src/motion/compute/motionPropertyValues.test.ts +55 -0
- package/src/motion/compute/motionPropertyValues.ts +70 -0
- package/src/motion/compute/normalize.test.ts +99 -0
- package/src/motion/compute/normalize.ts +289 -0
- package/src/motion/compute/validate.test.ts +229 -0
- package/src/motion/compute/validate.ts +156 -0
- package/src/motion/index.ts +2 -0
- package/src/motion/native/serializeMotionTimeline.test.ts +61 -0
- package/src/motion/native/serializeMotionTimeline.ts +27 -0
- package/src/platform-adapter/createPlatformSync.ts +5 -3
- package/src/platform-adapter/pico-os/PicoOSPlatform.ts +76 -11
- package/src/platform-adapter/spatialRequestMetadata.test.ts +175 -0
- package/src/platform-adapter/spatialRequestMetadata.ts +48 -0
- package/src/platform-adapter/vision-os/VisionOSPlatform.ts +6 -1
- package/src/reality/entity/SpatialEntity.ts +127 -0
- package/src/runtime/capability-data.ts +104 -4
- package/src/runtime/index.ts +0 -11
- package/src/runtime/keys.ts +12 -1
- package/src/runtime/supports.test.ts +143 -4
- package/src/runtime/supports.ts +3 -1
- package/src/runtime/useAnimation.capability.test.ts +275 -0
- package/src/scene-polyfill.manifest.test.ts +306 -5
- package/src/scene-polyfill.request-metadata.test.ts +39 -0
- package/src/scene-polyfill.test.ts +33 -94
- package/src/scene-polyfill.ts +117 -87
- package/src/spatial-window-polyfill.ts +18 -2
- package/src/transform-roundtrip.test.ts +90 -0
- package/src/types/animation.ts +224 -0
- package/src/types/global.ts +1 -8
- package/src/types/motion/index.ts +10 -0
- package/src/types/motion/spatializedElementMotion.ts +49 -0
- package/src/types/motion/spatializedMotion.ts +147 -0
- package/src/types/motion/spatializedPlayback.ts +17 -0
- package/src/types/motion/spatializedVisual.ts +24 -0
- package/src/types/types.ts +3 -0
- package/src/utils.ts +54 -0
- package/tsup.config.ts +61 -36
- package/vitest.config.ts +5 -1
- package/dist/iife/index.d.ts +0 -1251
- package/dist/iife/index.global.js +0 -75
- package/dist/iife/index.global.js.map +0 -1
- package/src/platform-adapter/ssr/SSRPlatform.ts +0 -52
- /package/src/{ssr-polyfill.ts → isSSREnv.ts} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Spatialized2DElement } from './Spatialized2DElement.js';
|
|
2
|
+
import { SpatializedStatic3DElement } from './SpatializedStatic3DElement.js';
|
|
3
|
+
import { af as SpatializedDynamic3DElement, o as ModelSource, n as ModelLoadingMode } from './spatializedElementMotion-_0XWPQCE.js';
|
|
4
|
+
import './types/motion/spatializedVisual.js';
|
|
5
|
+
import './types/motion/spatializedPlayback.js';
|
|
6
|
+
import './types/global.js';
|
|
7
|
+
import './physicalMetrics-W5uZ5xKb.js';
|
|
8
|
+
import './SpatialObject.js';
|
|
9
|
+
import './reality/component/SpatialComponent.js';
|
|
10
|
+
|
|
11
|
+
declare function createSpatialized2DElement(): Promise<Spatialized2DElement>;
|
|
12
|
+
declare function createSpatializedStatic3DElement(modelURL?: string, sources?: ModelSource[], loading?: ModelLoadingMode): Promise<SpatializedStatic3DElement>;
|
|
13
|
+
declare function createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement>;
|
|
14
|
+
|
|
15
|
+
export { createSpatialized2DElement, createSpatializedDynamic3DElement, createSpatializedStatic3DElement };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateSpatializedDynamic3DElementCommand,
|
|
3
|
+
CreateSpatializedStatic3DElementCommand
|
|
4
|
+
} from "./JSBCommand";
|
|
5
|
+
import { Spatialized2DElement } from "./Spatialized2DElement";
|
|
6
|
+
import { SpatializedStatic3DElement } from "./SpatializedStatic3DElement";
|
|
7
|
+
import { SpatializedDynamic3DElement } from "./SpatializedDynamic3DElement";
|
|
8
|
+
import { createNativeSpatialDiv } from "./spatial-host";
|
|
9
|
+
async function createSpatialized2DElement() {
|
|
10
|
+
const result = await createNativeSpatialDiv();
|
|
11
|
+
if (!result.success) {
|
|
12
|
+
throw new Error("createSpatialized2DElement failed");
|
|
13
|
+
} else {
|
|
14
|
+
const { id, windowProxy } = result.data;
|
|
15
|
+
windowProxy.document.head.innerHTML = `<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
16
|
+
<base href="${document.baseURI}">`;
|
|
17
|
+
return new Spatialized2DElement(id, windowProxy);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function createSpatializedStatic3DElement(modelURL, sources, loading = "eager") {
|
|
21
|
+
const result = await new CreateSpatializedStatic3DElementCommand(
|
|
22
|
+
modelURL,
|
|
23
|
+
sources,
|
|
24
|
+
loading
|
|
25
|
+
).execute();
|
|
26
|
+
if (!result.success) {
|
|
27
|
+
throw new Error("createSpatializedStatic3DElement failed");
|
|
28
|
+
} else {
|
|
29
|
+
const { id } = result.data;
|
|
30
|
+
return new SpatializedStatic3DElement(id, modelURL, sources, loading);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function createSpatializedDynamic3DElement() {
|
|
34
|
+
const result = await new CreateSpatializedDynamic3DElementCommand().execute();
|
|
35
|
+
if (!result.success) {
|
|
36
|
+
throw new Error("createSpatializedDynamic3DElement failed");
|
|
37
|
+
} else {
|
|
38
|
+
const { id } = result.data;
|
|
39
|
+
return new SpatializedDynamic3DElement(id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
createSpatialized2DElement,
|
|
44
|
+
createSpatializedDynamic3DElement,
|
|
45
|
+
createSpatializedStatic3DElement
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=SpatializedElementCreator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SpatializedElementCreator.ts"],"sourcesContent":["import {\n CreateSpatializedDynamic3DElementCommand,\n CreateSpatializedStatic3DElementCommand,\n} from './JSBCommand'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { createNativeSpatialDiv } from './spatial-host'\nimport { ModelLoadingMode, ModelSource } from './types/types'\n\nexport async function createSpatialized2DElement(): Promise<Spatialized2DElement> {\n const result = await createNativeSpatialDiv()\n if (!result.success) {\n throw new Error('createSpatialized2DElement failed')\n } else {\n const { id, windowProxy } = result.data!\n // set base href to make sure the relative url is correct\n windowProxy.document.head.innerHTML = `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <base href=\"${document.baseURI}\">`\n return new Spatialized2DElement(id, windowProxy)\n }\n}\n\nexport async function createSpatializedStatic3DElement(\n modelURL?: string,\n sources?: ModelSource[],\n loading: ModelLoadingMode = 'eager',\n): Promise<SpatializedStatic3DElement> {\n const result = await new CreateSpatializedStatic3DElementCommand(\n modelURL,\n sources,\n loading,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatializedStatic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedStatic3DElement(id, modelURL, sources, loading)\n }\n}\n\nexport async function createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n const result = await new CreateSpatializedDynamic3DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatializedDynamic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedDynamic3DElement(id)\n }\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAC3C,SAAS,mCAAmC;AAC5C,SAAS,8BAA8B;AAGvC,eAAsB,6BAA4D;AAChF,QAAM,SAAS,MAAM,uBAAuB;AAC5C,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD,OAAO;AACL,UAAM,EAAE,IAAI,YAAY,IAAI,OAAO;AAEnC,gBAAY,SAAS,KAAK,YAAY;AAAA,oBACtB,SAAS,OAAO;AAChC,WAAO,IAAI,qBAAqB,IAAI,WAAW;AAAA,EACjD;AACF;AAEA,eAAsB,iCACpB,UACA,SACA,UAA4B,SACS;AACrC,QAAM,SAAS,MAAM,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,QAAQ;AACV,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D,OAAO;AACL,UAAM,EAAE,GAAG,IAAI,OAAO;AACtB,WAAO,IAAI,2BAA2B,IAAI,UAAU,SAAS,OAAO;AAAA,EACtE;AACF;AAEA,eAAsB,oCAA0E;AAC9F,QAAM,SAAS,MAAM,IAAI,yCAAyC,EAAE,QAAQ;AAC5E,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D,OAAO;AACL,UAAM,EAAE,GAAG,IAAI,OAAO;AACtB,WAAO,IAAI,4BAA4B,EAAE;AAAA,EAC3C;AACF;","names":[]}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { ag as SpatializedElement, o as ModelSource, n as ModelLoadingMode, ap as SpatializedStatic3DElementProperties, aK as CommandResult, aS as AnimationStateChangeDetail, aT as ModelLoadSuccess, aU as ModelLoadFailure, aV as ReceiveEventData, aW as AnimationStateChangeMsg, aX as EntityTransformChangeMsg, aq as StageMode } from './spatializedElementMotion-_0XWPQCE.js';
|
|
2
|
+
import './types/motion/spatializedVisual.js';
|
|
3
|
+
import './types/motion/spatializedPlayback.js';
|
|
4
|
+
import './types/global.js';
|
|
5
|
+
import './physicalMetrics-W5uZ5xKb.js';
|
|
6
|
+
import './SpatialObject.js';
|
|
7
|
+
import './reality/component/SpatialComponent.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a static 3D model element in the spatial environment.
|
|
11
|
+
* This class handles loading and displaying pre-built 3D models from URLs,
|
|
12
|
+
* and provides events for load success and failure.
|
|
13
|
+
*/
|
|
14
|
+
declare class SpatializedStatic3DElement extends SpatializedElement {
|
|
15
|
+
/**
|
|
16
|
+
* Identifies the motion target kind supported by this element.
|
|
17
|
+
*/
|
|
18
|
+
readonly kind: "static3d";
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new spatialized static 3D element with the specified ID and URL.
|
|
21
|
+
* Registers the element to receive spatial events.
|
|
22
|
+
* @param id Unique identifier for this element
|
|
23
|
+
* @param modelURL URL of the 3D model
|
|
24
|
+
* @param sources Optional fallback model sources
|
|
25
|
+
* @param loading Initial loading mode (`'eager'` by default)
|
|
26
|
+
*/
|
|
27
|
+
constructor(id: string, modelURL?: string, sources?: ModelSource[], loading?: ModelLoadingMode);
|
|
28
|
+
/**
|
|
29
|
+
* Promise resolver for the ready state.
|
|
30
|
+
* Used to resolve the ready promise when the model is loaded.
|
|
31
|
+
*/
|
|
32
|
+
private _readyResolve?;
|
|
33
|
+
/**
|
|
34
|
+
* Caches the last model URL to detect changes.
|
|
35
|
+
* Used to reset the ready promise when the model URL changes.
|
|
36
|
+
*/
|
|
37
|
+
private modelURL?;
|
|
38
|
+
get modelUrl(): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Caches the last sources array to detect changes.
|
|
41
|
+
*/
|
|
42
|
+
private sources?;
|
|
43
|
+
/**
|
|
44
|
+
* The model URL that was successfully loaded by the native runtime.
|
|
45
|
+
*/
|
|
46
|
+
private _currentSrc;
|
|
47
|
+
get currentSrc(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new promise for tracking the ready state of the model.
|
|
50
|
+
* @returns Promise that resolves when the model is loaded (true) or fails to load (false)
|
|
51
|
+
*/
|
|
52
|
+
private createReadyPromise;
|
|
53
|
+
/**
|
|
54
|
+
* Promise that resolves when the model is loaded.
|
|
55
|
+
* Resolves to true on successful load, false on failure.
|
|
56
|
+
*/
|
|
57
|
+
ready: Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Updates the properties of this static 3D element.
|
|
60
|
+
* Handles special case for modelURL changes by resetting the ready promise.
|
|
61
|
+
* @param properties Partial set of properties to update
|
|
62
|
+
* @returns Promise resolving when the update is complete
|
|
63
|
+
*/
|
|
64
|
+
updateProperties(properties: Partial<SpatializedStatic3DElementProperties>): Promise<CommandResult<any>>;
|
|
65
|
+
/**
|
|
66
|
+
* Total animation duration in seconds, synced from native.
|
|
67
|
+
*/
|
|
68
|
+
private _duration;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the total animation duration in seconds.
|
|
71
|
+
*/
|
|
72
|
+
get duration(): number;
|
|
73
|
+
/**
|
|
74
|
+
* Playback speed multiplier.
|
|
75
|
+
*/
|
|
76
|
+
private _playbackRate;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the current playback rate.
|
|
79
|
+
*/
|
|
80
|
+
get playbackRate(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the playback rate and sends it to native.
|
|
83
|
+
*/
|
|
84
|
+
set playbackRate(value: number);
|
|
85
|
+
/**
|
|
86
|
+
* Last playback position sampled from native (seconds).
|
|
87
|
+
*/
|
|
88
|
+
private _currentTime;
|
|
89
|
+
/**
|
|
90
|
+
* Unix epoch time (ms) corresponding to `_currentTime`. Sourced from the
|
|
91
|
+
* native `timestamp` on samples, or `Date.now()` on local seeks/transitions.
|
|
92
|
+
*/
|
|
93
|
+
private _anchorTimestamp;
|
|
94
|
+
private clampTime;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the current (un-scaled) playback position in seconds. While
|
|
97
|
+
* playing, the value is extrapolated from the last anchor using
|
|
98
|
+
* `playbackRate` and clamped to `[0, duration]`; while paused it returns
|
|
99
|
+
* the anchor directly.
|
|
100
|
+
*/
|
|
101
|
+
get currentTime(): number;
|
|
102
|
+
/**
|
|
103
|
+
* Seeks the animation to `value` seconds (clamped to `[0, duration]`) and
|
|
104
|
+
* forwards the request to native.
|
|
105
|
+
*/
|
|
106
|
+
set currentTime(value: number);
|
|
107
|
+
/**
|
|
108
|
+
* Whether the animation is currently paused.
|
|
109
|
+
*/
|
|
110
|
+
private _paused;
|
|
111
|
+
/**
|
|
112
|
+
* Returns whether the animation is currently paused.
|
|
113
|
+
*/
|
|
114
|
+
get paused(): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Callback for animation state changes.
|
|
117
|
+
*/
|
|
118
|
+
private _onAnimationStateChangeCallback?;
|
|
119
|
+
/**
|
|
120
|
+
* Sets the callback for animation state changes.
|
|
121
|
+
*/
|
|
122
|
+
set onAnimationStateChangeCallback(callback: undefined | ((detail: AnimationStateChangeDetail) => void));
|
|
123
|
+
/**
|
|
124
|
+
* Starts or resumes animation playback.
|
|
125
|
+
* @returns Promise resolving when the command is sent
|
|
126
|
+
*/
|
|
127
|
+
play(): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Pauses animation playback.
|
|
130
|
+
* @returns Promise resolving when the command is sent
|
|
131
|
+
*/
|
|
132
|
+
pause(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Processes events received from the WebSpatial environment.
|
|
135
|
+
* Handles model loading events in addition to base spatial events.
|
|
136
|
+
* @param data The event data received from the WebSpatial system
|
|
137
|
+
*/
|
|
138
|
+
onReceiveEvent(data: Static3DReceiveEventData): void;
|
|
139
|
+
/**
|
|
140
|
+
* Whether the model should automatically play its first animation on load.
|
|
141
|
+
*/
|
|
142
|
+
private _autoplay;
|
|
143
|
+
/**
|
|
144
|
+
* Returns whether autoplay is enabled for this element.
|
|
145
|
+
*/
|
|
146
|
+
get autoplay(): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Asset fetch policy. `'lazy'` defers fetching until the host signals the
|
|
149
|
+
* element is in view; `'eager'` fetches immediately.
|
|
150
|
+
*/
|
|
151
|
+
private _loading;
|
|
152
|
+
get loading(): ModelLoadingMode;
|
|
153
|
+
/**
|
|
154
|
+
* Whether the model animation should loop continuously.
|
|
155
|
+
*/
|
|
156
|
+
private _loop;
|
|
157
|
+
/**
|
|
158
|
+
* Returns whether loop is enabled for this element.
|
|
159
|
+
*/
|
|
160
|
+
get loop(): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Callback function for successful model loading.
|
|
163
|
+
*/
|
|
164
|
+
private _onLoadCallback?;
|
|
165
|
+
/**
|
|
166
|
+
* Sets the callback function for successful model loading.
|
|
167
|
+
* @param callback Function to call when the model is loaded successfully
|
|
168
|
+
*/
|
|
169
|
+
set onLoadCallback(callback: undefined | (() => void));
|
|
170
|
+
/**
|
|
171
|
+
* Callback function for model loading failure.
|
|
172
|
+
*/
|
|
173
|
+
private _onLoadFailureCallback?;
|
|
174
|
+
/**
|
|
175
|
+
* Sets the callback function for model loading failure.
|
|
176
|
+
* @param callback Function to call when the model fails to load
|
|
177
|
+
*/
|
|
178
|
+
set onLoadFailureCallback(callback: undefined | (() => void));
|
|
179
|
+
/**
|
|
180
|
+
* Built-in interaction mode. In `'orbit'` the native layer drives the
|
|
181
|
+
* transform and `entityTransform` is read-only.
|
|
182
|
+
*/
|
|
183
|
+
private _stagemode;
|
|
184
|
+
get stagemode(): StageMode;
|
|
185
|
+
/**
|
|
186
|
+
* Latest transform of the model, including native-driven manipulations such
|
|
187
|
+
* as orbit interaction.
|
|
188
|
+
*/
|
|
189
|
+
private _entityTransform;
|
|
190
|
+
get entityTransform(): DOMMatrixReadOnly;
|
|
191
|
+
set entityTransform(transform: DOMMatrixReadOnly);
|
|
192
|
+
}
|
|
193
|
+
type Static3DReceiveEventData = ModelLoadSuccess | ModelLoadFailure | ReceiveEventData | AnimationStateChangeMsg | EntityTransformChangeMsg;
|
|
194
|
+
|
|
195
|
+
export { SpatializedStatic3DElement };
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { UpdateSpatializedStatic3DElementProperties } from "./JSBCommand";
|
|
2
|
+
import { SpatializedElement } from "./SpatializedElement";
|
|
3
|
+
import {
|
|
4
|
+
SpatialWebMsgType
|
|
5
|
+
} from "./WebMsgCommand";
|
|
6
|
+
class SpatializedStatic3DElement extends SpatializedElement {
|
|
7
|
+
/**
|
|
8
|
+
* Identifies the motion target kind supported by this element.
|
|
9
|
+
*/
|
|
10
|
+
kind = "static3d";
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new spatialized static 3D element with the specified ID and URL.
|
|
13
|
+
* Registers the element to receive spatial events.
|
|
14
|
+
* @param id Unique identifier for this element
|
|
15
|
+
* @param modelURL URL of the 3D model
|
|
16
|
+
* @param sources Optional fallback model sources
|
|
17
|
+
* @param loading Initial loading mode (`'eager'` by default)
|
|
18
|
+
*/
|
|
19
|
+
constructor(id, modelURL, sources, loading = "eager") {
|
|
20
|
+
super(id);
|
|
21
|
+
this.modelURL = modelURL;
|
|
22
|
+
this.sources = sources;
|
|
23
|
+
this._loading = loading;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Promise resolver for the ready state.
|
|
27
|
+
* Used to resolve the ready promise when the model is loaded.
|
|
28
|
+
*/
|
|
29
|
+
_readyResolve;
|
|
30
|
+
/**
|
|
31
|
+
* Caches the last model URL to detect changes.
|
|
32
|
+
* Used to reset the ready promise when the model URL changes.
|
|
33
|
+
*/
|
|
34
|
+
modelURL;
|
|
35
|
+
// @TODO: Deprecate modelURL property from Web and Swift code
|
|
36
|
+
get modelUrl() {
|
|
37
|
+
return this.modelURL;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Caches the last sources array to detect changes.
|
|
41
|
+
*/
|
|
42
|
+
sources;
|
|
43
|
+
/**
|
|
44
|
+
* The model URL that was successfully loaded by the native runtime.
|
|
45
|
+
*/
|
|
46
|
+
_currentSrc = "";
|
|
47
|
+
get currentSrc() {
|
|
48
|
+
return this._currentSrc;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new promise for tracking the ready state of the model.
|
|
52
|
+
* @returns Promise that resolves when the model is loaded (true) or fails to load (false)
|
|
53
|
+
*/
|
|
54
|
+
createReadyPromise() {
|
|
55
|
+
this._readyResolve?.(false);
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
this._readyResolve = resolve;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Promise that resolves when the model is loaded.
|
|
62
|
+
* Resolves to true on successful load, false on failure.
|
|
63
|
+
*/
|
|
64
|
+
ready = this.createReadyPromise();
|
|
65
|
+
/**
|
|
66
|
+
* Updates the properties of this static 3D element.
|
|
67
|
+
* Handles special case for modelURL changes by resetting the ready promise.
|
|
68
|
+
* @param properties Partial set of properties to update
|
|
69
|
+
* @returns Promise resolving when the update is complete
|
|
70
|
+
*/
|
|
71
|
+
async updateProperties(properties) {
|
|
72
|
+
let needsReadyReset = false;
|
|
73
|
+
if (properties.modelURL !== void 0) {
|
|
74
|
+
if (this.modelURL !== properties.modelURL) {
|
|
75
|
+
this.modelURL = properties.modelURL;
|
|
76
|
+
needsReadyReset = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (properties.sources !== void 0) {
|
|
80
|
+
const prevJson = JSON.stringify(this.sources);
|
|
81
|
+
const nextJson = JSON.stringify(properties.sources);
|
|
82
|
+
if (prevJson !== nextJson) {
|
|
83
|
+
this.sources = properties.sources;
|
|
84
|
+
needsReadyReset = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (needsReadyReset) {
|
|
88
|
+
this.ready = this.createReadyPromise();
|
|
89
|
+
}
|
|
90
|
+
if (properties.autoplay !== void 0) {
|
|
91
|
+
this._autoplay = properties.autoplay;
|
|
92
|
+
}
|
|
93
|
+
if (properties.loop !== void 0) {
|
|
94
|
+
this._loop = properties.loop;
|
|
95
|
+
}
|
|
96
|
+
if (properties.playbackRate !== void 0) {
|
|
97
|
+
if (!this._paused) {
|
|
98
|
+
this._currentTime = this.currentTime;
|
|
99
|
+
this._anchorTimestamp = Date.now();
|
|
100
|
+
}
|
|
101
|
+
this._playbackRate = properties.playbackRate;
|
|
102
|
+
}
|
|
103
|
+
if (properties.currentTime !== void 0) {
|
|
104
|
+
this._currentTime = properties.currentTime;
|
|
105
|
+
this._anchorTimestamp = Date.now();
|
|
106
|
+
}
|
|
107
|
+
if (properties.loading !== void 0) {
|
|
108
|
+
this._loading = properties.loading;
|
|
109
|
+
}
|
|
110
|
+
if (properties.stagemode !== void 0) {
|
|
111
|
+
this._stagemode = properties.stagemode;
|
|
112
|
+
}
|
|
113
|
+
return new UpdateSpatializedStatic3DElementProperties(
|
|
114
|
+
this,
|
|
115
|
+
properties
|
|
116
|
+
).execute();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Total animation duration in seconds, synced from native.
|
|
120
|
+
*/
|
|
121
|
+
_duration = 0;
|
|
122
|
+
/**
|
|
123
|
+
* Returns the total animation duration in seconds.
|
|
124
|
+
*/
|
|
125
|
+
get duration() {
|
|
126
|
+
return this._duration;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Playback speed multiplier.
|
|
130
|
+
*/
|
|
131
|
+
_playbackRate = 1;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the current playback rate.
|
|
134
|
+
*/
|
|
135
|
+
get playbackRate() {
|
|
136
|
+
return this._playbackRate;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Sets the playback rate and sends it to native.
|
|
140
|
+
*/
|
|
141
|
+
set playbackRate(value) {
|
|
142
|
+
this.updateProperties({ playbackRate: value });
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Last playback position sampled from native (seconds).
|
|
146
|
+
*/
|
|
147
|
+
_currentTime = 0;
|
|
148
|
+
/**
|
|
149
|
+
* Unix epoch time (ms) corresponding to `_currentTime`. Sourced from the
|
|
150
|
+
* native `timestamp` on samples, or `Date.now()` on local seeks/transitions.
|
|
151
|
+
*/
|
|
152
|
+
_anchorTimestamp = 0;
|
|
153
|
+
clampTime(time) {
|
|
154
|
+
if (!Number.isFinite(time) || time < 0) return 0;
|
|
155
|
+
if (time > this._duration) {
|
|
156
|
+
return this.loop && this.duration > 0 ? time % this._duration : this.duration;
|
|
157
|
+
}
|
|
158
|
+
return time;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Returns the current (un-scaled) playback position in seconds. While
|
|
162
|
+
* playing, the value is extrapolated from the last anchor using
|
|
163
|
+
* `playbackRate` and clamped to `[0, duration]`; while paused it returns
|
|
164
|
+
* the anchor directly.
|
|
165
|
+
*/
|
|
166
|
+
get currentTime() {
|
|
167
|
+
if (this._paused) return this._currentTime;
|
|
168
|
+
const elapsed = (Date.now() - this._anchorTimestamp) / 1e3;
|
|
169
|
+
return this.clampTime(this._currentTime + elapsed * this._playbackRate);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Seeks the animation to `value` seconds (clamped to `[0, duration]`) and
|
|
173
|
+
* forwards the request to native.
|
|
174
|
+
*/
|
|
175
|
+
set currentTime(value) {
|
|
176
|
+
const time = Number.isNaN(value) ? 0 : clamp(value, 0, this.duration);
|
|
177
|
+
this.updateProperties({ currentTime: time });
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Whether the animation is currently paused.
|
|
181
|
+
*/
|
|
182
|
+
_paused = true;
|
|
183
|
+
/**
|
|
184
|
+
* Returns whether the animation is currently paused.
|
|
185
|
+
*/
|
|
186
|
+
get paused() {
|
|
187
|
+
return this._paused;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Callback for animation state changes.
|
|
191
|
+
*/
|
|
192
|
+
_onAnimationStateChangeCallback;
|
|
193
|
+
/**
|
|
194
|
+
* Sets the callback for animation state changes.
|
|
195
|
+
*/
|
|
196
|
+
set onAnimationStateChangeCallback(callback) {
|
|
197
|
+
this._onAnimationStateChangeCallback = callback;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Starts or resumes animation playback.
|
|
201
|
+
* @returns Promise resolving when the command is sent
|
|
202
|
+
*/
|
|
203
|
+
async play() {
|
|
204
|
+
if (this._paused) {
|
|
205
|
+
this._anchorTimestamp = Date.now();
|
|
206
|
+
}
|
|
207
|
+
this._paused = false;
|
|
208
|
+
await this.updateProperties({ animationPaused: false });
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Pauses animation playback.
|
|
212
|
+
* @returns Promise resolving when the command is sent
|
|
213
|
+
*/
|
|
214
|
+
async pause() {
|
|
215
|
+
if (!this._paused) {
|
|
216
|
+
this._currentTime = this.currentTime;
|
|
217
|
+
this._anchorTimestamp = Date.now();
|
|
218
|
+
}
|
|
219
|
+
this._paused = true;
|
|
220
|
+
await this.updateProperties({ animationPaused: true });
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Processes events received from the WebSpatial environment.
|
|
224
|
+
* Handles model loading events in addition to base spatial events.
|
|
225
|
+
* @param data The event data received from the WebSpatial system
|
|
226
|
+
*/
|
|
227
|
+
onReceiveEvent(data) {
|
|
228
|
+
if (data.type === SpatialWebMsgType.modelloaded) {
|
|
229
|
+
this._currentSrc = data.detail?.src ?? this.modelURL ?? "";
|
|
230
|
+
this._onLoadCallback?.();
|
|
231
|
+
this._readyResolve?.(true);
|
|
232
|
+
} else if (data.type === SpatialWebMsgType.modelloadfailed) {
|
|
233
|
+
this._onLoadFailureCallback?.();
|
|
234
|
+
this._readyResolve?.(false);
|
|
235
|
+
} else if (data.type === SpatialWebMsgType.animationstatechange) {
|
|
236
|
+
this._paused = data.detail.paused;
|
|
237
|
+
this._duration = data.detail.duration;
|
|
238
|
+
this._currentTime = data.detail.currentTime ?? 0;
|
|
239
|
+
this._anchorTimestamp = data.detail.timestamp ?? Date.now();
|
|
240
|
+
this._onAnimationStateChangeCallback?.(data.detail);
|
|
241
|
+
} else if (data.type === SpatialWebMsgType.entitytransformchange) {
|
|
242
|
+
this._entityTransform = new DOMMatrixReadOnly(data.detail.transform);
|
|
243
|
+
} else {
|
|
244
|
+
super.onReceiveEvent(data);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Whether the model should automatically play its first animation on load.
|
|
249
|
+
*/
|
|
250
|
+
_autoplay = false;
|
|
251
|
+
/**
|
|
252
|
+
* Returns whether autoplay is enabled for this element.
|
|
253
|
+
*/
|
|
254
|
+
get autoplay() {
|
|
255
|
+
return this._autoplay;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Asset fetch policy. `'lazy'` defers fetching until the host signals the
|
|
259
|
+
* element is in view; `'eager'` fetches immediately.
|
|
260
|
+
*/
|
|
261
|
+
_loading = "eager";
|
|
262
|
+
get loading() {
|
|
263
|
+
return this._loading;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Whether the model animation should loop continuously.
|
|
267
|
+
*/
|
|
268
|
+
_loop = false;
|
|
269
|
+
/**
|
|
270
|
+
* Returns whether loop is enabled for this element.
|
|
271
|
+
*/
|
|
272
|
+
get loop() {
|
|
273
|
+
return this._loop;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Callback function for successful model loading.
|
|
277
|
+
*/
|
|
278
|
+
_onLoadCallback;
|
|
279
|
+
/**
|
|
280
|
+
* Sets the callback function for successful model loading.
|
|
281
|
+
* @param callback Function to call when the model is loaded successfully
|
|
282
|
+
*/
|
|
283
|
+
set onLoadCallback(callback) {
|
|
284
|
+
this._onLoadCallback = callback;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Callback function for model loading failure.
|
|
288
|
+
*/
|
|
289
|
+
_onLoadFailureCallback;
|
|
290
|
+
/**
|
|
291
|
+
* Sets the callback function for model loading failure.
|
|
292
|
+
* @param callback Function to call when the model fails to load
|
|
293
|
+
*/
|
|
294
|
+
set onLoadFailureCallback(callback) {
|
|
295
|
+
this._onLoadFailureCallback = callback;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Built-in interaction mode. In `'orbit'` the native layer drives the
|
|
299
|
+
* transform and `entityTransform` is read-only.
|
|
300
|
+
*/
|
|
301
|
+
_stagemode = "none";
|
|
302
|
+
get stagemode() {
|
|
303
|
+
return this._stagemode;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Latest transform of the model, including native-driven manipulations such
|
|
307
|
+
* as orbit interaction.
|
|
308
|
+
*/
|
|
309
|
+
_entityTransform = new DOMMatrixReadOnly();
|
|
310
|
+
get entityTransform() {
|
|
311
|
+
return this._entityTransform;
|
|
312
|
+
}
|
|
313
|
+
set entityTransform(transform) {
|
|
314
|
+
if (this._stagemode === "orbit") return;
|
|
315
|
+
this._entityTransform = transform;
|
|
316
|
+
this.updateProperties({
|
|
317
|
+
modelTransform: Array.from(transform.toFloat64Array())
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function clamp(num, min, max) {
|
|
322
|
+
return num <= min ? min : num >= max ? max : num;
|
|
323
|
+
}
|
|
324
|
+
export {
|
|
325
|
+
SpatializedStatic3DElement
|
|
326
|
+
};
|
|
327
|
+
//# sourceMappingURL=SpatializedStatic3DElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SpatializedStatic3DElement.ts"],"sourcesContent":["import { UpdateSpatializedStatic3DElementProperties } from './JSBCommand'\nimport { ReceiveEventData, SpatializedElement } from './SpatializedElement'\nimport {\n ModelLoadingMode,\n ModelSource,\n SpatializedStatic3DElementProperties,\n StageMode,\n} from './types/types'\nimport {\n ModelLoadSuccess,\n ModelLoadFailure,\n SpatialWebMsgType,\n AnimationStateChangeDetail,\n AnimationStateChangeMsg,\n EntityTransformChangeMsg,\n} from './WebMsgCommand'\n\n/**\n * Represents a static 3D model element in the spatial environment.\n * This class handles loading and displaying pre-built 3D models from URLs,\n * and provides events for load success and failure.\n */\nexport class SpatializedStatic3DElement extends SpatializedElement {\n /**\n * Identifies the motion target kind supported by this element.\n */\n override readonly kind = 'static3d' as const\n\n /**\n * Creates a new spatialized static 3D element with the specified ID and URL.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n * @param modelURL URL of the 3D model\n * @param sources Optional fallback model sources\n * @param loading Initial loading mode (`'eager'` by default)\n */\n constructor(\n id: string,\n modelURL?: string,\n sources?: ModelSource[],\n loading: ModelLoadingMode = 'eager',\n ) {\n super(id)\n this.modelURL = modelURL\n this.sources = sources\n this._loading = loading\n }\n\n /**\n * Promise resolver for the ready state.\n * Used to resolve the ready promise when the model is loaded.\n */\n private _readyResolve?: (success: boolean) => void\n\n /**\n * Caches the last model URL to detect changes.\n * Used to reset the ready promise when the model URL changes.\n */\n private modelURL?: string\n // @TODO: Deprecate modelURL property from Web and Swift code\n get modelUrl(): string | undefined {\n return this.modelURL\n }\n\n /**\n * Caches the last sources array to detect changes.\n */\n private sources?: ModelSource[]\n\n /**\n * The model URL that was successfully loaded by the native runtime.\n */\n private _currentSrc: string = ''\n\n get currentSrc(): string {\n return this._currentSrc\n }\n\n /**\n * Creates a new promise for tracking the ready state of the model.\n * @returns Promise that resolves when the model is loaded (true) or fails to load (false)\n */\n private createReadyPromise() {\n // If there's an existing promise reject it before it's replaced\n this._readyResolve?.(false)\n return new Promise<boolean>(resolve => {\n this._readyResolve = resolve\n })\n }\n\n /**\n * Promise that resolves when the model is loaded.\n * Resolves to true on successful load, false on failure.\n */\n ready: Promise<boolean> = this.createReadyPromise()\n\n /**\n * Updates the properties of this static 3D element.\n * Handles special case for modelURL changes by resetting the ready promise.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n let needsReadyReset = false\n if (properties.modelURL !== undefined) {\n if (this.modelURL !== properties.modelURL) {\n this.modelURL = properties.modelURL\n needsReadyReset = true\n }\n }\n if (properties.sources !== undefined) {\n const prevJson = JSON.stringify(this.sources)\n const nextJson = JSON.stringify(properties.sources)\n if (prevJson !== nextJson) {\n this.sources = properties.sources\n needsReadyReset = true\n }\n }\n if (needsReadyReset) {\n this.ready = this.createReadyPromise()\n }\n if (properties.autoplay !== undefined) {\n this._autoplay = properties.autoplay\n }\n if (properties.loop !== undefined) {\n this._loop = properties.loop\n }\n if (properties.playbackRate !== undefined) {\n // Re-anchor so extrapolation uses the new rate only for future elapsed\n // time, not the window between the last sample and this change.\n if (!this._paused) {\n this._currentTime = this.currentTime\n this._anchorTimestamp = Date.now()\n }\n this._playbackRate = properties.playbackRate\n }\n if (properties.currentTime !== undefined) {\n // Optimistically update the local anchor so subsequent reads reflect\n // the requested seek without waiting for the next native sample.\n this._currentTime = properties.currentTime\n this._anchorTimestamp = Date.now()\n }\n if (properties.loading !== undefined) {\n this._loading = properties.loading\n }\n if (properties.stagemode !== undefined) {\n this._stagemode = properties.stagemode\n }\n return new UpdateSpatializedStatic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n\n /**\n * Total animation duration in seconds, synced from native.\n */\n private _duration: number = 0\n\n /**\n * Returns the total animation duration in seconds.\n */\n get duration(): number {\n return this._duration\n }\n\n /**\n * Playback speed multiplier.\n */\n private _playbackRate: number = 1\n\n /**\n * Returns the current playback rate.\n */\n get playbackRate(): number {\n return this._playbackRate\n }\n\n /**\n * Sets the playback rate and sends it to native.\n */\n set playbackRate(value: number) {\n this.updateProperties({ playbackRate: value })\n }\n\n /**\n * Last playback position sampled from native (seconds).\n */\n private _currentTime: number = 0\n\n /**\n * Unix epoch time (ms) corresponding to `_currentTime`. Sourced from the\n * native `timestamp` on samples, or `Date.now()` on local seeks/transitions.\n */\n private _anchorTimestamp: number = 0\n\n private clampTime(time: number): number {\n if (!Number.isFinite(time) || time < 0) return 0\n // When looping the current time is modulo the duration\n if (time > this._duration) {\n return this.loop && this.duration > 0\n ? time % this._duration\n : this.duration\n }\n return time\n }\n\n /**\n * Returns the current (un-scaled) playback position in seconds. While\n * playing, the value is extrapolated from the last anchor using\n * `playbackRate` and clamped to `[0, duration]`; while paused it returns\n * the anchor directly.\n */\n get currentTime(): number {\n if (this._paused) return this._currentTime\n const elapsed = (Date.now() - this._anchorTimestamp) / 1000\n return this.clampTime(this._currentTime + elapsed * this._playbackRate)\n }\n\n /**\n * Seeks the animation to `value` seconds (clamped to `[0, duration]`) and\n * forwards the request to native.\n */\n set currentTime(value: number) {\n const time = Number.isNaN(value) ? 0 : clamp(value, 0, this.duration)\n this.updateProperties({ currentTime: time })\n }\n\n /**\n * Whether the animation is currently paused.\n */\n private _paused: boolean = true\n\n /**\n * Returns whether the animation is currently paused.\n */\n get paused(): boolean {\n return this._paused\n }\n\n /**\n * Callback for animation state changes.\n */\n private _onAnimationStateChangeCallback?: (\n detail: AnimationStateChangeDetail,\n ) => void\n\n /**\n * Sets the callback for animation state changes.\n */\n set onAnimationStateChangeCallback(\n callback: undefined | ((detail: AnimationStateChangeDetail) => void),\n ) {\n this._onAnimationStateChangeCallback = callback\n }\n\n /**\n * Starts or resumes animation playback.\n * @returns Promise resolving when the command is sent\n */\n async play(): Promise<void> {\n if (this._paused) {\n // Start extrapolating from the last known position on resume.\n this._anchorTimestamp = Date.now()\n }\n this._paused = false\n await this.updateProperties({ animationPaused: false })\n }\n\n /**\n * Pauses animation playback.\n * @returns Promise resolving when the command is sent\n */\n async pause(): Promise<void> {\n if (!this._paused) {\n // Freeze the extrapolated position so reads remain stable until the\n // next native sample arrives.\n this._currentTime = this.currentTime\n this._anchorTimestamp = Date.now()\n }\n this._paused = true\n await this.updateProperties({ animationPaused: true })\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles model loading events in addition to base spatial events.\n * @param data The event data received from the WebSpatial system\n */\n override onReceiveEvent(data: Static3DReceiveEventData) {\n if (data.type === SpatialWebMsgType.modelloaded) {\n // On old runtimes (<⍺2.1) detail is not returned so fallback to modelURL\n this._currentSrc = data.detail?.src ?? this.modelURL ?? ''\n // Handle successful model loading\n this._onLoadCallback?.()\n this._readyResolve?.(true)\n } else if (data.type === SpatialWebMsgType.modelloadfailed) {\n // Handle model loading failure\n this._onLoadFailureCallback?.()\n this._readyResolve?.(false)\n } else if (data.type === SpatialWebMsgType.animationstatechange) {\n this._paused = data.detail.paused\n this._duration = data.detail.duration\n // In unsupported environments currentTime is invalid\n this._currentTime = data.detail.currentTime ?? 0\n this._anchorTimestamp = data.detail.timestamp ?? Date.now()\n this._onAnimationStateChangeCallback?.(data.detail)\n } else if (data.type === SpatialWebMsgType.entitytransformchange) {\n this._entityTransform = new DOMMatrixReadOnly(data.detail.transform)\n } else {\n // Handle other spatial events using the base class implementation\n super.onReceiveEvent(data)\n }\n }\n\n /**\n * Whether the model should automatically play its first animation on load.\n */\n private _autoplay: boolean = false\n\n /**\n * Returns whether autoplay is enabled for this element.\n */\n get autoplay(): boolean {\n return this._autoplay\n }\n\n /**\n * Asset fetch policy. `'lazy'` defers fetching until the host signals the\n * element is in view; `'eager'` fetches immediately.\n */\n private _loading: ModelLoadingMode = 'eager'\n\n get loading(): ModelLoadingMode {\n return this._loading\n }\n\n /**\n * Whether the model animation should loop continuously.\n */\n private _loop: boolean = false\n\n /**\n * Returns whether loop is enabled for this element.\n */\n get loop(): boolean {\n return this._loop\n }\n\n /**\n * Callback function for successful model loading.\n */\n private _onLoadCallback?: () => void\n\n /**\n * Sets the callback function for successful model loading.\n * @param callback Function to call when the model is loaded successfully\n */\n set onLoadCallback(callback: undefined | (() => void)) {\n this._onLoadCallback = callback\n }\n\n /**\n * Callback function for model loading failure.\n */\n private _onLoadFailureCallback?: undefined | (() => void)\n\n /**\n * Sets the callback function for model loading failure.\n * @param callback Function to call when the model fails to load\n */\n set onLoadFailureCallback(callback: undefined | (() => void)) {\n this._onLoadFailureCallback = callback\n }\n\n /**\n * Built-in interaction mode. In `'orbit'` the native layer drives the\n * transform and `entityTransform` is read-only.\n */\n private _stagemode: StageMode = 'none'\n\n get stagemode(): StageMode {\n return this._stagemode\n }\n\n /**\n * Latest transform of the model, including native-driven manipulations such\n * as orbit interaction.\n */\n private _entityTransform: DOMMatrixReadOnly = new DOMMatrixReadOnly()\n\n get entityTransform(): DOMMatrixReadOnly {\n return this._entityTransform\n }\n\n set entityTransform(transform: DOMMatrixReadOnly) {\n // In orbit mode the native layer owns the transform, so ignore writes.\n if (this._stagemode === 'orbit') return\n this._entityTransform = transform\n // The public API is `entityTransform`, but the JSB property stays\n // `modelTransform` so the native side remains backward compatible.\n this.updateProperties({\n modelTransform: Array.from(transform.toFloat64Array()),\n })\n }\n}\n\n// Equivalent of proposed Math.clamp\nfunction clamp(num: number, min: number, max: number) {\n return num <= min ? min : num >= max ? max : num\n}\n\ntype Static3DReceiveEventData =\n | ModelLoadSuccess\n | ModelLoadFailure\n | ReceiveEventData\n | AnimationStateChangeMsg\n | EntityTransformChangeMsg\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { b3 as AnimationCanceledEventPayload, b4 as AnimationCompletedEventPayload, b5 as AnimationFailedEventPayload, aS as AnimationStateChangeDetail, aW as AnimationStateChangeMsg, b6 as EntityTransformChangeDetail, aX as EntityTransformChangeMsg, aU as ModelLoadFailure, aT as ModelLoadSuccess, b7 as ObjectDestroyMsg, b8 as SpatialDragEndMsg, b9 as SpatialDragMsg, ba as SpatialDragStartMsg, bb as SpatialMagnifyEndMsg, bc as SpatialMagnifyMsg, bd as SpatialRotateEndMsg, be as SpatialRotateMsg, bf as SpatialTapMsg, aP as SpatialWebMsgType } from './spatializedElementMotion-_0XWPQCE.js';
|
|
2
|
+
import './types/motion/spatializedVisual.js';
|
|
3
|
+
import './types/motion/spatializedPlayback.js';
|
|
4
|
+
import './types/global.js';
|
|
5
|
+
import './physicalMetrics-W5uZ5xKb.js';
|
|
6
|
+
import './SpatialObject.js';
|
|
7
|
+
import './reality/component/SpatialComponent.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var SpatialWebMsgType = /* @__PURE__ */ ((SpatialWebMsgType2) => {
|
|
2
|
+
SpatialWebMsgType2["modelloaded"] = "modelloaded";
|
|
3
|
+
SpatialWebMsgType2["modelloadfailed"] = "modelloadfailed";
|
|
4
|
+
SpatialWebMsgType2["spatialtap"] = "spatialtap";
|
|
5
|
+
SpatialWebMsgType2["spatialdragstart"] = "spatialdragstart";
|
|
6
|
+
SpatialWebMsgType2["spatialdrag"] = "spatialdrag";
|
|
7
|
+
SpatialWebMsgType2["spatialdragend"] = "spatialdragend";
|
|
8
|
+
SpatialWebMsgType2["spatialrotate"] = "spatialrotate";
|
|
9
|
+
SpatialWebMsgType2["spatialrotateend"] = "spatialrotateend";
|
|
10
|
+
SpatialWebMsgType2["spatialmagnify"] = "spatialmagnify";
|
|
11
|
+
SpatialWebMsgType2["spatialmagnifyend"] = "spatialmagnifyend";
|
|
12
|
+
SpatialWebMsgType2["animationstatechange"] = "animationstatechange";
|
|
13
|
+
SpatialWebMsgType2["entitytransformchange"] = "entitytransformchange";
|
|
14
|
+
SpatialWebMsgType2["animationcompleted"] = "animationcompleted";
|
|
15
|
+
SpatialWebMsgType2["animationstopped"] = "animationstopped";
|
|
16
|
+
SpatialWebMsgType2["animationfailed"] = "animationfailed";
|
|
17
|
+
SpatialWebMsgType2["objectdestroy"] = "objectdestroy";
|
|
18
|
+
return SpatialWebMsgType2;
|
|
19
|
+
})(SpatialWebMsgType || {});
|
|
20
|
+
export {
|
|
21
|
+
SpatialWebMsgType
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=WebMsgCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/WebMsgCommand.ts"],"sourcesContent":["import {\n SpatialDragEventDetail,\n SpatialTapEventDetail,\n SpatialRotateEventDetail,\n SpatialMagnifyEventDetail,\n SpatialDragStartEventDetail,\n SpatialDragEndEventDetail,\n} from './types/types'\n\nexport enum SpatialWebMsgType {\n modelloaded = 'modelloaded',\n modelloadfailed = 'modelloadfailed',\n spatialtap = 'spatialtap',\n spatialdragstart = 'spatialdragstart',\n spatialdrag = 'spatialdrag',\n spatialdragend = 'spatialdragend',\n spatialrotate = 'spatialrotate',\n spatialrotateend = 'spatialrotateend',\n spatialmagnify = 'spatialmagnify',\n spatialmagnifyend = 'spatialmagnifyend',\n\n animationstatechange = 'animationstatechange',\n\n // Native-driven transform updates (e.g. while in `stagemode=\"orbit\"`)\n entitytransformchange = 'entitytransformchange',\n\n // Animation terminal events (keyed by animationId, not by this enum)\n animationcompleted = 'animationcompleted',\n animationstopped = 'animationstopped',\n animationfailed = 'animationfailed',\n\n objectdestroy = 'objectdestroy',\n}\n\nexport interface ObjectDestroyMsg {\n type: SpatialWebMsgType.objectdestroy\n}\n\nexport interface SpatialTapMsg {\n type: SpatialWebMsgType.spatialtap\n detail: SpatialTapEventDetail\n}\n\nexport interface SpatialDragStartMsg {\n type: SpatialWebMsgType.spatialdragstart\n detail: SpatialDragStartEventDetail\n}\n\nexport interface SpatialDragMsg {\n type: SpatialWebMsgType.spatialdrag\n detail: SpatialDragEventDetail\n}\n\nexport interface SpatialDragEndMsg {\n type: SpatialWebMsgType.spatialdragend\n detail: SpatialDragEndEventDetail\n}\n\nexport interface SpatialRotateMsg {\n type: SpatialWebMsgType.spatialrotate\n detail: SpatialRotateEventDetail\n}\n\nexport interface SpatialRotateEndMsg {\n type: SpatialWebMsgType.spatialrotateend\n detail: SpatialRotateEventDetail\n}\n\nexport interface SpatialMagnifyMsg {\n type: SpatialWebMsgType.spatialmagnify\n detail: SpatialMagnifyEventDetail\n}\n\nexport interface SpatialMagnifyEndMsg {\n type: SpatialWebMsgType.spatialmagnifyend\n detail: SpatialMagnifyEventDetail\n}\n\nexport interface ModelLoadSuccess {\n type: SpatialWebMsgType.modelloaded\n // detail object is undefined in old native runtimes\n detail?: { src: string }\n}\n\nexport interface ModelLoadFailure {\n type: SpatialWebMsgType.modelloadfailed\n}\n\nexport interface AnimationStateChangeDetail {\n paused: boolean\n duration: number\n /**\n * Sampled animation playback position in seconds at `timestamp`.\n * Optional for compatibility with older native runtimes.\n */\n currentTime?: number\n /**\n * Unix epoch time in milliseconds at which `currentTime` was sampled.\n * Used to extrapolate `currentTime` between samples while playing.\n */\n timestamp?: number\n}\n\nexport interface AnimationStateChangeMsg {\n type: SpatialWebMsgType.animationstatechange\n detail: AnimationStateChangeDetail\n}\n\nexport interface EntityTransformChangeDetail {\n /** Column-major 4x4 matrix (16 numbers) representing the manipulated transform. */\n transform: number[]\n}\n\nexport interface EntityTransformChangeMsg {\n type: SpatialWebMsgType.entitytransformchange\n detail: EntityTransformChangeDetail\n}\n\n// Animation terminal event payloads (delivered via SpatialWebEvent keyed by animationId)\n\nexport interface AnimationCompletedEventPayload {\n type: 'completed'\n /** Column-major 4x4 matrix (16 numbers) representing the final native transform. */\n transform: number[]\n}\n\nexport interface AnimationCanceledEventPayload {\n type: 'canceled'\n /** Column-major 4x4 matrix (16 numbers) representing the restored transform after cancel. */\n transform: number[]\n}\n\nexport interface AnimationFailedEventPayload {\n type: 'failed'\n animationId: string\n command: 'play' | 'pause' | 'resume' | 'cancel'\n code?: string\n reason: string\n}\n"],"mappings":"AASO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,mBAAA,iBAAc;AACd,EAAAA,mBAAA,qBAAkB;AAClB,EAAAA,mBAAA,gBAAa;AACb,EAAAA,mBAAA,sBAAmB;AACnB,EAAAA,mBAAA,iBAAc;AACd,EAAAA,mBAAA,oBAAiB;AACjB,EAAAA,mBAAA,mBAAgB;AAChB,EAAAA,mBAAA,sBAAmB;AACnB,EAAAA,mBAAA,oBAAiB;AACjB,EAAAA,mBAAA,uBAAoB;AAEpB,EAAAA,mBAAA,0BAAuB;AAGvB,EAAAA,mBAAA,2BAAwB;AAGxB,EAAAA,mBAAA,wBAAqB;AACrB,EAAAA,mBAAA,sBAAmB;AACnB,EAAAA,mBAAA,qBAAkB;AAElB,EAAAA,mBAAA,mBAAgB;AAtBN,SAAAA;AAAA,GAAA;","names":["SpatialWebMsgType"]}
|