@webspatial/core-sdk 0.1.5 → 0.1.7

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 (76) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.d.ts +712 -2
  3. package/dist/index.js +1500 -1
  4. package/dist/index.js.map +1 -0
  5. package/package.json +6 -5
  6. package/tsup.config.ts +23 -0
  7. package/dist/core/Spatial.d.ts +0 -27
  8. package/dist/core/Spatial.d.ts.map +0 -1
  9. package/dist/core/Spatial.js +0 -41
  10. package/dist/core/SpatialEntity.d.ts +0 -92
  11. package/dist/core/SpatialEntity.d.ts.map +0 -1
  12. package/dist/core/SpatialEntity.js +0 -122
  13. package/dist/core/SpatialHelper.d.ts +0 -39
  14. package/dist/core/SpatialHelper.d.ts.map +0 -1
  15. package/dist/core/SpatialHelper.js +0 -195
  16. package/dist/core/SpatialObject.d.ts +0 -20
  17. package/dist/core/SpatialObject.d.ts.map +0 -1
  18. package/dist/core/SpatialObject.js +0 -23
  19. package/dist/core/SpatialSession.d.ts +0 -164
  20. package/dist/core/SpatialSession.d.ts.map +0 -1
  21. package/dist/core/SpatialSession.js +0 -318
  22. package/dist/core/SpatialTransform.d.ts +0 -23
  23. package/dist/core/SpatialTransform.d.ts.map +0 -1
  24. package/dist/core/SpatialTransform.js +0 -31
  25. package/dist/core/SpatialWindowContainer.d.ts +0 -31
  26. package/dist/core/SpatialWindowContainer.d.ts.map +0 -1
  27. package/dist/core/SpatialWindowContainer.js +0 -48
  28. package/dist/core/component/EventSpatialComponent.d.ts +0 -22
  29. package/dist/core/component/EventSpatialComponent.d.ts.map +0 -1
  30. package/dist/core/component/EventSpatialComponent.js +0 -23
  31. package/dist/core/component/SpatialComponent.d.ts +0 -11
  32. package/dist/core/component/SpatialComponent.d.ts.map +0 -1
  33. package/dist/core/component/SpatialComponent.js +0 -23
  34. package/dist/core/component/SpatialInputComponent.d.ts +0 -22
  35. package/dist/core/component/SpatialInputComponent.d.ts.map +0 -1
  36. package/dist/core/component/SpatialInputComponent.js +0 -14
  37. package/dist/core/component/SpatialModel3DComponent.d.ts +0 -91
  38. package/dist/core/component/SpatialModel3DComponent.d.ts.map +0 -1
  39. package/dist/core/component/SpatialModel3DComponent.js +0 -185
  40. package/dist/core/component/SpatialModelComponent.d.ts +0 -22
  41. package/dist/core/component/SpatialModelComponent.d.ts.map +0 -1
  42. package/dist/core/component/SpatialModelComponent.js +0 -34
  43. package/dist/core/component/SpatialViewComponent.d.ts +0 -22
  44. package/dist/core/component/SpatialViewComponent.d.ts.map +0 -1
  45. package/dist/core/component/SpatialViewComponent.js +0 -30
  46. package/dist/core/component/SpatialWindowComponent.d.ts +0 -86
  47. package/dist/core/component/SpatialWindowComponent.d.ts.map +0 -1
  48. package/dist/core/component/SpatialWindowComponent.js +0 -114
  49. package/dist/core/component/index.d.ts +0 -7
  50. package/dist/core/component/index.d.ts.map +0 -1
  51. package/dist/core/component/index.js +0 -6
  52. package/dist/core/index.d.ts +0 -11
  53. package/dist/core/index.d.ts.map +0 -1
  54. package/dist/core/index.js +0 -9
  55. package/dist/core/private/WebSpatial.d.ts +0 -46
  56. package/dist/core/private/WebSpatial.d.ts.map +0 -1
  57. package/dist/core/private/WebSpatial.js +0 -282
  58. package/dist/core/private/remote-command/RemoteCommand.d.ts +0 -8
  59. package/dist/core/private/remote-command/RemoteCommand.d.ts.map +0 -1
  60. package/dist/core/private/remote-command/RemoteCommand.js +0 -11
  61. package/dist/core/private/remote-command/index.d.ts +0 -2
  62. package/dist/core/private/remote-command/index.d.ts.map +0 -1
  63. package/dist/core/private/remote-command/index.js +0 -1
  64. package/dist/core/resource/SpatialMeshResource.d.ts +0 -7
  65. package/dist/core/resource/SpatialMeshResource.d.ts.map +0 -1
  66. package/dist/core/resource/SpatialMeshResource.js +0 -6
  67. package/dist/core/resource/SpatialPhysicallyBasedMaterialResource.d.ts +0 -37
  68. package/dist/core/resource/SpatialPhysicallyBasedMaterialResource.d.ts.map +0 -1
  69. package/dist/core/resource/SpatialPhysicallyBasedMaterialResource.js +0 -37
  70. package/dist/core/resource/index.d.ts +0 -3
  71. package/dist/core/resource/index.d.ts.map +0 -1
  72. package/dist/core/resource/index.js +0 -2
  73. package/dist/core/types.d.ts +0 -23
  74. package/dist/core/types.d.ts.map +0 -1
  75. package/dist/core/types.js +0 -1
  76. package/dist/index.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,2 +1,712 @@
1
- export * from './core/index';
2
- //# sourceMappingURL=index.d.ts.map
1
+ type WindowStyle = 'Plain' | 'Volumetric';
2
+ interface WindowContainerOptions {
3
+ defaultSize?: {
4
+ width: number;
5
+ height: number;
6
+ };
7
+ resizability?: 'automatic' | 'contentSize' | 'contentMinSize';
8
+ }
9
+ type LoadingMethodKind = 'show' | 'hide';
10
+ interface sceneDataShape {
11
+ method?: 'createRoot' | 'showRoot';
12
+ sceneConfig?: WindowContainerOptions;
13
+ url?: string;
14
+ window: Window;
15
+ }
16
+ interface sceneDataJSBShape {
17
+ method?: 'createRoot' | 'showRoot';
18
+ sceneConfig?: WindowContainerOptions;
19
+ url?: string;
20
+ windowID?: string;
21
+ windowContainerID?: string;
22
+ }
23
+
24
+ declare class WindowContainer {
25
+ id: string;
26
+ }
27
+ declare class WebSpatialResource {
28
+ id: string;
29
+ windowContainerId: string;
30
+ data: any;
31
+ receiveEvent(): void;
32
+ }
33
+
34
+ /**
35
+ * @hidden
36
+ * Parent class of spatial objects, should not be used directly
37
+ */
38
+ declare class SpatialObject {
39
+ /** @hidden */
40
+ _resource: WebSpatialResource;
41
+ /** @hidden */
42
+ constructor(
43
+ /** @hidden */
44
+ _resource: WebSpatialResource);
45
+ /**
46
+ * Marks resource to be released (it should no longer be used)
47
+ */
48
+ destroy(): Promise<void>;
49
+ name: string;
50
+ protected onDestroy(): Promise<void>;
51
+ }
52
+
53
+ declare class Vec3 {
54
+ x: number;
55
+ y: number;
56
+ z: number;
57
+ constructor(x?: number, y?: number, z?: number);
58
+ }
59
+ declare class Vec4 {
60
+ x: number;
61
+ y: number;
62
+ z: number;
63
+ w: number;
64
+ constructor(x?: number, y?: number, z?: number, w?: number);
65
+ }
66
+ /**
67
+ * Transform containing position, orientation and scale
68
+ */
69
+ declare class SpatialTransform {
70
+ position: Vec3;
71
+ /** Quaternion value for x,y,z,w */
72
+ orientation: Vec4;
73
+ scale: Vec3;
74
+ }
75
+
76
+ /**
77
+ * Anchored window managed by the OS
78
+ */
79
+ declare class SpatialWindowContainer {
80
+ /** @hidden */
81
+ _wg: WindowContainer;
82
+ /** @hidden */
83
+ constructor(
84
+ /** @hidden */
85
+ _wg: WindowContainer);
86
+ /**
87
+ * @hidden
88
+ * Sets sets the open configuration for opening new window containers
89
+ * @param options style options
90
+ */
91
+ _setOpenSettings(options: {
92
+ resolution: {
93
+ width: number;
94
+ height: number;
95
+ };
96
+ }): Promise<void>;
97
+ /**
98
+ * Retrieves the root entity of the windowContainer
99
+ * @returns the root entity of the windowContainer if one exists
100
+ */
101
+ getRootEntity(): Promise<SpatialEntity | null>;
102
+ setRootEntity(entity: SpatialEntity): Promise<void>;
103
+ }
104
+
105
+ /**
106
+ * Entity used to describe an object that can be added to the scene
107
+ */
108
+ declare class SpatialEntity extends SpatialObject {
109
+ /**
110
+ * Transform corresponding to the entity
111
+ * note: updateTransform must be called for transform to be synced to rendering
112
+ */
113
+ transform: SpatialTransform;
114
+ /** @hidden */
115
+ private _destroyed;
116
+ /** @hidden */
117
+ private get _entity();
118
+ /**
119
+ * Syncs the transform with the renderer, must be called to observe updates
120
+ */
121
+ updateTransform(): Promise<void>;
122
+ /**
123
+ * Syncs the zIndex with the renderer
124
+ */
125
+ updateZIndex(zIndex: number): Promise<void>;
126
+ private components;
127
+ /**
128
+ * Attaches a component to the entity to be displayed
129
+ * [TODO] review pass by value vs ref and ownership model for this
130
+ */
131
+ setComponent(component: SpatialComponent): Promise<void>;
132
+ /**
133
+ * Removes a component from the entity
134
+ */
135
+ removeComponent<T extends SpatialComponent>(type: new (...args: any[]) => T): Promise<void>;
136
+ /**
137
+ * Gets a component from the entity
138
+ */
139
+ getComponent<T extends SpatialComponent>(type: new (...args: any[]) => T): T | undefined;
140
+ /**
141
+ * @hidden
142
+ * Sets the window container that this entity should be rendered by (this does not effect resource ownership)
143
+ * @param wg the window container that should render this entity
144
+ */
145
+ _setParentWindowContainer(wg: SpatialWindowContainer): Promise<void>;
146
+ /**
147
+ * Sets a parent entity, if that entity or its parents are attached to a window container, this entity will be displayed
148
+ * @param e parent entity or null to remove current parent
149
+ */
150
+ setParent(e: SpatialEntity | null): Promise<void>;
151
+ /**
152
+ * Sets the coordinate space of this entity (Default: App)
153
+ * "App" = game engine style coordinates in meters
154
+ * "Dom" = Windowing coordinates in dom units (eg. 0,0,0 is top left of window)
155
+ * "Root" = Coordinate space is ignored and content is displayed and updated as window container's root object, window containers can only have one root entity
156
+ * [TODO] review this api
157
+ * @param space coordinate space mode
158
+ */
159
+ setCoordinateSpace(space: 'App' | 'Dom' | 'Root'): Promise<void>;
160
+ /**
161
+ * Query the 3d boudning box of the entity
162
+ * @returns The bounding box of the entity
163
+ */
164
+ getBoundingBox(): Promise<{
165
+ center: {
166
+ x: number;
167
+ y: number;
168
+ z: number;
169
+ };
170
+ extents: {
171
+ x: number;
172
+ y: number;
173
+ z: number;
174
+ };
175
+ }>;
176
+ /**
177
+ * Sets if the entity should be visible (default: True)
178
+ * @param visible
179
+ */
180
+ setVisible(visible: boolean): Promise<void>;
181
+ /**
182
+ * Removes a reference to the entity by the renderer and this object should no longer be used. [TODO] Attached components will not be destroyed
183
+ */
184
+ destroy(): Promise<void>;
185
+ /**
186
+ * Check if destroy has been called
187
+ */
188
+ isDestroyed(): boolean;
189
+ /** @hidden */
190
+ _setName(name: string): Promise<unknown>;
191
+ }
192
+
193
+ /** @hidden */
194
+ declare class SpatialComponent extends SpatialObject {
195
+ /**
196
+ * Gets the entity this component is attached to
197
+ * @returns entity or null
198
+ */
199
+ getEntity(): Promise<SpatialEntity | null>;
200
+ }
201
+
202
+ /**
203
+ * Material type for SpatialDiv or HTML document.
204
+ *
205
+ * This type defines the background material options for both SpatialDiv elements and HTML documents.
206
+ *
207
+ * - `'none'`: This is the default value.
208
+ * - For HTML documents, the web page window will have the default native background.
209
+ * - For SpatialDiv, the window will have a transparent background.
210
+ * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).
211
+ * - `'thick'`: Represents a thick material in AVP.
212
+ * - `'regular'`: Represents a regular material in AVP.
213
+ * - `'thin'`: Represents a thin material in AVP.
214
+ * - `'transparent'`: Represents a fully transparent background.
215
+ */
216
+ type BackgroundMaterialType = 'none' | 'translucent' | 'thick' | 'regular' | 'thin' | 'transparent';
217
+ type CornerRadius = {
218
+ topLeading: number;
219
+ bottomLeading: number;
220
+ topTrailing: number;
221
+ bottomTrailing: number;
222
+ };
223
+ type StyleParam = {
224
+ material?: {
225
+ type: BackgroundMaterialType;
226
+ };
227
+ cornerRadius?: number | CornerRadius;
228
+ };
229
+ /**
230
+ * Used to position an web window in 3D space
231
+ */
232
+ declare class SpatialWindowComponent extends SpatialComponent {
233
+ /**
234
+ * Loads a url page in the window
235
+ * @param url url to load
236
+ */
237
+ loadURL(url: string): Promise<void>;
238
+ setFromWindow(window: any): Promise<void>;
239
+ /**
240
+ * Sets the resolution of the window, the resulting dimensions when rendered will be equal to 1/1360 units
241
+ * eg. if the resolution is set to 1360x1360 it will be a 1x1 plane
242
+ * See 1360 in spatialViewUI.swift for how this ratio works
243
+ * @param width width in pixels
244
+ * @param height height in pixels
245
+ */
246
+ setResolution(width: number, height: number): Promise<void>;
247
+ /**
248
+ * [Experimental] Sets the anchor which the entity this is attached to will rotate around
249
+ * @param rotationAnchor
250
+ */
251
+ setRotationAnchor(rotationAnchor: Vec3): Promise<void>;
252
+ /**
253
+ * [Experimental] Sets the opacity of the window after apply material
254
+ * @param opacity
255
+ */
256
+ setOpacity(opacity: number): Promise<void>;
257
+ /**
258
+ * Sets the style that should be applied to the window
259
+ * @param options style options
260
+ */
261
+ setStyle(styleParam: StyleParam): Promise<void>;
262
+ /**
263
+ * Modifies the amount the spatial window can be scrolled
264
+ * Should only be used internally
265
+ * See https://developer.apple.com/documentation/uikit/1624475-uiedgeinsetsmake?language=objc
266
+ * @param insets margin to modify scroll distances by
267
+ */
268
+ setScrollEdgeInsets(insets: {
269
+ top: number;
270
+ left: number;
271
+ bottom: number;
272
+ right: number;
273
+ }): Promise<void>;
274
+ /**
275
+ * Enable/Disable scrolling in the window (defaults to enabled), if disabled, scrolling will be applied to the root page
276
+ * @param enabled value to set
277
+ */
278
+ setScrollEnabled(enabled: boolean): Promise<void>;
279
+ /**
280
+ * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
281
+ * @param scrollWithParent value to set
282
+ */
283
+ setScrollWithParent(scrollWithParent: boolean): Promise<void>;
284
+ }
285
+
286
+ /**
287
+ * @description
288
+ * Represents a spatial component that handles events related to spatial interactions.
289
+ * This class extends `SpatialComponent` and provides additional functionality for managing
290
+ * event-driven spatial behaviors.
291
+ *
292
+ * @hidden
293
+ * This class is intended for internal use and should not be exposed in the public API.
294
+ */
295
+ declare abstract class EventSpatialComponent extends SpatialComponent {
296
+ constructor(_resource: WebSpatialResource);
297
+ /**
298
+ * @description
299
+ * Abstract method to be implemented by subclasses. Called when a spatial event is received.
300
+ * @param data The data associated with the received event.
301
+ */
302
+ protected abstract onRecvEvent(data: any): void;
303
+ protected onDestroy(): Promise<void>;
304
+ }
305
+
306
+ /**
307
+ * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
308
+ */
309
+ type TranslateEvent = {
310
+ eventType: 'dragstart' | 'dragend' | 'drag';
311
+ translate?: Vec3;
312
+ };
313
+ /**
314
+ * Used to handle input events on an entity
315
+ */
316
+ declare class SpatialInputComponent extends EventSpatialComponent {
317
+ protected onRecvEvent(data: any): void;
318
+ /**
319
+ * Callback fired when a translate event occurs
320
+ * @param data translate event data
321
+ */
322
+ onTranslate(data: TranslateEvent): void;
323
+ }
324
+
325
+ /**
326
+ * Mesh asset containing geometry
327
+ */
328
+ declare class SpatialMeshResource extends SpatialObject {
329
+ }
330
+
331
+ /**
332
+ * PBR material which can be set on a SpatialModelComponent
333
+ */
334
+ declare class SpatialPhysicallyBasedMaterialResource extends SpatialObject {
335
+ /**
336
+ * Base color of the material containing rgba between 0 and 1
337
+ */
338
+ baseColor: {
339
+ r: number;
340
+ g: number;
341
+ b: number;
342
+ a: number;
343
+ };
344
+ /**
345
+ * PBR metalic value between 0 and 1
346
+ */
347
+ metallic: {
348
+ value: number;
349
+ };
350
+ /**
351
+ * PBR roughness value between 0 and 1
352
+ */
353
+ roughness: {
354
+ value: number;
355
+ };
356
+ _modelComponentAttachedTo: {
357
+ [key: string]: SpatialModelComponent;
358
+ };
359
+ _addToComponent(c: SpatialModelComponent): void;
360
+ /**
361
+ * Syncs state of color, metallic, roupghness to the renderer
362
+ */
363
+ update(): Promise<void>;
364
+ }
365
+
366
+ /**
367
+ * Used to position a model in 3D space, made up of a mesh and materials to be applied to the mesh
368
+ */
369
+ declare class SpatialModelComponent extends SpatialComponent {
370
+ private cachedMaterials;
371
+ /**
372
+ * Sets the mesh to be displayed by the component
373
+ * @param mesh mesh to set
374
+ */
375
+ setMesh(mesh: SpatialMeshResource): Promise<void>;
376
+ /**
377
+ * Sets the materials that should be applied to the mesh
378
+ * @param materials array of materials to set
379
+ */
380
+ setMaterials(materials: Array<SpatialPhysicallyBasedMaterialResource>): Promise<void>;
381
+ /** @hidden */
382
+ _syncMaterials(): Promise<void>;
383
+ }
384
+
385
+ /**
386
+ * Represenets a volume that can be added to the webpage
387
+ * Child entities will be added within this volume's space
388
+ * Defaults to having 1x1x1 meter dimensions
389
+ * Resolution defaults to 100x100 pixels
390
+ * Only will be displayed on entities in "ROOT" or "DOM" space
391
+ * If the resolution of the spatial view is not a square, the volume will be larger based on the ratio with the shortest side being 1 meter.
392
+ * (eg. 200x100 = 2m x 1m x 1m volume)
393
+ */
394
+ declare class SpatialViewComponent extends SpatialComponent {
395
+ /**
396
+ * Sets the resolution of the spatial view in dom pixels
397
+ */
398
+ setResolution(width: number, height: number): Promise<void>;
399
+ /**
400
+ * Sets if content of the spatialView should be within a portal
401
+ * If true, volume will be behind the page, if false, it will be in front of the page
402
+ */
403
+ setIsPortal(isPortal: Boolean): Promise<void>;
404
+ }
405
+
406
+ /**
407
+ * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
408
+ */
409
+ type SpatialModelDragEvent = {
410
+ eventType: 'dragstart' | 'dragend' | 'drag';
411
+ translation3D: Vec3;
412
+ startLocation3D: Vec3;
413
+ };
414
+ /**
415
+ * Used to position a model3d in 3D space
416
+ */
417
+ declare class SpatialModel3DComponent extends EventSpatialComponent {
418
+ protected onRecvEvent(data: any): void;
419
+ /**
420
+ * Sets the resolution of the spatial view in dom pixels
421
+ */
422
+ setResolution(width: number, height: number): Promise<void>;
423
+ setRotationAnchor(rotationAnchor: Vec3): Promise<void>;
424
+ /**
425
+ * Sets the opacity of the model
426
+ * @param opacity
427
+ */
428
+ setOpacity(opacity: number): Promise<void>;
429
+ /**
430
+ * Sets how the model fill the rect
431
+ * @param contentMode
432
+ */
433
+ setContentMode(contentMode: 'fill' | 'fit'): Promise<void>;
434
+ /**
435
+ * Constrains this model dimensions to the specified aspect ratio.
436
+ * with a value of 0, the model will use the original aspect ratio.
437
+ *
438
+ * @param aspectRatio number
439
+ */
440
+ setAspectRatio(aspectRatio: number): Promise<void>;
441
+ /**
442
+ * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
443
+ * @param scrollWithParent value to set
444
+ */
445
+ setScrollWithParent(scrollWithParent: boolean): Promise<void>;
446
+ /**
447
+ * Sets whether the model appear in original size or fit the rect
448
+ * @param resizable
449
+ */
450
+ setResizable(resizable: boolean): Promise<void>;
451
+ /**
452
+ * Callback fired when model load success
453
+ */
454
+ onSuccess?: () => void;
455
+ /**
456
+ * Callback fired when model load failure
457
+ * @param errorReason
458
+ */
459
+ onFailure?: (errorReason: string) => void;
460
+ /**
461
+ * Callback fired when model was dragged at the beginning
462
+ * @param dragEvent
463
+ */
464
+ private _onDragStart?;
465
+ set onDragStart(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
466
+ /**
467
+ * Callback fired when model was dragged
468
+ * @param dragEvent
469
+ */
470
+ private _onDrag?;
471
+ set onDrag(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
472
+ /**
473
+ * Callback fired when model was dragged at the ending
474
+ * @param dragEvent
475
+ */
476
+ private _onDragEnd?;
477
+ set onDragEnd(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
478
+ private get enableDragEvent();
479
+ /**
480
+ * Callback fired when model was tapped
481
+ */
482
+ private _onTap?;
483
+ set onTap(callback: (() => void) | undefined);
484
+ /** Callback fired when model was double tapped */
485
+ private _onDoubleTap?;
486
+ set onDoubleTap(callback: (() => void) | undefined);
487
+ /** Callback fired when model was long pressed */
488
+ private _onLongPress?;
489
+ set onLongPress(callback: (() => void) | undefined);
490
+ }
491
+
492
+ type CreateResourceOptions = {
493
+ windowContainer?: SpatialWindowContainer | null;
494
+ windowComponent?: SpatialWindowComponent | null;
495
+ };
496
+ /**
497
+ * Animation callback with timestamp
498
+ */
499
+ type animCallback = (time: DOMHighResTimeStamp) => Promise<any>;
500
+ /**
501
+ * Session use to establish a connection to the spatial renderer of the system. All resources must be created by the session
502
+ */
503
+ declare class SpatialSession {
504
+ /** @hidden */
505
+ _engineUpdateListeners: animCallback[];
506
+ /** @hidden */
507
+ _frameLoopStarted: boolean;
508
+ /**
509
+ * Add event listener callback to be called each frame
510
+ * @param callback callback to be called each update
511
+ */
512
+ addOnEngineUpdateEventListener(callback: animCallback): void;
513
+ /**
514
+ * Creates a Entity
515
+ * @returns Entity
516
+ */
517
+ createEntity(options?: CreateResourceOptions): Promise<SpatialEntity>;
518
+ /**
519
+ * Creates a WindowComponent
520
+ * [TODO] should creation of components be moved to entity? and these made private?
521
+ * @returns WindowComponent
522
+ */
523
+ createWindowComponent(options?: CreateResourceOptions): Promise<SpatialWindowComponent>;
524
+ /**
525
+ * Creates a ViewComponent used to display 3D content within the entity
526
+ * @returns SpatialViewComponent
527
+ */
528
+ createViewComponent(options?: CreateResourceOptions): Promise<SpatialViewComponent>;
529
+ /**
530
+ * Creates a ModelComponent used to display geometry + material of a 3D model
531
+ * @returns ModelComponent
532
+ */
533
+ createModelComponent(options?: {
534
+ url: string;
535
+ } & CreateResourceOptions): Promise<SpatialModelComponent>;
536
+ /**
537
+ * Creates a Model3DComponent
538
+ * @returns Model3DComponent
539
+ */
540
+ createModel3DComponent(options?: {
541
+ url: string;
542
+ } & CreateResourceOptions): Promise<SpatialModel3DComponent>;
543
+ /**
544
+ * Creates a InputComponent
545
+ * [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model
546
+ * @returns InputComponent
547
+ */
548
+ createInputComponent(options?: CreateResourceOptions): Promise<SpatialInputComponent>;
549
+ /**
550
+ * Creates a MeshResource containing geometry data
551
+ * @returns MeshResource
552
+ */
553
+ createMeshResource(options?: {
554
+ shape?: string;
555
+ } & CreateResourceOptions): Promise<SpatialMeshResource>;
556
+ /**
557
+ * Creates a PhysicallyBasedMaterial containing PBR material data
558
+ * @returns PhysicallyBasedMaterial
559
+ */
560
+ createPhysicallyBasedMaterialResource(options?: {} & CreateResourceOptions): Promise<SpatialPhysicallyBasedMaterialResource>;
561
+ /**
562
+ * Creates a WindowContainer
563
+ * @returns SpatialWindowContainer
564
+ * */
565
+ createWindowContainer(options?: {
566
+ style: WindowStyle;
567
+ } & CreateResourceOptions): Promise<SpatialWindowContainer>;
568
+ /**
569
+ * Creates a Scene to display content within an anchored area managed by the OS
570
+ * @hidden
571
+ * @param {WindowStyle} [style='Plain'] - The style of the Scene container to be created with. Defaults to 'Plain'.
572
+ * @param {Object} [cfg={}] - Configuration object for the Scene.
573
+ * @returns Boolean
574
+ */
575
+ _createScene(style: WindowStyle | undefined, cfg: {
576
+ sceneData: sceneDataShape;
577
+ }): Promise<boolean>;
578
+ /**
579
+ * Retrieves the window for this page
580
+ * @returns the window component corresponding to the js running on this page
581
+ * [TODO] discuss implications of this not being async
582
+ */
583
+ getCurrentWindowComponent(): SpatialWindowComponent;
584
+ /**
585
+ * Retrieves the parent window for this page or null if this is the root page
586
+ * @returns the window component or null
587
+ */
588
+ getParentWindowComponent(): Promise<SpatialWindowComponent | null>;
589
+ /**
590
+ * Logs a message to the native apps console
591
+ * @param msg mesage to log
592
+ */
593
+ log(...msg: any[]): Promise<void>;
594
+ /**
595
+ * @hidden
596
+ * Debugging only, used to ping the native renderer
597
+ */
598
+ _ping(msg: string): Promise<unknown>;
599
+ /**
600
+ * @hidden
601
+ * Debugging to get internal state from native code
602
+ * @returns data as a js object
603
+ */
604
+ _getStats(): Promise<{
605
+ objects: any;
606
+ refObjects: any;
607
+ }>;
608
+ /**
609
+ * @hidden
610
+ */
611
+ _inspect(spatialObjectId?: string): Promise<any>;
612
+ /**
613
+ * @hidden
614
+ */
615
+ _inspectRootWindowContainer(): Promise<any>;
616
+ /** Opens the immersive space */
617
+ openImmersiveSpace(): Promise<void>;
618
+ /** Closes the immersive space */
619
+ dismissImmersiveSpace(): Promise<void>;
620
+ private static _immersiveWindowContainer;
621
+ /**
622
+ * Retreives the window container corresponding to the Immersive space
623
+ * @returns the immersive window container
624
+ */
625
+ getImmersiveWindowContainer(): Promise<SpatialWindowContainer>;
626
+ private static _currentWindowContainer;
627
+ /**
628
+ * Gets the current window container for the window
629
+ * [TODO] discuss what happens if it doesnt yet have a window container
630
+ * @returns the current window container for the window
631
+ */
632
+ getCurrentWindowContainer(): SpatialWindowContainer;
633
+ /**
634
+ * Start a transaction that queues up commands to submit them all at once to reduce ipc overhead
635
+ * @param fn function to be run, within this function, promises will not resolve
636
+ * @returns promise for the entire transaction completion
637
+ */
638
+ transaction(fn: Function): Promise<unknown>;
639
+ /**
640
+ * Creates a window context object that is compatable with SpatialWindowComponent's setFromWindow API
641
+ * @returns window context
642
+ */
643
+ createWindowContext(): Promise<Window | null>;
644
+ /** @hidden */
645
+ _getEntity(id: string): Promise<SpatialEntity>;
646
+ /** @hidden */
647
+ setLoading(method: LoadingMethodKind, style?: string): Promise<unknown>;
648
+ }
649
+
650
+ /**
651
+ * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr
652
+ */
653
+ declare class Spatial {
654
+ /**
655
+ * Requests a session object from the browser
656
+ * @returns The session or null if not availible in the current browser
657
+ * [TODO] discuss implications of this not being async
658
+ */
659
+ requestSession(): SpatialSession | null;
660
+ /**
661
+ * @returns true if web spatial is supported by this webpage
662
+ */
663
+ isSupported(): any;
664
+ /**
665
+ * Gets the native version, format is "x.x.x"
666
+ * @returns native version string
667
+ */
668
+ getNativeVersion(): any;
669
+ /**
670
+ * Gets the client version, format is "x.x.x"
671
+ * @returns client version string
672
+ */
673
+ getClientVersion(): string;
674
+ }
675
+
676
+ /**
677
+ * Helper class used to quickly add spatial content to standard web pages
678
+ * [Experimental] expect APIs to potentially change in future versions
679
+ */
680
+ declare class SpatialHelper {
681
+ session: SpatialSession;
682
+ private static _instance;
683
+ static get instance(): SpatialHelper | null;
684
+ constructor(session: SpatialSession);
685
+ shape: {
686
+ createShapeEntity: (shape?: string) => Promise<SpatialEntity>;
687
+ createModelEntity: (url: string) => Promise<SpatialEntity>;
688
+ wrapInBoundingBoxEntity: (entityToWrap: SpatialEntity) => Promise<SpatialEntity>;
689
+ };
690
+ navigation: {
691
+ openPanel: (url: string, options?: {
692
+ resolution: {
693
+ width: number;
694
+ height: number;
695
+ };
696
+ }) => Promise<void>;
697
+ openVolume: (url: string, options?: {
698
+ resolution: {
699
+ width: number;
700
+ height: number;
701
+ };
702
+ }) => Promise<void>;
703
+ };
704
+ dom: {
705
+ attachSpatialView: (divOnPage: HTMLElement) => Promise<{
706
+ entity: SpatialEntity;
707
+ }>;
708
+ };
709
+ setBackgroundStyle: (style: StyleParam, backgroundColor?: string) => Promise<void>;
710
+ }
711
+
712
+ export { type BackgroundMaterialType, type CornerRadius, type LoadingMethodKind, Spatial, SpatialComponent, SpatialEntity, SpatialHelper, SpatialInputComponent, SpatialMeshResource, SpatialModel3DComponent, SpatialModelComponent, type SpatialModelDragEvent, SpatialPhysicallyBasedMaterialResource, SpatialSession, SpatialTransform, SpatialViewComponent, SpatialWindowComponent, SpatialWindowContainer, type StyleParam, Vec3, Vec4, type WindowContainerOptions, type WindowStyle, type sceneDataJSBShape, type sceneDataShape };