@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
@@ -1,91 +0,0 @@
1
- import { EventSpatialComponent } from './EventSpatialComponent';
2
- import { Vec3 } from '../SpatialTransform';
3
- /**
4
- * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
5
- */
6
- export type SpatialModelDragEvent = {
7
- eventType: 'dragstart' | 'dragend' | 'drag';
8
- translation3D: Vec3;
9
- startLocation3D: Vec3;
10
- };
11
- export type TapEvent = {
12
- eventType: 'tap';
13
- };
14
- /**
15
- * Used to position a model3d in 3D space
16
- */
17
- export declare class SpatialModel3DComponent extends EventSpatialComponent {
18
- protected onRecvEvent(data: any): void;
19
- /**
20
- * Sets the resolution of the spatial view in dom pixels
21
- */
22
- setResolution(width: number, height: number): Promise<void>;
23
- setRotationAnchor(rotationAnchor: Vec3): Promise<void>;
24
- /**
25
- * Sets the opacity of the model
26
- * @param opacity
27
- */
28
- setOpacity(opacity: number): Promise<void>;
29
- /**
30
- * Sets how the model fill the rect
31
- * @param contentMode
32
- */
33
- setContentMode(contentMode: 'fill' | 'fit'): Promise<void>;
34
- /**
35
- * Constrains this model dimensions to the specified aspect ratio.
36
- * with a value of 0, the model will use the original aspect ratio.
37
- *
38
- * @param aspectRatio number
39
- */
40
- setAspectRatio(aspectRatio: number): Promise<void>;
41
- /**
42
- * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
43
- * @param scrollWithParent value to set
44
- */
45
- setScrollWithParent(scrollWithParent: boolean): Promise<void>;
46
- /**
47
- * Sets whether the model appear in original size or fit the rect
48
- * @param resizable
49
- */
50
- setResizable(resizable: boolean): Promise<void>;
51
- /**
52
- * Callback fired when model load success
53
- */
54
- onSuccess?: () => void;
55
- /**
56
- * Callback fired when model load failure
57
- * @param errorReason
58
- */
59
- onFailure?: (errorReason: string) => void;
60
- /**
61
- * Callback fired when model was dragged at the beginning
62
- * @param dragEvent
63
- */
64
- private _onDragStart?;
65
- set onDragStart(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
66
- /**
67
- * Callback fired when model was dragged
68
- * @param dragEvent
69
- */
70
- private _onDrag?;
71
- set onDrag(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
72
- /**
73
- * Callback fired when model was dragged at the ending
74
- * @param dragEvent
75
- */
76
- private _onDragEnd?;
77
- set onDragEnd(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
78
- private get enableDragEvent();
79
- /**
80
- * Callback fired when model was tapped
81
- */
82
- private _onTap?;
83
- set onTap(callback: (() => void) | undefined);
84
- /** Callback fired when model was double tapped */
85
- private _onDoubleTap?;
86
- set onDoubleTap(callback: (() => void) | undefined);
87
- /** Callback fired when model was long pressed */
88
- private _onLongPress?;
89
- set onLongPress(callback: (() => void) | undefined);
90
- }
91
- //# sourceMappingURL=SpatialModel3DComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpatialModel3DComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialModel3DComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAA;IAC3C,aAAa,EAAE,IAAI,CAAA;IACnB,eAAe,EAAE,IAAI,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,KAAK,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,qBAAqB;cAC7C,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAiC/C;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAM3C,iBAAiB,CAAC,cAAc,EAAE,IAAI;IAM5C;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM;IAMhC;;;OAGG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK;IAMhD;;;;;OAKG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM;IAMxC;;;OAGG;IACG,mBAAmB,CAAC,gBAAgB,EAAE,OAAO;IAMnD;;;OAGG;IACG,YAAY,CAAC,SAAS,EAAE,OAAO;IAMrC;;OAEG;IACI,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IAE7B;;;OAGG;IACI,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IAEhD;;;OAGG;IACH,OAAO,CAAC,YAAY,CAAC,CAA4C;IACjE,IAAW,WAAW,CACpB,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,EAQnE;IAED;;;OAGG;IACH,OAAO,CAAC,OAAO,CAAC,CAA4C;IAC5D,IAAW,MAAM,CACf,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,EAQnE;IAED;;;OAGG;IACH,OAAO,CAAC,UAAU,CAAC,CAA4C;IAC/D,IAAW,SAAS,CAClB,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,EAQnE;IAED,OAAO,KAAK,eAAe,GAM1B;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,CAAY;IAC3B,IAAW,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAOlD;IAED,kDAAkD;IAClD,OAAO,CAAC,YAAY,CAAC,CAAY;IACjC,IAAW,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAOxD;IAED,iDAAiD;IACjD,OAAO,CAAC,YAAY,CAAC,CAAY;IACjC,IAAW,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAOxD;CACF"}
@@ -1,185 +0,0 @@
1
- import { EventSpatialComponent } from './EventSpatialComponent';
2
- import { WebSpatial } from '../private/WebSpatial';
3
- /**
4
- * Used to position a model3d in 3D space
5
- */
6
- export class SpatialModel3DComponent extends EventSpatialComponent {
7
- onRecvEvent(data) {
8
- const { eventType, value, error } = data;
9
- switch (eventType) {
10
- case 'phase':
11
- if (value === 'success') {
12
- this.onSuccess?.();
13
- }
14
- else {
15
- this.onFailure?.(error);
16
- }
17
- break;
18
- case 'dragstart':
19
- this._onDragStart?.(value);
20
- break;
21
- case 'dragend':
22
- this._onDragEnd?.(value);
23
- break;
24
- case 'drag':
25
- this._onDrag?.(value);
26
- break;
27
- case 'tap':
28
- this._onTap?.();
29
- break;
30
- case 'doubletap':
31
- this._onDoubleTap?.();
32
- break;
33
- case 'longpress':
34
- this._onLongPress?.();
35
- break;
36
- default:
37
- break;
38
- }
39
- }
40
- /**
41
- * Sets the resolution of the spatial view in dom pixels
42
- */
43
- async setResolution(width, height) {
44
- await WebSpatial.updateResource(this._resource, {
45
- resolution: { x: width, y: height },
46
- });
47
- }
48
- async setRotationAnchor(rotationAnchor) {
49
- await WebSpatial.updateResource(this._resource, {
50
- rotationAnchor: rotationAnchor,
51
- });
52
- }
53
- /**
54
- * Sets the opacity of the model
55
- * @param opacity
56
- */
57
- async setOpacity(opacity) {
58
- await WebSpatial.updateResource(this._resource, {
59
- opacity,
60
- });
61
- }
62
- /**
63
- * Sets how the model fill the rect
64
- * @param contentMode
65
- */
66
- async setContentMode(contentMode) {
67
- await WebSpatial.updateResource(this._resource, {
68
- contentMode,
69
- });
70
- }
71
- /**
72
- * Constrains this model dimensions to the specified aspect ratio.
73
- * with a value of 0, the model will use the original aspect ratio.
74
- *
75
- * @param aspectRatio number
76
- */
77
- async setAspectRatio(aspectRatio) {
78
- await WebSpatial.updateResource(this._resource, {
79
- aspectRatio,
80
- });
81
- }
82
- /**
83
- * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
84
- * @param scrollWithParent value to set
85
- */
86
- async setScrollWithParent(scrollWithParent) {
87
- await WebSpatial.updateResource(this._resource, {
88
- scrollWithParent: scrollWithParent,
89
- });
90
- }
91
- /**
92
- * Sets whether the model appear in original size or fit the rect
93
- * @param resizable
94
- */
95
- async setResizable(resizable) {
96
- await WebSpatial.updateResource(this._resource, {
97
- resizable,
98
- });
99
- }
100
- /**
101
- * Callback fired when model load success
102
- */
103
- onSuccess;
104
- /**
105
- * Callback fired when model load failure
106
- * @param errorReason
107
- */
108
- onFailure;
109
- /**
110
- * Callback fired when model was dragged at the beginning
111
- * @param dragEvent
112
- */
113
- _onDragStart;
114
- set onDragStart(callback) {
115
- if (this._onDragStart !== callback) {
116
- this._onDragStart = callback;
117
- WebSpatial.updateResource(this._resource, {
118
- enableDragEvent: this.enableDragEvent,
119
- });
120
- }
121
- }
122
- /**
123
- * Callback fired when model was dragged
124
- * @param dragEvent
125
- */
126
- _onDrag;
127
- set onDrag(callback) {
128
- if (this._onDrag !== callback) {
129
- this._onDrag = callback;
130
- WebSpatial.updateResource(this._resource, {
131
- enableDragEvent: this.enableDragEvent,
132
- });
133
- }
134
- }
135
- /**
136
- * Callback fired when model was dragged at the ending
137
- * @param dragEvent
138
- */
139
- _onDragEnd;
140
- set onDragEnd(callback) {
141
- if (this._onDragEnd !== callback) {
142
- this._onDragEnd = callback;
143
- WebSpatial.updateResource(this._resource, {
144
- enableDragEvent: this.enableDragEvent,
145
- });
146
- }
147
- }
148
- get enableDragEvent() {
149
- return (undefined !== this._onDrag ||
150
- undefined !== this._onDragStart ||
151
- undefined !== this._onDragEnd);
152
- }
153
- /**
154
- * Callback fired when model was tapped
155
- */
156
- _onTap;
157
- set onTap(callback) {
158
- if (this._onTap !== callback) {
159
- this._onTap = callback;
160
- WebSpatial.updateResource(this._resource, {
161
- enableTapEvent: undefined !== callback,
162
- });
163
- }
164
- }
165
- /** Callback fired when model was double tapped */
166
- _onDoubleTap;
167
- set onDoubleTap(callback) {
168
- if (this._onDoubleTap !== callback) {
169
- this._onDoubleTap = callback;
170
- WebSpatial.updateResource(this._resource, {
171
- enableDoubleTapEvent: undefined !== callback,
172
- });
173
- }
174
- }
175
- /** Callback fired when model was long pressed */
176
- _onLongPress;
177
- set onLongPress(callback) {
178
- if (this._onLongPress !== callback) {
179
- this._onLongPress = callback;
180
- WebSpatial.updateResource(this._resource, {
181
- enableLongPressEvent: undefined !== callback,
182
- });
183
- }
184
- }
185
- }
@@ -1,22 +0,0 @@
1
- import { SpatialMeshResource } from '../resource/SpatialMeshResource';
2
- import { SpatialPhysicallyBasedMaterialResource } from '../resource/SpatialPhysicallyBasedMaterialResource';
3
- import { SpatialComponent } from './SpatialComponent';
4
- /**
5
- * Used to position a model in 3D space, made up of a mesh and materials to be applied to the mesh
6
- */
7
- export declare class SpatialModelComponent extends SpatialComponent {
8
- private cachedMaterials;
9
- /**
10
- * Sets the mesh to be displayed by the component
11
- * @param mesh mesh to set
12
- */
13
- setMesh(mesh: SpatialMeshResource): Promise<void>;
14
- /**
15
- * Sets the materials that should be applied to the mesh
16
- * @param materials array of materials to set
17
- */
18
- setMaterials(materials: Array<SpatialPhysicallyBasedMaterialResource>): Promise<void>;
19
- /** @hidden */
20
- _syncMaterials(): Promise<void>;
21
- }
22
- //# sourceMappingURL=SpatialModelComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpatialModelComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialModelComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,sCAAsC,EAAE,MAAM,oDAAoD,CAAA;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,gBAAgB;IACzD,OAAO,CAAC,eAAe,CAAsD;IAC7E;;;OAGG;IACG,OAAO,CAAC,IAAI,EAAE,mBAAmB;IAMvC;;;OAGG;IACG,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,sCAAsC,CAAC;IAU3E,cAAc;IACR,cAAc;CAGrB"}
@@ -1,34 +0,0 @@
1
- import { SpatialComponent } from './SpatialComponent';
2
- import { WebSpatial } from '../private/WebSpatial';
3
- /**
4
- * Used to position a model in 3D space, made up of a mesh and materials to be applied to the mesh
5
- */
6
- export class SpatialModelComponent extends SpatialComponent {
7
- cachedMaterials = new Array();
8
- /**
9
- * Sets the mesh to be displayed by the component
10
- * @param mesh mesh to set
11
- */
12
- async setMesh(mesh) {
13
- await WebSpatial.updateResource(this._resource, {
14
- meshResource: mesh._resource.id,
15
- });
16
- }
17
- /**
18
- * Sets the materials that should be applied to the mesh
19
- * @param materials array of materials to set
20
- */
21
- async setMaterials(materials) {
22
- this.cachedMaterials = materials;
23
- await WebSpatial.updateResource(this._resource, {
24
- materials: materials.map(m => {
25
- m._addToComponent(this);
26
- return m._resource.id;
27
- }),
28
- });
29
- }
30
- /** @hidden */
31
- async _syncMaterials() {
32
- await this.setMaterials(this.cachedMaterials);
33
- }
34
- }
@@ -1,22 +0,0 @@
1
- import { SpatialComponent } from './SpatialComponent';
2
- /**
3
- * Represenets a volume that can be added to the webpage
4
- * Child entities will be added within this volume's space
5
- * Defaults to having 1x1x1 meter dimensions
6
- * Resolution defaults to 100x100 pixels
7
- * Only will be displayed on entities in "ROOT" or "DOM" space
8
- * 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.
9
- * (eg. 200x100 = 2m x 1m x 1m volume)
10
- */
11
- export declare class SpatialViewComponent extends SpatialComponent {
12
- /**
13
- * Sets the resolution of the spatial view in dom pixels
14
- */
15
- setResolution(width: number, height: number): Promise<void>;
16
- /**
17
- * Sets if content of the spatialView should be within a portal
18
- * If true, volume will be behind the page, if false, it will be in front of the page
19
- */
20
- setIsPortal(isPortal: Boolean): Promise<void>;
21
- }
22
- //# sourceMappingURL=SpatialViewComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpatialViewComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialViewComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMjD;;;OAGG;IACG,WAAW,CAAC,QAAQ,EAAE,OAAO;CAKpC"}
@@ -1,30 +0,0 @@
1
- import { WebSpatial } from '../private/WebSpatial';
2
- import { SpatialComponent } from './SpatialComponent';
3
- /**
4
- * Represenets a volume that can be added to the webpage
5
- * Child entities will be added within this volume's space
6
- * Defaults to having 1x1x1 meter dimensions
7
- * Resolution defaults to 100x100 pixels
8
- * Only will be displayed on entities in "ROOT" or "DOM" space
9
- * 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.
10
- * (eg. 200x100 = 2m x 1m x 1m volume)
11
- */
12
- export class SpatialViewComponent extends SpatialComponent {
13
- /**
14
- * Sets the resolution of the spatial view in dom pixels
15
- */
16
- async setResolution(width, height) {
17
- await WebSpatial.updateResource(this._resource, {
18
- resolution: { x: width, y: height },
19
- });
20
- }
21
- /**
22
- * Sets if content of the spatialView should be within a portal
23
- * If true, volume will be behind the page, if false, it will be in front of the page
24
- */
25
- async setIsPortal(isPortal) {
26
- await WebSpatial.updateResource(this._resource, {
27
- isPortal: isPortal,
28
- });
29
- }
30
- }
@@ -1,86 +0,0 @@
1
- import { SpatialComponent } from './SpatialComponent';
2
- import { Vec3 } from '../SpatialTransform';
3
- /**
4
- * Material type for SpatialDiv or HTML document.
5
- *
6
- * This type defines the background material options for both SpatialDiv elements and HTML documents.
7
- *
8
- * - `'none'`: This is the default value.
9
- * - For HTML documents, the web page window will have the default native background.
10
- * - For SpatialDiv, the window will have a transparent background.
11
- * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).
12
- * - `'thick'`: Represents a thick material in AVP.
13
- * - `'regular'`: Represents a regular material in AVP.
14
- * - `'thin'`: Represents a thin material in AVP.
15
- * - `'transparent'`: Represents a fully transparent background.
16
- */
17
- export type BackgroundMaterialType = 'none' | 'translucent' | 'thick' | 'regular' | 'thin' | 'transparent';
18
- export type CornerRadius = {
19
- topLeading: number;
20
- bottomLeading: number;
21
- topTrailing: number;
22
- bottomTrailing: number;
23
- };
24
- export type StyleParam = {
25
- material?: {
26
- type: BackgroundMaterialType;
27
- };
28
- cornerRadius?: number | CornerRadius;
29
- };
30
- /**
31
- * Used to position an web window in 3D space
32
- */
33
- export declare class SpatialWindowComponent extends SpatialComponent {
34
- /**
35
- * Loads a url page in the window
36
- * @param url url to load
37
- */
38
- loadURL(url: string): Promise<void>;
39
- setFromWindow(window: any): Promise<void>;
40
- /**
41
- * Sets the resolution of the window, the resulting dimensions when rendered will be equal to 1/1360 units
42
- * eg. if the resolution is set to 1360x1360 it will be a 1x1 plane
43
- * See 1360 in spatialViewUI.swift for how this ratio works
44
- * @param width width in pixels
45
- * @param height height in pixels
46
- */
47
- setResolution(width: number, height: number): Promise<void>;
48
- /**
49
- * [Experimental] Sets the anchor which the entity this is attached to will rotate around
50
- * @param rotationAnchor
51
- */
52
- setRotationAnchor(rotationAnchor: Vec3): Promise<void>;
53
- /**
54
- * [Experimental] Sets the opacity of the window after apply material
55
- * @param opacity
56
- */
57
- setOpacity(opacity: number): Promise<void>;
58
- /**
59
- * Sets the style that should be applied to the window
60
- * @param options style options
61
- */
62
- setStyle(styleParam: StyleParam): Promise<void>;
63
- /**
64
- * Modifies the amount the spatial window can be scrolled
65
- * Should only be used internally
66
- * See https://developer.apple.com/documentation/uikit/1624475-uiedgeinsetsmake?language=objc
67
- * @param insets margin to modify scroll distances by
68
- */
69
- setScrollEdgeInsets(insets: {
70
- top: number;
71
- left: number;
72
- bottom: number;
73
- right: number;
74
- }): Promise<void>;
75
- /**
76
- * Enable/Disable scrolling in the window (defaults to enabled), if disabled, scrolling will be applied to the root page
77
- * @param enabled value to set
78
- */
79
- setScrollEnabled(enabled: boolean): Promise<void>;
80
- /**
81
- * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
82
- * @param scrollWithParent value to set
83
- */
84
- setScrollWithParent(scrollWithParent: boolean): Promise<void>;
85
- }
86
- //# sourceMappingURL=SpatialWindowComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpatialWindowComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialWindowComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN,aAAa,GACb,OAAO,GACP,SAAS,GACT,MAAM,GACN,aAAa,CAAA;AAEjB,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,sBAAsB,CAAA;KAC7B,CAAA;IACD,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;CACrC,CAAA;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,gBAAgB;IAC1D;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM;IAInB,aAAa,CAAC,MAAM,EAAE,GAAG;IAY/B;;;;;;OAMG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMjD;;;OAGG;IACG,iBAAiB,CAAC,cAAc,EAAE,IAAI;IAM5C;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM;IAMhC;;;OAGG;IACG,QAAQ,CAAC,UAAU,EAAE,UAAU;IAgCrC;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE;QAChC,GAAG,EAAE,MAAM,CAAA;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;KACd;IAMD;;;OAGG;IACG,gBAAgB,CAAC,OAAO,EAAE,OAAO;IAIvC;;;OAGG;IACG,mBAAmB,CAAC,gBAAgB,EAAE,OAAO;CAKpD"}
@@ -1,114 +0,0 @@
1
- import { SpatialComponent } from './SpatialComponent';
2
- import { WebSpatial } from '../private/WebSpatial';
3
- /**
4
- * Used to position an web window in 3D space
5
- */
6
- export class SpatialWindowComponent extends SpatialComponent {
7
- /**
8
- * Loads a url page in the window
9
- * @param url url to load
10
- */
11
- async loadURL(url) {
12
- await WebSpatial.updateResource(this._resource, { url: url });
13
- }
14
- async setFromWindow(window) {
15
- if (window._webSpatialID) {
16
- await WebSpatial.updateResource(this._resource, {
17
- windowID: window._webSpatialID,
18
- });
19
- }
20
- else {
21
- await console.warn('failed to call setFromWindow, window provided is not valid');
22
- }
23
- }
24
- /**
25
- * Sets the resolution of the window, the resulting dimensions when rendered will be equal to 1/1360 units
26
- * eg. if the resolution is set to 1360x1360 it will be a 1x1 plane
27
- * See 1360 in spatialViewUI.swift for how this ratio works
28
- * @param width width in pixels
29
- * @param height height in pixels
30
- */
31
- async setResolution(width, height) {
32
- await WebSpatial.updateResource(this._resource, {
33
- resolution: { x: width, y: height },
34
- });
35
- }
36
- /**
37
- * [Experimental] Sets the anchor which the entity this is attached to will rotate around
38
- * @param rotationAnchor
39
- */
40
- async setRotationAnchor(rotationAnchor) {
41
- await WebSpatial.updateResource(this._resource, {
42
- rotationAnchor: rotationAnchor,
43
- });
44
- }
45
- /**
46
- * [Experimental] Sets the opacity of the window after apply material
47
- * @param opacity
48
- */
49
- async setOpacity(opacity) {
50
- await WebSpatial.updateResource(this._resource, {
51
- opacity,
52
- });
53
- }
54
- /**
55
- * Sets the style that should be applied to the window
56
- * @param options style options
57
- */
58
- async setStyle(styleParam) {
59
- const { material, cornerRadius } = styleParam;
60
- const options = {};
61
- if (material?.type) {
62
- options.backgroundMaterial = material.type;
63
- }
64
- if (cornerRadius !== undefined) {
65
- if (typeof cornerRadius === 'number') {
66
- options.cornerRadius = {
67
- topLeading: cornerRadius,
68
- bottomLeading: cornerRadius,
69
- topTrailing: cornerRadius,
70
- bottomTrailing: cornerRadius,
71
- };
72
- }
73
- else {
74
- options.cornerRadius = { ...cornerRadius };
75
- }
76
- }
77
- if (document && document.readyState == 'loading') {
78
- // Avoid flash of unstyled content by sending style command via a link element
79
- var encoded = encodeURIComponent(JSON.stringify(options));
80
- var x = document.createElement('link');
81
- x.rel = 'stylesheet';
82
- x.href = 'forceStyle://mystyle.css?' + 'style=' + encoded;
83
- document.head.appendChild(x);
84
- }
85
- await WebSpatial.updateResource(this._resource, { style: options });
86
- }
87
- /**
88
- * Modifies the amount the spatial window can be scrolled
89
- * Should only be used internally
90
- * See https://developer.apple.com/documentation/uikit/1624475-uiedgeinsetsmake?language=objc
91
- * @param insets margin to modify scroll distances by
92
- */
93
- async setScrollEdgeInsets(insets) {
94
- await WebSpatial.updateResource(this._resource, {
95
- setScrollEdgeInsets: insets,
96
- });
97
- }
98
- /**
99
- * Enable/Disable scrolling in the window (defaults to enabled), if disabled, scrolling will be applied to the root page
100
- * @param enabled value to set
101
- */
102
- async setScrollEnabled(enabled) {
103
- await WebSpatial.updateResource(this._resource, { scrollEnabled: enabled });
104
- }
105
- /**
106
- * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements
107
- * @param scrollWithParent value to set
108
- */
109
- async setScrollWithParent(scrollWithParent) {
110
- await WebSpatial.updateResource(this._resource, {
111
- scrollWithParent: scrollWithParent,
112
- });
113
- }
114
- }
@@ -1,7 +0,0 @@
1
- export { SpatialComponent } from './SpatialComponent';
2
- export { SpatialWindowComponent, type BackgroundMaterialType, type StyleParam, type CornerRadius, } from './SpatialWindowComponent';
3
- export { SpatialInputComponent } from './SpatialInputComponent';
4
- export { SpatialModelComponent } from './SpatialModelComponent';
5
- export { SpatialViewComponent } from './SpatialViewComponent';
6
- export { SpatialModel3DComponent, type SpatialModelDragEvent, } from './SpatialModel3DComponent';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAA"}
@@ -1,6 +0,0 @@
1
- export { SpatialComponent } from './SpatialComponent';
2
- export { SpatialWindowComponent, } from './SpatialWindowComponent';
3
- export { SpatialInputComponent } from './SpatialInputComponent';
4
- export { SpatialModelComponent } from './SpatialModelComponent';
5
- export { SpatialViewComponent } from './SpatialViewComponent';
6
- export { SpatialModel3DComponent, } from './SpatialModel3DComponent';
@@ -1,11 +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';
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACjE,cAAc,SAAS,CAAA"}
@@ -1,9 +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 { SpatialTransform, Vec3, Vec4 } from './SpatialTransform';
9
- export * from './types';