@webspatial/core-sdk 1.0.5 → 1.2.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 +16 -0
- package/dist/iife/index.d.ts +29 -32
- package/dist/iife/index.global.js +3 -3
- package/dist/iife/index.global.js.map +1 -1
- package/dist/index.d.ts +29 -32
- package/dist/index.js +170 -75
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/JSBCommand.ts +1 -1
- package/src/SpatialScene.ts +2 -2
- package/src/SpatialSession.ts +7 -4
- package/src/SpatializedElement.ts +13 -53
- package/src/SpatializedStatic3DElement.ts +1 -1
- package/src/WebMsgCommand.ts +8 -3
- package/src/coverage-boost.test.ts +1060 -0
- package/src/jsbcommand.coverage.test.ts +542 -0
- package/src/platform-adapter/android/AndroidPlatform.ts +2 -2
- package/src/platform-adapter/index.ts +31 -3
- package/src/platform-adapter/vision-os/VisionOSPlatform.ts +0 -1
- package/src/platform-adapter/xr/XRPlatform.ts +133 -0
- package/src/reality/component/index.ts +1 -1
- package/src/reality/entity/SpatialEntity.ts +6 -14
- package/src/reality/entity/index.ts +1 -1
- package/src/reality/geometry/SpatialBoxGeometry.ts +4 -1
- package/src/reality/geometry/index.ts +1 -1
- package/src/reality/material/index.ts +1 -1
- package/src/reality/resource/index.ts +1 -1
- package/src/scene-polyfill.ts +25 -9
- package/src/types/internal.ts +5 -5
- package/src/types/types.ts +23 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @webspatial/core-sdk
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 539e61f: fix entity drag gesture event type
|
|
8
|
+
- f0ab8eb: Maintain the original creation process of Spatialized2DElement on the Android platform and optimize the creation process of Spatialized2DElement on the new platform
|
|
9
|
+
- 4359ba1: Reconstruct the creation process of Spatialized2dElement
|
|
10
|
+
- 2632112: Optimize the creation process of SpatialDiv on Android
|
|
11
|
+
- bdd9065: Change <Model> entityTransform type from DOMMatrix to DOMMatrixReadOnly
|
|
12
|
+
|
|
13
|
+
## 1.1.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 3412d6d: using correct spatialid name when running on Android
|
|
18
|
+
|
|
3
19
|
## 1.0.5
|
|
4
20
|
|
|
5
21
|
## 1.0.4
|
package/dist/iife/index.d.ts
CHANGED
|
@@ -55,10 +55,8 @@ declare enum SpatialWebMsgType {
|
|
|
55
55
|
spatialdragstart = "spatialdragstart",
|
|
56
56
|
spatialdrag = "spatialdrag",
|
|
57
57
|
spatialdragend = "spatialdragend",
|
|
58
|
-
spatialrotatestart = "spatialrotatestart",
|
|
59
58
|
spatialrotate = "spatialrotate",
|
|
60
59
|
spatialrotateend = "spatialrotateend",
|
|
61
|
-
spatialmagnifystart = "spatialmagnifystart",
|
|
62
60
|
spatialmagnify = "spatialmagnify",
|
|
63
61
|
spatialmagnifyend = "spatialmagnifyend",
|
|
64
62
|
objectdestroy = "objectdestroy"
|
|
@@ -89,13 +87,17 @@ interface SpatialTapMsg {
|
|
|
89
87
|
type: SpatialWebMsgType.spatialtap;
|
|
90
88
|
detail: SpatialTapEventDetail;
|
|
91
89
|
}
|
|
90
|
+
interface SpatialDragStartMsg {
|
|
91
|
+
type: SpatialWebMsgType.spatialdragstart;
|
|
92
|
+
detail: SpatialDragStartEventDetail;
|
|
93
|
+
}
|
|
92
94
|
interface SpatialDragMsg {
|
|
93
95
|
type: SpatialWebMsgType.spatialdrag;
|
|
94
96
|
detail: SpatialDragEventDetail;
|
|
95
97
|
}
|
|
96
98
|
interface SpatialDragEndMsg {
|
|
97
99
|
type: SpatialWebMsgType.spatialdragend;
|
|
98
|
-
detail:
|
|
100
|
+
detail: SpatialDragEndEventDetail;
|
|
99
101
|
}
|
|
100
102
|
interface SpatialRotateMsg {
|
|
101
103
|
type: SpatialWebMsgType.spatialrotate;
|
|
@@ -167,26 +169,19 @@ declare abstract class SpatializedElement extends SpatialObject {
|
|
|
167
169
|
* Handles various spatial events like transforms, gestures, and interactions.
|
|
168
170
|
* @param data The event data received from the WebSpatial system
|
|
169
171
|
*/
|
|
170
|
-
protected onReceiveEvent(data: CubeInfoMsg | TransformMsg | SpatialTapMsg | SpatialDragMsg | SpatialDragEndMsg | SpatialRotateMsg | SpatialRotateEndMsg | ObjectDestroyMsg): void;
|
|
172
|
+
protected onReceiveEvent(data: CubeInfoMsg | TransformMsg | SpatialTapMsg | SpatialDragStartMsg | SpatialDragMsg | SpatialDragEndMsg | SpatialRotateMsg | SpatialRotateEndMsg | ObjectDestroyMsg): void;
|
|
171
173
|
private _onSpatialTap?;
|
|
172
174
|
set onSpatialTap(value: (event: SpatialTapEvent) => void | undefined);
|
|
173
|
-
private _isDragging;
|
|
174
175
|
private _onSpatialDragStart?;
|
|
175
|
-
set onSpatialDragStart(value: (event:
|
|
176
|
+
set onSpatialDragStart(value: (event: SpatialDragStartEvent) => void | undefined);
|
|
176
177
|
private _onSpatialDrag?;
|
|
177
178
|
set onSpatialDrag(value: (event: SpatialDragEvent) => void | undefined);
|
|
178
179
|
private _onSpatialDragEnd?;
|
|
179
180
|
set onSpatialDragEnd(value: ((event: SpatialDragEndEvent) => void) | undefined);
|
|
180
|
-
private _isRotating;
|
|
181
|
-
private _onSpatialRotateStart?;
|
|
182
|
-
set onSpatialRotateStart(value: ((event: SpatialRotateEvent) => void) | undefined);
|
|
183
181
|
private _onSpatialRotate?;
|
|
184
182
|
set onSpatialRotate(value: ((event: SpatialRotateEvent) => void) | undefined);
|
|
185
183
|
private _onSpatialRotateEnd?;
|
|
186
184
|
set onSpatialRotateEnd(value: ((event: SpatialRotateEndEvent) => void) | undefined);
|
|
187
|
-
private _isMagnify;
|
|
188
|
-
private _onSpatialMagnifyStart?;
|
|
189
|
-
set onSpatialMagnifyStart(value: ((event: SpatialMagnifyEvent) => void) | undefined);
|
|
190
185
|
private _onSpatialMagnify?;
|
|
191
186
|
set onSpatialMagnify(value: ((event: SpatialMagnifyEvent) => void) | undefined);
|
|
192
187
|
private _onSpatialMagnifyEnd?;
|
|
@@ -211,6 +206,12 @@ interface Vec3 {
|
|
|
211
206
|
z: number;
|
|
212
207
|
}
|
|
213
208
|
type Point3D = Vec3;
|
|
209
|
+
interface Quaternion {
|
|
210
|
+
x: number;
|
|
211
|
+
y: number;
|
|
212
|
+
z: number;
|
|
213
|
+
w: number;
|
|
214
|
+
}
|
|
214
215
|
/**
|
|
215
216
|
* Material type for SpatialDiv or HTML document.
|
|
216
217
|
*
|
|
@@ -259,10 +260,8 @@ interface SpatializedElementProperties {
|
|
|
259
260
|
enableDragStartGesture: boolean;
|
|
260
261
|
enableDragGesture: boolean;
|
|
261
262
|
enableDragEndGesture: boolean;
|
|
262
|
-
enableRotateStartGesture: boolean;
|
|
263
263
|
enableRotateGesture: boolean;
|
|
264
264
|
enableRotateEndGesture: boolean;
|
|
265
|
-
enableMagnifyStartGesture: boolean;
|
|
266
265
|
enableMagnifyGesture: boolean;
|
|
267
266
|
enableMagnifyEndGesture: boolean;
|
|
268
267
|
}
|
|
@@ -405,33 +404,31 @@ interface SpatialTapEventDetail {
|
|
|
405
404
|
location3D: Point3D;
|
|
406
405
|
}
|
|
407
406
|
type SpatialTapEvent = CustomEvent<SpatialTapEventDetail>;
|
|
408
|
-
interface
|
|
409
|
-
location3D: Point3D;
|
|
407
|
+
interface SpatialDragStartEventDetail {
|
|
410
408
|
startLocation3D: Point3D;
|
|
409
|
+
}
|
|
410
|
+
interface SpatialDragEventDetail {
|
|
411
411
|
translation3D: Vec3;
|
|
412
|
-
predictedEndTranslation3D: Vec3;
|
|
413
|
-
predictedEndLocation3D: Point3D;
|
|
414
|
-
velocity: Size;
|
|
415
412
|
}
|
|
413
|
+
interface SpatialDragEndEventDetail {
|
|
414
|
+
}
|
|
415
|
+
type SpatialDragStartEvent = CustomEvent<SpatialDragStartEventDetail>;
|
|
416
416
|
type SpatialDragEvent = CustomEvent<SpatialDragEventDetail>;
|
|
417
|
-
type SpatialDragEndEvent =
|
|
417
|
+
type SpatialDragEndEvent = CustomEvent<SpatialDragEndEventDetail>;
|
|
418
418
|
interface SpatialRotateEventDetail {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
startAnchor3D: Vec3;
|
|
423
|
-
startLocation3D: Point3D;
|
|
419
|
+
quaternion: Quaternion;
|
|
420
|
+
}
|
|
421
|
+
interface SpatialRotateEndEventDetail {
|
|
424
422
|
}
|
|
425
423
|
type SpatialRotateEvent = CustomEvent<SpatialRotateEventDetail>;
|
|
426
|
-
type SpatialRotateEndEvent =
|
|
424
|
+
type SpatialRotateEndEvent = CustomEvent<SpatialRotateEndEventDetail>;
|
|
427
425
|
interface SpatialMagnifyEventDetail {
|
|
428
426
|
magnification: number;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
startLocation3D: Point3D;
|
|
427
|
+
}
|
|
428
|
+
interface SpatialMagnifyEndEventDetail {
|
|
432
429
|
}
|
|
433
430
|
type SpatialMagnifyEvent = CustomEvent<SpatialMagnifyEventDetail>;
|
|
434
|
-
type SpatialMagnifyEndEvent =
|
|
431
|
+
type SpatialMagnifyEndEvent = CustomEvent<SpatialMagnifyEndEventDetail>;
|
|
435
432
|
type SpatialEntityOrReality = SpatialEntity | SpatializedDynamic3DElement;
|
|
436
433
|
|
|
437
434
|
declare class SpatialComponent extends SpatialObject {
|
|
@@ -670,7 +667,7 @@ declare class SpatializedStatic3DElement extends SpatializedElement {
|
|
|
670
667
|
* @param callback Function to call when the model fails to load
|
|
671
668
|
*/
|
|
672
669
|
set onLoadFailureCallback(callback: undefined | (() => void));
|
|
673
|
-
updateModelTransform(transform:
|
|
670
|
+
updateModelTransform(transform: DOMMatrixReadOnly): void;
|
|
674
671
|
}
|
|
675
672
|
|
|
676
673
|
/**
|
|
@@ -859,4 +856,4 @@ declare global {
|
|
|
859
856
|
|
|
860
857
|
declare const isSSREnv: () => boolean;
|
|
861
858
|
|
|
862
|
-
export { type BackgroundMaterialType, type BaseplateVisibilityType, BaseplateVisibilityValues, type CornerRadius, CubeInfo$1 as CubeInfo, type ModelAssetOptions, ModelComponent, type ModelComponentOptions, type Point3D, type Size, type Size3D, Spatial, SpatialBoxGeometry, type SpatialBoxGeometryOptions, SpatialComponent, SpatialConeGeometry, type SpatialConeGeometryOptions, SpatialCylinderGeometry, type SpatialCylinderGeometryOptions, type SpatialDragEndEvent, type SpatialDragEvent, type SpatialDragEventDetail, SpatialEntity, type SpatialEntityEventType, type SpatialEntityOrReality, type SpatialEntityProperties, type SpatialEntityUserData, SpatialGeometry, type SpatialGeometryOptions, type SpatialGeometryType, type SpatialMagnifyEndEvent, type SpatialMagnifyEvent, type SpatialMagnifyEventDetail, SpatialMaterial, type SpatialMaterialType, SpatialModelAsset, type SpatialModelDragEvent, SpatialModelEntity, type SpatialModelEntityCreationOptions, SpatialObject, SpatialPlaneGeometry, type SpatialPlaneGeometryOptions, type SpatialRotateEndEvent, type SpatialRotateEvent, type SpatialRotateEventDetail, SpatialScene, type SpatialSceneCreationOptions$1 as SpatialSceneCreationOptions, type SpatialSceneProperties, SpatialSceneState$1 as SpatialSceneState, type SpatialSceneType$1 as SpatialSceneType, SpatialSceneValues, SpatialSession, SpatialSphereGeometry, type SpatialSphereGeometryOptions, type SpatialTapEvent, type SpatialTapEventDetail, SpatialUnlitMaterial, type SpatialUnlitMaterialOptions, Spatialized2DElement, type Spatialized2DElementProperties, SpatializedDynamic3DElement, SpatializedElement, type SpatializedElementProperties, SpatializedElementType, SpatializedStatic3DElement, type SpatializedStatic3DElementProperties, type Vec3, type WorldAlignmentType, WorldAlignmentValues, type WorldScalingType, WorldScalingValues, isSSREnv, isValidBaseplateVisibilityType, isValidSceneUnit, isValidSpatialSceneType, isValidWorldAlignmentType, isValidWorldScalingType };
|
|
859
|
+
export { type BackgroundMaterialType, type BaseplateVisibilityType, BaseplateVisibilityValues, type CornerRadius, CubeInfo$1 as CubeInfo, type ModelAssetOptions, ModelComponent, type ModelComponentOptions, type Point3D, type Quaternion, type Size, type Size3D, Spatial, SpatialBoxGeometry, type SpatialBoxGeometryOptions, SpatialComponent, SpatialConeGeometry, type SpatialConeGeometryOptions, SpatialCylinderGeometry, type SpatialCylinderGeometryOptions, type SpatialDragEndEvent, type SpatialDragEndEventDetail, type SpatialDragEvent, type SpatialDragEventDetail, type SpatialDragStartEvent, type SpatialDragStartEventDetail, SpatialEntity, type SpatialEntityEventType, type SpatialEntityOrReality, type SpatialEntityProperties, type SpatialEntityUserData, SpatialGeometry, type SpatialGeometryOptions, type SpatialGeometryType, type SpatialMagnifyEndEvent, type SpatialMagnifyEndEventDetail, type SpatialMagnifyEvent, type SpatialMagnifyEventDetail, SpatialMaterial, type SpatialMaterialType, SpatialModelAsset, type SpatialModelDragEvent, SpatialModelEntity, type SpatialModelEntityCreationOptions, SpatialObject, SpatialPlaneGeometry, type SpatialPlaneGeometryOptions, type SpatialRotateEndEvent, type SpatialRotateEndEventDetail, type SpatialRotateEvent, type SpatialRotateEventDetail, SpatialScene, type SpatialSceneCreationOptions$1 as SpatialSceneCreationOptions, type SpatialSceneProperties, SpatialSceneState$1 as SpatialSceneState, type SpatialSceneType$1 as SpatialSceneType, SpatialSceneValues, SpatialSession, SpatialSphereGeometry, type SpatialSphereGeometryOptions, type SpatialTapEvent, type SpatialTapEventDetail, SpatialUnlitMaterial, type SpatialUnlitMaterialOptions, Spatialized2DElement, type Spatialized2DElementProperties, SpatializedDynamic3DElement, SpatializedElement, type SpatializedElementProperties, SpatializedElementType, SpatializedStatic3DElement, type SpatializedStatic3DElementProperties, type Vec3, type WorldAlignmentType, WorldAlignmentValues, type WorldScalingType, WorldScalingValues, isSSREnv, isValidBaseplateVisibilityType, isValidSceneUnit, isValidSpatialSceneType, isValidWorldAlignmentType, isValidWorldScalingType };
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
(function(){
|
|
3
3
|
if(typeof window === 'undefined') return;
|
|
4
4
|
if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
|
|
5
|
-
window.__webspatialsdk__['core-sdk-version'] = "1.0
|
|
5
|
+
window.__webspatialsdk__['core-sdk-version'] = "1.2.0"
|
|
6
6
|
})()
|
|
7
7
|
|
|
8
|
-
"use strict";var webspatialCore=(()=>{var zt=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var Gt=(i,e)=>{for(var t in e)zt(i,t,{get:e[t],enumerable:!0})},Ve=(i,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ge(e))!Ie.call(i,r)&&r!==t&&zt(i,r,{get:()=>e[r],enumerable:!(a=ze(e,r))||a.enumerable});return i};var It=i=>Ve(zt({},"__esModule",{value:!0}),i);var We,I,Vt=f(()=>{"use strict";We=typeof window>"u",I=()=>We});var H,Qt=f(()=>{"use strict";H=class{callJSB(e,t){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocol(e,t,a,r){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocolSync(e,t,a,r,n){return{success:!0,data:void 0,errorCode:void 0,errorMessage:void 0}}}});function g(i){return{success:!0,data:i,errorCode:"",errorMessage:""}}function M(i,e=""){return{success:!1,data:void 0,errorCode:i,errorMessage:e}}var Wt=f(()=>{"use strict"});var m,D=f(()=>{"use strict";m=class i{static eventReceiver={};static init(){window.__SpatialWebEvent=({id:e,data:t})=>{i.eventReceiver[e]?.(t)}}static addEventReceiver(e,t){i.eventReceiver[e]=t}static removeEventReceiver(e){delete i.eventReceiver[e]}}});var Xt={};Gt(Xt,{AndroidPlatform:()=>Lt});function Ae(){return At=(At+1)%_e,`rId_${At}`}var _t,At,_e,Lt,Yt=f(()=>{"use strict";Wt();u();D();_t=0,At=0,_e=1e5;Lt=class{async callJSB(e,t){return new Promise((a,r)=>{try{let n=Ae();m.addEventReceiver(n,p=>{if(m.removeEventReceiver(n),p.success)a(g(p.data));else{let{code:c,message:x}=p.data;a(M(c,x))}});let o=window.webspatialBridge.postMessage(n,e,t);if(o!==""){m.removeEventReceiver(n);let p=JSON.parse(o);if(p.success)a(g(p.data));else{let{code:c,message:x}=p.data;a(M(c,x))}}}catch(n){console.error(`AndroidPlatform cmd: ${e}, msg: ${t} error: ${n}`);let{code:o,message:p}=n;a(M(o,p))}})}async callWebSpatialProtocol(e,t,a,r){await new Promise(c=>setTimeout(c,16*_t)),_t++;let n=await new V().execute();for(;!n.data.can;)await new Promise(c=>setTimeout(c,16)),n=await new V().execute();let{windowProxy:o}=this.openWindow(e,t,a,r);for(;!o?.open;)await new Promise(c=>setTimeout(c,16));for(o?.open("about:blank","_self");!o?.SpatialId;)await new Promise(c=>setTimeout(c,16));let p=o?.SpatialId;return _t--,Promise.resolve(g({windowProxy:o,id:p}))}callWebSpatialProtocolSync(e,t,a,r){let{spatialId:n="",windowProxy:o}=this.openWindow(e,t,a,r);return g({windowProxy:o,id:n})}openWindow(e,t,a,r){return{spatialId:"",windowProxy:window.open(`webspatial://${e}?${t||""}`,a,r)}}}});var Zt={};Gt(Zt,{VisionOSPlatform:()=>Bt});var Bt,te=f(()=>{"use strict";Wt();Bt=class{async callJSB(e,t){try{let a=await window.webkit.messageHandlers.bridge.postMessage(`${e}::${t}`);return g(a)}catch(a){let{code:r,message:n}=JSON.parse(a.message);return M(r,n)}}callWebSpatialProtocol(e,t,a,r){let{spatialId:n,windowProxy:o}=this.openWindow(e,t,a,r);return Promise.resolve(g({windowProxy:o,id:n}))}callWebSpatialProtocolSync(e,t,a,r){let{spatialId:n="",windowProxy:o}=this.openWindow(e,t,a,r);return g({windowProxy:o,id:n})}openWindow(e,t,a,r){let n=window.open(`webspatial://${e}?${t||""}`,a,r);return{spatialId:n?.navigator.userAgent?.match(/\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\b/gi)?.[0],windowProxy:n}}}});function ee(){if(I())return new H;if(window.navigator.userAgent.includes("Android")||window.navigator.userAgent.includes("Linux")){let i=(Yt(),It(Xt)).AndroidPlatform;return new i}else{let i=(te(),It(Zt)).VisionOSPlatform;return new i}}var ie=f(()=>{"use strict";Vt();Qt()});function q(i,e){return i===""?0:i.endsWith("%")?e*parseFloat(i)/100:parseFloat(i)}function ae(i){let e=parseFloat(i.getPropertyValue("width")),t=i.getPropertyValue("border-top-left-radius"),a=i.getPropertyValue("border-top-right-radius"),r=i.getPropertyValue("border-bottom-left-radius"),n=i.getPropertyValue("border-bottom-right-radius");return{topLeading:q(t,e),bottomLeading:q(r,e),topTrailing:q(a,e),bottomTrailing:q(n,e)}}function re(i,e,t){let{x:a,y:r,z:n}=i,{x:o,y:p,z:c}=e,{x,y:Ce,z:Oe}=t,v=new DOMMatrix;return v=v.translate(a,r,n),v=v.rotate(o,p,c),v=v.scale(x,Ce,Oe),v}var Ut=f(()=>{"use strict"});var jt,s,K,Q,X,Y,Z,tt,E,et,it,at,rt,nt,ot,st,pt,lt,ct,dt,mt,ut,yt,St,ft,w,gt,ht,Et,bt,xt,V,vt,wt,Pt,u=f(()=>{"use strict";ie();Ut();jt=ee(),s=class{commandType="";async execute(){let e=this.getParams(),t=e?JSON.stringify(e):"";return jt.callJSB(this.commandType,t)}},K=class extends s{constructor(t,a){super();this.entity=t;this.properties=a}commandType="UpdateEntityProperties";getParams(){let t=re(this.properties.position??this.entity.position,this.properties.rotation??this.entity.rotation,this.properties.scale??this.entity.scale).toFloat64Array();return{entityId:this.entity.id,transform:t}}},Q=class extends s{constructor(t,a,r){super();this.entity=t;this.type=a;this.isEnable=r}commandType="UpdateEntityEvent";getParams(){return{type:this.type,entityId:this.entity.id,isEnable:this.isEnable}}},X=class extends s{properties;commandType="UpdateSpatialSceneProperties";constructor(e){super(),this.properties=e}getParams(){return this.properties}},Y=class extends s{config;commandType="UpdateSceneConfig";constructor(e){super(),this.config=e}getParams(){return{config:this.config}}},Z=class extends s{constructor(t){super();this.id=t}commandType="FocusScene";getParams(){return{id:this.id}}},tt=class extends s{commandType="GetSpatialSceneState";constructor(){super()}getParams(){return{}}},E=class extends s{constructor(t){super();this.spatialObject=t}getParams(){let t=this.getExtraParams();return{id:this.spatialObject.id,...t}}},et=class extends E{properties;commandType="UpdateSpatialized2DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},it=class extends E{properties;commandType="UpdateSpatializedDynamic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return{id:this.spatialObject.id,...this.properties}}},at=class extends E{properties;commandType="UpdateUnlitMaterialProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},rt=class extends E{matrix;commandType="UpdateSpatializedElementTransform";constructor(e,t){super(e),this.matrix=t}getExtraParams(){return{matrix:Array.from(this.matrix.toFloat64Array())}}},nt=class extends E{properties;commandType="UpdateSpatializedStatic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},ot=class extends E{commandType="AddSpatializedElementToSpatialized2DElement";spatializedElement;constructor(e,t){super(e),this.spatializedElement=t}getExtraParams(){return{spatializedElementId:this.spatializedElement.id}}},st=class extends s{commandType="AddSpatializedElementToSpatialScene";spatializedElement;constructor(e){super(),this.spatializedElement=e}getParams(){return{spatializedElementId:this.spatializedElement.id}}},pt=class extends s{constructor(t){super();this.modelURL=t;this.modelURL=t}commandType="CreateSpatializedStatic3DElement";getParams(){return{modelURL:this.modelURL}}},lt=class extends s{getParams(){return{test:!0}}commandType="CreateSpatializedDynamic3DElement"},ct=class extends s{constructor(t){super();this.name=t}getParams(){return{name:this.name}}commandType="CreateSpatialEntity"},dt=class extends s{constructor(t){super();this.options=t}getParams(){let t=this.options.mesh.id,a=this.options.materials.map(r=>r.id);return{geometryId:t,materialIds:a}}commandType="CreateModelComponent"},mt=class extends s{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateSpatialModelEntity"},ut=class extends s{constructor(t){super();this.options=t}getParams(){return{url:this.options.url}}commandType="CreateModelAsset"},yt=class extends s{constructor(t,a={}){super();this.type=t;this.options=a}getParams(){return{type:this.type,...this.options}}commandType="CreateGeometry"},St=class extends s{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateUnlitMaterial"},ft=class extends s{constructor(t,a){super();this.entity=t;this.comp=a}getParams(){return{entityId:this.entity.id,componentId:this.comp.id}}commandType="AddComponentToEntity"},w=class extends s{constructor(t,a){super();this.childId=t;this.parentId=a}getParams(){return{childId:this.childId,parentId:this.parentId}}commandType="SetParentToEntity"},gt=class extends s{constructor(t,a,r){super();this.fromEntityId=t;this.toEntityId=a;this.fromPosition=r}getParams(){return{fromEntityId:this.fromEntityId,toEntityId:this.toEntityId,position:this.fromPosition}}commandType="ConvertFromEntityToEntity"},ht=class extends s{constructor(t,a){super();this.fromEntityId=t;this.position=a}getParams(){return{fromEntityId:this.fromEntityId,position:this.position}}commandType="ConvertFromEntityToScene"},Et=class extends s{constructor(t,a){super();this.entityId=t;this.position=a}getParams(){return{entityId:this.entityId,position:this.position}}commandType="ConvertFromSceneToEntity"},bt=class extends s{constructor(t=""){super();this.id=t}commandType="Inspect";getParams(){return this.id?{id:this.id}:{id:""}}},xt=class extends s{constructor(t){super();this.id=t}commandType="Destroy";getParams(){return{id:this.id}}},V=class extends s{constructor(t=""){super();this.id=t}commandType="CheckWebViewCanCreate";getParams(){return{id:this.id}}},vt=class extends s{target;features;async execute(){let e=this.getQuery();return jt.callWebSpatialProtocol(this.commandType,e,this.target,this.features)}executeSync(){let e=this.getQuery();return jt.callWebSpatialProtocolSync(this.commandType,e,this.target,this.features)}getQuery(){let e,t=this.getParams();return t&&(e=Object.keys(t).map(a=>{let r=t[a],n=typeof r=="object"?JSON.stringify(r):r;return`${a}=${encodeURIComponent(n)}`}).join("&")),e}},wt=class extends vt{commandType="createSpatialized2DElement";constructor(){super()}getParams(){return{}}},Pt=class extends vt{constructor(t,a,r,n){super();this.url=t;this.config=a;this.target=r;this.features=n}commandType="createSpatialScene";getParams(){return{url:this.url,config:this.config}}}});var Qe={};Gt(Qe,{BaseplateVisibilityValues:()=>oe,CubeInfo:()=>W,ModelComponent:()=>L,Spatial:()=>G,SpatialBoxGeometry:()=>F,SpatialComponent:()=>A,SpatialConeGeometry:()=>J,SpatialCylinderGeometry:()=>N,SpatialEntity:()=>P,SpatialGeometry:()=>y,SpatialMaterial:()=>B,SpatialModelAsset:()=>j,SpatialModelEntity:()=>_,SpatialObject:()=>d,SpatialPlaneGeometry:()=>$,SpatialScene:()=>h,SpatialSceneState:()=>Ht,SpatialSceneValues:()=>le,SpatialSession:()=>z,SpatialSphereGeometry:()=>k,SpatialUnlitMaterial:()=>U,Spatialized2DElement:()=>T,SpatializedDynamic3DElement:()=>C,SpatializedElement:()=>S,SpatializedElementType:()=>ne,SpatializedStatic3DElement:()=>R,WorldAlignmentValues:()=>pe,WorldScalingValues:()=>se,isSSREnv:()=>I,isValidBaseplateVisibilityType:()=>kt,isValidSceneUnit:()=>Mt,isValidSpatialSceneType:()=>Jt,isValidWorldAlignmentType:()=>$t,isValidWorldScalingType:()=>Nt});u();var d=class{constructor(e){this.id=e}name;isDestroyed=!1;async inspect(){let e=await new bt(this.id).execute();if(e.success)return e.data;throw new Error(e.errorMessage)}async destroy(){if(this.isDestroyed)return;let e=await new xt(this.id).execute();if(e.success)return this.onDestroy(),this.isDestroyed=!0,e.data;if(this.isDestroyed)return;throw new Error(e.errorMessage)}onDestroy(){}};u();u();var Ft,h=class i extends d{static getInstance(){return Ft||(Ft=new i("")),Ft}async updateSpatialProperties(e){return new X(e).execute()}async addSpatializedElement(e){return new st(e).execute()}async updateSceneCreationConfig(e){return new Y(e).execute()}async getState(){return(await new tt().execute()).data.name}};var ne=(a=>(a[a.Spatialized2DElement=0]="Spatialized2DElement",a[a.SpatializedStatic3DElement=1]="SpatializedStatic3DElement",a[a.SpatializedDynamic3DElement=2]="SpatializedDynamic3DElement",a))(ne||{}),oe=["automatic","visible","hidden"];function kt(i){return oe.includes(i)}var se=["automatic","dynamic"];function Nt(i){return se.includes(i)}var pe=["adaptive","automatic","gravityAligned"];function $t(i){return pe.includes(i)}var le=["window","volume"];function Jt(i){return le.includes(i)}function Mt(i){if(typeof i=="number")return i>=0;if(typeof i=="string"){if(i.endsWith("px"))return isNaN(Number(i.slice(0,-2)))?!1:Number(i.slice(0,-2))>=0;if(i.endsWith("m"))return isNaN(Number(i.slice(0,-1)))?!1:Number(i.slice(0,-1))>=0}return!1}var Ht=(n=>(n.idle="idle",n.pending="pending",n.willVisible="willVisible",n.visible="visible",n.fail="fail",n))(Ht||{}),W=class{constructor(e,t){this.size=e;this.origin=t;this.size=e,this.origin=t}get x(){return this.origin.x}get y(){return this.origin.y}get z(){return this.origin.z}get width(){return this.size.width}get height(){return this.size.height}get depth(){return this.size.depth}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get back(){return this.z}get front(){return this.z+this.depth}};var Le={defaultSize:{width:1280,height:720}},Be={defaultSize:{width:.94,height:.94,depth:.94}},Ue="webspatial://",Dt=class i{originalOpen;static instance;static getInstance(){return i.instance||(i.instance=new i),i.instance}init(e){this.originalOpen=e.open.bind(e),e.open=this.open}configMap={};getConfig(e){if(!(e===void 0||!this.configMap[e]))return this.configMap[e]}open=(e,t,a)=>{if(e?.startsWith(Ue))return this.originalOpen(e,t,a);let r=`${window.location.protocol}//${window.location.host}`;if(e?.startsWith(r)||(e=r+e),t==="_self"||t==="_parent"||t==="_top")return this.originalOpen(e,t,a);let n=t?this.getConfig(t):void 0,p=new Pt(e,n,t,a).executeSync();typeof t=="string"&&this.configMap[t]&&delete this.configMap[t];let c=p.data?.id;return c&&new Z(c).execute(),p.data?.windowProxy};initScene(e,t,a){let r=a?.type??"window",n=Kt(r),o=t({...n}),[p,c]=ue(o,r);c.length>0&&console.warn(`initScene ${e} with errors: ${c.join(", ")}`),this.configMap[e]={...p,type:r}}};function ce(i){return i/1360}function de(i){return i*1360}function me(i,e,t){if(typeof i=="number")return t==="px"&&e==="px"||t==="m"&&e==="m"?i:t==="px"&&e==="m"?ce(i):t==="m"&&e==="px"?de(i):i;if(e==="m"){if(i.endsWith("m"))return Number(i.slice(0,-1));if(i.endsWith("px"))return ce(Number(i.slice(0,-2)));throw new Error("formatToNumber: invalid str")}else if(e==="px"){if(i.endsWith("px"))return Number(i.slice(0,-2));if(i.endsWith("m"))return de(Number(i.slice(0,-1)));throw new Error("formatToNumber: invalid str")}else throw new Error("formatToNumber: invalid targetUnit")}function ue(i,e){let t=Kt(e),a=[],r=e==="window";if(Jt(e)||a.push("sceneType"),i.defaultSize){let n=["width","height","depth"];for(let o of n)o in i.defaultSize&&(Mt(i.defaultSize[o])?i.defaultSize[o]=me(i.defaultSize[o],r?"px":"m",r?"px":"m"):(i.defaultSize[o]=t.defaultSize[o],a.push(`defaultSize.${o}`)))}if(i.resizability){let n=["minWidth","minHeight","maxWidth","maxHeight"];for(let o of n)o in i.resizability&&(Mt(i.resizability[o])?i.resizability[o]=me(i.resizability[o],"px",r?"px":"m"):(i.resizability[o]=void 0,a.push(`resizability.${o}`)))}return i.worldScaling&&(Nt(i.worldScaling)||(i.worldScaling="automatic",a.push("worldScaling"))),i.worldAlignment&&($t(i.worldAlignment)||(i.worldAlignment="automatic",a.push("worldAlignment"))),i.baseplateVisibility&&(kt(i.baseplateVisibility)||(i.baseplateVisibility="automatic",a.push("baseplateVisibility"))),[i,a]}function ye(i,e,t){return Dt.getInstance().initScene(i,e,t)}function je(i){Dt.getInstance().init(i)}function qt(i){i.document.onclick=function(e){let t=e.target,a=!1;for(;!a;){if(t&&t.tagName=="A")return!Fe(e);if(t&&t.parentElement)t=t.parentElement;else break}}}function Fe(i){let e=i.target;if(e.tagName==="A"){let t=e,a=t.target,r=t.href;if(a&&a!=="_self")return i.preventDefault(),window.open(r,a),!0}}function Kt(i){return i==="window"?Le:Be}async function ke(){if(!window.opener||await h.getInstance().getState()!=="pending")return;function e(t){document.readyState==="interactive"||document.readyState==="complete"?t():document.addEventListener("DOMContentLoaded",t)}e(async()=>{let t=Kt(window.xrCurrentSceneType??"window"),a=t;if(typeof window.xrCurrentSceneDefaults=="function")try{a=await window.xrCurrentSceneDefaults?.(t)}catch(p){console.error(p)}await new Promise((p,c)=>{setTimeout(()=>{p(null)},1e3)});let r=window.xrCurrentSceneType??"window",[n,o]=ue(a,r);o.length>0&&console.warn(`window.xrCurrentSceneDefaults with errors: ${o.join(", ")}`),await h.getInstance().updateSceneCreationConfig({...n,type:r})})}function Se(){je(window),qt(window),ke()}u();u();u();D();function l(i,e){return new CustomEvent(i,{bubbles:!0,cancelable:!1,detail:e})}var S=class extends d{constructor(t){super(t);this.id=t;m.addEventReceiver(t,this.onReceiveEvent.bind(this))}async updateTransform(t){return new rt(this,t).execute()}_cubeInfo;get cubeInfo(){return this._cubeInfo}_transform;_transformInv;get transform(){return this._transform}get transformInv(){return this._transformInv}onReceiveEvent(t){let{type:a}=t;if(a==="objectdestroy")this.isDestroyed=!0;else if(a==="cubeInfo"){let r=t;this._cubeInfo=new W(r.size,r.origin)}else if(a==="transform")this._transform=new DOMMatrix([t.detail.column0[0],t.detail.column0[1],t.detail.column0[2],0,t.detail.column1[0],t.detail.column1[1],t.detail.column1[2],0,t.detail.column2[0],t.detail.column2[1],t.detail.column2[2],0,t.detail.column3[0],t.detail.column3[1],t.detail.column3[2],1]),this._transformInv=this._transform.inverse();else if(a==="spatialtap"){let r=l("spatialtap",t.detail);this._onSpatialTap?.(r)}else if(a==="spatialdrag"){if(!this._isDragging){let n=l("spatialdragstart",t.detail);this._onSpatialDragStart?.(n)}this._isDragging=!0;let r=l("spatialdrag",t.detail);this._onSpatialDrag?.(r)}else if(a==="spatialdragend"){this._isDragging=!1;let r=l("spatialdragend",t.detail);this._onSpatialDragEnd?.(r)}else if(a==="spatialrotate"){if(!this._isRotating){let n=l("spatialrotatestart",t.detail);this._onSpatialRotateStart?.(n)}this._isRotating=!0;let r=l("spatialrotate",t.detail);this._onSpatialRotate?.(r)}else if(a==="spatialrotateend"){this._isRotating=!1;let r=l("spatialrotateend",t.detail);this._onSpatialRotateEnd?.(r)}else if(a==="spatialmagnify"){if(!this._isMagnify){let n=l("spatialmagnifystart",t.detail);this._onSpatialMagnifyStart?.(n)}this._isMagnify=!0;let r=l("spatialmagnify",t.detail);this._onSpatialMagnify?.(r)}else if(a==="spatialmagnifyend"){this._isMagnify=!1;let r=l("spatialmagnifyend",t.detail);this._onSpatialMagnifyEnd?.(r)}}_onSpatialTap;set onSpatialTap(t){this._onSpatialTap=t,this.updateProperties({enableTapGesture:t!==void 0})}_isDragging=!1;_onSpatialDragStart;set onSpatialDragStart(t){this._onSpatialDragStart=t,this.updateProperties({enableDragStartGesture:this._onSpatialDragStart!==void 0})}_onSpatialDrag;set onSpatialDrag(t){this._onSpatialDrag=t,this.updateProperties({enableDragGesture:this._onSpatialDrag!==void 0})}_onSpatialDragEnd;set onSpatialDragEnd(t){this._onSpatialDragEnd=t,this.updateProperties({enableDragEndGesture:t!==void 0})}_isRotating=!1;_onSpatialRotateStart;set onSpatialRotateStart(t){this._onSpatialRotateStart=t,this.updateProperties({enableRotateStartGesture:this._onSpatialRotateStart!==void 0})}_onSpatialRotate;set onSpatialRotate(t){this._onSpatialRotate=t,this.updateProperties({enableRotateGesture:this._onSpatialRotate!==void 0})}_onSpatialRotateEnd;set onSpatialRotateEnd(t){this._onSpatialRotateEnd=t,this.updateProperties({enableRotateEndGesture:t!==void 0})}_isMagnify=!1;_onSpatialMagnifyStart;set onSpatialMagnifyStart(t){this._onSpatialMagnifyStart=t,this.updateProperties({enableMagnifyStartGesture:t!==void 0})}_onSpatialMagnify;set onSpatialMagnify(t){this._onSpatialMagnify=t,this.updateProperties({enableMagnifyGesture:t!==void 0})}_onSpatialMagnifyEnd;set onSpatialMagnifyEnd(t){this._onSpatialMagnifyEnd=t,this.updateProperties({enableMagnifyEndGesture:t!==void 0})}onDestroy(){m.removeEventReceiver(this.id)}};var T=class extends S{constructor(t,a){super(t);this.windowProxy=a;qt(a)}async updateProperties(t){return new et(this,t).execute()}async addSpatializedElement(t){return new ot(this,t).execute()}};u();var R=class extends S{_readyResolve;modelURL="";createReadyPromise(){return new Promise(e=>{this._readyResolve=e})}ready=this.createReadyPromise();async updateProperties(e){return e.modelURL!==void 0&&this.modelURL!==e.modelURL&&(this.modelURL=e.modelURL,this.ready=this.createReadyPromise()),new nt(this,e).execute()}onReceiveEvent(e){e.type==="modelloaded"?(this._onLoadCallback?.(),this._readyResolve?.(!0)):e.type==="modelloadfailed"?(this._onLoadFailureCallback?.(),this._readyResolve?.(!1)):super.onReceiveEvent(e)}_onLoadCallback;set onLoadCallback(e){this._onLoadCallback=e}_onLoadFailureCallback;set onLoadFailureCallback(e){this._onLoadFailureCallback=e}updateModelTransform(e){let t=Array.from(e.toFloat64Array());this.updateProperties({modelTransform:t})}};u();var C=class extends S{children=[];constructor(e){super(e)}async addEntity(e){let t=new w(e.id,this.id).execute();return this.children.push(e),e.parent=this,t}async updateProperties(e){return new it(this,e).execute()}};async function fe(){let i=await new wt().execute();if(i.success){let{id:e,windowProxy:t}=i.data;return t.document.head.innerHTML=`<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
|
-
<base href="${document.baseURI}">`,new
|
|
8
|
+
"use strict";var webspatialCore=(()=>{var Vt=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var h=(i,e)=>()=>(i&&(e=i(i=0)),e);var q=(i,e)=>{for(var t in e)Vt(i,t,{get:e[t],enumerable:!0})},Le=(i,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _e(e))!Be.call(i,r)&&r!==t&&Vt(i,r,{get:()=>e[r],enumerable:!(a=Ae(e,r))||a.enumerable});return i};var H=i=>Le(Vt({},"__esModule",{value:!0}),i);var Ue,G,At=h(()=>{"use strict";Ue=typeof window>"u",G=()=>Ue});var X,Yt=h(()=>{"use strict";X=class{callJSB(e,t){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocol(e,t,a,r){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocolSync(e,t,a,r,n){return{success:!0,data:void 0,errorCode:void 0,errorMessage:void 0}}}});function y(i){return{success:!0,data:i,errorCode:"",errorMessage:""}}function g(i,e=""){return{success:!1,data:void 0,errorCode:i,errorMessage:e}}var Q=h(()=>{"use strict"});var c,P=h(()=>{"use strict";c=class i{static eventReceiver={};static init(){window.__SpatialWebEvent=({id:e,data:t})=>{i.eventReceiver[e]?.(t)}}static addEventReceiver(e,t){i.eventReceiver[e]=t}static removeEventReceiver(e){delete i.eventReceiver[e]}}});var ee={};q(ee,{XRPlatform:()=>Bt});function te(){return _t=(_t+1)%je,`rId_${_t}`}var _t,je,Bt,ie=h(()=>{"use strict";Q();P();_t=0,je=1e5;Bt=class{async callJSB(e,t){return new Promise((a,r)=>{try{let n=te();c.addEventReceiver(n,s=>{if(c.removeEventReceiver(n),s.success)a(y(s.data));else{let{code:p,message:u}=s.data;a(g(p,u))}});let o=window.webspatialBridge.postMessage(n,e,t);if(o!==""){c.removeEventReceiver(n);let s=JSON.parse(o);if(s.success)a(y(s.data));else{let{code:p,message:u}=s.data;a(g(p,u))}}}catch(n){console.error(`XRPlatform cmd: ${e}, msg: ${t} error: ${n}`);let{code:o,message:s}=n;a(g(o,s))}})}async callWebSpatialProtocol(e,t,a,r){return new Promise((n,o)=>{let s=te();try{let p=null;c.addEventReceiver(s,u=>{console.log("createdId",s,u.spatialId),n(y({windowProxy:p,id:u.spatialId})),c.removeEventReceiver(s)}),p=this.openWindow(e,t,a,r).windowProxy,p?.open(`about:blank?rid=${s}`,"_self")}catch(p){console.error(`open window error: ${p}`);let{code:u,message:Wt}=p;c.removeEventReceiver(s),n(g(u,Wt))}})}callWebSpatialProtocolSync(e,t,a,r){let{spatialId:n="",windowProxy:o}=this.openWindow(e,t,a,r);return y({windowProxy:o,id:n})}openWindow(e,t,a,r){return{spatialId:"",windowProxy:window.open(`webspatial://${e}?${t||""}`,a,r)}}}});var ae={};q(ae,{AndroidPlatform:()=>jt});function Fe(){return Ut=(Ut+1)%ke,`rId_${Ut}`}var Lt,Ut,ke,jt,re=h(()=>{"use strict";Q();S();P();Lt=0,Ut=0,ke=1e5;jt=class{async callJSB(e,t){return new Promise((a,r)=>{try{let n=Fe();c.addEventReceiver(n,s=>{if(c.removeEventReceiver(n),s.success)a(y(s.data));else{let{code:p,message:u}=s.data;a(g(p,u))}});let o=window.webspatialBridge.postMessage(n,e,t);if(o!==""){c.removeEventReceiver(n);let s=JSON.parse(o);if(s.success)a(y(s.data));else{let{code:p,message:u}=s.data;a(g(p,u))}}}catch(n){console.error(`AndroidPlatform cmd: ${e}, msg: ${t} error: ${n}`);let{code:o,message:s}=n;a(g(o,s))}})}async callWebSpatialProtocol(e,t,a,r){await new Promise(p=>setTimeout(p,16*Lt)),Lt++;let n=await new W().execute();for(;!n.data.can;)await new Promise(p=>setTimeout(p,16)),n=await new W().execute();let{windowProxy:o}=this.openWindow(e,t,a,r);for(;!o?.open;)await new Promise(p=>setTimeout(p,16));for(o?.open("about:blank","_self");!o?.__SpatialId;)await new Promise(p=>setTimeout(p,16));let s=o?.__SpatialId;return Lt--,Promise.resolve(y({windowProxy:o,id:s}))}callWebSpatialProtocolSync(e,t,a,r){let{spatialId:n="",windowProxy:o}=this.openWindow(e,t,a,r);return y({windowProxy:o,id:n})}openWindow(e,t,a,r){return{spatialId:"",windowProxy:window.open(`webspatial://${e}?${t||""}`,a,r)}}}});var ne={};q(ne,{VisionOSPlatform:()=>kt});var kt,oe=h(()=>{"use strict";Q();kt=class{async callJSB(e,t){try{let a=await window.webkit.messageHandlers.bridge.postMessage(`${e}::${t}`);return y(a)}catch(a){let{code:r,message:n}=JSON.parse(a.message);return g(r,n)}}callWebSpatialProtocol(e,t,a,r){let{spatialId:n,windowProxy:o}=this.openWindow(e,t,a,r);return Promise.resolve(y({windowProxy:o,id:n}))}callWebSpatialProtocolSync(e,t,a,r){let{spatialId:n="",windowProxy:o}=this.openWindow(e,t,a,r);return y({windowProxy:o,id:n})}openWindow(e,t,a,r){let n=window.open(`webspatial://${e}?${t||""}`,a,r);return{spatialId:n?.navigator.userAgent?.match(/\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\b/gi)?.[0],windowProxy:n}}}});function Ne(i){let e=i.match(/WebSpatial\/(\d+)\.(\d+)\.(\d+)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null}function $e(i,e){if(!i)return!1;for(let t=0;t<3;t+=1){let a=i[t]-e[t];if(a>0)return!0;if(a<0)return!1}return!1}function se(){if(G())return new X;let i=window.navigator.userAgent,e=Ne(i);if(i.includes("PicoWebApp")&&$e(e,[0,0,1])){let t=(ie(),H(ee)).XRPlatform;return new t}else if(i.includes("Android")||i.includes("Linux")){let t=(re(),H(ae)).AndroidPlatform;return new t}else{let t=(oe(),H(ne)).VisionOSPlatform;return new t}}var pe=h(()=>{"use strict";At();Yt()});function K(i,e){return i===""?0:i.endsWith("%")?e*parseFloat(i)/100:parseFloat(i)}function le(i){let e=parseFloat(i.getPropertyValue("width")),t=i.getPropertyValue("border-top-left-radius"),a=i.getPropertyValue("border-top-right-radius"),r=i.getPropertyValue("border-bottom-left-radius"),n=i.getPropertyValue("border-bottom-right-radius");return{topLeading:K(t,e),bottomLeading:K(r,e),topTrailing:K(a,e),bottomTrailing:K(n,e)}}function ce(i,e,t){let{x:a,y:r,z:n}=i,{x:o,y:s,z:p}=e,{x:u,y:Wt,z:Ve}=t,w=new DOMMatrix;return w=w.translate(a,r,n),w=w.rotate(o,s,p),w=w.scale(u,Wt,Ve),w}var Ft=h(()=>{"use strict"});var Nt,l,Z,Y,tt,et,it,at,x,rt,nt,ot,st,pt,lt,ct,dt,mt,ut,yt,St,ft,gt,ht,Et,M,bt,xt,vt,wt,Pt,W,Mt,Dt,Rt,S=h(()=>{"use strict";pe();Ft();Nt=se(),l=class{commandType="";async execute(){let e=this.getParams(),t=e?JSON.stringify(e):"";return Nt.callJSB(this.commandType,t)}},Z=class extends l{constructor(t,a){super();this.entity=t;this.properties=a}commandType="UpdateEntityProperties";getParams(){let t=ce(this.properties.position??this.entity.position,this.properties.rotation??this.entity.rotation,this.properties.scale??this.entity.scale).toFloat64Array();return{entityId:this.entity.id,transform:t}}},Y=class extends l{constructor(t,a,r){super();this.entity=t;this.type=a;this.isEnable=r}commandType="UpdateEntityEvent";getParams(){return{type:this.type,entityId:this.entity.id,isEnable:this.isEnable}}},tt=class extends l{properties;commandType="UpdateSpatialSceneProperties";constructor(e){super(),this.properties=e}getParams(){return this.properties}},et=class extends l{config;commandType="UpdateSceneConfig";constructor(e){super(),this.config=e}getParams(){return{config:this.config}}},it=class extends l{constructor(t){super();this.id=t}commandType="FocusScene";getParams(){return{id:this.id}}},at=class extends l{commandType="GetSpatialSceneState";constructor(){super()}getParams(){return{}}},x=class extends l{constructor(t){super();this.spatialObject=t}getParams(){let t=this.getExtraParams();return{id:this.spatialObject.id,...t}}},rt=class extends x{properties;commandType="UpdateSpatialized2DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},nt=class extends x{properties;commandType="UpdateSpatializedDynamic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return{id:this.spatialObject.id,...this.properties}}},ot=class extends x{properties;commandType="UpdateUnlitMaterialProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},st=class extends x{matrix;commandType="UpdateSpatializedElementTransform";constructor(e,t){super(e),this.matrix=t}getExtraParams(){return{matrix:Array.from(this.matrix.toFloat64Array())}}},pt=class extends x{properties;commandType="UpdateSpatializedStatic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},lt=class extends x{commandType="AddSpatializedElementToSpatialized2DElement";spatializedElement;constructor(e,t){super(e),this.spatializedElement=t}getExtraParams(){return{spatializedElementId:this.spatializedElement.id}}},ct=class extends l{commandType="AddSpatializedElementToSpatialScene";spatializedElement;constructor(e){super(),this.spatializedElement=e}getParams(){return{spatializedElementId:this.spatializedElement.id}}},dt=class extends l{constructor(t){super();this.modelURL=t;this.modelURL=t}commandType="CreateSpatializedStatic3DElement";getParams(){return{modelURL:this.modelURL}}},mt=class extends l{getParams(){return{test:!0}}commandType="CreateSpatializedDynamic3DElement"},ut=class extends l{constructor(t){super();this.name=t}getParams(){return{name:this.name}}commandType="CreateSpatialEntity"},yt=class extends l{constructor(t){super();this.options=t}getParams(){let t=this.options.mesh.id,a=this.options.materials.map(r=>r.id);return{geometryId:t,materialIds:a}}commandType="CreateModelComponent"},St=class extends l{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateSpatialModelEntity"},ft=class extends l{constructor(t){super();this.options=t}getParams(){return{url:this.options.url}}commandType="CreateModelAsset"},gt=class extends l{constructor(t,a={}){super();this.type=t;this.options=a}getParams(){return{type:this.type,...this.options}}commandType="CreateGeometry"},ht=class extends l{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateUnlitMaterial"},Et=class extends l{constructor(t,a){super();this.entity=t;this.comp=a}getParams(){return{entityId:this.entity.id,componentId:this.comp.id}}commandType="AddComponentToEntity"},M=class extends l{constructor(t,a){super();this.childId=t;this.parentId=a}getParams(){return{childId:this.childId,parentId:this.parentId}}commandType="SetParentToEntity"},bt=class extends l{constructor(t,a,r){super();this.fromEntityId=t;this.toEntityId=a;this.fromPosition=r}getParams(){return{fromEntityId:this.fromEntityId,toEntityId:this.toEntityId,position:this.fromPosition}}commandType="ConvertFromEntityToEntity"},xt=class extends l{constructor(t,a){super();this.fromEntityId=t;this.position=a}getParams(){return{fromEntityId:this.fromEntityId,position:this.position}}commandType="ConvertFromEntityToScene"},vt=class extends l{constructor(t,a){super();this.entityId=t;this.position=a}getParams(){return{entityId:this.entityId,position:this.position}}commandType="ConvertFromSceneToEntity"},wt=class extends l{constructor(t=""){super();this.id=t}commandType="Inspect";getParams(){return this.id?{id:this.id}:{id:""}}},Pt=class extends l{constructor(t){super();this.id=t}commandType="Destroy";getParams(){return{id:this.id}}},W=class extends l{constructor(t=""){super();this.id=t}commandType="CheckWebViewCanCreate";getParams(){return{id:this.id}}},Mt=class extends l{target;features;async execute(){let e=this.getQuery();return Nt.callWebSpatialProtocol(this.commandType,e,this.target,this.features)}executeSync(){let e=this.getQuery();return Nt.callWebSpatialProtocolSync(this.commandType,e,this.target,this.features)}getQuery(){let e,t=this.getParams();return t&&(e=Object.keys(t).map(a=>{let r=t[a],n=typeof r=="object"?JSON.stringify(r):r;return`${a}=${encodeURIComponent(n)}`}).join("&")),e}},Dt=class extends Mt{commandType="createSpatialized2DElement";constructor(){super()}getParams(){return{}}},Rt=class extends Mt{constructor(t,a,r,n){super();this.url=t;this.config=a;this.target=r;this.features=n}commandType="createSpatialScene";getParams(){return{url:this.url,config:this.config}}}});var ri={};q(ri,{BaseplateVisibilityValues:()=>me,CubeInfo:()=>V,ModelComponent:()=>B,Spatial:()=>I,SpatialBoxGeometry:()=>k,SpatialComponent:()=>_,SpatialConeGeometry:()=>J,SpatialCylinderGeometry:()=>N,SpatialEntity:()=>D,SpatialGeometry:()=>f,SpatialMaterial:()=>L,SpatialModelAsset:()=>j,SpatialModelEntity:()=>A,SpatialObject:()=>d,SpatialPlaneGeometry:()=>$,SpatialScene:()=>b,SpatialSceneState:()=>Qt,SpatialSceneValues:()=>Se,SpatialSession:()=>z,SpatialSphereGeometry:()=>F,SpatialUnlitMaterial:()=>U,Spatialized2DElement:()=>R,SpatializedDynamic3DElement:()=>C,SpatializedElement:()=>E,SpatializedElementType:()=>de,SpatializedStatic3DElement:()=>T,WorldAlignmentValues:()=>ye,WorldScalingValues:()=>ue,isSSREnv:()=>G,isValidBaseplateVisibilityType:()=>Jt,isValidSceneUnit:()=>Tt,isValidSpatialSceneType:()=>Xt,isValidWorldAlignmentType:()=>Ht,isValidWorldScalingType:()=>qt});S();var d=class{constructor(e){this.id=e}name;isDestroyed=!1;async inspect(){let e=await new wt(this.id).execute();if(e.success)return e.data;throw new Error(e.errorMessage)}async destroy(){if(this.isDestroyed)return;let e=await new Pt(this.id).execute();if(e.success)return this.onDestroy(),this.isDestroyed=!0,e.data;if(this.isDestroyed)return;throw new Error(e.errorMessage)}onDestroy(){}};S();S();var $t,b=class i extends d{static getInstance(){return $t||($t=new i("")),$t}async updateSpatialProperties(e){return new tt(e).execute()}async addSpatializedElement(e){return new ct(e).execute()}async updateSceneCreationConfig(e){return new et(e).execute()}async getState(){return(await new at().execute()).data.name}};var de=(a=>(a[a.Spatialized2DElement=0]="Spatialized2DElement",a[a.SpatializedStatic3DElement=1]="SpatializedStatic3DElement",a[a.SpatializedDynamic3DElement=2]="SpatializedDynamic3DElement",a))(de||{}),me=["automatic","visible","hidden"];function Jt(i){return me.includes(i)}var ue=["automatic","dynamic"];function qt(i){return ue.includes(i)}var ye=["adaptive","automatic","gravityAligned"];function Ht(i){return ye.includes(i)}var Se=["window","volume"];function Xt(i){return Se.includes(i)}function Tt(i){if(typeof i=="number")return i>=0;if(typeof i=="string"){if(i.endsWith("px"))return isNaN(Number(i.slice(0,-2)))?!1:Number(i.slice(0,-2))>=0;if(i.endsWith("m"))return isNaN(Number(i.slice(0,-1)))?!1:Number(i.slice(0,-1))>=0}return!1}var Qt=(n=>(n.idle="idle",n.pending="pending",n.willVisible="willVisible",n.visible="visible",n.fail="fail",n))(Qt||{}),V=class{constructor(e,t){this.size=e;this.origin=t;this.size=e,this.origin=t}get x(){return this.origin.x}get y(){return this.origin.y}get z(){return this.origin.z}get width(){return this.size.width}get height(){return this.size.height}get depth(){return this.size.depth}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get back(){return this.z}get front(){return this.z+this.depth}};var Je={defaultSize:{width:1280,height:720}},qe={defaultSize:{width:.94,height:.94,depth:.94}},He="webspatial://",Ct=class i{originalOpen;static instance;static getInstance(){return i.instance||(i.instance=new i),i.instance}init(e){this.originalOpen=e.open.bind(e),e.open=this.open}configMap={};getConfig(e){if(!(e===void 0||!this.configMap[e]))return this.configMap[e]}ensureAbsoluteUrl(e){if(!e||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e))return e;if(e.startsWith("//"))return`${window.location.protocol}${e}`;try{return new URL(e,document.baseURI).toString()}catch{return e}}open=(e,t,a)=>{if(e?.startsWith(He))return this.originalOpen(e,t,a);if(e=this.ensureAbsoluteUrl(e),t==="_self"||t==="_parent"||t==="_top")return this.originalOpen(e,t,a);let r=t?this.getConfig(t):void 0,o=new Rt(e,r,t,a).executeSync(),s=o.data?.id;return s&&new it(s).execute(),o.data?.windowProxy};initScene(e,t,a){let r=a?.type??"window",n=Zt(r),o=t({...n}),[s,p]=Ee(o,r);p.length>0&&console.warn(`initScene ${e} with errors: ${p.join(", ")}`),this.configMap[e]={...s,type:r}}};function fe(i){return i/1360}function ge(i){return i*1360}function he(i,e,t){if(typeof i=="number")return t==="px"&&e==="px"||t==="m"&&e==="m"?i:t==="px"&&e==="m"?fe(i):t==="m"&&e==="px"?ge(i):i;if(e==="m"){if(i.endsWith("m"))return Number(i.slice(0,-1));if(i.endsWith("px"))return fe(Number(i.slice(0,-2)));throw new Error("formatToNumber: invalid str")}else if(e==="px"){if(i.endsWith("px"))return Number(i.slice(0,-2));if(i.endsWith("m"))return ge(Number(i.slice(0,-1)));throw new Error("formatToNumber: invalid str")}else throw new Error("formatToNumber: invalid targetUnit")}function Ee(i,e){let t=Zt(e),a=[],r=e==="window";if(Xt(e)||a.push("sceneType"),i.defaultSize){let n=["width","height","depth"];for(let o of n)o in i.defaultSize&&(Tt(i.defaultSize[o])?i.defaultSize[o]=he(i.defaultSize[o],r?"px":"m",r?"px":"m"):(i.defaultSize[o]=t.defaultSize[o],a.push(`defaultSize.${o}`)))}if(i.resizability){let n=["minWidth","minHeight","maxWidth","maxHeight"];for(let o of n)o in i.resizability&&(Tt(i.resizability[o])?i.resizability[o]=he(i.resizability[o],"px",r?"px":"m"):(i.resizability[o]=void 0,a.push(`resizability.${o}`)))}return i.worldScaling&&(qt(i.worldScaling)||(i.worldScaling="automatic",a.push("worldScaling"))),i.worldAlignment&&(Ht(i.worldAlignment)||(i.worldAlignment="automatic",a.push("worldAlignment"))),i.baseplateVisibility&&(Jt(i.baseplateVisibility)||(i.baseplateVisibility="automatic",a.push("baseplateVisibility"))),[i,a]}function be(i,e,t){return Ct.getInstance().initScene(i,e,t)}function Xe(i){Ct.getInstance().init(i)}function Kt(i){i.document.onclick=function(e){let t=e.target,a=!1;for(;!a;){if(t&&t.tagName=="A")return!Qe(e);if(t&&t.parentElement)t=t.parentElement;else break}}}function Qe(i){let e=i.target;if(e.tagName==="A"){let t=e,a=t.target,r=t.href;if(a&&a!=="_self")return i.preventDefault(),window.open(r,a),!0}}function Zt(i){return i==="window"?Je:qe}async function Ke(){if(!window.opener||await b.getInstance().getState()!=="pending")return;function e(t){document.readyState==="interactive"||document.readyState==="complete"?t():document.addEventListener("DOMContentLoaded",t)}e(async()=>{let t=Zt(window.xrCurrentSceneType??"window"),a=t;if(typeof window.xrCurrentSceneDefaults=="function")try{a=await window.xrCurrentSceneDefaults?.(t)}catch(s){console.error(s)}await new Promise((s,p)=>{setTimeout(()=>{s(null)},1e3)});let r=window.xrCurrentSceneType??"window",[n,o]=Ee(a,r);o.length>0&&console.warn(`window.xrCurrentSceneDefaults with errors: ${o.join(", ")}`),await b.getInstance().updateSceneCreationConfig({...n,type:r})})}function xe(){Xe(window),Kt(window),Ke()}S();S();S();P();function m(i,e){return new CustomEvent(i,{bubbles:!0,cancelable:!1,detail:e})}var E=class extends d{constructor(t){super(t);this.id=t;c.addEventReceiver(t,this.onReceiveEvent.bind(this))}async updateTransform(t){return new st(this,t).execute()}_cubeInfo;get cubeInfo(){return this._cubeInfo}_transform;_transformInv;get transform(){return this._transform}get transformInv(){return this._transformInv}onReceiveEvent(t){let{type:a}=t;if(a==="objectdestroy")this.isDestroyed=!0;else if(a==="cubeInfo"){let r=t;this._cubeInfo=new V(r.size,r.origin)}else if(a==="transform")this._transform=new DOMMatrix([t.detail.column0[0],t.detail.column0[1],t.detail.column0[2],0,t.detail.column1[0],t.detail.column1[1],t.detail.column1[2],0,t.detail.column2[0],t.detail.column2[1],t.detail.column2[2],0,t.detail.column3[0],t.detail.column3[1],t.detail.column3[2],1]),this._transformInv=this._transform.inverse();else if(a==="spatialtap"){let r=m("spatialtap",t.detail);this._onSpatialTap?.(r)}else if(a==="spatialdragstart"){let r=m("spatialdragstart",t.detail);this._onSpatialDragStart?.(r)}else if(a==="spatialdrag"){let r=m("spatialdrag",t.detail);this._onSpatialDrag?.(r)}else if(a==="spatialdragend"){let r=m("spatialdragend",t.detail);this._onSpatialDragEnd?.(r)}else if(a==="spatialrotate"){let r=m("spatialrotate",t.detail);this._onSpatialRotate?.(r)}else if(a==="spatialrotateend"){let r=m("spatialrotateend",t.detail);this._onSpatialRotateEnd?.(r)}else if(a==="spatialmagnify"){let r=m("spatialmagnify",t.detail);this._onSpatialMagnify?.(r)}else if(a==="spatialmagnifyend"){let r=m("spatialmagnifyend",t.detail);this._onSpatialMagnifyEnd?.(r)}}_onSpatialTap;set onSpatialTap(t){this._onSpatialTap=t,this.updateProperties({enableTapGesture:t!==void 0})}_onSpatialDragStart;set onSpatialDragStart(t){this._onSpatialDragStart=t,this.updateProperties({enableDragStartGesture:this._onSpatialDragStart!==void 0})}_onSpatialDrag;set onSpatialDrag(t){this._onSpatialDrag=t,this.updateProperties({enableDragGesture:this._onSpatialDrag!==void 0})}_onSpatialDragEnd;set onSpatialDragEnd(t){this._onSpatialDragEnd=t,this.updateProperties({enableDragEndGesture:t!==void 0})}_onSpatialRotate;set onSpatialRotate(t){this._onSpatialRotate=t,this.updateProperties({enableRotateGesture:this._onSpatialRotate!==void 0})}_onSpatialRotateEnd;set onSpatialRotateEnd(t){this._onSpatialRotateEnd=t,this.updateProperties({enableRotateEndGesture:t!==void 0})}_onSpatialMagnify;set onSpatialMagnify(t){this._onSpatialMagnify=t,this.updateProperties({enableMagnifyGesture:t!==void 0})}_onSpatialMagnifyEnd;set onSpatialMagnifyEnd(t){this._onSpatialMagnifyEnd=t,this.updateProperties({enableMagnifyEndGesture:t!==void 0})}onDestroy(){c.removeEventReceiver(this.id)}};var R=class extends E{constructor(t,a){super(t);this.windowProxy=a;Kt(a)}async updateProperties(t){return new rt(this,t).execute()}async addSpatializedElement(t){return new lt(this,t).execute()}};S();var T=class extends E{_readyResolve;modelURL="";createReadyPromise(){return new Promise(e=>{this._readyResolve=e})}ready=this.createReadyPromise();async updateProperties(e){return e.modelURL!==void 0&&this.modelURL!==e.modelURL&&(this.modelURL=e.modelURL,this.ready=this.createReadyPromise()),new pt(this,e).execute()}onReceiveEvent(e){e.type==="modelloaded"?(this._onLoadCallback?.(),this._readyResolve?.(!0)):e.type==="modelloadfailed"?(this._onLoadFailureCallback?.(),this._readyResolve?.(!1)):super.onReceiveEvent(e)}_onLoadCallback;set onLoadCallback(e){this._onLoadCallback=e}_onLoadFailureCallback;set onLoadFailureCallback(e){this._onLoadFailureCallback=e}updateModelTransform(e){let t=Array.from(e.toFloat64Array());this.updateProperties({modelTransform:t})}};S();var C=class extends E{children=[];constructor(e){super(e)}async addEntity(e){let t=new M(e.id,this.id).execute();return this.children.push(e),e.parent=this,t}async updateProperties(e){return new nt(this,e).execute()}};async function ve(){let i=await new Dt().execute();if(i.success){let{id:e,windowProxy:t}=i.data;return t.document.head.innerHTML=`<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
|
+
<base href="${document.baseURI}">`,new R(e,t)}else throw new Error("createSpatialized2DElement failed")}async function we(i){let e=await new dt(i).execute();if(e.success){let{id:t}=e.data;return new T(t)}else throw new Error("createSpatializedStatic3DElement failed")}async function Pe(){let i=await new mt().execute();if(i.success){let{id:e}=i.data;return new C(e)}else throw new Error("createSpatializedDynamic3DElement failed")}S();S();S();P();var D=class i extends d{constructor(t,a){super(t);this.userData=a;c.addEventReceiver(t,this.onReceiveEvent)}position={x:0,y:0,z:0};rotation={x:0,y:0,z:0};scale={x:1,y:1,z:1};events={};children=[];parent=null;async addComponent(t){return new Et(this,t).execute()}async setPosition(t){return this.updateTransform({position:t})}async setRotation(t){return this.updateTransform({rotation:t})}async setScale(t){return this.updateTransform({scale:t})}async addEntity(t){let a=await new M(t.id,this.id).execute();return this.children.push(t),t.parent=this,a}async removeFromParent(){let t=await new M(this.id,void 0).execute();return this.parent&&(this.parent.children=this.parent.children.filter(a=>a.id!==this.id),this.parent=null),t}async updateTransform(t){return this.position=t.position??this.position,this.rotation=t.rotation??this.rotation,this.scale=t.scale??this.scale,new Z(this,t).execute()}async addEvent(t,a){if(this.events[t])this.events[t]=a;else try{await this.updateEntityEvent(t,!0),this.events[t]=a}catch{console.error("addEvent failed",t)}}async removeEvent(t){if(this.events[t]){delete this.events[t];try{await this.updateEntityEvent(t,!1)}catch{console.error("removeEvent failed",t)}}}async updateEntityEvent(t,a){return new Y(this,t,a).execute()}onReceiveEvent=t=>{let{type:a}=t;if(a==="objectdestroy")this.isDestroyed=!0;else if(a==="spatialtap"){let r=m("spatialtap",t.detail);this.dispatchEvent(r)}else if(a==="spatialdragstart"){let r=m("spatialdragstart",t.detail);this.dispatchEvent(r)}else if(a==="spatialdrag"){let r=m("spatialdrag",t.detail);this.dispatchEvent(r)}else if(a==="spatialdragend"){let r=m("spatialdragend",t.detail);this.dispatchEvent(r)}else if(a==="spatialrotate"){let r=m("spatialrotate",t.detail);this.dispatchEvent(r)}else if(a==="spatialrotateend"){let r=m("spatialrotateend",t.detail);this.dispatchEvent(r)}else if(a==="spatialmagnify"){let r=m("spatialmagnify",t.detail);this.dispatchEvent(r)}else if(a==="spatialmagnifyend"){let r=m("spatialmagnifyend",t.detail);this.dispatchEvent(r)}};dispatchEvent(t){t.__origin||Object.defineProperty(t,"__origin",{value:this,enumerable:!1}),this.events[t.type]?.(t),t.bubbles&&!t.cancelBubble&&this.parent&&this.parent instanceof i&&this.parent.dispatchEvent(t)}onDestroy(){c.removeEventReceiver(this.id),this.children.forEach(t=>{t.parent=null}),this.children=[],this.parent&&(this.parent.children=this.parent.children.filter(t=>t.id!==this.id),this.parent=null)}async convertFromEntityToEntity(t,a,r){return new bt(t,a,r).execute()}async convertFromEntityToScene(t,a){return new xt(t,a).execute()}async convertFromSceneToEntity(t,a){return new vt(t,a).execute()}};var A=class extends D{constructor(t,a,r){super(t,r);this.id=t;this.options=a;this.userData=r}};P();var _=class extends d{constructor(e){super(e),c.addEventReceiver(e,this.onReceiveEvent)}onReceiveEvent=e=>{let{type:t}=e;t==="objectdestroy"&&(this.isDestroyed=!0)}};var B=class extends _{constructor(t,a){super(t);this.options=a}};S();var L=class extends d{constructor(t,a){super(t);this.id=t;this.type=a;this.type=a}};var U=class extends L{constructor(t,a){super(t,"unlit");this.id=t;this.options=a}updateProperties(t){return new ot(this,t).execute()}};var j=class extends d{constructor(t,a){super(t);this.id=t;this.options=a}};async function Me(i){let e=await new ut(i?.name).execute();if(e.success){let{id:t}=e.data;return new D(t,i)}else throw new Error("createSpatialEntity failed:"+e?.errorMessage)}async function O(i,e){let t=await new gt(i.type,e).execute();if(t.success){let{id:a}=t.data;return new i(a,e)}else throw new Error("createSpatialGeometry failed:"+t?.errorMessage)}async function De(i){let e=await new ht(i).execute();if(e.success){let{id:t}=e.data;return new U(t,i)}else throw new Error("createSpatialUnlitMaterial failed:"+e?.errorMessage)}async function Re(i){let e=await new yt(i).execute();if(e.success){let{id:t}=e.data;return new B(t,i)}else throw new Error("createModelComponent failed:"+e?.errorMessage)}async function Te(i,e){let t=await new St(i).execute();if(t.success){let{id:a}=t.data;return new A(a,i,e)}else throw new Error("createSpatialModelEntity failed:"+t?.errorMessage)}async function Ce(i){let e=await new ft(i).execute();if(e.success){let{id:t}=e.data;return new j(t,i)}else throw new Error("createModelAsset failed:"+e?.errorMessage)}var f=class extends d{constructor(t,a){super(t);this.id=t;this.options=a}static type};var k=class extends f{constructor(t,a){super(t,a);this.id=t;this.options=a}static type="BoxGeometry"};var F=class extends f{constructor(t,a){super(t,a);this.id=t;this.options=a}static type="SphereGeometry"};var N=class extends f{constructor(t,a){super(t,a);this.id=t;this.options=a}static type="CylinderGeometry"};var $=class extends f{constructor(t,a){super(t,a);this.id=t;this.options=a}static type="PlaneGeometry"};var J=class extends f{constructor(t,a){super(t,a);this.id=t;this.options=a}static type="ConeGeometry"};var z=class{getSpatialScene(){return b.getInstance()}createSpatialized2DElement(){return ve()}createSpatializedStatic3DElement(e=""){return we(e)}initScene=be;createSpatializedDynamic3DElement(){return Pe()}createEntity(e){return Me(e)}createBoxGeometry(e={}){return O(k,e)}createPlaneGeometry(e={}){return O($,e)}createSphereGeometry(e={}){return O(F,e)}createConeGeometry(e){return O(J,e)}createCylinderGeometry(e){return O(N,e)}createModelComponent(e){return Re(e)}createUnlitMaterial(e){return De(e)}createModelAsset(e){return Ce(e)}createSpatialModelEntity(e,t){return Te(e,t)}};P();var I=class{requestSession(){return this.runInSpatialWeb()?(c.init(),new z):null}runInSpatialWeb(){return navigator.userAgent.indexOf("WebSpatial/")>0}isSupported(){return!0}getNativeVersion(){return window.__WebSpatialData&&window.__WebSpatialData.getNativeVersion?window.__WebSpatialData.getNativeVersion():window.WebSpatailNativeVersion==="PACKAGE_VERSION"?this.getClientVersion():window.WebSpatailNativeVersion}getClientVersion(){return"1.2.0"}};At();Ft();var Oe=new I,Gt,Ot={backgroundMaterial:"--xr-background-material"},ze="";function zt(i){i!==ze&&(Gt?.getSpatialScene()?.updateSpatialProperties({material:i}),ze=i)}function Ze(){let e=getComputedStyle(document.documentElement).getPropertyValue(Ot.backgroundMaterial);zt(e||"none")}var v={topLeading:0,bottomLeading:0,topTrailing:0,bottomTrailing:0};function Ie(){let i=getComputedStyle(document.documentElement),e=le(i);Ye(e)}function Ye(i){(v.topLeading!==i.topLeading||v.bottomLeading!==i.bottomLeading||v.topTrailing!==i.topTrailing||v.bottomTrailing!==i.bottomTrailing)&&(Gt?.getSpatialScene()?.updateSpatialProperties({cornerRadius:i}),v.topLeading=i.topLeading,v.bottomLeading=i.bottomLeading,v.topTrailing=i.topTrailing,v.bottomTrailing=i.bottomTrailing)}function ti(i){Gt?.getSpatialScene().updateSpatialProperties({opacity:i})}function Ge(){let i=getComputedStyle(document.documentElement),e=parseFloat(i.getPropertyValue("opacity"));ti(e)}function ei(){let i=document.documentElement.style,e=new Proxy(i,{set:function(t,a,r){let n=Reflect.set(t,a,r);return a===Ot.backgroundMaterial&&zt(r),(a==="border-radius"||a==="borderRadius"||a==="border-top-left-radius"||a==="borderTopLeftRadius"||a==="border-top-right-radius"||a==="borderTopRightRadius"||a==="border-bottom-left-radius"||a==="borderBottomLeftRadius"||a==="border-bottom-right-radius"||a==="borderBottomRightRadius")&&Ie(),a==="opacity"&&Ge(),n},get:function(t,a){return typeof t[a]=="function"?function(...r){if(a==="setProperty"){let[n,o]=r;n===Ot.backgroundMaterial&&zt(o)}else if(a==="removeProperty"){let[n]=r;n===Ot.backgroundMaterial&&zt("none")}return t[a](...r)}:Reflect.get(t,a)}});Object.defineProperty(document.documentElement,"style",{get:function(){return e}})}function ii(){new MutationObserver(It).observe(document.head,{childList:!0,subtree:!0})}function It(){Ze(),Ie(),Ge()}function ai(){new MutationObserver(e=>{e.forEach(t=>{t.type==="attributes"&&t.attributeName&&It()})}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}async function We(){Oe.runInSpatialWeb()&&(Gt=await Oe.requestSession(),document.readyState==="complete"?It():window.addEventListener("load",()=>{It()}),ei(),ii(),ai())}!G()&&navigator.userAgent.indexOf("WebSpatial/")>0&&(xe(),We());return H(ri);})();
|
|
10
10
|
//# sourceMappingURL=index.global.js.map
|