@webspatial/core-sdk 1.6.1 → 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.
Files changed (320) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +10 -0
  3. package/dist/JSBCommand.d.ts +398 -0
  4. package/dist/JSBCommand.js +668 -0
  5. package/dist/JSBCommand.js.map +1 -0
  6. package/dist/Spatial.d.ts +63 -0
  7. package/dist/Spatial.js +60 -0
  8. package/dist/Spatial.js.map +1 -0
  9. package/dist/SpatialObject.d.ts +19 -0
  10. package/dist/SpatialObject.js +44 -0
  11. package/dist/SpatialObject.js.map +1 -0
  12. package/dist/SpatialScene.d.ts +51 -0
  13. package/dist/SpatialScene.js +74 -0
  14. package/dist/SpatialScene.js.map +1 -0
  15. package/dist/SpatialSession.d.ts +143 -0
  16. package/dist/SpatialSession.js +173 -0
  17. package/dist/SpatialSession.js.map +1 -0
  18. package/dist/SpatialWebEvent.d.ts +8 -0
  19. package/dist/SpatialWebEvent.js +18 -0
  20. package/dist/SpatialWebEvent.js.map +1 -0
  21. package/dist/SpatialWebEventCreator.d.ts +11 -0
  22. package/dist/SpatialWebEventCreator.js +11 -0
  23. package/dist/SpatialWebEventCreator.js.map +1 -0
  24. package/dist/Spatialized2DElement.d.ts +42 -0
  25. package/dist/Spatialized2DElement.js +47 -0
  26. package/dist/Spatialized2DElement.js.map +1 -0
  27. package/dist/SpatializedDynamic3DElement.d.ts +7 -0
  28. package/dist/SpatializedDynamic3DElement.js +43 -0
  29. package/dist/SpatializedDynamic3DElement.js.map +1 -0
  30. package/dist/SpatializedElement.d.ts +7 -0
  31. package/dist/SpatializedElement.js +206 -0
  32. package/dist/SpatializedElement.js.map +1 -0
  33. package/dist/SpatializedElementCreator.d.ts +15 -0
  34. package/dist/SpatializedElementCreator.js +47 -0
  35. package/dist/SpatializedElementCreator.js.map +1 -0
  36. package/dist/SpatializedStatic3DElement.d.ts +195 -0
  37. package/dist/SpatializedStatic3DElement.js +327 -0
  38. package/dist/SpatializedStatic3DElement.js.map +1 -0
  39. package/dist/WebMsgCommand.d.ts +7 -0
  40. package/dist/WebMsgCommand.js +23 -0
  41. package/dist/WebMsgCommand.js.map +1 -0
  42. package/dist/index.d.ts +35 -1101
  43. package/dist/index.js +21 -3393
  44. package/dist/index.js.map +1 -1
  45. package/dist/install-polyfills.d.ts +2 -0
  46. package/dist/install-polyfills.js +13 -0
  47. package/dist/install-polyfills.js.map +1 -0
  48. package/dist/isSSREnv.d.ts +3 -0
  49. package/dist/isSSREnv.js +6 -0
  50. package/dist/isSSREnv.js.map +1 -0
  51. package/dist/motion/AnimationObject.d.ts +7 -0
  52. package/dist/motion/AnimationObject.js +140 -0
  53. package/dist/motion/AnimationObject.js.map +1 -0
  54. package/dist/motion/compute/index.d.ts +10 -0
  55. package/dist/motion/compute/index.js +19 -0
  56. package/dist/motion/compute/index.js.map +1 -0
  57. package/dist/motion/compute/motionPropertyValues.d.ts +19 -0
  58. package/dist/motion/compute/motionPropertyValues.js +50 -0
  59. package/dist/motion/compute/motionPropertyValues.js.map +1 -0
  60. package/dist/motion/compute/normalize.d.ts +31 -0
  61. package/dist/motion/compute/normalize.js +201 -0
  62. package/dist/motion/compute/normalize.js.map +1 -0
  63. package/dist/motion/compute/validate.d.ts +22 -0
  64. package/dist/motion/compute/validate.js +103 -0
  65. package/dist/motion/compute/validate.js.map +1 -0
  66. package/dist/motion/index.d.ts +8 -0
  67. package/dist/motion/index.js +6 -0
  68. package/dist/motion/index.js.map +1 -0
  69. package/dist/motion/native/serializeMotionTimeline.d.ts +12 -0
  70. package/dist/motion/native/serializeMotionTimeline.js +21 -0
  71. package/dist/motion/native/serializeMotionTimeline.js.map +1 -0
  72. package/dist/physicalMetrics-W5uZ5xKb.d.ts +48 -0
  73. package/dist/physicalMetrics.d.ts +1 -0
  74. package/dist/physicalMetrics.js +58 -0
  75. package/dist/physicalMetrics.js.map +1 -0
  76. package/dist/platform-adapter/CommandResultUtils.d.ts +12 -0
  77. package/dist/platform-adapter/CommandResultUtils.js +21 -0
  78. package/dist/platform-adapter/CommandResultUtils.js.map +1 -0
  79. package/dist/platform-adapter/createPlatformSync.d.ts +16 -0
  80. package/dist/platform-adapter/createPlatformSync.js +30 -0
  81. package/dist/platform-adapter/createPlatformSync.js.map +1 -0
  82. package/dist/platform-adapter/index.d.ts +12 -0
  83. package/dist/platform-adapter/index.js +10 -0
  84. package/dist/platform-adapter/index.js.map +1 -0
  85. package/dist/platform-adapter/interface.d.ts +7 -0
  86. package/dist/platform-adapter/interface.js +1 -0
  87. package/dist/platform-adapter/interface.js.map +1 -0
  88. package/dist/platform-adapter/pico-os/PicoOSPlatform.d.ts +25 -0
  89. package/dist/platform-adapter/pico-os/PicoOSPlatform.js +168 -0
  90. package/dist/platform-adapter/pico-os/PicoOSPlatform.js.map +1 -0
  91. package/dist/platform-adapter/puppeteer/PuppeteerPlatform.d.ts +66 -0
  92. package/dist/platform-adapter/puppeteer/PuppeteerPlatform.js +372 -0
  93. package/dist/platform-adapter/puppeteer/PuppeteerPlatform.js.map +1 -0
  94. package/dist/platform-adapter/spatialRequestMetadata.d.ts +6 -0
  95. package/dist/platform-adapter/spatialRequestMetadata.js +39 -0
  96. package/dist/platform-adapter/spatialRequestMetadata.js.map +1 -0
  97. package/dist/platform-adapter/spatialSceneQuery.d.ts +12 -0
  98. package/dist/platform-adapter/spatialSceneQuery.js +12 -0
  99. package/dist/platform-adapter/spatialSceneQuery.js.map +1 -0
  100. package/dist/platform-adapter/vision-os/VisionOSPlatform.d.ts +19 -0
  101. package/dist/platform-adapter/vision-os/VisionOSPlatform.js +77 -0
  102. package/dist/platform-adapter/vision-os/VisionOSPlatform.js.map +1 -0
  103. package/dist/platform-runtime.d.ts +12 -0
  104. package/dist/platform-runtime.js +14 -0
  105. package/dist/platform-runtime.js.map +1 -0
  106. package/dist/reality/Attachment.d.ts +19 -0
  107. package/dist/reality/Attachment.js +39 -0
  108. package/dist/reality/Attachment.js.map +1 -0
  109. package/dist/reality/component/ModelComponent.d.ts +14 -0
  110. package/dist/reality/component/ModelComponent.js +11 -0
  111. package/dist/reality/component/ModelComponent.js.map +1 -0
  112. package/dist/reality/component/SpatialComponent.d.ts +8 -0
  113. package/dist/reality/component/SpatialComponent.js +19 -0
  114. package/dist/reality/component/SpatialComponent.js.map +1 -0
  115. package/dist/reality/component/index.d.ts +8 -0
  116. package/dist/reality/component/index.js +3 -0
  117. package/dist/reality/component/index.js.map +1 -0
  118. package/dist/reality/entity/SpatialEntity.d.ts +7 -0
  119. package/dist/reality/entity/SpatialEntity.js +291 -0
  120. package/dist/reality/entity/SpatialEntity.js.map +1 -0
  121. package/dist/reality/entity/SpatialModelEntity.d.ts +17 -0
  122. package/dist/reality/entity/SpatialModelEntity.js +17 -0
  123. package/dist/reality/entity/SpatialModelEntity.js.map +1 -0
  124. package/dist/reality/entity/index.d.ts +8 -0
  125. package/dist/reality/entity/index.js +3 -0
  126. package/dist/reality/entity/index.js.map +1 -0
  127. package/dist/reality/geometry/SpatialBoxGeometry.d.ts +16 -0
  128. package/dist/reality/geometry/SpatialBoxGeometry.js +13 -0
  129. package/dist/reality/geometry/SpatialBoxGeometry.js.map +1 -0
  130. package/dist/reality/geometry/SpatialConeGeometry.d.ts +16 -0
  131. package/dist/reality/geometry/SpatialConeGeometry.js +13 -0
  132. package/dist/reality/geometry/SpatialConeGeometry.js.map +1 -0
  133. package/dist/reality/geometry/SpatialCylinderGeometry.d.ts +16 -0
  134. package/dist/reality/geometry/SpatialCylinderGeometry.js +13 -0
  135. package/dist/reality/geometry/SpatialCylinderGeometry.js.map +1 -0
  136. package/dist/reality/geometry/SpatialGeometry.d.ts +7 -0
  137. package/dist/reality/geometry/SpatialGeometry.js +13 -0
  138. package/dist/reality/geometry/SpatialGeometry.js.map +1 -0
  139. package/dist/reality/geometry/SpatialPlaneGeometry.d.ts +16 -0
  140. package/dist/reality/geometry/SpatialPlaneGeometry.js +13 -0
  141. package/dist/reality/geometry/SpatialPlaneGeometry.js.map +1 -0
  142. package/dist/reality/geometry/SpatialSphereGeometry.d.ts +16 -0
  143. package/dist/reality/geometry/SpatialSphereGeometry.js +13 -0
  144. package/dist/reality/geometry/SpatialSphereGeometry.js.map +1 -0
  145. package/dist/reality/geometry/index.d.ts +12 -0
  146. package/dist/reality/geometry/index.js +7 -0
  147. package/dist/reality/geometry/index.js.map +1 -0
  148. package/dist/reality/index.d.ts +18 -0
  149. package/dist/reality/index.js +7 -0
  150. package/dist/reality/index.js.map +1 -0
  151. package/dist/reality/material/SpatialMaterial.d.ts +7 -0
  152. package/dist/reality/material/SpatialMaterial.js +13 -0
  153. package/dist/reality/material/SpatialMaterial.js.map +1 -0
  154. package/dist/reality/material/SpatialUnlitMaterial.d.ts +16 -0
  155. package/dist/reality/material/SpatialUnlitMaterial.js +16 -0
  156. package/dist/reality/material/SpatialUnlitMaterial.js.map +1 -0
  157. package/dist/reality/material/index.d.ts +8 -0
  158. package/dist/reality/material/index.js +3 -0
  159. package/dist/reality/material/index.js.map +1 -0
  160. package/dist/reality/realityCreator.d.ts +22 -0
  161. package/dist/reality/realityCreator.js +89 -0
  162. package/dist/reality/realityCreator.js.map +1 -0
  163. package/dist/reality/resource/SpatialModelAsset.d.ts +15 -0
  164. package/dist/reality/resource/SpatialModelAsset.js +12 -0
  165. package/dist/reality/resource/SpatialModelAsset.js.map +1 -0
  166. package/dist/reality/resource/SpatialTextureResource.d.ts +16 -0
  167. package/dist/reality/resource/SpatialTextureResource.js +16 -0
  168. package/dist/reality/resource/SpatialTextureResource.js.map +1 -0
  169. package/dist/reality/resource/index.d.ts +9 -0
  170. package/dist/reality/resource/index.js +3 -0
  171. package/dist/reality/resource/index.js.map +1 -0
  172. package/dist/runtime/WebSpatialRuntimeError.d.ts +10 -0
  173. package/dist/runtime/WebSpatialRuntimeError.js +14 -0
  174. package/dist/runtime/WebSpatialRuntimeError.js.map +1 -0
  175. package/dist/runtime/capability-data.d.ts +12 -0
  176. package/dist/runtime/capability-data.js +134 -0
  177. package/dist/runtime/capability-data.js.map +1 -0
  178. package/dist/runtime/index.d.ts +8 -0
  179. package/dist/runtime/index.js +27 -0
  180. package/dist/runtime/index.js.map +1 -0
  181. package/dist/runtime/jsbAdapterPlatform.d.ts +9 -0
  182. package/dist/runtime/jsbAdapterPlatform.js +38 -0
  183. package/dist/runtime/jsbAdapterPlatform.js.map +1 -0
  184. package/dist/runtime/keys.d.ts +34 -0
  185. package/dist/runtime/keys.js +122 -0
  186. package/dist/runtime/keys.js.map +1 -0
  187. package/dist/runtime/semver.d.ts +8 -0
  188. package/dist/runtime/semver.js +32 -0
  189. package/dist/runtime/semver.js.map +1 -0
  190. package/dist/runtime/supports.d.ts +22 -0
  191. package/dist/runtime/supports.js +78 -0
  192. package/dist/runtime/supports.js.map +1 -0
  193. package/dist/runtime/types.d.ts +12 -0
  194. package/dist/runtime/types.js +1 -0
  195. package/dist/runtime/types.js.map +1 -0
  196. package/dist/runtime/userAgent.d.ts +20 -0
  197. package/dist/runtime/userAgent.js +41 -0
  198. package/dist/runtime/userAgent.js.map +1 -0
  199. package/dist/scene-polyfill.d.ts +18 -0
  200. package/dist/scene-polyfill.js +480 -0
  201. package/dist/scene-polyfill.js.map +1 -0
  202. package/dist/spatial-host.d.ts +13 -0
  203. package/dist/spatial-host.js +18 -0
  204. package/dist/spatial-host.js.map +1 -0
  205. package/dist/spatial-window-polyfill.d.ts +3 -0
  206. package/dist/spatial-window-polyfill.js +155 -0
  207. package/dist/spatial-window-polyfill.js.map +1 -0
  208. package/dist/spatializedElementMotion-_0XWPQCE.d.ts +1009 -0
  209. package/dist/types/animation.d.ts +7 -0
  210. package/dist/types/animation.js +1 -0
  211. package/dist/types/animation.js.map +1 -0
  212. package/dist/types/global.d.ts +38 -0
  213. package/dist/types/global.js +1 -0
  214. package/dist/types/global.js.map +1 -0
  215. package/dist/types/internal.d.ts +7 -0
  216. package/dist/types/internal.js +12 -0
  217. package/dist/types/internal.js.map +1 -0
  218. package/dist/types/motion/index.d.ts +7 -0
  219. package/dist/types/motion/index.js +3 -0
  220. package/dist/types/motion/index.js.map +1 -0
  221. package/dist/types/motion/spatializedElementMotion.d.ts +7 -0
  222. package/dist/types/motion/spatializedElementMotion.js +1 -0
  223. package/dist/types/motion/spatializedElementMotion.js.map +1 -0
  224. package/dist/types/motion/spatializedMotion.d.ts +7 -0
  225. package/dist/types/motion/spatializedMotion.js +16 -0
  226. package/dist/types/motion/spatializedMotion.js.map +1 -0
  227. package/dist/types/motion/spatializedPlayback.d.ts +11 -0
  228. package/dist/types/motion/spatializedPlayback.js +1 -0
  229. package/dist/types/motion/spatializedPlayback.js.map +1 -0
  230. package/dist/types/motion/spatializedVisual.d.ts +35 -0
  231. package/dist/types/motion/spatializedVisual.js +1 -0
  232. package/dist/types/motion/spatializedVisual.js.map +1 -0
  233. package/dist/types/types.d.ts +7 -0
  234. package/dist/types/types.js +117 -0
  235. package/dist/types/types.js.map +1 -0
  236. package/dist/utils.d.ts +44 -0
  237. package/dist/utils.js +86 -0
  238. package/dist/utils.js.map +1 -0
  239. package/package.json +20 -4
  240. package/src/JSBCommand.ts +148 -91
  241. package/src/Spatial.ts +0 -21
  242. package/src/SpatialObject.ts +10 -0
  243. package/src/SpatialScene.ts +1 -5
  244. package/src/SpatialSession.ts +17 -3
  245. package/src/Spatialized2DElement.ts +5 -0
  246. package/src/SpatializedDynamic3DElement.ts +5 -1
  247. package/src/SpatializedElement.ts +29 -0
  248. package/src/SpatializedElementCreator.ts +6 -4
  249. package/src/SpatializedStatic3DElement.test.ts +99 -0
  250. package/src/SpatializedStatic3DElement.ts +141 -4
  251. package/src/WebMsgCommand.ts +50 -0
  252. package/src/coverage-boost.test.ts +258 -316
  253. package/src/index.ts +28 -12
  254. package/src/install-polyfills.ts +38 -0
  255. package/src/jsbcommand.coverage.test.ts +42 -48
  256. package/src/motion/AnimationObject.test.ts +421 -0
  257. package/src/motion/AnimationObject.ts +208 -0
  258. package/src/motion/compute/index.ts +10 -0
  259. package/src/motion/compute/motionPropertyValues.test.ts +55 -0
  260. package/src/motion/compute/motionPropertyValues.ts +70 -0
  261. package/src/motion/compute/normalize.test.ts +99 -0
  262. package/src/motion/compute/normalize.ts +289 -0
  263. package/src/motion/compute/validate.test.ts +229 -0
  264. package/src/motion/compute/validate.ts +156 -0
  265. package/src/motion/index.ts +2 -0
  266. package/src/motion/native/serializeMotionTimeline.test.ts +61 -0
  267. package/src/motion/native/serializeMotionTimeline.ts +27 -0
  268. package/src/platform-adapter/CommandResultUtils.ts +2 -2
  269. package/src/platform-adapter/createPlatformSync.ts +36 -0
  270. package/src/platform-adapter/index.ts +5 -51
  271. package/src/platform-adapter/interface.ts +35 -23
  272. package/src/platform-adapter/pico-os/PicoOSPlatform.ts +156 -59
  273. package/src/platform-adapter/puppeteer/PuppeteerPlatform.ts +37 -11
  274. package/src/platform-adapter/spatialRequestMetadata.test.ts +175 -0
  275. package/src/platform-adapter/spatialRequestMetadata.ts +48 -0
  276. package/src/platform-adapter/spatialSceneQuery.ts +17 -0
  277. package/src/platform-adapter/vision-os/VisionOSPlatform.ts +60 -24
  278. package/src/platform-runtime.ts +13 -0
  279. package/src/reality/Attachment.ts +2 -2
  280. package/src/reality/entity/SpatialEntity.ts +127 -2
  281. package/src/reality/realityCreator.ts +15 -1
  282. package/src/reality/resource/SpatialTextureResource.ts +16 -0
  283. package/src/reality/resource/index.ts +1 -0
  284. package/src/runtime/WebSpatialRuntimeError.ts +16 -0
  285. package/src/runtime/capability-data.ts +213 -0
  286. package/src/runtime/contract-review.test.ts +44 -0
  287. package/src/runtime/index.ts +17 -0
  288. package/src/runtime/jsbAdapterPlatform.test.ts +36 -0
  289. package/src/runtime/jsbAdapterPlatform.ts +51 -0
  290. package/src/runtime/keys.ts +140 -0
  291. package/src/runtime/semver.ts +33 -0
  292. package/src/runtime/supports.test.ts +346 -0
  293. package/src/runtime/supports.ts +112 -0
  294. package/src/runtime/types.ts +11 -0
  295. package/src/runtime/useAnimation.capability.test.ts +275 -0
  296. package/src/runtime/userAgent.ts +64 -0
  297. package/src/scene-polyfill.manifest.test.ts +312 -9
  298. package/src/scene-polyfill.request-metadata.test.ts +39 -0
  299. package/src/scene-polyfill.test.ts +33 -94
  300. package/src/scene-polyfill.ts +125 -92
  301. package/src/spatial-host.ts +25 -0
  302. package/src/spatial-window-polyfill.ts +18 -2
  303. package/src/transform-roundtrip.test.ts +90 -0
  304. package/src/types/animation.ts +224 -0
  305. package/src/types/{global.d.ts → global.ts} +10 -12
  306. package/src/types/motion/index.ts +10 -0
  307. package/src/types/motion/spatializedElementMotion.ts +49 -0
  308. package/src/types/motion/spatializedMotion.ts +147 -0
  309. package/src/types/motion/spatializedPlayback.ts +17 -0
  310. package/src/types/motion/spatializedVisual.ts +24 -0
  311. package/src/types/types.ts +12 -0
  312. package/src/utils.ts +54 -0
  313. package/tsup.config.ts +61 -36
  314. package/vitest.config.ts +5 -1
  315. package/dist/iife/index.d.ts +0 -1101
  316. package/dist/iife/index.global.js +0 -75
  317. package/dist/iife/index.global.js.map +0 -1
  318. package/src/platform-adapter/android/AndroidPlatform.ts +0 -133
  319. package/src/platform-adapter/ssr/SSRPlatform.ts +0 -43
  320. /package/src/{ssr-polyfill.ts → isSSREnv.ts} +0 -0
@@ -0,0 +1,668 @@
1
+ import { getPlatform } from "./platform-runtime";
2
+ import { pointToPhysical } from "./physicalMetrics";
3
+ import {
4
+ getRuntime,
5
+ supports,
6
+ VISIONOS_DEBUG_SHELL_VERSION_PLACEHOLDER
7
+ } from "./runtime/supports";
8
+ import { composeSRT } from "./utils";
9
+ class JSBCommand {
10
+ commandType = "";
11
+ async execute() {
12
+ const param = this.getParams();
13
+ const msg = param ? JSON.stringify(param) : "";
14
+ const platform = await getPlatform();
15
+ return platform.callJSB(this.commandType, msg);
16
+ }
17
+ }
18
+ class UpdateEntityPropertiesCommand extends JSBCommand {
19
+ constructor(entity, properties) {
20
+ super();
21
+ this.entity = entity;
22
+ this.properties = properties;
23
+ }
24
+ commandType = "UpdateEntityProperties";
25
+ getParams() {
26
+ const transform = composeSRT(
27
+ this.properties.position ?? this.entity.position,
28
+ this.properties.rotation ?? this.entity.rotation,
29
+ this.properties.scale ?? this.entity.scale
30
+ ).toFloat64Array();
31
+ return {
32
+ entityId: this.entity.id,
33
+ transform
34
+ };
35
+ }
36
+ }
37
+ class UpdateEntityEventCommand extends JSBCommand {
38
+ constructor(entity, type, isEnable) {
39
+ super();
40
+ this.entity = entity;
41
+ this.type = type;
42
+ this.isEnable = isEnable;
43
+ }
44
+ commandType = "UpdateEntityEvent";
45
+ getParams() {
46
+ return {
47
+ type: this.type,
48
+ entityId: this.entity.id,
49
+ isEnable: this.isEnable
50
+ };
51
+ }
52
+ }
53
+ class UpdateEntityEventsCommand extends JSBCommand {
54
+ // let types:[String:Bool]
55
+ // let entityId:String
56
+ constructor(entity, types) {
57
+ super();
58
+ this.entity = entity;
59
+ this.types = types;
60
+ }
61
+ getParams() {
62
+ return {
63
+ entityId: this.entity.id,
64
+ types: this.types
65
+ };
66
+ }
67
+ }
68
+ class UpdateSpatialSceneProperties extends JSBCommand {
69
+ properties;
70
+ commandType = "UpdateSpatialSceneProperties";
71
+ constructor(properties) {
72
+ super();
73
+ this.properties = properties;
74
+ }
75
+ getParams() {
76
+ return this.properties;
77
+ }
78
+ }
79
+ class UpdateSceneConfig extends JSBCommand {
80
+ config;
81
+ commandType = "UpdateSceneConfig";
82
+ constructor(config) {
83
+ super();
84
+ this.config = config;
85
+ }
86
+ getParams() {
87
+ return { config: this.config };
88
+ }
89
+ }
90
+ class FocusScene extends JSBCommand {
91
+ constructor(id) {
92
+ super();
93
+ this.id = id;
94
+ }
95
+ commandType = "FocusScene";
96
+ getParams() {
97
+ return { id: this.id };
98
+ }
99
+ }
100
+ class GetSpatialSceneState extends JSBCommand {
101
+ commandType = "GetSpatialSceneState";
102
+ constructor() {
103
+ super();
104
+ }
105
+ getParams() {
106
+ return {};
107
+ }
108
+ }
109
+ class SpatializedElementCommand extends JSBCommand {
110
+ constructor(spatialObject) {
111
+ super();
112
+ this.spatialObject = spatialObject;
113
+ }
114
+ getParams() {
115
+ const extraParams = this.getExtraParams();
116
+ return { id: this.spatialObject.id, ...extraParams };
117
+ }
118
+ }
119
+ class UpdateSpatialized2DElementProperties extends SpatializedElementCommand {
120
+ properties;
121
+ commandType = "UpdateSpatialized2DElementProperties";
122
+ constructor(spatialObject, properties) {
123
+ super(spatialObject);
124
+ this.properties = properties;
125
+ }
126
+ getExtraParams() {
127
+ return this.properties;
128
+ }
129
+ }
130
+ class UpdateSpatializedDynamic3DElementProperties extends SpatializedElementCommand {
131
+ properties;
132
+ commandType = "UpdateSpatializedDynamic3DElementProperties";
133
+ constructor(spatialObject, properties) {
134
+ super(spatialObject);
135
+ this.properties = properties;
136
+ }
137
+ getExtraParams() {
138
+ return {
139
+ id: this.spatialObject.id,
140
+ ...this.properties
141
+ };
142
+ }
143
+ }
144
+ class UpdateUnlitMaterialProperties extends SpatializedElementCommand {
145
+ properties;
146
+ commandType = "UpdateUnlitMaterialProperties";
147
+ constructor(spatialObject, properties) {
148
+ super(spatialObject);
149
+ this.properties = properties;
150
+ }
151
+ getExtraParams() {
152
+ return this.properties;
153
+ }
154
+ }
155
+ class UpdateSpatializedElementTransform extends SpatializedElementCommand {
156
+ matrix;
157
+ commandType = "UpdateSpatializedElementTransform";
158
+ constructor(spatialObject, matrix) {
159
+ super(spatialObject);
160
+ this.matrix = matrix;
161
+ }
162
+ getExtraParams() {
163
+ return { matrix: Array.from(this.matrix.toFloat64Array()) };
164
+ }
165
+ }
166
+ class UpdateSpatializedStatic3DElementProperties extends SpatializedElementCommand {
167
+ properties;
168
+ commandType = "UpdateSpatializedStatic3DElementProperties";
169
+ constructor(spatialObject, properties) {
170
+ super(spatialObject);
171
+ this.properties = properties;
172
+ }
173
+ getExtraParams() {
174
+ return this.properties;
175
+ }
176
+ }
177
+ class AddSpatializedElementToSpatialized2DElement extends SpatializedElementCommand {
178
+ commandType = "AddSpatializedElementToSpatialized2DElement";
179
+ spatializedElement;
180
+ constructor(spatialObject, spatializedElement) {
181
+ super(spatialObject);
182
+ this.spatializedElement = spatializedElement;
183
+ }
184
+ getExtraParams() {
185
+ return { spatializedElementId: this.spatializedElement.id };
186
+ }
187
+ }
188
+ class AddSpatializedElementToSpatialScene extends JSBCommand {
189
+ commandType = "AddSpatializedElementToSpatialScene";
190
+ spatializedElement;
191
+ constructor(spatializedElement) {
192
+ super();
193
+ this.spatializedElement = spatializedElement;
194
+ }
195
+ getParams() {
196
+ return {
197
+ spatializedElementId: this.spatializedElement.id
198
+ };
199
+ }
200
+ }
201
+ class CreateSpatializedStatic3DElementCommand extends JSBCommand {
202
+ constructor(modelURL, sources, loading = "eager") {
203
+ super();
204
+ this.modelURL = modelURL;
205
+ this.sources = sources;
206
+ this.loading = loading;
207
+ this.modelURL = modelURL;
208
+ this.sources = sources;
209
+ this.loading = loading;
210
+ }
211
+ commandType = "CreateSpatializedStatic3DElement";
212
+ getParams() {
213
+ return {
214
+ modelURL: this.modelURL,
215
+ sources: this.sources,
216
+ loading: this.loading
217
+ };
218
+ }
219
+ }
220
+ class CreateSpatializedDynamic3DElementCommand extends JSBCommand {
221
+ getParams() {
222
+ return { test: true };
223
+ }
224
+ commandType = "CreateSpatializedDynamic3DElement";
225
+ }
226
+ class CreateSpatialEntityCommand extends JSBCommand {
227
+ constructor(name) {
228
+ super();
229
+ this.name = name;
230
+ }
231
+ getParams() {
232
+ return { name: this.name };
233
+ }
234
+ commandType = "CreateSpatialEntity";
235
+ }
236
+ class CreateModelComponentCommand extends JSBCommand {
237
+ constructor(options) {
238
+ super();
239
+ this.options = options;
240
+ }
241
+ getParams() {
242
+ let geometryId = this.options.mesh.id;
243
+ let materialIds = this.options.materials.map((material) => material.id);
244
+ return { geometryId, materialIds };
245
+ }
246
+ commandType = "CreateModelComponent";
247
+ }
248
+ class CreateSpatialModelEntityCommand extends JSBCommand {
249
+ constructor(options) {
250
+ super();
251
+ this.options = options;
252
+ }
253
+ getParams() {
254
+ return this.options;
255
+ }
256
+ commandType = "CreateSpatialModelEntity";
257
+ }
258
+ class CreateModelAssetCommand extends JSBCommand {
259
+ constructor(options) {
260
+ super();
261
+ this.options = options;
262
+ }
263
+ getParams() {
264
+ return { url: this.options.url };
265
+ }
266
+ commandType = "CreateModelAsset";
267
+ }
268
+ class CreateSpatialGeometryCommand extends JSBCommand {
269
+ constructor(type, options = {}) {
270
+ super();
271
+ this.type = type;
272
+ this.options = options;
273
+ }
274
+ getParams() {
275
+ return { type: this.type, ...this.options };
276
+ }
277
+ commandType = "CreateGeometry";
278
+ }
279
+ class CreateSpatialUnlitMaterialCommand extends JSBCommand {
280
+ constructor(options) {
281
+ super();
282
+ this.options = options;
283
+ }
284
+ getParams() {
285
+ return this.options;
286
+ }
287
+ commandType = "CreateUnlitMaterial";
288
+ }
289
+ class AddComponentToEntityCommand extends JSBCommand {
290
+ constructor(entity, comp) {
291
+ super();
292
+ this.entity = entity;
293
+ this.comp = comp;
294
+ }
295
+ getParams() {
296
+ return {
297
+ entityId: this.entity.id,
298
+ componentId: this.comp.id
299
+ };
300
+ }
301
+ commandType = "AddComponentToEntity";
302
+ }
303
+ class RemoveComponentFromEntityCommand extends JSBCommand {
304
+ constructor(entity, comp) {
305
+ super();
306
+ this.entity = entity;
307
+ this.comp = comp;
308
+ }
309
+ getParams() {
310
+ return {
311
+ entityId: this.entity.id,
312
+ componentId: this.comp.id
313
+ };
314
+ }
315
+ commandType = "RemoveComponentFromEntity";
316
+ }
317
+ class SetMaterialsOnEntityCommand extends JSBCommand {
318
+ constructor(entityId, materials) {
319
+ super();
320
+ this.entityId = entityId;
321
+ this.materials = materials;
322
+ }
323
+ getParams() {
324
+ return {
325
+ entityId: this.entityId,
326
+ materialIds: this.materials.map((m) => m.id)
327
+ };
328
+ }
329
+ commandType = "SetMaterialsOnEntity";
330
+ }
331
+ class AddEntityToDynamic3DCommand extends JSBCommand {
332
+ constructor(d3dEle, entity) {
333
+ super();
334
+ this.d3dEle = d3dEle;
335
+ this.entity = entity;
336
+ }
337
+ getParams() {
338
+ return {
339
+ entityId: this.entity.id,
340
+ dynamic3dId: this.d3dEle.id
341
+ };
342
+ }
343
+ commandType = "AddEntityToDynamic3D";
344
+ }
345
+ class AddEntityToEntityCommand extends JSBCommand {
346
+ constructor(parent, child) {
347
+ super();
348
+ this.parent = parent;
349
+ this.child = child;
350
+ }
351
+ getParams() {
352
+ return {
353
+ parentId: this.parent.id,
354
+ childId: this.child.id
355
+ };
356
+ }
357
+ commandType = "AddEntityToEntity";
358
+ }
359
+ class RemoveEntityFromParentCommand extends JSBCommand {
360
+ constructor(entity) {
361
+ super();
362
+ this.entity = entity;
363
+ }
364
+ getParams() {
365
+ return {
366
+ entityId: this.entity.id
367
+ };
368
+ }
369
+ commandType = "RemoveEntityFromParent";
370
+ }
371
+ class SetParentForEntityCommand extends JSBCommand {
372
+ // childId, parentId
373
+ constructor(childId, parentId) {
374
+ super();
375
+ this.childId = childId;
376
+ this.parentId = parentId;
377
+ }
378
+ getParams() {
379
+ return {
380
+ childId: this.childId,
381
+ parentId: this.parentId
382
+ };
383
+ }
384
+ commandType = "SetParentToEntity";
385
+ }
386
+ class ConvertFromEntityToEntityCommand extends JSBCommand {
387
+ constructor(fromEntityId, toEntityId, fromPosition) {
388
+ super();
389
+ this.fromEntityId = fromEntityId;
390
+ this.toEntityId = toEntityId;
391
+ this.fromPosition = fromPosition;
392
+ }
393
+ getParams() {
394
+ return {
395
+ fromEntityId: this.fromEntityId,
396
+ toEntityId: this.toEntityId,
397
+ position: this.fromPosition
398
+ };
399
+ }
400
+ commandType = "ConvertFromEntityToEntity";
401
+ }
402
+ class ConvertFromEntityToSceneCommand extends JSBCommand {
403
+ constructor(fromEntityId, position) {
404
+ super();
405
+ this.fromEntityId = fromEntityId;
406
+ this.position = position;
407
+ }
408
+ getParams() {
409
+ return {
410
+ fromEntityId: this.fromEntityId,
411
+ position: this.position
412
+ };
413
+ }
414
+ commandType = "ConvertFromEntityToScene";
415
+ }
416
+ class ConvertFromSceneToEntityCommand extends JSBCommand {
417
+ // let entityId: String
418
+ // let position:Vec3
419
+ constructor(entityId, position) {
420
+ super();
421
+ this.entityId = entityId;
422
+ this.position = position;
423
+ }
424
+ getParams() {
425
+ return {
426
+ entityId: this.entityId,
427
+ position: this.position
428
+ };
429
+ }
430
+ commandType = "ConvertFromSceneToEntity";
431
+ }
432
+ class ConvertCoordinateCommand extends JSBCommand {
433
+ constructor(position, fromId, toId) {
434
+ super();
435
+ this.position = position;
436
+ this.fromId = fromId;
437
+ this.toId = toId;
438
+ }
439
+ getParams() {
440
+ return {
441
+ position: this.position,
442
+ fromId: this.fromId,
443
+ toId: this.toId
444
+ };
445
+ }
446
+ commandType = "ConvertCoordinate";
447
+ }
448
+ class CreateTextureCommand extends JSBCommand {
449
+ constructor(url) {
450
+ super();
451
+ this.url = url;
452
+ }
453
+ getParams() {
454
+ return {
455
+ url: this.url
456
+ };
457
+ }
458
+ commandType = "CreateTexture";
459
+ }
460
+ class UpdateTexturePropertiesCommand extends SpatializedElementCommand {
461
+ properties;
462
+ commandType = "UpdateTextureProperties";
463
+ constructor(spatialObject, properties) {
464
+ super(spatialObject);
465
+ this.properties = properties;
466
+ }
467
+ getExtraParams() {
468
+ return this.properties;
469
+ }
470
+ }
471
+ class InspectCommand extends JSBCommand {
472
+ constructor(id = "") {
473
+ super();
474
+ this.id = id;
475
+ }
476
+ commandType = "Inspect";
477
+ getParams() {
478
+ return this.id ? { id: this.id } : { id: "" };
479
+ }
480
+ }
481
+ class DestroyCommand extends JSBCommand {
482
+ constructor(id) {
483
+ super();
484
+ this.id = id;
485
+ }
486
+ commandType = "Destroy";
487
+ getParams() {
488
+ return { id: this.id };
489
+ }
490
+ }
491
+ class CheckWebViewCanCreateCommand extends JSBCommand {
492
+ constructor(id = "") {
493
+ super();
494
+ this.id = id;
495
+ }
496
+ commandType = "CheckWebViewCanCreate";
497
+ getParams() {
498
+ return { id: this.id };
499
+ }
500
+ }
501
+ class AnimateTransformJSBCommand extends JSBCommand {
502
+ constructor(command) {
503
+ super();
504
+ this.command = command;
505
+ }
506
+ commandType = "AnimateTransform";
507
+ getParams() {
508
+ const { type, animationId, entityId } = this.command;
509
+ const params = { type, animationId };
510
+ if (entityId !== void 0) params.entityId = entityId;
511
+ if (type === "play") {
512
+ if (this.command.toTransform) {
513
+ params.toTransform = Array.from(this.command.toTransform);
514
+ }
515
+ if (this.command.fromTransform) {
516
+ params.fromTransform = Array.from(this.command.fromTransform);
517
+ }
518
+ if (this.command.duration !== void 0)
519
+ params.duration = this.command.duration;
520
+ if (this.command.timingFunction !== void 0)
521
+ params.timingFunction = this.command.timingFunction;
522
+ if (this.command.delay !== void 0) params.delay = this.command.delay;
523
+ if (this.command.loop !== void 0) params.loop = this.command.loop;
524
+ if (this.command.playbackRate !== void 0)
525
+ params.playbackRate = this.command.playbackRate;
526
+ }
527
+ return params;
528
+ }
529
+ }
530
+ function usePlacementProtocol() {
531
+ const rt = getRuntime();
532
+ if (rt.type === "visionos" && rt.shellVersion === VISIONOS_DEBUG_SHELL_VERSION_PLACEHOLDER) {
533
+ return false;
534
+ }
535
+ return supports("AttachmentEntity", ["placement"]);
536
+ }
537
+ function toPlacementVec3(position) {
538
+ const [x, y, z] = position ?? [0, 0, 0];
539
+ return { x, y, z };
540
+ }
541
+ class InitializeAttachmentCommand extends JSBCommand {
542
+ constructor(attachmentId, options) {
543
+ super();
544
+ this.attachmentId = attachmentId;
545
+ this.options = options;
546
+ }
547
+ commandType = "InitializeAttachment";
548
+ getParams() {
549
+ const p = this.options;
550
+ if (!usePlacementProtocol()) {
551
+ return {
552
+ id: this.attachmentId,
553
+ parentEntityId: p.parentEntityId,
554
+ position: p.position ?? [0, 0, 0],
555
+ size: p.size,
556
+ ownerViewId: p.ownerViewId
557
+ };
558
+ }
559
+ return {
560
+ id: this.attachmentId,
561
+ placementId: p.parentEntityId,
562
+ position: toPlacementVec3(p.position),
563
+ width: pointToPhysical(p.size.width),
564
+ height: pointToPhysical(p.size.height),
565
+ ownerViewId: p.ownerViewId
566
+ };
567
+ }
568
+ }
569
+ class UpdateAttachmentEntityCommand extends JSBCommand {
570
+ constructor(attachmentId, options) {
571
+ super();
572
+ this.attachmentId = attachmentId;
573
+ this.options = options;
574
+ }
575
+ commandType = "UpdateAttachmentEntity";
576
+ getParams() {
577
+ if (!usePlacementProtocol()) {
578
+ return {
579
+ id: this.attachmentId,
580
+ ...this.options
581
+ };
582
+ }
583
+ const { position, size } = this.options;
584
+ return {
585
+ id: this.attachmentId,
586
+ ...position ? { position: toPlacementVec3(position) } : {},
587
+ ...size ? {
588
+ width: pointToPhysical(size.width),
589
+ height: pointToPhysical(size.height)
590
+ } : {}
591
+ };
592
+ }
593
+ }
594
+ class CreateSpatializedElementAnimationJSBCommand extends JSBCommand {
595
+ constructor(command) {
596
+ super();
597
+ this.command = command;
598
+ }
599
+ commandType = "CreateSpatializedElementAnimation";
600
+ getParams() {
601
+ const { elementId, timeline } = this.command;
602
+ return {
603
+ elementId,
604
+ timeline
605
+ };
606
+ }
607
+ }
608
+ class ControlSpatializedElementAnimationJSBCommand extends JSBCommand {
609
+ constructor(command) {
610
+ super();
611
+ this.command = command;
612
+ }
613
+ commandType = "ControlSpatializedElementAnimation";
614
+ getParams() {
615
+ const { animationId, type } = this.command;
616
+ return {
617
+ animationId,
618
+ type
619
+ };
620
+ }
621
+ }
622
+ export {
623
+ AddComponentToEntityCommand,
624
+ AddEntityToDynamic3DCommand,
625
+ AddEntityToEntityCommand,
626
+ AddSpatializedElementToSpatialScene,
627
+ AddSpatializedElementToSpatialized2DElement,
628
+ AnimateTransformJSBCommand,
629
+ CheckWebViewCanCreateCommand,
630
+ ControlSpatializedElementAnimationJSBCommand,
631
+ ConvertCoordinateCommand,
632
+ ConvertFromEntityToEntityCommand,
633
+ ConvertFromEntityToSceneCommand,
634
+ ConvertFromSceneToEntityCommand,
635
+ CreateModelAssetCommand,
636
+ CreateModelComponentCommand,
637
+ CreateSpatialEntityCommand,
638
+ CreateSpatialGeometryCommand,
639
+ CreateSpatialModelEntityCommand,
640
+ CreateSpatialUnlitMaterialCommand,
641
+ CreateSpatializedDynamic3DElementCommand,
642
+ CreateSpatializedElementAnimationJSBCommand,
643
+ CreateSpatializedStatic3DElementCommand,
644
+ CreateTextureCommand,
645
+ DestroyCommand,
646
+ FocusScene,
647
+ GetSpatialSceneState,
648
+ InitializeAttachmentCommand,
649
+ InspectCommand,
650
+ RemoveComponentFromEntityCommand,
651
+ RemoveEntityFromParentCommand,
652
+ SetMaterialsOnEntityCommand,
653
+ SetParentForEntityCommand,
654
+ SpatializedElementCommand,
655
+ UpdateAttachmentEntityCommand,
656
+ UpdateEntityEventCommand,
657
+ UpdateEntityEventsCommand,
658
+ UpdateEntityPropertiesCommand,
659
+ UpdateSceneConfig,
660
+ UpdateSpatialSceneProperties,
661
+ UpdateSpatialized2DElementProperties,
662
+ UpdateSpatializedDynamic3DElementProperties,
663
+ UpdateSpatializedElementTransform,
664
+ UpdateSpatializedStatic3DElementProperties,
665
+ UpdateTexturePropertiesCommand,
666
+ UpdateUnlitMaterialProperties
667
+ };
668
+ //# sourceMappingURL=JSBCommand.js.map