@webspatial/core-sdk 0.0.2 → 0.0.4-alpha.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @webspatial/core-sdk
2
2
 
3
+ ## 0.0.4-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 997d398: support fixed position for Model including wrapped under a spatialdiv
8
+
9
+ ## 0.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - ee36e07: add SpatialObject name to provide more infomation when debug
14
+
3
15
  ## 0.0.2
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialEntity.d.ts","sourceRoot":"","sources":["../../src/core/SpatialEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C;;GAEG;AACH,qBAAa,aAAc,SAAQ,aAAa;IAC9C;;;OAGG;IACH,SAAS,mBAAyB;IAElC,cAAc;IACd,OAAO,CAAC,UAAU,CAAQ;IAC1B,cAAc;IACd,OAAO,KAAK,OAAO,GAElB;IAED;;OAEG;IACG,eAAe;IAIrB;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM;IAIjC,OAAO,CAAC,UAAU,CAA6C;IAE/D;;;OAGG;IACG,YAAY,CAAC,SAAS,EAAE,gBAAgB;IAK9C;;OAEG;IACG,eAAe,CAAC,CAAC,SAAS,gBAAgB,EAC9C,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC;IASjC;;OAEG;IACH,YAAY,CAAC,CAAC,SAAS,gBAAgB,EACrC,IAAI,EAAE,KAAK,GAAG,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ACG,YAAY,CAAC,SAAS,EAAE,gBAAgB;IAK9C;;OAEG;IACG,eAAe,CAAC,CAAC,SAAS,gBAAgB,EAC9C,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC;IASjC;;OAEG;IACH,YAAY,CAAC,CAAC,SAAS,gBAAgB,EACrC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAC9B,CAAC,GAAG,SAAS;IAIhB;;;;OAIG;IACG,yBAAyB,CAAC,EAAE,EAAE,sBAAsB;IAM1D;;;OAGG;IACG,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI;IAMvC;;;;;;;OAOG;IACG,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM;IAItD;;;OAGG;IACG,cAAc;gBAKR;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE;iBAClC;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE;;IAIhD;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,OAAO;IAIjC;;OAEG;IACG,OAAO;IAKb;;OAEG;IACH,WAAW;IAKX,cAAc;IACR,QAAQ,CAAC,IAAI,EAAE,MAAM;CAI5B"}
@@ -116,6 +116,7 @@ export class SpatialEntity extends SpatialObject {
116
116
  // Set Entity name. Currently for debugging only.
117
117
  /** @hidden */
118
118
  async _setName(name) {
119
+ this.name = name;
119
120
  return WebSpatial.updateResource(this._entity, { name });
120
121
  }
121
122
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialHelper.d.ts","sourceRoot":"","sources":["../../src/core/SpatialHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,UAAU,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,EAAE,aAAa,EAAE,M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BAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,MAAM,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE;MA8C9D;IAED,GAAG;uCACoC,WAAW;;;MAgDjD;IAED,kBAAkB,UACT,UAAU,6CAKlB;CACF"}
@@ -76,10 +76,20 @@ export class SpatialHelper {
76
76
  ._setOpenSettings({ resolution: options.resolution });
77
77
  }
78
78
  // Create window container
79
- var wg = await this.session.createWindowContainer({ style: 'Plain' });
79
+ var wg = await this.session.createWindowContainer({
80
+ style: 'Plain',
81
+ windowComponent: null,
82
+ windowContainer: null,
83
+ });
80
84
  // Create a root entity displaying a webpage
81
- var ent = await this.session.createEntity();
82
- var i = await this.session.createWindowComponent({ windowContainer: wg });
85
+ var ent = await this.session.createEntity({
86
+ windowComponent: null,
87
+ windowContainer: wg,
88
+ });
89
+ var i = await this.session.createWindowComponent({
90
+ windowComponent: null,
91
+ windowContainer: wg,
92
+ });
83
93
  await i.loadURL(url);
84
94
  await ent.setCoordinateSpace('Root');
85
95
  await ent.setComponent(i);
@@ -91,15 +101,31 @@ export class SpatialHelper {
91
101
  ._setOpenSettings({ resolution: { width: 900, height: 700 } });
92
102
  },
93
103
  openVolume: async (url, options) => {
94
- var wg = await this.session.createWindowContainer({ style: 'Volumetric' });
104
+ var wg = await this.session.createWindowContainer({
105
+ style: 'Volumetric',
106
+ windowComponent: null,
107
+ windowContainer: null,
108
+ });
95
109
  // Create a root view entity within the window container
96
- var rootEnt = await this.session.createEntity();
97
- await rootEnt.setComponent(await this.session.createViewComponent({ windowContainer: wg }));
110
+ var rootEnt = await this.session.createEntity({
111
+ windowComponent: null,
112
+ windowContainer: wg,
113
+ });
114
+ await rootEnt.setComponent(await this.session.createViewComponent({
115
+ windowComponent: null,
116
+ windowContainer: wg,
117
+ }));
98
118
  await rootEnt.setCoordinateSpace('Root');
99
119
  await wg.setRootEntity(rootEnt);
100
120
  // Add webpage to the window container
101
- var ent = await this.session.createEntity();
102
- var i = await this.session.createWindowComponent({ windowContainer: wg });
121
+ var ent = await this.session.createEntity({
122
+ windowComponent: null,
123
+ windowContainer: wg,
124
+ });
125
+ var i = await this.session.createWindowComponent({
126
+ windowComponent: null,
127
+ windowContainer: wg,
128
+ });
103
129
  await i.loadURL(url);
104
130
  if (options?.resolution) {
105
131
  await i.setResolution(options.resolution.width, options.resolution.height);
@@ -14,6 +14,7 @@ export declare class SpatialObject {
14
14
  * Marks resource to be released (it should no longer be used)
15
15
  */
16
16
  destroy(): Promise<void>;
17
+ name: string;
17
18
  protected onDestroy(): Promise<void>;
18
19
  }
19
20
  //# sourceMappingURL=SpatialObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialObject.d.ts","sourceRoot":"","sources":["../../src/core/SpatialObject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;;GAGG;AACH,qBAAa,aAAa;IAGtB,cAAc;IACP,SAAS,EAAE,kBAAkB;IAHtC,cAAc;;IAEZ,cAAc;IACP,SAAS,EAAE,kBAAkB;IAGtC;;OAEG;IACG,OAAO;cAKG,SAAS;CAC1B"}
1
+ {"version":3,"file":"SpatialObject.d.ts","sourceRoot":"","sources":["../../src/core/SpatialObject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;;GAGG;AACH,qBAAa,aAAa;IAGtB,cAAc;IACP,SAAS,EAAE,kBAAkB;IAHtC,cAAc;;IAEZ,cAAc;IACP,SAAS,EAAE,kBAAkB;IAGtC;;OAEG;IACG,OAAO;IAKN,IAAI,EAAE,MAAM,CAAK;cAER,SAAS;CAC1B"}
@@ -18,5 +18,6 @@ export class SpatialObject {
18
18
  await WebSpatial.destroyResource(this._resource);
19
19
  await this.onDestroy();
20
20
  }
21
+ name = '';
21
22
  async onDestroy() { }
22
23
  }
@@ -3,6 +3,10 @@ import { SpatialWindowContainer } from './SpatialWindowContainer';
3
3
  import { LoadingMethodKind, sceneDataShape, WindowStyle } from './types';
4
4
  import { SpatialMeshResource, SpatialPhysicallyBasedMaterialResource } from './resource';
5
5
  import { SpatialModelComponent, SpatialInputComponent, SpatialWindowComponent, SpatialViewComponent, SpatialModel3DComponent } from './component';
6
+ type CreateResourceOptions = {
7
+ windowContainer?: SpatialWindowContainer | null;
8
+ windowComponent?: SpatialWindowComponent | null;
9
+ };
6
10
  /**
7
11
  * Animation callback with timestamp
8
12
  */
@@ -24,63 +28,57 @@ export declare class SpatialSession {
24
28
  * Creates a Entity
25
29
  * @returns Entity
26
30
  */
27
- createEntity(): Promise<SpatialEntity>;
31
+ createEntity(options?: CreateResourceOptions): Promise<SpatialEntity>;
28
32
  /**
29
33
  * Creates a WindowComponent
30
34
  * [TODO] should creation of components be moved to entity? and these made private?
31
35
  * @returns WindowComponent
32
36
  */
33
- createWindowComponent(options?: {
34
- windowContainer?: SpatialWindowContainer;
35
- }): Promise<SpatialWindowComponent>;
37
+ createWindowComponent(options?: CreateResourceOptions): Promise<SpatialWindowComponent>;
36
38
  /**
37
39
  * Creates a ViewComponent used to display 3D content within the entity
38
40
  * @returns SpatialViewComponent
39
41
  */
40
- createViewComponent(options?: {
41
- windowContainer?: SpatialWindowContainer;
42
- }): Promise<SpatialViewComponent>;
42
+ createViewComponent(options?: CreateResourceOptions): Promise<SpatialViewComponent>;
43
43
  /**
44
44
  * Creates a ModelComponent used to display geometry + material of a 3D model
45
45
  * @returns ModelComponent
46
46
  */
47
47
  createModelComponent(options?: {
48
48
  url: string;
49
- }): Promise<SpatialModelComponent>;
49
+ } & CreateResourceOptions): Promise<SpatialModelComponent>;
50
50
  /**
51
51
  * Creates a Model3DComponent
52
52
  * @returns Model3DComponent
53
53
  */
54
54
  createModel3DComponent(options?: {
55
55
  url: string;
56
- }): Promise<SpatialModel3DComponent>;
56
+ } & CreateResourceOptions): Promise<SpatialModel3DComponent>;
57
57
  /**
58
58
  * Creates a InputComponent
59
59
  * [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model
60
60
  * @returns InputComponent
61
61
  */
62
- createInputComponent(): Promise<SpatialInputComponent>;
62
+ createInputComponent(options?: CreateResourceOptions): Promise<SpatialInputComponent>;
63
63
  /**
64
64
  * Creates a MeshResource containing geometry data
65
65
  * @returns MeshResource
66
66
  */
67
67
  createMeshResource(options?: {
68
68
  shape?: string;
69
- }): Promise<SpatialMeshResource>;
69
+ } & CreateResourceOptions): Promise<SpatialMeshResource>;
70
70
  /**
71
71
  * Creates a PhysicallyBasedMaterial containing PBR material data
72
72
  * @returns PhysicallyBasedMaterial
73
73
  */
74
- createPhysicallyBasedMaterialResource(options?: {}): Promise<SpatialPhysicallyBasedMaterialResource>;
74
+ createPhysicallyBasedMaterialResource(options?: {} & CreateResourceOptions): Promise<SpatialPhysicallyBasedMaterialResource>;
75
75
  /**
76
76
  * Creates a WindowContainer
77
77
  * @returns SpatialWindowContainer
78
78
  * */
79
79
  createWindowContainer(options?: {
80
80
  style: WindowStyle;
81
- windowContainer?: SpatialWindowContainer | null;
82
- windowComponent?: SpatialWindowComponent | null;
83
- }): Promise<SpatialWindowContainer>;
81
+ } & CreateResourceOptions): Promise<SpatialWindowContainer>;
84
82
  /**
85
83
  * Creates a Scene to display content within an anchored area managed by the OS
86
84
  * @hidden
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialSession.d.ts","sourceRoot":"","sources":["../../src/core/SpatialSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAMjE,OAAO,EACL,iBAAiB,EACjB,cAAc,EAEd,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACvC,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,aAAa,CA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OAGG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM;IAIvB;;;;OAIG;IACG,SAAS;iBACsC,GAAG;oBAAc,GAAG;;IAGzE;;OAEG;IACG,QAAQ,CAAC,eAAe,GAAE,MAA2C;IAI3E;;OAEG;IACG,2BAA2B;IAIjC,gCAAgC;IAC1B,kBAAkB;IAIxB,iCAAiC;IAC3B,qBAAqB;IAI3B,OAAO,CAAC,MAAM,CAAC,yBAAyB,CACD;IACvC;;;OAGG;IACG,2BAA2B;IAYjC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAwC;IAE9E;;;;OAIG;IACH,yBAAyB;IAWzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,QAAQ;IAMxB;;;OAGG;IACG,mBAAmB;IAgCzB,cAAc;IACR,UAAU,CAAC,EAAE,EAAE,MAAM;IAoB3B,cAAc;IACR,UAAU,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;CAG3D"}
@@ -51,8 +51,9 @@ export class SpatialSession {
51
51
  * Creates a Entity
52
52
  * @returns Entity
53
53
  */
54
- async createEntity() {
55
- let entity = await WebSpatial.createResource('Entity', WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel());
54
+ async createEntity(options) {
55
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
56
+ let entity = await WebSpatial.createResource('Entity', parentWindowContainer, parentWindow);
56
57
  return new SpatialEntity(entity);
57
58
  }
58
59
  /**
@@ -61,9 +62,8 @@ export class SpatialSession {
61
62
  * @returns WindowComponent
62
63
  */
63
64
  async createWindowComponent(options) {
64
- let entity = await WebSpatial.createResource('SpatialWebView', options?.windowContainer
65
- ? options?.windowContainer._wg
66
- : WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel());
65
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
66
+ let entity = await WebSpatial.createResource('SpatialWebView', parentWindowContainer, parentWindow);
67
67
  return new SpatialWindowComponent(entity);
68
68
  }
69
69
  /**
@@ -71,9 +71,8 @@ export class SpatialSession {
71
71
  * @returns SpatialViewComponent
72
72
  */
73
73
  async createViewComponent(options) {
74
- let entity = await WebSpatial.createResource('SpatialView', options?.windowContainer
75
- ? options?.windowContainer._wg
76
- : WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel());
74
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
75
+ let entity = await WebSpatial.createResource('SpatialView', parentWindowContainer, parentWindow);
77
76
  return new SpatialViewComponent(entity);
78
77
  }
79
78
  /**
@@ -81,11 +80,12 @@ export class SpatialSession {
81
80
  * @returns ModelComponent
82
81
  */
83
82
  async createModelComponent(options) {
83
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
84
84
  var opts = undefined;
85
85
  if (options) {
86
86
  opts = { modelURL: options.url };
87
87
  }
88
- let entity = await WebSpatial.createResource('ModelComponent', WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel(), opts);
88
+ let entity = await WebSpatial.createResource('ModelComponent', parentWindowContainer, parentWindow, opts);
89
89
  return new SpatialModelComponent(entity);
90
90
  }
91
91
  /**
@@ -93,11 +93,12 @@ export class SpatialSession {
93
93
  * @returns Model3DComponent
94
94
  */
95
95
  async createModel3DComponent(options) {
96
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
96
97
  var opts = undefined;
97
98
  if (options) {
98
99
  opts = { modelURL: options.url };
99
100
  }
100
- let entity = await WebSpatial.createResource('Model3DComponent', WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel(), opts);
101
+ let entity = await WebSpatial.createResource('Model3DComponent', parentWindowContainer, parentWindow, opts);
101
102
  return new SpatialModel3DComponent(entity);
102
103
  }
103
104
  /**
@@ -105,8 +106,9 @@ export class SpatialSession {
105
106
  * [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model
106
107
  * @returns InputComponent
107
108
  */
108
- async createInputComponent() {
109
- let entity = await WebSpatial.createResource('InputComponent', WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel());
109
+ async createInputComponent(options) {
110
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
111
+ let entity = await WebSpatial.createResource('InputComponent', parentWindowContainer, parentWindow);
110
112
  return new SpatialInputComponent(entity);
111
113
  }
112
114
  /**
@@ -114,7 +116,8 @@ export class SpatialSession {
114
116
  * @returns MeshResource
115
117
  */
116
118
  async createMeshResource(options) {
117
- let entity = await WebSpatial.createResource('MeshResource', WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel(), options);
119
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
120
+ let entity = await WebSpatial.createResource('MeshResource', parentWindowContainer, parentWindow, options);
118
121
  return new SpatialMeshResource(entity);
119
122
  }
120
123
  /**
@@ -122,7 +125,8 @@ export class SpatialSession {
122
125
  * @returns PhysicallyBasedMaterial
123
126
  */
124
127
  async createPhysicallyBasedMaterialResource(options) {
125
- let entity = await WebSpatial.createResource('PhysicallyBasedMaterial', WebSpatial.getCurrentWindowContainer(), WebSpatial.getCurrentWebPanel(), options);
128
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options);
129
+ let entity = await WebSpatial.createResource('PhysicallyBasedMaterial', parentWindowContainer, parentWindow, options);
126
130
  return new SpatialPhysicallyBasedMaterialResource(entity);
127
131
  }
128
132
  /**
@@ -38,6 +38,11 @@ export declare class SpatialModel3DComponent extends EventSpatialComponent {
38
38
  * @param aspectRatio number
39
39
  */
40
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>;
41
46
  /**
42
47
  * Sets whether the model appear in original size or fit the rect
43
48
  * @param resizable
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialModel3DComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialModel3DComponent.ts"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C,CAAY;IACjC,IAAW,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAOxD;CACF"}
@@ -79,6 +79,15 @@ export class SpatialModel3DComponent extends EventSpatialComponent {
79
79
  aspectRatio,
80
80
  });
81
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
+ }
82
91
  /**
83
92
  * Sets whether the model appear in original size or fit the rect
84
93
  * @param resizable
@@ -35,7 +35,7 @@ export declare class WebSpatial {
35
35
  static inspectRootWindowContainer(): Promise<any>;
36
36
  static setComponent(entity: WebSpatialResource, resource: WebSpatialResource): Promise<void>;
37
37
  static removeComponent(entity: WebSpatialResource, resource: WebSpatialResource): Promise<void>;
38
- static createResource(type: string, windowContainer: WindowContainer, parentWebView: WebSpatialResource, params?: any): Promise<WebSpatialResource>;
38
+ static createResource(type: string, windowContainer: WindowContainer | null, parentWebView: WebSpatialResource | null, params?: any): Promise<WebSpatialResource>;
39
39
  static updateWindowContainer(wg: WindowContainer, data: any): Promise<unknown>;
40
40
  static updateResource(resource: WebSpatialResource, data?: any): Promise<unknown>;
41
41
  static setLoading(method: LoadingMethodKind, style?: string): Promise<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"WebSpatial.d.ts","sourceRoot":"","sources":["../../../src/core/private/WebSpatial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,cAAc,EAEf,MAAM,UAAU,CAAA;AAEjB,qBAAa,eAAe;IAC1B,EAAE,SAAK;CACR;AAED,qBAAa,kBAAkB;IAC7B,EAAE,SAAK;IACP,iBAAiB,SAAK;IACtB,IAAI,EAAS,GAAG,CAAA;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AAW,YAAU,EAC5B,eAAe,EAAE,eAAe,GAAG,IAAI,EACvC,aAAa,EAAE,kBAAkB,GAAG,IAAI;WAiB7B,eAAe,CAAC,QAAQ,EAAE,kBAAkB;WAU5C,IAAI,CAAC,GAAG,EAAE,MAAM;WAmBhB,QAAQ;WAaR,OAAO,CAAC,eAAe,EAAE,MAAM;WAa/B,0BAA0B;WAI1B,YAAY,CACvB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,kBAAkB;WAWjB,eAAe,CAC1B,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,kBAAkB;WAajB,cAAc,CACzB,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,eAAe,GAAG,IAAI,EACvC,aAAa,EAAE,kBAAkB,GAAG,IAAI,EACxC,MAAM,GAAS,GAAG;WAmBP,qBAAqB,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG;WAapD,cAAc,CAAC,QAAQ,EAAE,kBAAkB,EAAE,IAAI,GAAE,GAAU;WAc7D,UAAU,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;WAgBpD,kBAAkB;WAKlB,qBAAqB;IAKlC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC;CAiBrD"}
@@ -206,8 +206,8 @@ export class WebSpatial {
206
206
  // parentWebView is the SpatialWebView that the resource will be tied to (if not provided, resource will continue to exist even if this page is unloaded)
207
207
  static async createResource(type, windowContainer, parentWebView, params = {}) {
208
208
  var cmd = new RemoteCommand('createResource', {
209
- windowContainerID: windowContainer.id,
210
- resourceID: parentWebView.id,
209
+ windowContainerID: windowContainer ? windowContainer.id : undefined,
210
+ resourceID: parentWebView ? parentWebView.id : undefined,
211
211
  type: type,
212
212
  params: params,
213
213
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webspatial/core-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4-alpha.0",
4
4
  "description": "this is runtime for webspatial",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.js",
@@ -141,6 +141,7 @@ export class SpatialEntity extends SpatialObject {
141
141
  // Set Entity name. Currently for debugging only.
142
142
  /** @hidden */
143
143
  async _setName(name: string) {
144
+ this.name = name
144
145
  return WebSpatial.updateResource(this._entity, { name })
145
146
  }
146
147
  }
@@ -88,11 +88,21 @@ export class SpatialHelper {
88
88
  }
89
89
 
90
90
  // Create window container
91
- var wg = await this.session.createWindowContainer({ style: 'Plain' })
91
+ var wg = await this.session.createWindowContainer({
92
+ style: 'Plain',
93
+ windowComponent: null,
94
+ windowContainer: null,
95
+ })
92
96
 
93
97
  // Create a root entity displaying a webpage
94
- var ent = await this.session!.createEntity()
95
- var i = await this.session!.createWindowComponent({ windowContainer: wg })
98
+ var ent = await this.session!.createEntity({
99
+ windowComponent: null,
100
+ windowContainer: wg,
101
+ })
102
+ var i = await this.session!.createWindowComponent({
103
+ windowComponent: null,
104
+ windowContainer: wg,
105
+ })
96
106
  await i.loadURL(url)
97
107
  await ent.setCoordinateSpace('Root')
98
108
  await ent.setComponent(i)
@@ -109,22 +119,41 @@ export class SpatialHelper {
109
119
  url: string,
110
120
  options?: { resolution: { width: number; height: number } },
111
121
  ) => {
112
- var wg = await this.session.createWindowContainer({ style: 'Volumetric' })
122
+ var wg = await this.session.createWindowContainer({
123
+ style: 'Volumetric',
124
+ windowComponent: null,
125
+ windowContainer: null,
126
+ })
113
127
 
114
128
  // Create a root view entity within the window container
115
- var rootEnt = await this.session!.createEntity()
129
+ var rootEnt = await this.session!.createEntity({
130
+ windowComponent: null,
131
+ windowContainer: wg,
132
+ })
116
133
  await rootEnt.setComponent(
117
- await this.session!.createViewComponent({ windowContainer: wg }),
134
+ await this.session!.createViewComponent({
135
+ windowComponent: null,
136
+ windowContainer: wg,
137
+ }),
118
138
  )
119
139
  await rootEnt.setCoordinateSpace('Root')
120
140
  await wg.setRootEntity(rootEnt)
121
141
 
122
142
  // Add webpage to the window container
123
- var ent = await this.session!.createEntity()
124
- var i = await this.session!.createWindowComponent({ windowContainer: wg })
143
+ var ent = await this.session!.createEntity({
144
+ windowComponent: null,
145
+ windowContainer: wg,
146
+ })
147
+ var i = await this.session!.createWindowComponent({
148
+ windowComponent: null,
149
+ windowContainer: wg,
150
+ })
125
151
  await i.loadURL(url)
126
152
  if (options?.resolution) {
127
- await i.setResolution(options.resolution.width, options.resolution.height)
153
+ await i.setResolution(
154
+ options.resolution.width,
155
+ options.resolution.height,
156
+ )
128
157
  } else {
129
158
  await i.setResolution(1000, 1000)
130
159
  }
@@ -20,5 +20,7 @@ export class SpatialObject {
20
20
  await this.onDestroy()
21
21
  }
22
22
 
23
+ public name: string = ''
24
+
23
25
  protected async onDestroy() {}
24
26
  }
@@ -25,6 +25,11 @@ import {
25
25
  } from './component'
26
26
  import { RemoteCommand } from './private/remote-command'
27
27
 
28
+ type CreateResourceOptions = {
29
+ windowContainer?: SpatialWindowContainer | null
30
+ windowComponent?: SpatialWindowComponent | null
31
+ }
32
+
28
33
  /**
29
34
  * Animation callback with timestamp
30
35
  */
@@ -35,10 +40,9 @@ type animCallback = (time: DOMHighResTimeStamp) => Promise<any>
35
40
  * @param options
36
41
  * @returns parsed results
37
42
  */
38
- function _parseParentResources(options?: {
39
- windowContainer?: SpatialWindowContainer | null
40
- windowComponent?: SpatialWindowComponent | null
41
- }): [WindowContainer | null, WebSpatialResource | null] {
43
+ function _parseParentResources(
44
+ options?: CreateResourceOptions,
45
+ ): [WindowContainer | null, WebSpatialResource | null] {
42
46
  var parentWindowContainer: WindowContainer | null = null
43
47
  if (options?.windowContainer !== null) {
44
48
  parentWindowContainer = options?.windowContainer
@@ -88,11 +92,12 @@ export class SpatialSession {
88
92
  * Creates a Entity
89
93
  * @returns Entity
90
94
  */
91
- async createEntity() {
95
+ async createEntity(options?: CreateResourceOptions) {
96
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
92
97
  let entity = await WebSpatial.createResource(
93
98
  'Entity',
94
- WebSpatial.getCurrentWindowContainer(),
95
- WebSpatial.getCurrentWebPanel(),
99
+ parentWindowContainer,
100
+ parentWindow,
96
101
  )
97
102
  return new SpatialEntity(entity)
98
103
  }
@@ -102,15 +107,12 @@ export class SpatialSession {
102
107
  * [TODO] should creation of components be moved to entity? and these made private?
103
108
  * @returns WindowComponent
104
109
  */
105
- async createWindowComponent(options?: {
106
- windowContainer?: SpatialWindowContainer
107
- }) {
110
+ async createWindowComponent(options?: CreateResourceOptions) {
111
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
108
112
  let entity = await WebSpatial.createResource(
109
113
  'SpatialWebView',
110
- options?.windowContainer
111
- ? options?.windowContainer._wg
112
- : WebSpatial.getCurrentWindowContainer(),
113
- WebSpatial.getCurrentWebPanel(),
114
+ parentWindowContainer,
115
+ parentWindow,
114
116
  )
115
117
  return new SpatialWindowComponent(entity)
116
118
  }
@@ -119,15 +121,12 @@ export class SpatialSession {
119
121
  * Creates a ViewComponent used to display 3D content within the entity
120
122
  * @returns SpatialViewComponent
121
123
  */
122
- async createViewComponent(options?: {
123
- windowContainer?: SpatialWindowContainer
124
- }) {
124
+ async createViewComponent(options?: CreateResourceOptions) {
125
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
125
126
  let entity = await WebSpatial.createResource(
126
127
  'SpatialView',
127
- options?.windowContainer
128
- ? options?.windowContainer._wg
129
- : WebSpatial.getCurrentWindowContainer(),
130
- WebSpatial.getCurrentWebPanel(),
128
+ parentWindowContainer,
129
+ parentWindow,
131
130
  )
132
131
  return new SpatialViewComponent(entity)
133
132
  }
@@ -136,15 +135,18 @@ export class SpatialSession {
136
135
  * Creates a ModelComponent used to display geometry + material of a 3D model
137
136
  * @returns ModelComponent
138
137
  */
139
- async createModelComponent(options?: { url: string }) {
138
+ async createModelComponent(
139
+ options?: { url: string } & CreateResourceOptions,
140
+ ) {
141
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
140
142
  var opts = undefined
141
143
  if (options) {
142
144
  opts = { modelURL: options.url }
143
145
  }
144
146
  let entity = await WebSpatial.createResource(
145
147
  'ModelComponent',
146
- WebSpatial.getCurrentWindowContainer(),
147
- WebSpatial.getCurrentWebPanel(),
148
+ parentWindowContainer,
149
+ parentWindow,
148
150
  opts,
149
151
  )
150
152
  return new SpatialModelComponent(entity)
@@ -154,15 +156,18 @@ export class SpatialSession {
154
156
  * Creates a Model3DComponent
155
157
  * @returns Model3DComponent
156
158
  */
157
- async createModel3DComponent(options?: { url: string }) {
159
+ async createModel3DComponent(
160
+ options?: { url: string } & CreateResourceOptions,
161
+ ) {
162
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
158
163
  var opts = undefined
159
164
  if (options) {
160
165
  opts = { modelURL: options.url }
161
166
  }
162
167
  let entity = await WebSpatial.createResource(
163
168
  'Model3DComponent',
164
- WebSpatial.getCurrentWindowContainer(),
165
- WebSpatial.getCurrentWebPanel(),
169
+ parentWindowContainer,
170
+ parentWindow,
166
171
  opts,
167
172
  )
168
173
  return new SpatialModel3DComponent(entity)
@@ -173,11 +178,12 @@ export class SpatialSession {
173
178
  * [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model
174
179
  * @returns InputComponent
175
180
  */
176
- async createInputComponent() {
181
+ async createInputComponent(options?: CreateResourceOptions) {
182
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
177
183
  let entity = await WebSpatial.createResource(
178
184
  'InputComponent',
179
- WebSpatial.getCurrentWindowContainer(),
180
- WebSpatial.getCurrentWebPanel(),
185
+ parentWindowContainer,
186
+ parentWindow,
181
187
  )
182
188
  return new SpatialInputComponent(entity)
183
189
  }
@@ -186,11 +192,14 @@ export class SpatialSession {
186
192
  * Creates a MeshResource containing geometry data
187
193
  * @returns MeshResource
188
194
  */
189
- async createMeshResource(options?: { shape?: string }) {
195
+ async createMeshResource(
196
+ options?: { shape?: string } & CreateResourceOptions,
197
+ ) {
198
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
190
199
  let entity = await WebSpatial.createResource(
191
200
  'MeshResource',
192
- WebSpatial.getCurrentWindowContainer(),
193
- WebSpatial.getCurrentWebPanel(),
201
+ parentWindowContainer,
202
+ parentWindow,
194
203
  options,
195
204
  )
196
205
  return new SpatialMeshResource(entity)
@@ -200,11 +209,14 @@ export class SpatialSession {
200
209
  * Creates a PhysicallyBasedMaterial containing PBR material data
201
210
  * @returns PhysicallyBasedMaterial
202
211
  */
203
- async createPhysicallyBasedMaterialResource(options?: {}) {
212
+ async createPhysicallyBasedMaterialResource(
213
+ options?: {} & CreateResourceOptions,
214
+ ) {
215
+ var [parentWindowContainer, parentWindow] = _parseParentResources(options)
204
216
  let entity = await WebSpatial.createResource(
205
217
  'PhysicallyBasedMaterial',
206
- WebSpatial.getCurrentWindowContainer(),
207
- WebSpatial.getCurrentWebPanel(),
218
+ parentWindowContainer,
219
+ parentWindow,
208
220
  options,
209
221
  )
210
222
  return new SpatialPhysicallyBasedMaterialResource(entity)
@@ -213,11 +225,11 @@ export class SpatialSession {
213
225
  * Creates a WindowContainer
214
226
  * @returns SpatialWindowContainer
215
227
  * */
216
- async createWindowContainer(options?: {
217
- style: WindowStyle
218
- windowContainer?: SpatialWindowContainer | null
219
- windowComponent?: SpatialWindowComponent | null
220
- }) {
228
+ async createWindowContainer(
229
+ options?: {
230
+ style: WindowStyle
231
+ } & CreateResourceOptions,
232
+ ) {
221
233
  var style = options?.style ? options?.style : 'Plain'
222
234
  var [parentWindowContainer, parentWindow] = _parseParentResources(options)
223
235
  return new SpatialWindowContainer(
@@ -99,6 +99,16 @@ export class SpatialModel3DComponent extends EventSpatialComponent {
99
99
  })
100
100
  }
101
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
+
102
112
  /**
103
113
  * Sets whether the model appear in original size or fit the rect
104
114
  * @param resizable
@@ -16,7 +16,7 @@ export class WebSpatialResource {
16
16
  windowContainerId = ''
17
17
  data = {} as any
18
18
 
19
- receiveEvent() {}
19
+ receiveEvent() { }
20
20
  }
21
21
 
22
22
  export class WebSpatial {
@@ -41,7 +41,7 @@ export class WebSpatial {
41
41
  }
42
42
 
43
43
  static init() {
44
- ;(window as any).__SpatialWebEvent = (e: any) => {
44
+ ; (window as any).__SpatialWebEvent = (e: any) => {
45
45
  if (e.resourceId) {
46
46
  var callback = WebSpatial.eventReceivers[e.resourceId]
47
47
  callback(e.data)
@@ -96,10 +96,10 @@ export class WebSpatial {
96
96
  var msg = JSON.stringify(cmd)
97
97
 
98
98
  if (WebSpatial.getBackend() == 'AVP') {
99
- ;(window as any).webkit.messageHandlers.bridge.postMessage(msg)
99
+ ; (window as any).webkit.messageHandlers.bridge.postMessage(msg)
100
100
  return
101
101
  } else {
102
- ;(window as any).bridge.nativeMessage(msg)
102
+ ; (window as any).bridge.nativeMessage(msg)
103
103
  return
104
104
  }
105
105
  }
@@ -261,13 +261,13 @@ export class WebSpatial {
261
261
  // parentWebView is the SpatialWebView that the resource will be tied to (if not provided, resource will continue to exist even if this page is unloaded)
262
262
  static async createResource(
263
263
  type: string,
264
- windowContainer: WindowContainer,
265
- parentWebView: WebSpatialResource,
264
+ windowContainer: WindowContainer | null,
265
+ parentWebView: WebSpatialResource | null,
266
266
  params = {} as any,
267
267
  ) {
268
268
  var cmd = new RemoteCommand('createResource', {
269
- windowContainerID: windowContainer.id,
270
- resourceID: parentWebView.id,
269
+ windowContainerID: windowContainer ? windowContainer.id : undefined,
270
+ resourceID: parentWebView ? parentWebView.id : undefined,
271
271
  type: type,
272
272
  params: params,
273
273
  })