@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,173 @@
|
|
|
1
|
+
import { initScene } from "./scene-polyfill";
|
|
2
|
+
import { SpatialScene } from "./SpatialScene";
|
|
3
|
+
import {
|
|
4
|
+
createSpatialized2DElement,
|
|
5
|
+
createSpatializedDynamic3DElement
|
|
6
|
+
} from "./SpatializedElementCreator";
|
|
7
|
+
import { createSpatializedStatic3DElement } from "./SpatializedElementCreator";
|
|
8
|
+
import { createAttachmentEntity } from "./reality/Attachment";
|
|
9
|
+
import {
|
|
10
|
+
createModelAsset,
|
|
11
|
+
createModelComponent,
|
|
12
|
+
createSpatialEntity,
|
|
13
|
+
createSpatialGeometry,
|
|
14
|
+
createSpatialModelEntity,
|
|
15
|
+
createSpatialTexture,
|
|
16
|
+
createSpatialUnlitMaterial
|
|
17
|
+
} from "./reality/realityCreator";
|
|
18
|
+
import {
|
|
19
|
+
SpatialBoxGeometry,
|
|
20
|
+
SpatialPlaneGeometry,
|
|
21
|
+
SpatialSphereGeometry,
|
|
22
|
+
SpatialConeGeometry,
|
|
23
|
+
SpatialCylinderGeometry
|
|
24
|
+
} from "./reality";
|
|
25
|
+
class SpatialSession {
|
|
26
|
+
/**
|
|
27
|
+
* Gets the singleton instance of the spatial scene.
|
|
28
|
+
* The spatial scene is the root container for all spatial elements.
|
|
29
|
+
* @returns The SpatialScene singleton instance
|
|
30
|
+
*/
|
|
31
|
+
getSpatialScene() {
|
|
32
|
+
return SpatialScene.getInstance();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new 2D element that can be spatialized in the 3D environment.
|
|
36
|
+
* 2D elements represent HTML content that can be positioned in 3D space.
|
|
37
|
+
* @returns Promise resolving to a new Spatialized2DElement instance
|
|
38
|
+
*/
|
|
39
|
+
createSpatialized2DElement() {
|
|
40
|
+
return createSpatialized2DElement();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new static 3D element with an optional model URL.
|
|
44
|
+
* Static 3D elements represent pre-built 3D models that can be loaded from a URL.
|
|
45
|
+
* @param modelURL Optional URL to the 3D model to load
|
|
46
|
+
* @param sources Optional list of fallback model sources
|
|
47
|
+
* @param loading Whether the asset should fetch eagerly or be deferred (`'lazy'`)
|
|
48
|
+
* @returns Promise resolving to a new SpatializedStatic3DElement instance
|
|
49
|
+
*/
|
|
50
|
+
createSpatializedStatic3DElement(modelURL, sources, loading = "eager") {
|
|
51
|
+
return createSpatializedStatic3DElement(modelURL, sources, loading);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Initializes the spatial scene with custom configuration.
|
|
55
|
+
* This is a reference to the initScene function from scene-polyfill.
|
|
56
|
+
*/
|
|
57
|
+
initScene = initScene;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new dynamic 3D element that can be manipulated at runtime.
|
|
60
|
+
* Dynamic 3D elements allow for programmatic creation and modification of 3D content.
|
|
61
|
+
* @returns Promise resolving to a new SpatializedDynamic3DElement instance
|
|
62
|
+
*/
|
|
63
|
+
createSpatializedDynamic3DElement() {
|
|
64
|
+
return createSpatializedDynamic3DElement();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new spatial entity with an optional name.
|
|
68
|
+
* Entities are the basic building blocks for creating custom 3D content.
|
|
69
|
+
* @param name Optional name for the entity
|
|
70
|
+
* @returns Promise resolving to a new SpatialEntity instance
|
|
71
|
+
*/
|
|
72
|
+
createEntity(userData) {
|
|
73
|
+
return createSpatialEntity(userData);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates a box geometry with optional configuration.
|
|
77
|
+
* @param options Configuration options for the box geometry
|
|
78
|
+
* @returns Promise resolving to a new SpatialBoxGeometry instance
|
|
79
|
+
*/
|
|
80
|
+
createBoxGeometry(options = {}) {
|
|
81
|
+
return createSpatialGeometry(SpatialBoxGeometry, options);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a plane geometry with optional configuration.
|
|
85
|
+
* @param options Configuration options for the plane geometry
|
|
86
|
+
* @returns Promise resolving to a new SpatialPlaneGeometry instance
|
|
87
|
+
*/
|
|
88
|
+
createPlaneGeometry(options = {}) {
|
|
89
|
+
return createSpatialGeometry(SpatialPlaneGeometry, options);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates a sphere geometry with optional configuration.
|
|
93
|
+
* @param options Configuration options for the sphere geometry
|
|
94
|
+
* @returns Promise resolving to a new SpatialSphereGeometry instance
|
|
95
|
+
*/
|
|
96
|
+
createSphereGeometry(options = {}) {
|
|
97
|
+
return createSpatialGeometry(SpatialSphereGeometry, options);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Creates a cone geometry with the specified configuration.
|
|
101
|
+
* @param options Configuration options for the cone geometry
|
|
102
|
+
* @returns Promise resolving to a new SpatialConeGeometry instance
|
|
103
|
+
*/
|
|
104
|
+
createConeGeometry(options) {
|
|
105
|
+
return createSpatialGeometry(SpatialConeGeometry, options);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates a cylinder geometry with the specified configuration.
|
|
109
|
+
* @param options Configuration options for the cylinder geometry
|
|
110
|
+
* @returns Promise resolving to a new SpatialCylinderGeometry instance
|
|
111
|
+
*/
|
|
112
|
+
createCylinderGeometry(options) {
|
|
113
|
+
return createSpatialGeometry(SpatialCylinderGeometry, options);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates a model component with the specified configuration.
|
|
117
|
+
* Model components are used to add 3D model rendering capabilities to entities.
|
|
118
|
+
* @param options Configuration options for the model component
|
|
119
|
+
* @returns Promise resolving to a new ModelComponent instance
|
|
120
|
+
*/
|
|
121
|
+
createModelComponent(options) {
|
|
122
|
+
return createModelComponent(options);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates an unlit material with the specified configuration.
|
|
126
|
+
* Unlit materials don't respond to lighting in the scene.
|
|
127
|
+
* @param options Configuration options for the unlit material
|
|
128
|
+
* @returns Promise resolving to a new SpatialUnlitMaterial instance
|
|
129
|
+
*/
|
|
130
|
+
createUnlitMaterial(options) {
|
|
131
|
+
return createSpatialUnlitMaterial(options);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Creates a texture resource from the specified image URL.
|
|
135
|
+
* Texture resources can be referenced by materials and other spatial content.
|
|
136
|
+
* @param options Configuration options for the texture resource
|
|
137
|
+
* @returns Promise resolving to a new SpatialTextureResource instance
|
|
138
|
+
*/
|
|
139
|
+
createTexture(options) {
|
|
140
|
+
return createSpatialTexture(options);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Creates a model asset with the specified configuration.
|
|
144
|
+
* Model assets represent 3D model resources that can be used by entities.
|
|
145
|
+
* @param options Configuration options for the model asset
|
|
146
|
+
* @returns Promise resolving to a new SpatialModelAsset instance
|
|
147
|
+
*/
|
|
148
|
+
createModelAsset(options) {
|
|
149
|
+
return createModelAsset(options);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Creates a spatial model entity with the specified configuration.
|
|
153
|
+
* This is a convenience method for creating an entity with a model component.
|
|
154
|
+
* @param options Configuration options for the spatial model entity
|
|
155
|
+
* @returns Promise resolving to a new SpatialModelEntity instance
|
|
156
|
+
*/
|
|
157
|
+
createSpatialModelEntity(options, userData) {
|
|
158
|
+
return createSpatialModelEntity(options, userData);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Creates an attachment entity that renders 2D HTML content as a child
|
|
162
|
+
* of a 3D entity in the scene graph.
|
|
163
|
+
* @param options Configuration options including parent entity ID, position, and size
|
|
164
|
+
* @returns Promise resolving to a new Attachment instance
|
|
165
|
+
*/
|
|
166
|
+
createAttachmentEntity(options) {
|
|
167
|
+
return createAttachmentEntity(options);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export {
|
|
171
|
+
SpatialSession
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=SpatialSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SpatialSession.ts"],"sourcesContent":["import { initScene } from './scene-polyfill'\nimport { SpatialScene } from './SpatialScene'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport {\n createSpatialized2DElement,\n createSpatializedDynamic3DElement,\n} from './SpatializedElementCreator'\nimport { createSpatializedStatic3DElement } from './SpatializedElementCreator'\nimport { Attachment, createAttachmentEntity } from './reality/Attachment'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialBoxGeometryOptions,\n SpatialConeGeometryOptions,\n SpatialCylinderGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialPlaneGeometryOptions,\n SpatialSphereGeometryOptions,\n SpatialUnlitMaterialOptions,\n SpatialTextureResourceOptions,\n SpatialEntityUserData,\n AttachmentEntityOptions,\n ModelLoadingMode,\n ModelSource,\n} from './types/types'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport {\n createModelAsset,\n createModelComponent,\n createSpatialEntity,\n createSpatialGeometry,\n createSpatialModelEntity,\n createSpatialTexture,\n createSpatialUnlitMaterial,\n} from './reality/realityCreator'\nimport {\n SpatialBoxGeometry,\n SpatialPlaneGeometry,\n SpatialSphereGeometry,\n SpatialConeGeometry,\n SpatialCylinderGeometry,\n} from './reality'\n\n/**\n * Session used to establish a connection to the spatial renderer of the system.\n * All spatial resources must be created through this session object.\n * This class serves as the main factory for creating spatial elements and geometries.\n */\nexport class SpatialSession {\n /**\n * Gets the singleton instance of the spatial scene.\n * The spatial scene is the root container for all spatial elements.\n * @returns The SpatialScene singleton instance\n */\n getSpatialScene(): SpatialScene {\n return SpatialScene.getInstance()\n }\n\n /**\n * Creates a new 2D element that can be spatialized in the 3D environment.\n * 2D elements represent HTML content that can be positioned in 3D space.\n * @returns Promise resolving to a new Spatialized2DElement instance\n */\n createSpatialized2DElement(): Promise<Spatialized2DElement> {\n return createSpatialized2DElement()\n }\n\n /**\n * Creates a new static 3D element with an optional model URL.\n * Static 3D elements represent pre-built 3D models that can be loaded from a URL.\n * @param modelURL Optional URL to the 3D model to load\n * @param sources Optional list of fallback model sources\n * @param loading Whether the asset should fetch eagerly or be deferred (`'lazy'`)\n * @returns Promise resolving to a new SpatializedStatic3DElement instance\n */\n createSpatializedStatic3DElement(\n modelURL?: string,\n sources?: ModelSource[],\n loading: ModelLoadingMode = 'eager',\n ): Promise<SpatializedStatic3DElement> {\n return createSpatializedStatic3DElement(modelURL, sources, loading)\n }\n\n /**\n * Initializes the spatial scene with custom configuration.\n * This is a reference to the initScene function from scene-polyfill.\n */\n initScene = initScene\n\n /**\n * Creates a new dynamic 3D element that can be manipulated at runtime.\n * Dynamic 3D elements allow for programmatic creation and modification of 3D content.\n * @returns Promise resolving to a new SpatializedDynamic3DElement instance\n */\n createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n return createSpatializedDynamic3DElement()\n }\n\n /**\n * Creates a new spatial entity with an optional name.\n * Entities are the basic building blocks for creating custom 3D content.\n * @param name Optional name for the entity\n * @returns Promise resolving to a new SpatialEntity instance\n */\n createEntity(userData?: SpatialEntityUserData): Promise<SpatialEntity> {\n return createSpatialEntity(userData)\n }\n\n /**\n * Creates a box geometry with optional configuration.\n * @param options Configuration options for the box geometry\n * @returns Promise resolving to a new SpatialBoxGeometry instance\n */\n createBoxGeometry(options: SpatialBoxGeometryOptions = {}) {\n return createSpatialGeometry(SpatialBoxGeometry, options)\n }\n\n /**\n * Creates a plane geometry with optional configuration.\n * @param options Configuration options for the plane geometry\n * @returns Promise resolving to a new SpatialPlaneGeometry instance\n */\n createPlaneGeometry(options: SpatialPlaneGeometryOptions = {}) {\n return createSpatialGeometry(SpatialPlaneGeometry, options)\n }\n\n /**\n * Creates a sphere geometry with optional configuration.\n * @param options Configuration options for the sphere geometry\n * @returns Promise resolving to a new SpatialSphereGeometry instance\n */\n createSphereGeometry(options: SpatialSphereGeometryOptions = {}) {\n return createSpatialGeometry(SpatialSphereGeometry, options)\n }\n\n /**\n * Creates a cone geometry with the specified configuration.\n * @param options Configuration options for the cone geometry\n * @returns Promise resolving to a new SpatialConeGeometry instance\n */\n createConeGeometry(options: SpatialConeGeometryOptions) {\n return createSpatialGeometry(SpatialConeGeometry, options)\n }\n\n /**\n * Creates a cylinder geometry with the specified configuration.\n * @param options Configuration options for the cylinder geometry\n * @returns Promise resolving to a new SpatialCylinderGeometry instance\n */\n createCylinderGeometry(options: SpatialCylinderGeometryOptions) {\n return createSpatialGeometry(SpatialCylinderGeometry, options)\n }\n\n /**\n * Creates a model component with the specified configuration.\n * Model components are used to add 3D model rendering capabilities to entities.\n * @param options Configuration options for the model component\n * @returns Promise resolving to a new ModelComponent instance\n */\n createModelComponent(options: ModelComponentOptions) {\n return createModelComponent(options)\n }\n\n /**\n * Creates an unlit material with the specified configuration.\n * Unlit materials don't respond to lighting in the scene.\n * @param options Configuration options for the unlit material\n * @returns Promise resolving to a new SpatialUnlitMaterial instance\n */\n createUnlitMaterial(options: SpatialUnlitMaterialOptions) {\n return createSpatialUnlitMaterial(options)\n }\n\n /**\n * Creates a texture resource from the specified image URL.\n * Texture resources can be referenced by materials and other spatial content.\n * @param options Configuration options for the texture resource\n * @returns Promise resolving to a new SpatialTextureResource instance\n */\n createTexture(options: SpatialTextureResourceOptions) {\n return createSpatialTexture(options)\n }\n\n /**\n * Creates a model asset with the specified configuration.\n * Model assets represent 3D model resources that can be used by entities.\n * @param options Configuration options for the model asset\n * @returns Promise resolving to a new SpatialModelAsset instance\n */\n createModelAsset(options: ModelAssetOptions) {\n return createModelAsset(options)\n }\n\n /**\n * Creates a spatial model entity with the specified configuration.\n * This is a convenience method for creating an entity with a model component.\n * @param options Configuration options for the spatial model entity\n * @returns Promise resolving to a new SpatialModelEntity instance\n */\n createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n ) {\n return createSpatialModelEntity(options, userData)\n }\n\n /**\n * Creates an attachment entity that renders 2D HTML content as a child\n * of a 3D entity in the scene graph.\n * @param options Configuration options including parent entity ID, position, and size\n * @returns Promise resolving to a new Attachment instance\n */\n createAttachmentEntity(\n options: AttachmentEntityOptions,\n ): Promise<Attachment> {\n return createAttachmentEntity(options)\n }\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,wCAAwC;AACjD,SAAqB,8BAA8B;AAoBnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOA,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1B,kBAAgC;AAC9B,WAAO,aAAa,YAAY;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,6BAA4D;AAC1D,WAAO,2BAA2B;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,iCACE,UACA,SACA,UAA4B,SACS;AACrC,WAAO,iCAAiC,UAAU,SAAS,OAAO;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOZ,oCAA0E;AACxE,WAAO,kCAAkC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,aAAa,UAA0D;AACrE,WAAO,oBAAoB,QAAQ;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkB,UAAqC,CAAC,GAAG;AACzD,WAAO,sBAAsB,oBAAoB,OAAO;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,oBAAoB,UAAuC,CAAC,GAAG;AAC7D,WAAO,sBAAsB,sBAAsB,OAAO;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAAqB,UAAwC,CAAC,GAAG;AAC/D,WAAO,sBAAsB,uBAAuB,OAAO;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,SAAqC;AACtD,WAAO,sBAAsB,qBAAqB,OAAO;AAAA,EAC3D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,uBAAuB,SAAyC;AAC9D,WAAO,sBAAsB,yBAAyB,OAAO;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,qBAAqB,SAAgC;AACnD,WAAO,qBAAqB,OAAO;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,oBAAoB,SAAsC;AACxD,WAAO,2BAA2B,OAAO;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAc,SAAwC;AACpD,WAAO,qBAAqB,OAAO;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,iBAAiB,SAA4B;AAC3C,WAAO,iBAAiB,OAAO;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,yBACE,SACA,UACA;AACA,WAAO,yBAAyB,SAAS,QAAQ;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,uBACE,SACqB;AACrB,WAAO,uBAAuB,OAAO;AAAA,EACvC;AACF;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare class SpatialWebEvent {
|
|
2
|
+
static eventReceiver: Record<string, (data: any) => void>;
|
|
3
|
+
static init(): void;
|
|
4
|
+
static addEventReceiver(id: string, callback: (data: any) => void): void;
|
|
5
|
+
static removeEventReceiver(id: string): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { SpatialWebEvent };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class SpatialWebEvent {
|
|
2
|
+
static eventReceiver = {};
|
|
3
|
+
static init() {
|
|
4
|
+
window.__SpatialWebEvent = ({ id, data }) => {
|
|
5
|
+
SpatialWebEvent.eventReceiver[id]?.(data);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
static addEventReceiver(id, callback) {
|
|
9
|
+
SpatialWebEvent.eventReceiver[id] = callback;
|
|
10
|
+
}
|
|
11
|
+
static removeEventReceiver(id) {
|
|
12
|
+
delete SpatialWebEvent.eventReceiver[id];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
SpatialWebEvent
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=SpatialWebEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SpatialWebEvent.ts"],"sourcesContent":["interface SpatialWebEventData {\n id: string\n data: any\n}\n\nexport class SpatialWebEvent {\n static eventReceiver: Record<string, (data: any) => void> = {}\n static init() {\n // inject __SpatialWebEvent\n window.__SpatialWebEvent = ({ id, data }: SpatialWebEventData) => {\n // console.log('__SpatialWebEvent', id, data)\n SpatialWebEvent.eventReceiver[id]?.(data)\n }\n }\n\n static addEventReceiver(id: string, callback: (data: any) => void) {\n SpatialWebEvent.eventReceiver[id] = callback\n }\n\n static removeEventReceiver(id: string) {\n delete SpatialWebEvent.eventReceiver[id]\n }\n}\n"],"mappings":"AAKO,MAAM,gBAAgB;AAAA,EAC3B,OAAO,gBAAqD,CAAC;AAAA,EAC7D,OAAO,OAAO;AAEZ,WAAO,oBAAoB,CAAC,EAAE,IAAI,KAAK,MAA2B;AAEhE,sBAAgB,cAAc,EAAE,IAAI,IAAI;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,OAAO,iBAAiB,IAAY,UAA+B;AACjE,oBAAgB,cAAc,EAAE,IAAI;AAAA,EACtC;AAAA,EAEA,OAAO,oBAAoB,IAAY;AACrC,WAAO,gBAAgB,cAAc,EAAE;AAAA,EACzC;AACF;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { 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';
|
|
8
|
+
|
|
9
|
+
declare function createSpatialEvent<T>(type: SpatialWebMsgType, detail: T): CustomEvent<T>;
|
|
10
|
+
|
|
11
|
+
export { createSpatialEvent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SpatialWebEventCreator.ts"],"sourcesContent":["import { SpatialWebMsgType } from './WebMsgCommand'\n\nexport function createSpatialEvent<T>(\n type: SpatialWebMsgType,\n detail: T,\n): CustomEvent<T> {\n return new CustomEvent<T>(type, {\n bubbles: true,\n cancelable: false,\n detail,\n })\n}\n"],"mappings":"AAEO,SAAS,mBACd,MACA,QACgB;AAChB,SAAO,IAAI,YAAe,MAAM;AAAA,IAC9B,SAAS;AAAA,IACT,YAAY;AAAA,IACZ;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ag as SpatializedElement, ae as Spatialized2DElementProperties, aK as CommandResult } 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 2D HTML element that has been spatialized in 3D space.
|
|
11
|
+
* This class handles the integration between 2D web content and the 3D spatial environment,
|
|
12
|
+
* allowing HTML elements to be positioned and interacted with in spatial applications.
|
|
13
|
+
*/
|
|
14
|
+
declare class Spatialized2DElement extends SpatializedElement {
|
|
15
|
+
readonly windowProxy: WindowProxy;
|
|
16
|
+
/**
|
|
17
|
+
* Identifies the motion target kind supported by this element.
|
|
18
|
+
*/
|
|
19
|
+
readonly kind: "spatialized2d";
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new spatialized 2D element.
|
|
22
|
+
* @param id Unique identifier for this element
|
|
23
|
+
* @param windowProxy Reference to the window object containing the 2D content
|
|
24
|
+
*/
|
|
25
|
+
constructor(id: string, windowProxy: WindowProxy);
|
|
26
|
+
/**
|
|
27
|
+
* Updates the properties of this 2D element.
|
|
28
|
+
* This can include size, position, background, and other visual properties.
|
|
29
|
+
* @param properties Partial set of properties to update
|
|
30
|
+
* @returns Promise resolving when the update is complete
|
|
31
|
+
*/
|
|
32
|
+
updateProperties(properties: Partial<Spatialized2DElementProperties>): Promise<CommandResult<any>>;
|
|
33
|
+
/**
|
|
34
|
+
* Adds a child spatialized element to this 2D element.
|
|
35
|
+
* This allows for creating hierarchical structures of spatial elements.
|
|
36
|
+
* @param element The child element to add
|
|
37
|
+
* @returns Promise resolving when the element is added
|
|
38
|
+
*/
|
|
39
|
+
addSpatializedElement(element: SpatializedElement): Promise<CommandResult<any>>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { Spatialized2DElement };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddSpatializedElementToSpatialized2DElement,
|
|
3
|
+
UpdateSpatialized2DElementProperties
|
|
4
|
+
} from "./JSBCommand";
|
|
5
|
+
import { hijackWindowATag } from "./scene-polyfill";
|
|
6
|
+
import { SpatializedElement } from "./SpatializedElement";
|
|
7
|
+
class Spatialized2DElement extends SpatializedElement {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new spatialized 2D element.
|
|
10
|
+
* @param id Unique identifier for this element
|
|
11
|
+
* @param windowProxy Reference to the window object containing the 2D content
|
|
12
|
+
*/
|
|
13
|
+
constructor(id, windowProxy) {
|
|
14
|
+
super(id);
|
|
15
|
+
this.windowProxy = windowProxy;
|
|
16
|
+
hijackWindowATag(windowProxy);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Identifies the motion target kind supported by this element.
|
|
20
|
+
*/
|
|
21
|
+
kind = "spatialized2d";
|
|
22
|
+
/**
|
|
23
|
+
* Updates the properties of this 2D element.
|
|
24
|
+
* This can include size, position, background, and other visual properties.
|
|
25
|
+
* @param properties Partial set of properties to update
|
|
26
|
+
* @returns Promise resolving when the update is complete
|
|
27
|
+
*/
|
|
28
|
+
async updateProperties(properties) {
|
|
29
|
+
return new UpdateSpatialized2DElementProperties(this, properties).execute();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Adds a child spatialized element to this 2D element.
|
|
33
|
+
* This allows for creating hierarchical structures of spatial elements.
|
|
34
|
+
* @param element The child element to add
|
|
35
|
+
* @returns Promise resolving when the element is added
|
|
36
|
+
*/
|
|
37
|
+
async addSpatializedElement(element) {
|
|
38
|
+
return new AddSpatializedElementToSpatialized2DElement(
|
|
39
|
+
this,
|
|
40
|
+
element
|
|
41
|
+
).execute();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
Spatialized2DElement
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=Spatialized2DElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Spatialized2DElement.ts"],"sourcesContent":["import {\n AddSpatializedElementToSpatialized2DElement,\n UpdateSpatialized2DElementProperties,\n} from './JSBCommand'\nimport { hijackWindowATag } from './scene-polyfill'\nimport { SpatializedElement } from './SpatializedElement'\nimport { Spatialized2DElementProperties } from './types/types'\n\n/**\n * Represents a 2D HTML element that has been spatialized in 3D space.\n * This class handles the integration between 2D web content and the 3D spatial environment,\n * allowing HTML elements to be positioned and interacted with in spatial applications.\n */\nexport class Spatialized2DElement extends SpatializedElement {\n /**\n * Identifies the motion target kind supported by this element.\n */\n override readonly kind = 'spatialized2d' as const\n\n /**\n * Creates a new spatialized 2D element.\n * @param id Unique identifier for this element\n * @param windowProxy Reference to the window object containing the 2D content\n */\n constructor(\n id: string,\n readonly windowProxy: WindowProxy,\n ) {\n super(id)\n // Hijack anchor tag events to handle navigation within the spatial context\n hijackWindowATag(windowProxy)\n }\n\n /**\n * Updates the properties of this 2D element.\n * This can include size, position, background, and other visual properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(properties: Partial<Spatialized2DElementProperties>) {\n return new UpdateSpatialized2DElementProperties(this, properties).execute()\n }\n\n /**\n * Adds a child spatialized element to this 2D element.\n * This allows for creating hierarchical structures of spatial elements.\n * @param element The child element to add\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialized2DElement(\n this,\n element,\n ).execute()\n }\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AAQ5B,MAAM,6BAA6B,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW3D,YACE,IACS,aACT;AACA,UAAM,EAAE;AAFC;AAIT,qBAAiB,WAAW;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAdkB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBzB,MAAM,iBAAiB,YAAqD;AAC1E,WAAO,IAAI,qCAAqC,MAAM,UAAU,EAAE,QAAQ;AAAA,EAC5E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,sBAAsB,SAA6B;AACvD,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF,EAAE,QAAQ;AAAA,EACZ;AACF;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { af as SpatializedDynamic3DElement } 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,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SetParentForEntityCommand,
|
|
3
|
+
UpdateSpatializedDynamic3DElementProperties
|
|
4
|
+
} from "./JSBCommand";
|
|
5
|
+
import { SpatializedElement } from "./SpatializedElement";
|
|
6
|
+
class SpatializedDynamic3DElement extends SpatializedElement {
|
|
7
|
+
/**
|
|
8
|
+
* Identifies the motion target kind supported by this element.
|
|
9
|
+
*/
|
|
10
|
+
kind = "dynamic3d";
|
|
11
|
+
children = [];
|
|
12
|
+
events = {};
|
|
13
|
+
constructor(id) {
|
|
14
|
+
super(id);
|
|
15
|
+
}
|
|
16
|
+
async addEntity(entity) {
|
|
17
|
+
const ans = new SetParentForEntityCommand(entity.id, this.id).execute();
|
|
18
|
+
this.children.push(entity);
|
|
19
|
+
entity.parent = this;
|
|
20
|
+
return ans;
|
|
21
|
+
}
|
|
22
|
+
addEvent(type, callback) {
|
|
23
|
+
this.events[type] = callback;
|
|
24
|
+
}
|
|
25
|
+
removeEvent(eventName) {
|
|
26
|
+
if (this.events[eventName]) {
|
|
27
|
+
delete this.events[eventName];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
dispatchEvent(evt) {
|
|
31
|
+
this.events[evt.type]?.(evt);
|
|
32
|
+
}
|
|
33
|
+
async updateProperties(properties) {
|
|
34
|
+
return new UpdateSpatializedDynamic3DElementProperties(
|
|
35
|
+
this,
|
|
36
|
+
properties
|
|
37
|
+
).execute();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
SpatializedDynamic3DElement
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=SpatializedDynamic3DElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SpatializedDynamic3DElement.ts"],"sourcesContent":["import {\n SetParentForEntityCommand,\n UpdateSpatializedDynamic3DElementProperties,\n} from './JSBCommand'\nimport { SpatialEntity } from './reality'\nimport { SpatializedElement } from './SpatializedElement'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatializedElementProperties,\n} from './types/types'\n\nexport class SpatializedDynamic3DElement extends SpatializedElement {\n /**\n * Identifies the motion target kind supported by this element.\n */\n override readonly kind = 'dynamic3d' as const\n\n children: SpatialEntityOrReality[] = []\n events: Record<string, (data: any) => void> = {}\n\n constructor(id: string) {\n super(id)\n }\n\n async addEntity(entity: SpatialEntity) {\n const ans = new SetParentForEntityCommand(entity.id, this.id).execute()\n this.children.push(entity)\n entity.parent = this\n return ans\n }\n\n addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n this.events[type] = callback\n }\n\n removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n this.events[evt.type]?.(evt)\n }\n\n async updateProperties(properties: Partial<SpatializedElementProperties>) {\n return new UpdateSpatializedDynamic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA0B;AAO5B,MAAM,oCAAoC,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAIhD,OAAO;AAAA,EAEzB,WAAqC,CAAC;AAAA,EACtC,SAA8C,CAAC;AAAA,EAE/C,YAAY,IAAY;AACtB,UAAM,EAAE;AAAA,EACV;AAAA,EAEA,MAAM,UAAU,QAAuB;AACrC,UAAM,MAAM,IAAI,0BAA0B,OAAO,IAAI,KAAK,EAAE,EAAE,QAAQ;AACtE,SAAK,SAAS,KAAK,MAAM;AACzB,WAAO,SAAS;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,SAAS,MAA8B,UAA+B;AACpE,SAAK,OAAO,IAAI,IAAI;AAAA,EACtB;AAAA,EAEA,YAAY,WAAmC;AAC7C,QAAI,KAAK,OAAO,SAAS,GAAG;AAC1B,aAAO,KAAK,OAAO,SAAS;AAAA,IAC9B;AAAA,EACF;AAAA,EAEA,cAAc,KAAkB;AAC9B,SAAK,OAAO,IAAI,IAAI,IAAI,GAAG;AAAA,EAC7B;AAAA,EAEA,MAAM,iBAAiB,YAAmD;AACxE,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF,EAAE,QAAQ;AAAA,EACZ;AACF;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { aV as ReceiveEventData, ag as SpatializedElement } from './spatializedElementMotion-_0XWPQCE.js';
|
|
2
|
+
import './SpatialObject.js';
|
|
3
|
+
import './types/motion/spatializedVisual.js';
|
|
4
|
+
import './types/motion/spatializedPlayback.js';
|
|
5
|
+
import './types/global.js';
|
|
6
|
+
import './physicalMetrics-W5uZ5xKb.js';
|
|
7
|
+
import './reality/component/SpatialComponent.js';
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { UpdateSpatializedElementTransform } from "./JSBCommand";
|
|
2
|
+
import { AnimationObject } from "./motion/AnimationObject";
|
|
3
|
+
import { SpatialObject } from "./SpatialObject";
|
|
4
|
+
import { SpatialWebEvent } from "./SpatialWebEvent";
|
|
5
|
+
import { createSpatialEvent } from "./SpatialWebEventCreator";
|
|
6
|
+
import {
|
|
7
|
+
normalizeMotionConfig,
|
|
8
|
+
validateNormalizedMotionConfig
|
|
9
|
+
} from "./motion/compute";
|
|
10
|
+
import { motionConfigToNativeTimeline } from "./motion/native/serializeMotionTimeline";
|
|
11
|
+
import {
|
|
12
|
+
SpatialWebMsgType
|
|
13
|
+
} from "./WebMsgCommand";
|
|
14
|
+
class SpatializedElement extends SpatialObject {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new spatialized element with the specified ID.
|
|
17
|
+
* Registers the element to receive spatial events.
|
|
18
|
+
* @param id Unique identifier for this element
|
|
19
|
+
*/
|
|
20
|
+
constructor(id) {
|
|
21
|
+
super(id);
|
|
22
|
+
this.id = id;
|
|
23
|
+
SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent.bind(this));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a native-first AnimationObject bound to this spatialized element.
|
|
27
|
+
*/
|
|
28
|
+
async createAnimation(config) {
|
|
29
|
+
const normalized = normalizeMotionConfig(config);
|
|
30
|
+
validateNormalizedMotionConfig(normalized);
|
|
31
|
+
return AnimationObject.create({
|
|
32
|
+
elementId: this.id,
|
|
33
|
+
timeline: motionConfigToNativeTimeline(normalized)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Updates the transformation matrix of this element in 3D space.
|
|
38
|
+
* This affects the position, rotation, and scale of the element.
|
|
39
|
+
* @param matrix The new transformation matrix
|
|
40
|
+
* @returns Promise resolving when the transform is updated
|
|
41
|
+
*/
|
|
42
|
+
async updateTransform(matrix) {
|
|
43
|
+
return new UpdateSpatializedElementTransform(this, matrix).execute();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Information about the element's bounding cube.
|
|
47
|
+
* Used for spatial calculations and hit testing.
|
|
48
|
+
*/
|
|
49
|
+
_cubeInfo;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the current cube information for this element.
|
|
52
|
+
* @returns The current CubeInfo or undefined if not set
|
|
53
|
+
*/
|
|
54
|
+
get cubeInfo() {
|
|
55
|
+
return this._cubeInfo;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The current transformation matrix of this element.
|
|
59
|
+
*/
|
|
60
|
+
_transform;
|
|
61
|
+
/**
|
|
62
|
+
* The inverse of the current transformation matrix.
|
|
63
|
+
* Used for converting world coordinates to local coordinates.
|
|
64
|
+
*/
|
|
65
|
+
_transformInv;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the current transformation matrix.
|
|
68
|
+
* @returns The current transformation matrix or undefined if not set
|
|
69
|
+
*/
|
|
70
|
+
get transform() {
|
|
71
|
+
return this._transform;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets the inverse of the current transformation matrix.
|
|
75
|
+
* @returns The inverse transformation matrix or undefined if not set
|
|
76
|
+
*/
|
|
77
|
+
get transformInv() {
|
|
78
|
+
return this._transformInv;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Processes events received from the WebSpatial environment.
|
|
82
|
+
* Handles various spatial events like transforms, gestures, and interactions.
|
|
83
|
+
* @param data The event data received from the WebSpatial system
|
|
84
|
+
*/
|
|
85
|
+
onReceiveEvent(data) {
|
|
86
|
+
const { type } = data;
|
|
87
|
+
if (type === SpatialWebMsgType.objectdestroy) {
|
|
88
|
+
this.isDestroyed = true;
|
|
89
|
+
} else if (type === SpatialWebMsgType.spatialtap) {
|
|
90
|
+
const event = createSpatialEvent(
|
|
91
|
+
SpatialWebMsgType.spatialtap,
|
|
92
|
+
data.detail
|
|
93
|
+
);
|
|
94
|
+
this._onSpatialTap?.(event);
|
|
95
|
+
} else if (type === SpatialWebMsgType.spatialdragstart) {
|
|
96
|
+
const dragStartEvent = createSpatialEvent(
|
|
97
|
+
SpatialWebMsgType.spatialdragstart,
|
|
98
|
+
data.detail
|
|
99
|
+
);
|
|
100
|
+
this._onSpatialDragStart?.(dragStartEvent);
|
|
101
|
+
} else if (type === SpatialWebMsgType.spatialdrag) {
|
|
102
|
+
const event = createSpatialEvent(
|
|
103
|
+
SpatialWebMsgType.spatialdrag,
|
|
104
|
+
data.detail
|
|
105
|
+
);
|
|
106
|
+
this._onSpatialDrag?.(event);
|
|
107
|
+
} else if (type === SpatialWebMsgType.spatialdragend) {
|
|
108
|
+
const event = createSpatialEvent(
|
|
109
|
+
SpatialWebMsgType.spatialdragend,
|
|
110
|
+
data.detail
|
|
111
|
+
);
|
|
112
|
+
this._onSpatialDragEnd?.(event);
|
|
113
|
+
} else if (type === SpatialWebMsgType.spatialrotate) {
|
|
114
|
+
const event = createSpatialEvent(
|
|
115
|
+
SpatialWebMsgType.spatialrotate,
|
|
116
|
+
data.detail
|
|
117
|
+
);
|
|
118
|
+
this._onSpatialRotate?.(event);
|
|
119
|
+
} else if (type === SpatialWebMsgType.spatialrotateend) {
|
|
120
|
+
const event = createSpatialEvent(
|
|
121
|
+
SpatialWebMsgType.spatialrotateend,
|
|
122
|
+
data.detail
|
|
123
|
+
);
|
|
124
|
+
this._onSpatialRotateEnd?.(event);
|
|
125
|
+
} else if (type === SpatialWebMsgType.spatialmagnify) {
|
|
126
|
+
const event = createSpatialEvent(
|
|
127
|
+
SpatialWebMsgType.spatialmagnify,
|
|
128
|
+
data.detail
|
|
129
|
+
);
|
|
130
|
+
this._onSpatialMagnify?.(event);
|
|
131
|
+
} else if (type === SpatialWebMsgType.spatialmagnifyend) {
|
|
132
|
+
const event = createSpatialEvent(
|
|
133
|
+
SpatialWebMsgType.spatialmagnifyend,
|
|
134
|
+
data.detail
|
|
135
|
+
);
|
|
136
|
+
this._onSpatialMagnifyEnd?.(event);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
_onSpatialTap;
|
|
140
|
+
set onSpatialTap(value) {
|
|
141
|
+
this._onSpatialTap = value;
|
|
142
|
+
this.updateProperties({
|
|
143
|
+
enableTapGesture: value !== void 0
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
_onSpatialDragStart;
|
|
147
|
+
set onSpatialDragStart(value) {
|
|
148
|
+
this._onSpatialDragStart = value;
|
|
149
|
+
this.updateProperties({
|
|
150
|
+
enableDragStartGesture: this._onSpatialDragStart !== void 0
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
_onSpatialDrag;
|
|
154
|
+
set onSpatialDrag(value) {
|
|
155
|
+
this._onSpatialDrag = value;
|
|
156
|
+
this.updateProperties({
|
|
157
|
+
enableDragGesture: this._onSpatialDrag !== void 0
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
_onSpatialDragEnd;
|
|
161
|
+
set onSpatialDragEnd(value) {
|
|
162
|
+
this._onSpatialDragEnd = value;
|
|
163
|
+
this.updateProperties({
|
|
164
|
+
enableDragEndGesture: value !== void 0
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
_onSpatialRotate;
|
|
168
|
+
set onSpatialRotate(value) {
|
|
169
|
+
this._onSpatialRotate = value;
|
|
170
|
+
this.updateProperties({
|
|
171
|
+
enableRotateGesture: this._onSpatialRotate !== void 0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
_onSpatialRotateEnd;
|
|
175
|
+
set onSpatialRotateEnd(value) {
|
|
176
|
+
this._onSpatialRotateEnd = value;
|
|
177
|
+
this.updateProperties({
|
|
178
|
+
enableRotateEndGesture: value !== void 0
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
_onSpatialMagnify;
|
|
182
|
+
set onSpatialMagnify(value) {
|
|
183
|
+
this._onSpatialMagnify = value;
|
|
184
|
+
this.updateProperties({
|
|
185
|
+
enableMagnifyGesture: value !== void 0
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
_onSpatialMagnifyEnd;
|
|
189
|
+
set onSpatialMagnifyEnd(value) {
|
|
190
|
+
this._onSpatialMagnifyEnd = value;
|
|
191
|
+
this.updateProperties({
|
|
192
|
+
enableMagnifyEndGesture: value !== void 0
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Cleans up resources when this element is destroyed.
|
|
197
|
+
* Removes event receivers to prevent memory leaks.
|
|
198
|
+
*/
|
|
199
|
+
onDestroy() {
|
|
200
|
+
SpatialWebEvent.removeEventReceiver(this.id);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
SpatializedElement
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=SpatializedElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SpatializedElement.ts"],"sourcesContent":["import { UpdateSpatializedElementTransform } from './JSBCommand'\nimport { AnimationObject } from './motion/AnimationObject'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialWebEvent } from './SpatialWebEvent'\nimport { createSpatialEvent } from './SpatialWebEventCreator'\nimport {\n normalizeMotionConfig,\n validateNormalizedMotionConfig,\n} from './motion/compute'\nimport { motionConfigToNativeTimeline } from './motion/native/serializeMotionTimeline'\nimport {\n CubeInfo,\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatialDragStartEvent,\n SpatializedElementProperties,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n SpatialRotateEndEvent,\n SpatialRotateEvent,\n SpatialTapEvent,\n} from './types/types'\nimport {\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialDragStartMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n} from './WebMsgCommand'\nimport type {\n SpatializedMotionConfig,\n SpatializedMotionKind,\n} from './types/motion/spatializedMotion'\n\n/**\n * Abstract base class for all spatialized elements in the WebSpatial environment.\n * Provides common functionality for elements that can exist in 3D space,\n * including transformation handling and gesture event processing.\n */\nexport abstract class SpatializedElement extends SpatialObject {\n /**\n * Identifies the motion target kind supported by this spatialized element.\n */\n abstract readonly kind: SpatializedMotionKind\n\n /**\n * Creates a new spatialized element with the specified ID.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n */\n constructor(public readonly id: string) {\n super(id)\n\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent.bind(this))\n }\n\n /**\n * Updates the properties of this spatialized element.\n * Must be implemented by derived classes to handle specific property updates.\n * @param properties Partial set of properties to update\n * @returns Promise resolving to the result of the update operation\n */\n abstract updateProperties(\n properties: Partial<SpatializedElementProperties>,\n ): Promise<WebSpatialProtocolResult>\n\n /**\n * Creates a native-first AnimationObject bound to this spatialized element.\n */\n async createAnimation(\n config: SpatializedMotionConfig,\n ): Promise<AnimationObject> {\n const normalized = normalizeMotionConfig(config)\n validateNormalizedMotionConfig(normalized)\n return AnimationObject.create({\n elementId: this.id,\n timeline: motionConfigToNativeTimeline(normalized),\n })\n }\n\n /**\n * Updates the transformation matrix of this element in 3D space.\n * This affects the position, rotation, and scale of the element.\n * @param matrix The new transformation matrix\n * @returns Promise resolving when the transform is updated\n */\n async updateTransform(matrix: DOMMatrix) {\n return new UpdateSpatializedElementTransform(this, matrix).execute()\n }\n\n /**\n * Information about the element's bounding cube.\n * Used for spatial calculations and hit testing.\n */\n private _cubeInfo?: CubeInfo\n\n /**\n * Gets the current cube information for this element.\n * @returns The current CubeInfo or undefined if not set\n */\n get cubeInfo() {\n return this._cubeInfo\n }\n\n /**\n * The current transformation matrix of this element.\n */\n private _transform?: DOMMatrix\n\n /**\n * The inverse of the current transformation matrix.\n * Used for converting world coordinates to local coordinates.\n */\n private _transformInv?: DOMMatrix\n\n /**\n * Gets the current transformation matrix.\n * @returns The current transformation matrix or undefined if not set\n */\n get transform() {\n return this._transform\n }\n\n /**\n * Gets the inverse of the current transformation matrix.\n * @returns The inverse transformation matrix or undefined if not set\n */\n get transformInv() {\n return this._transformInv\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles various spatial events like transforms, gestures, and interactions.\n * @param data The event data received from the WebSpatial system\n */\n protected onReceiveEvent(data: ReceiveEventData) {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n } else if (type === SpatialWebMsgType.spatialtap) {\n // Handle tap gestures\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialtap,\n (data as SpatialTapMsg).detail,\n )\n this._onSpatialTap?.(event)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const dragStartEvent = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n (data as SpatialDragStartMsg).detail,\n )\n this._onSpatialDragStart?.(dragStartEvent)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdrag,\n (data as SpatialDragMsg).detail,\n )\n this._onSpatialDrag?.(event)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n (data as SpatialDragEndMsg).detail,\n )\n this._onSpatialDragEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialrotate) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n (data as SpatialRotateMsg).detail,\n )\n this._onSpatialRotate?.(event)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n (data as SpatialRotateEndMsg).detail,\n )\n this._onSpatialRotateEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnify) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n (data as SpatialMagnifyMsg).detail,\n )\n this._onSpatialMagnify?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n (data as SpatialMagnifyEndMsg).detail,\n )\n this._onSpatialMagnifyEnd?.(event)\n }\n }\n\n private _onSpatialTap?: (event: SpatialTapEvent) => void\n set onSpatialTap(value: (event: SpatialTapEvent) => void | undefined) {\n this._onSpatialTap = value\n this.updateProperties({\n enableTapGesture: value !== undefined,\n })\n }\n\n private _onSpatialDragStart?: (event: SpatialDragStartEvent) => void\n set onSpatialDragStart(\n value: (event: SpatialDragStartEvent) => void | undefined,\n ) {\n this._onSpatialDragStart = value\n this.updateProperties({\n enableDragStartGesture: this._onSpatialDragStart !== undefined,\n })\n }\n\n private _onSpatialDrag?: (event: SpatialDragEvent) => void\n set onSpatialDrag(value: (event: SpatialDragEvent) => void | undefined) {\n this._onSpatialDrag = value\n this.updateProperties({\n enableDragGesture: this._onSpatialDrag !== undefined,\n })\n }\n\n private _onSpatialDragEnd?: (event: SpatialDragEndEvent) => void\n set onSpatialDragEnd(\n value: ((event: SpatialDragEndEvent) => void) | undefined,\n ) {\n this._onSpatialDragEnd = value\n this.updateProperties({\n enableDragEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialRotate?: (event: SpatialRotateEvent) => void\n set onSpatialRotate(\n value: ((event: SpatialRotateEvent) => void) | undefined,\n ) {\n this._onSpatialRotate = value\n this.updateProperties({\n enableRotateGesture: this._onSpatialRotate !== undefined,\n })\n }\n\n private _onSpatialRotateEnd?: (event: SpatialRotateEndEvent) => void\n set onSpatialRotateEnd(\n value: ((event: SpatialRotateEndEvent) => void) | undefined,\n ) {\n this._onSpatialRotateEnd = value\n this.updateProperties({\n enableRotateEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnify?: (event: SpatialMagnifyEvent) => void\n set onSpatialMagnify(\n value: ((event: SpatialMagnifyEvent) => void) | undefined,\n ) {\n this._onSpatialMagnify = value\n this.updateProperties({\n enableMagnifyGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent) => void\n set onSpatialMagnifyEnd(\n value: ((event: SpatialMagnifyEndEvent) => void) | undefined,\n ) {\n this._onSpatialMagnifyEnd = value\n this.updateProperties({\n enableMagnifyEndGesture: value !== undefined,\n })\n }\n\n /**\n * Cleans up resources when this element is destroyed.\n * Removes event receivers to prevent memory leaks.\n */\n override onDestroy() {\n SpatialWebEvent.removeEventReceiver(this.id)\n }\n}\n\nexport type ReceiveEventData =\n | SpatialTapMsg\n | SpatialDragStartMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg\n"],"mappings":"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","names":[]}
|