@webspatial/core-sdk 1.0.3 → 1.0.5

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 (82) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +112 -81
  3. package/dist/iife/index.d.ts +683 -561
  4. package/dist/iife/index.global.js +3 -4
  5. package/dist/iife/index.global.js.map +1 -1
  6. package/dist/index.d.ts +683 -561
  7. package/dist/index.js +2175 -1291
  8. package/dist/index.js.map +1 -1
  9. package/package.json +7 -4
  10. package/src/JSBCommand.ts +631 -0
  11. package/src/Spatial.ts +68 -0
  12. package/src/SpatialObject.ts +46 -0
  13. package/src/SpatialScene.ts +75 -0
  14. package/src/SpatialSession.ts +187 -0
  15. package/src/SpatialWebEvent.ts +23 -0
  16. package/src/SpatialWebEventCreator.ts +12 -0
  17. package/src/Spatialized2DElement.ts +51 -0
  18. package/src/SpatializedDynamic3DElement.ts +30 -0
  19. package/src/SpatializedElement.ts +331 -0
  20. package/src/SpatializedElementCreator.ts +45 -0
  21. package/src/SpatializedStatic3DElement.ts +111 -0
  22. package/src/WebMsgCommand.ts +88 -0
  23. package/src/index.ts +23 -1
  24. package/src/platform-adapter/CommandResultUtils.ts +22 -0
  25. package/src/platform-adapter/android/AndroidPlatform.ts +133 -0
  26. package/src/platform-adapter/index.ts +21 -0
  27. package/src/platform-adapter/interface.ts +36 -0
  28. package/src/platform-adapter/ssr/SSRPlatform.ts +43 -0
  29. package/src/platform-adapter/vision-os/VisionOSPlatform.ts +77 -0
  30. package/src/reality/component/ModelComponent.ts +11 -0
  31. package/src/reality/component/SpatialComponent.ts +17 -0
  32. package/src/reality/component/index.ts +2 -0
  33. package/src/reality/entity/SpatialEntity.ts +255 -0
  34. package/src/reality/entity/SpatialModelEntity.ts +15 -0
  35. package/src/reality/entity/index.ts +2 -0
  36. package/src/reality/geometry/SpatialBoxGeometry.ts +12 -0
  37. package/src/reality/geometry/SpatialConeGeometry.ts +15 -0
  38. package/src/reality/geometry/SpatialCylinderGeometry.ts +15 -0
  39. package/src/reality/geometry/SpatialGeometry.ts +12 -0
  40. package/src/reality/geometry/SpatialPlaneGeometry.ts +15 -0
  41. package/src/reality/geometry/SpatialSphereGeometry.ts +15 -0
  42. package/src/reality/geometry/index.ts +6 -0
  43. package/src/reality/index.ts +5 -0
  44. package/src/reality/material/SpatialMaterial.ts +14 -0
  45. package/src/reality/material/SpatialUnlitMaterial.ts +16 -0
  46. package/src/reality/material/index.ts +2 -0
  47. package/src/reality/realityCreator.ts +94 -0
  48. package/src/reality/resource/SpatialModelAsset.ts +11 -0
  49. package/src/reality/resource/index.ts +1 -0
  50. package/src/scene-polyfill.test.ts +376 -0
  51. package/src/scene-polyfill.ts +359 -0
  52. package/src/spatial-window-polyfill.ts +182 -0
  53. package/src/ssr-polyfill.ts +3 -0
  54. package/src/types/global.d.ts +33 -1
  55. package/src/types/internal.ts +13 -0
  56. package/src/types/types.ts +380 -0
  57. package/src/utils.ts +61 -0
  58. package/tsconfig.json +1 -1
  59. package/vitest.config.ts +8 -0
  60. package/src/core/Spatial.ts +0 -50
  61. package/src/core/SpatialEntity.ts +0 -147
  62. package/src/core/SpatialHelper.ts +0 -230
  63. package/src/core/SpatialObject.ts +0 -26
  64. package/src/core/SpatialSession.ts +0 -457
  65. package/src/core/SpatialTransform.ts +0 -26
  66. package/src/core/SpatialWindowContainer.ts +0 -59
  67. package/src/core/component/EventSpatialComponent.ts +0 -32
  68. package/src/core/component/SpatialComponent.ts +0 -26
  69. package/src/core/component/SpatialInputComponent.ts +0 -24
  70. package/src/core/component/SpatialModel3DComponent.ts +0 -223
  71. package/src/core/component/SpatialModelComponent.ts +0 -39
  72. package/src/core/component/SpatialViewComponent.ts +0 -32
  73. package/src/core/component/SpatialWindowComponent.ts +0 -177
  74. package/src/core/component/index.ts +0 -14
  75. package/src/core/index.ts +0 -10
  76. package/src/core/private/WebSpatial.ts +0 -383
  77. package/src/core/private/remote-command/RemoteCommand.ts +0 -15
  78. package/src/core/private/remote-command/index.ts +0 -1
  79. package/src/core/resource/SpatialMeshResource.ts +0 -6
  80. package/src/core/resource/SpatialPhysicallyBasedMaterialResource.ts +0 -42
  81. package/src/core/resource/index.ts +0 -2
  82. package/src/core/types.ts +0 -32
@@ -1,26 +0,0 @@
1
- export class Vec3 {
2
- constructor(
3
- public x = 0,
4
- public y = 0,
5
- public z = 0,
6
- ) {}
7
- }
8
-
9
- export class Vec4 {
10
- constructor(
11
- public x = 0,
12
- public y = 0,
13
- public z = 0,
14
- public w = 1,
15
- ) {}
16
- }
17
-
18
- /**
19
- * Transform containing position, orientation and scale
20
- */
21
- export class SpatialTransform {
22
- position = new Vec3(0, 0, 0)
23
- /** Quaternion value for x,y,z,w */
24
- orientation = new Vec4(0, 0, 0, 1)
25
- scale = new Vec3(1, 1, 1)
26
- }
@@ -1,59 +0,0 @@
1
- import {
2
- WebSpatial,
3
- WebSpatialResource,
4
- WindowContainer,
5
- } from './private/WebSpatial'
6
- import { SpatialEntity } from './SpatialEntity'
7
-
8
- /**
9
- * Anchored window managed by the OS
10
- */
11
- export class SpatialWindowContainer {
12
- /** @hidden */
13
- constructor(
14
- /** @hidden */
15
- public _wg: WindowContainer,
16
- ) {}
17
- /**
18
- * @hidden
19
- * Sets sets the open configuration for opening new window containers
20
- * @param options style options
21
- */
22
- async _setOpenSettings(options: {
23
- resolution: { width: number; height: number }
24
- }) {
25
- await WebSpatial.updateWindowContainer(this._wg, {
26
- nextOpenSettings: options,
27
- })
28
- }
29
-
30
- /**
31
- * Retrieves the root entity of the windowContainer
32
- * @returns the root entity of the windowContainer if one exists
33
- */
34
- async getRootEntity() {
35
- let reqResp: any = await WebSpatial.updateWindowContainer(this._wg, {
36
- getRootEntityID: '',
37
- })
38
- if (reqResp.data.rootEntId === '') {
39
- return null
40
- } else {
41
- var res = new WebSpatialResource()
42
- res.id = reqResp.data.rootEntId
43
- return new SpatialEntity(res)
44
- }
45
- }
46
- /*
47
- * Sets the root entity that this windowContainer will display (this does not effect resource ownership)
48
- * @param entity to display
49
- */
50
- async setRootEntity(entity: SpatialEntity) {
51
- await entity._setParentWindowContainer(this)
52
- }
53
-
54
- async close() {
55
- await WebSpatial.updateWindowContainer(this._wg, {
56
- close: true,
57
- })
58
- }
59
- }
@@ -1,32 +0,0 @@
1
- import { WebSpatial, WebSpatialResource } from '../private/WebSpatial'
2
- import { SpatialComponent } from './SpatialComponent'
3
-
4
- /**
5
- * @description
6
- * Represents a spatial component that handles events related to spatial interactions.
7
- * This class extends `SpatialComponent` and provides additional functionality for managing
8
- * event-driven spatial behaviors.
9
- *
10
- * @hidden
11
- * This class is intended for internal use and should not be exposed in the public API.
12
- */
13
- export abstract class EventSpatialComponent extends SpatialComponent {
14
- // Class implementation goes here
15
- constructor(_resource: WebSpatialResource) {
16
- super(_resource)
17
- WebSpatial.registerEventReceiver(_resource.id, (data: any) => {
18
- this.onRecvEvent(data)
19
- })
20
- }
21
-
22
- /**
23
- * @description
24
- * Abstract method to be implemented by subclasses. Called when a spatial event is received.
25
- * @param data The data associated with the received event.
26
- */
27
- protected abstract onRecvEvent(data: any): void
28
-
29
- protected override async onDestroy() {
30
- WebSpatial.unregisterEventReceiver(this._resource.id)
31
- }
32
- }
@@ -1,26 +0,0 @@
1
- import { WebSpatial, WebSpatialResource } from '../private/WebSpatial'
2
- import { SpatialEntity } from '../SpatialEntity'
3
- import { SpatialObject } from '../SpatialObject'
4
-
5
- /** @hidden */
6
- export class SpatialComponent extends SpatialObject {
7
- /**
8
- * Gets the entity this component is attached to
9
- * @returns entity or null
10
- */
11
- async getEntity() {
12
- let reqResp: any = await WebSpatial.updateResource(
13
- WebSpatial.getCurrentWebPanel(),
14
- { getEntityID: '' },
15
- )
16
- if (reqResp.data.parentID === '') {
17
- return new Promise<SpatialEntity | null>((res, rej) => {
18
- res(null)
19
- })
20
- } else {
21
- var res = new WebSpatialResource()
22
- res.id = reqResp.data.parentID
23
- return new SpatialEntity(res)
24
- }
25
- }
26
- }
@@ -1,24 +0,0 @@
1
- import { Vec3 } from '../SpatialTransform'
2
- import { EventSpatialComponent } from './EventSpatialComponent'
3
-
4
- /**
5
- * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
6
- */
7
- type TranslateEvent = {
8
- eventType: 'dragstart' | 'dragend' | 'drag'
9
- translate?: Vec3
10
- }
11
- /**
12
- * Used to handle input events on an entity
13
- */
14
- export class SpatialInputComponent extends EventSpatialComponent {
15
- protected override onRecvEvent(data: any): void {
16
- this.onTranslate(data)
17
- }
18
-
19
- /**
20
- * Callback fired when a translate event occurs
21
- * @param data translate event data
22
- */
23
- public onTranslate(data: TranslateEvent) {}
24
- }
@@ -1,223 +0,0 @@
1
- import { EventSpatialComponent } from './EventSpatialComponent'
2
- import { WebSpatial } from '../private/WebSpatial'
3
- import { Vec3 } from '../SpatialTransform'
4
-
5
- /**
6
- * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
7
- */
8
- export type SpatialModelDragEvent = {
9
- eventType: 'dragstart' | 'dragend' | 'drag'
10
- translation3D: Vec3
11
- startLocation3D: Vec3
12
- }
13
-
14
- export type TapEvent = {
15
- eventType: 'tap'
16
- }
17
-
18
- /**
19
- * Used to position a model3d in 3D space
20
- */
21
- export class SpatialModel3DComponent extends EventSpatialComponent {
22
- protected override onRecvEvent(data: any): void {
23
- const { eventType, value, error } = data
24
- switch (eventType) {
25
- case 'phase':
26
- if (value === 'success') {
27
- this.onSuccess?.()
28
- } else {
29
- this.onFailure?.(error as string)
30
- }
31
- break
32
- case 'dragstart':
33
- this._onDragStart?.(value)
34
- break
35
- case 'dragend':
36
- this._onDragEnd?.(value)
37
- break
38
- case 'drag':
39
- this._onDrag?.(value)
40
- break
41
- case 'tap':
42
- this._onTap?.()
43
- break
44
- case 'doubletap':
45
- this._onDoubleTap?.()
46
- break
47
- case 'longpress':
48
- this._onLongPress?.()
49
- break
50
-
51
- default:
52
- break
53
- }
54
- }
55
- /**
56
- * Sets the resolution of the spatial view in dom pixels
57
- */
58
- async setResolution(width: number, height: number) {
59
- await WebSpatial.updateResource(this._resource, {
60
- resolution: { x: width, y: height },
61
- })
62
- }
63
-
64
- async setRotationAnchor(rotationAnchor: Vec3) {
65
- await WebSpatial.updateResource(this._resource, {
66
- rotationAnchor: rotationAnchor,
67
- })
68
- }
69
-
70
- /**
71
- * Sets the opacity of the model
72
- * @param opacity
73
- */
74
- async setOpacity(opacity: number) {
75
- await WebSpatial.updateResource(this._resource, {
76
- opacity,
77
- })
78
- }
79
-
80
- /**
81
- * Sets how the model fill the rect
82
- * @param contentMode
83
- */
84
- async setContentMode(contentMode: 'fill' | 'fit') {
85
- await WebSpatial.updateResource(this._resource, {
86
- contentMode,
87
- })
88
- }
89
-
90
- /**
91
- * Constrains this model dimensions to the specified aspect ratio.
92
- * with a value of 0, the model will use the original aspect ratio.
93
- *
94
- * @param aspectRatio number
95
- */
96
- async setAspectRatio(aspectRatio: number) {
97
- await WebSpatial.updateResource(this._resource, {
98
- aspectRatio,
99
- })
100
- }
101
-
102
- /**
103
- * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
104
- * @param scrollWithParent value to set
105
- */
106
- async setScrollWithParent(scrollWithParent: boolean) {
107
- await WebSpatial.updateResource(this._resource, {
108
- scrollWithParent: scrollWithParent,
109
- })
110
- }
111
-
112
- /**
113
- * Sets whether the model appear in original size or fit the rect
114
- * @param resizable
115
- */
116
- async setResizable(resizable: boolean) {
117
- await WebSpatial.updateResource(this._resource, {
118
- resizable,
119
- })
120
- }
121
-
122
- /**
123
- * Callback fired when model load success
124
- */
125
- public onSuccess?: () => void
126
-
127
- /**
128
- * Callback fired when model load failure
129
- * @param errorReason
130
- */
131
- public onFailure?: (errorReason: string) => void
132
-
133
- /**
134
- * Callback fired when model was dragged at the beginning
135
- * @param dragEvent
136
- */
137
- private _onDragStart?: (dragEvent: SpatialModelDragEvent) => void
138
- public set onDragStart(
139
- callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,
140
- ) {
141
- if (this._onDragStart !== callback) {
142
- this._onDragStart = callback
143
- WebSpatial.updateResource(this._resource, {
144
- enableDragEvent: this.enableDragEvent,
145
- })
146
- }
147
- }
148
-
149
- /**
150
- * Callback fired when model was dragged
151
- * @param dragEvent
152
- */
153
- private _onDrag?: (dragEvent: SpatialModelDragEvent) => void
154
- public set onDrag(
155
- callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,
156
- ) {
157
- if (this._onDrag !== callback) {
158
- this._onDrag = callback
159
- WebSpatial.updateResource(this._resource, {
160
- enableDragEvent: this.enableDragEvent,
161
- })
162
- }
163
- }
164
-
165
- /**
166
- * Callback fired when model was dragged at the ending
167
- * @param dragEvent
168
- */
169
- private _onDragEnd?: (dragEvent: SpatialModelDragEvent) => void
170
- public set onDragEnd(
171
- callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,
172
- ) {
173
- if (this._onDragEnd !== callback) {
174
- this._onDragEnd = callback
175
- WebSpatial.updateResource(this._resource, {
176
- enableDragEvent: this.enableDragEvent,
177
- })
178
- }
179
- }
180
-
181
- private get enableDragEvent(): boolean {
182
- return (
183
- undefined !== this._onDrag ||
184
- undefined !== this._onDragStart ||
185
- undefined !== this._onDragEnd
186
- )
187
- }
188
-
189
- /**
190
- * Callback fired when model was tapped
191
- */
192
- private _onTap?: () => void
193
- public set onTap(callback: (() => void) | undefined) {
194
- if (this._onTap !== callback) {
195
- this._onTap = callback
196
- WebSpatial.updateResource(this._resource, {
197
- enableTapEvent: undefined !== callback,
198
- })
199
- }
200
- }
201
-
202
- /** Callback fired when model was double tapped */
203
- private _onDoubleTap?: () => void
204
- public set onDoubleTap(callback: (() => void) | undefined) {
205
- if (this._onDoubleTap !== callback) {
206
- this._onDoubleTap = callback
207
- WebSpatial.updateResource(this._resource, {
208
- enableDoubleTapEvent: undefined !== callback,
209
- })
210
- }
211
- }
212
-
213
- /** Callback fired when model was long pressed */
214
- private _onLongPress?: () => void
215
- public set onLongPress(callback: (() => void) | undefined) {
216
- if (this._onLongPress !== callback) {
217
- this._onLongPress = callback
218
- WebSpatial.updateResource(this._resource, {
219
- enableLongPressEvent: undefined !== callback,
220
- })
221
- }
222
- }
223
- }
@@ -1,39 +0,0 @@
1
- import { SpatialMeshResource } from '../resource/SpatialMeshResource'
2
- import { SpatialPhysicallyBasedMaterialResource } from '../resource/SpatialPhysicallyBasedMaterialResource'
3
- import { SpatialComponent } from './SpatialComponent'
4
- import { WebSpatial } from '../private/WebSpatial'
5
-
6
- /**
7
- * Used to position a model in 3D space, made up of a mesh and materials to be applied to the mesh
8
- */
9
- export class SpatialModelComponent extends SpatialComponent {
10
- private cachedMaterials = new Array<SpatialPhysicallyBasedMaterialResource>()
11
- /**
12
- * Sets the mesh to be displayed by the component
13
- * @param mesh mesh to set
14
- */
15
- async setMesh(mesh: SpatialMeshResource) {
16
- await WebSpatial.updateResource(this._resource, {
17
- meshResource: mesh._resource.id,
18
- })
19
- }
20
-
21
- /**
22
- * Sets the materials that should be applied to the mesh
23
- * @param materials array of materials to set
24
- */
25
- async setMaterials(materials: Array<SpatialPhysicallyBasedMaterialResource>) {
26
- this.cachedMaterials = materials
27
- await WebSpatial.updateResource(this._resource, {
28
- materials: materials.map(m => {
29
- m._addToComponent(this)
30
- return m._resource.id
31
- }),
32
- })
33
- }
34
-
35
- /** @hidden */
36
- async _syncMaterials() {
37
- await this.setMaterials(this.cachedMaterials)
38
- }
39
- }
@@ -1,32 +0,0 @@
1
- import { WebSpatial } from '../private/WebSpatial'
2
- import { SpatialComponent } from './SpatialComponent'
3
-
4
- /**
5
- * Represenets a volume that can be added to the webpage
6
- * Child entities will be added within this volume's space
7
- * Defaults to having 1x1x1 meter dimensions
8
- * Resolution defaults to 100x100 pixels
9
- * Only will be displayed on entities in "ROOT" or "DOM" space
10
- * 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.
11
- * (eg. 200x100 = 2m x 1m x 1m volume)
12
- */
13
- export class SpatialViewComponent extends SpatialComponent {
14
- /**
15
- * Sets the resolution of the spatial view in dom pixels
16
- */
17
- async setResolution(width: number, height: number) {
18
- await WebSpatial.updateResource(this._resource, {
19
- resolution: { x: width, y: height },
20
- })
21
- }
22
-
23
- /**
24
- * Sets if content of the spatialView should be within a portal
25
- * If true, volume will be behind the page, if false, it will be in front of the page
26
- */
27
- async setIsPortal(isPortal: Boolean) {
28
- await WebSpatial.updateResource(this._resource, {
29
- isPortal: isPortal,
30
- })
31
- }
32
- }
@@ -1,177 +0,0 @@
1
- import { SpatialComponent } from './SpatialComponent'
2
- import { WebSpatial } from '../private/WebSpatial'
3
- import { Vec3 } from '../SpatialTransform'
4
- import { SpatialHelper } from '../SpatialHelper'
5
-
6
- /**
7
- * Material type for SpatialDiv or HTML document.
8
- *
9
- * This type defines the background material options for both SpatialDiv elements and HTML documents.
10
- *
11
- * - `'none'`: This is the default value.
12
- * - For HTML documents, the web page window will have the default native background.
13
- * - For SpatialDiv, the window will have a transparent background.
14
- * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).
15
- * - `'thick'`: Represents a thick material in AVP.
16
- * - `'regular'`: Represents a regular material in AVP.
17
- * - `'thin'`: Represents a thin material in AVP.
18
- * - `'transparent'`: Represents a fully transparent background.
19
- */
20
- export type BackgroundMaterialType =
21
- | 'none'
22
- | 'translucent'
23
- | 'thick'
24
- | 'regular'
25
- | 'thin'
26
- | 'transparent'
27
-
28
- export type CornerRadius = {
29
- topLeading: number
30
- bottomLeading: number
31
- topTrailing: number
32
- bottomTrailing: number
33
- }
34
-
35
- export type StyleParam = {
36
- material?: {
37
- type: BackgroundMaterialType
38
- }
39
- cornerRadius?: number | CornerRadius
40
- }
41
-
42
- /**
43
- * Used to position an web window in 3D space
44
- */
45
- export class SpatialWindowComponent extends SpatialComponent {
46
- /**
47
- * Loads a url page in the window
48
- * @param url url to load
49
- */
50
- async loadURL(url: string) {
51
- await WebSpatial.updateResource(this._resource, { url: url })
52
- }
53
-
54
- async setFromWindow(window: any) {
55
- if (window._webSpatialID) {
56
- await WebSpatial.updateResource(this._resource, {
57
- windowID: window._webSpatialID,
58
- })
59
- } else {
60
- await console.warn(
61
- 'failed to call setFromWindow, window provided is not valid',
62
- )
63
- }
64
- }
65
-
66
- /**
67
- * Sets the resolution of the window, the resulting dimensions when rendered will be equal to 1/1360 units
68
- * eg. if the resolution is set to 1360x1360 it will be a 1x1 plane
69
- * See 1360 in spatialViewUI.swift for how this ratio works
70
- * @param width width in pixels
71
- * @param height height in pixels
72
- */
73
- async setResolution(width: number, height: number) {
74
- await WebSpatial.updateResource(this._resource, {
75
- resolution: { x: width, y: height },
76
- })
77
- }
78
-
79
- /**
80
- * [Experimental] Sets the anchor which the entity this is attached to will rotate around
81
- * @param rotationAnchor
82
- */
83
- async setRotationAnchor(rotationAnchor: Vec3) {
84
- await WebSpatial.updateResource(this._resource, {
85
- rotationAnchor: rotationAnchor,
86
- })
87
- }
88
-
89
- /**
90
- * [Experimental] Sets the opacity of the window after apply material
91
- * @param opacity
92
- */
93
- async setOpacity(opacity: number) {
94
- await WebSpatial.updateResource(this._resource, {
95
- opacity,
96
- })
97
- }
98
-
99
- /**
100
- * Sets the style that should be applied to the window
101
- * @param options style options
102
- */
103
- async setStyle(styleParam: StyleParam) {
104
- const currentWindowComponent =
105
- SpatialHelper.instance?.session.getCurrentWindowComponent()
106
- const isSettingSelfStyle =
107
- currentWindowComponent?._resource.id == this._resource.id
108
-
109
- const { material, cornerRadius } = styleParam
110
- const options: any = {}
111
- if (material?.type) {
112
- options.backgroundMaterial = material.type
113
- }
114
-
115
- if (cornerRadius !== undefined) {
116
- if (typeof cornerRadius === 'number') {
117
- options.cornerRadius = {
118
- topLeading: cornerRadius,
119
- bottomLeading: cornerRadius,
120
- topTrailing: cornerRadius,
121
- bottomTrailing: cornerRadius,
122
- }
123
- } else {
124
- options.cornerRadius = { ...cornerRadius }
125
- }
126
- }
127
-
128
- if (isSettingSelfStyle && document && document.readyState == 'loading') {
129
- // Avoid flash of unstyled content by sending style command via a link element
130
- var encoded = encodeURIComponent(JSON.stringify(options))
131
-
132
- const a = document.createElement(`a`)
133
- a.href = 'forcestyle://mystyle.css?' + 'style=' + encoded
134
- document.body.appendChild(a)
135
- a.click()
136
- // remove this element after trigger forceStyle action
137
- a.remove()
138
- } else {
139
- await WebSpatial.updateResource(this._resource, { style: options })
140
- }
141
- }
142
-
143
- /**
144
- * Modifies the amount the spatial window can be scrolled
145
- * Should only be used internally
146
- * See https://developer.apple.com/documentation/uikit/1624475-uiedgeinsetsmake?language=objc
147
- * @param insets margin to modify scroll distances by
148
- */
149
- async setScrollEdgeInsets(insets: {
150
- top: number
151
- left: number
152
- bottom: number
153
- right: number
154
- }) {
155
- await WebSpatial.updateResource(this._resource, {
156
- setScrollEdgeInsets: insets,
157
- })
158
- }
159
-
160
- /**
161
- * Enable/Disable scrolling in the window (defaults to enabled), if disabled, scrolling will be applied to the root page
162
- * @param enabled value to set
163
- */
164
- async setScrollEnabled(enabled: boolean) {
165
- await WebSpatial.updateResource(this._resource, { scrollEnabled: enabled })
166
- }
167
-
168
- /**
169
- * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
170
- * @param scrollWithParent value to set
171
- */
172
- async setScrollWithParent(scrollWithParent: boolean) {
173
- await WebSpatial.updateResource(this._resource, {
174
- scrollWithParent: scrollWithParent,
175
- })
176
- }
177
- }
@@ -1,14 +0,0 @@
1
- export { SpatialComponent } from './SpatialComponent'
2
- export {
3
- SpatialWindowComponent,
4
- type BackgroundMaterialType,
5
- type StyleParam,
6
- type CornerRadius,
7
- } from './SpatialWindowComponent'
8
- export { SpatialInputComponent } from './SpatialInputComponent'
9
- export { SpatialModelComponent } from './SpatialModelComponent'
10
- export { SpatialViewComponent } from './SpatialViewComponent'
11
- export {
12
- SpatialModel3DComponent,
13
- type SpatialModelDragEvent,
14
- } from './SpatialModel3DComponent'
package/src/core/index.ts DELETED
@@ -1,10 +0,0 @@
1
- export * from './component'
2
- export * from './resource'
3
- export { SpatialEntity } from './SpatialEntity'
4
- export { SpatialSession } from './SpatialSession'
5
- export { Spatial } from './Spatial'
6
- export { SpatialWindowContainer } from './SpatialWindowContainer'
7
- export { SpatialHelper } from './SpatialHelper'
8
- export { type WindowStyle } from './types'
9
- export { SpatialTransform, Vec3, Vec4 } from './SpatialTransform'
10
- export * from './types'