@webspatial/core-sdk 0.1.6 → 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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +712 -2
- package/dist/index.js +1500 -1
- package/dist/index.js.map +1 -0
- package/package.json +6 -5
- package/tsup.config.ts +23 -0
- package/dist/core/Spatial.d.ts +0 -27
- package/dist/core/Spatial.d.ts.map +0 -1
- package/dist/core/Spatial.js +0 -41
- package/dist/core/SpatialEntity.d.ts +0 -92
- package/dist/core/SpatialEntity.d.ts.map +0 -1
- package/dist/core/SpatialEntity.js +0 -122
- package/dist/core/SpatialHelper.d.ts +0 -39
- package/dist/core/SpatialHelper.d.ts.map +0 -1
- package/dist/core/SpatialHelper.js +0 -195
- package/dist/core/SpatialObject.d.ts +0 -20
- package/dist/core/SpatialObject.d.ts.map +0 -1
- package/dist/core/SpatialObject.js +0 -23
- package/dist/core/SpatialSession.d.ts +0 -164
- package/dist/core/SpatialSession.d.ts.map +0 -1
- package/dist/core/SpatialSession.js +0 -318
- package/dist/core/SpatialTransform.d.ts +0 -23
- package/dist/core/SpatialTransform.d.ts.map +0 -1
- package/dist/core/SpatialTransform.js +0 -31
- package/dist/core/SpatialWindowContainer.d.ts +0 -31
- package/dist/core/SpatialWindowContainer.d.ts.map +0 -1
- package/dist/core/SpatialWindowContainer.js +0 -48
- package/dist/core/component/EventSpatialComponent.d.ts +0 -22
- package/dist/core/component/EventSpatialComponent.d.ts.map +0 -1
- package/dist/core/component/EventSpatialComponent.js +0 -23
- package/dist/core/component/SpatialComponent.d.ts +0 -11
- package/dist/core/component/SpatialComponent.d.ts.map +0 -1
- package/dist/core/component/SpatialComponent.js +0 -23
- package/dist/core/component/SpatialInputComponent.d.ts +0 -22
- package/dist/core/component/SpatialInputComponent.d.ts.map +0 -1
- package/dist/core/component/SpatialInputComponent.js +0 -14
- package/dist/core/component/SpatialModel3DComponent.d.ts +0 -91
- package/dist/core/component/SpatialModel3DComponent.d.ts.map +0 -1
- package/dist/core/component/SpatialModel3DComponent.js +0 -185
- package/dist/core/component/SpatialModelComponent.d.ts +0 -22
- package/dist/core/component/SpatialModelComponent.d.ts.map +0 -1
- package/dist/core/component/SpatialModelComponent.js +0 -34
- package/dist/core/component/SpatialViewComponent.d.ts +0 -22
- package/dist/core/component/SpatialViewComponent.d.ts.map +0 -1
- package/dist/core/component/SpatialViewComponent.js +0 -30
- package/dist/core/component/SpatialWindowComponent.d.ts +0 -86
- package/dist/core/component/SpatialWindowComponent.d.ts.map +0 -1
- package/dist/core/component/SpatialWindowComponent.js +0 -114
- package/dist/core/component/index.d.ts +0 -7
- package/dist/core/component/index.d.ts.map +0 -1
- package/dist/core/component/index.js +0 -6
- package/dist/core/index.d.ts +0 -11
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -9
- package/dist/core/private/WebSpatial.d.ts +0 -46
- package/dist/core/private/WebSpatial.d.ts.map +0 -1
- package/dist/core/private/WebSpatial.js +0 -282
- package/dist/core/private/remote-command/RemoteCommand.d.ts +0 -8
- package/dist/core/private/remote-command/RemoteCommand.d.ts.map +0 -1
- package/dist/core/private/remote-command/RemoteCommand.js +0 -11
- package/dist/core/private/remote-command/index.d.ts +0 -2
- package/dist/core/private/remote-command/index.d.ts.map +0 -1
- package/dist/core/private/remote-command/index.js +0 -1
- package/dist/core/resource/SpatialMeshResource.d.ts +0 -7
- package/dist/core/resource/SpatialMeshResource.d.ts.map +0 -1
- package/dist/core/resource/SpatialMeshResource.js +0 -6
- package/dist/core/resource/SpatialPhysicallyBasedMaterialResource.d.ts +0 -37
- package/dist/core/resource/SpatialPhysicallyBasedMaterialResource.d.ts.map +0 -1
- package/dist/core/resource/SpatialPhysicallyBasedMaterialResource.js +0 -37
- package/dist/core/resource/index.d.ts +0 -3
- package/dist/core/resource/index.d.ts.map +0 -1
- package/dist/core/resource/index.js +0 -2
- package/dist/core/types.d.ts +0 -23
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js +0 -1
- package/dist/index.d.ts.map +0 -1
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { RemoteCommand } from './remote-command';
|
|
2
|
-
import { WindowStyle, LoadingMethodKind, sceneDataShape } from '../types';
|
|
3
|
-
export declare class WindowContainer {
|
|
4
|
-
id: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class WebSpatialResource {
|
|
7
|
-
id: string;
|
|
8
|
-
windowContainerId: string;
|
|
9
|
-
data: any;
|
|
10
|
-
receiveEvent(): void;
|
|
11
|
-
}
|
|
12
|
-
export declare class WebSpatial {
|
|
13
|
-
static eventPromises: any;
|
|
14
|
-
static transactionStarted: boolean;
|
|
15
|
-
static transactionCommands: RemoteCommand[];
|
|
16
|
-
private static eventReceivers;
|
|
17
|
-
static registerEventReceiver(resourceId: string, callback: (data: any) => void): void;
|
|
18
|
-
static unregisterEventReceiver(resourceId: string): void;
|
|
19
|
-
static init(): void;
|
|
20
|
-
static startTransaction(): void;
|
|
21
|
-
static sendTransaction(): Promise<unknown>;
|
|
22
|
-
static getBackend(): "AVP" | "UNKNOWN";
|
|
23
|
-
static sendCommand(cmd: RemoteCommand): Promise<void>;
|
|
24
|
-
static getImmersiveWindowContainer(): WindowContainer;
|
|
25
|
-
static getCurrentWindowContainer(): WindowContainer;
|
|
26
|
-
static getCurrentWebPanel(): WebSpatialResource;
|
|
27
|
-
static createScene(style: WindowStyle | undefined, cfg: {
|
|
28
|
-
sceneData: sceneDataShape;
|
|
29
|
-
}): Promise<boolean>;
|
|
30
|
-
static createWindowContainer(style: WindowStyle | undefined, windowContainer: WindowContainer | null, parentWebView: WebSpatialResource | null): Promise<WindowContainer>;
|
|
31
|
-
static destroyResource(resource: WebSpatialResource): Promise<void>;
|
|
32
|
-
static ping(msg: string): Promise<unknown>;
|
|
33
|
-
static getStats(): Promise<any>;
|
|
34
|
-
static inspect(spatialObjectId: string): Promise<any>;
|
|
35
|
-
static inspectRootWindowContainer(): Promise<any>;
|
|
36
|
-
static setComponent(entity: WebSpatialResource, resource: WebSpatialResource): Promise<void>;
|
|
37
|
-
static removeComponent(entity: WebSpatialResource, resource: WebSpatialResource): Promise<void>;
|
|
38
|
-
static createResource(type: string, windowContainer: WindowContainer | null, parentWebView: WebSpatialResource | null, params?: any): Promise<WebSpatialResource>;
|
|
39
|
-
static updateWindowContainer(wg: WindowContainer, data: any): Promise<unknown>;
|
|
40
|
-
static updateResource(resource: WebSpatialResource, data?: any): Promise<unknown>;
|
|
41
|
-
static setLoading(method: LoadingMethodKind, style?: string): Promise<unknown>;
|
|
42
|
-
static openImmersiveSpace(): Promise<void>;
|
|
43
|
-
static dismissImmersiveSpace(): Promise<void>;
|
|
44
|
-
static onFrame(fn: (curTime: number) => Promise<any>): void;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=WebSpatial.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;IAEhB,YAAY;CACb;AAED,qBAAa,UAAU;IACrB,OAAc,aAAa,EAAE,GAAG,CAAK;IAErC,OAAc,kBAAkB,UAAQ;IACxC,OAAc,mBAAmB,kBAAyB;IAG1D,OAAO,CAAC,MAAM,CAAC,cAAc,CACzB;WAEU,qBAAqB,CACjC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI;WAKjB,uBAAuB,CAAC,UAAU,EAAE,MAAM;IAIxD,MAAM,CAAC,IAAI;IAkBX,MAAM,CAAC,gBAAgB;WAKV,eAAe;IAa5B,MAAM,CAAC,UAAU;WAQJ,WAAW,CAAC,GAAG,EAAE,aAAa;IAoB3C,MAAM,CAAC,2BAA2B;IAMlC,MAAM,CAAC,yBAAyB;IAMhC,MAAM,CAAC,kBAAkB;WAOZ,WAAW,CACtB,KAAK,EAAE,WAAW,YAAU,EAC5B,GAAG,EAAE;QACH,SAAS,EAAE,cAAc,CAAA;KAC1B;WAyBU,qBAAqB,CAChC,KAAK,EAAE,WAAW,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"}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { RemoteCommand } from './remote-command';
|
|
2
|
-
export class WindowContainer {
|
|
3
|
-
id = '';
|
|
4
|
-
}
|
|
5
|
-
export class WebSpatialResource {
|
|
6
|
-
id = '';
|
|
7
|
-
windowContainerId = '';
|
|
8
|
-
data = {};
|
|
9
|
-
receiveEvent() { }
|
|
10
|
-
}
|
|
11
|
-
export class WebSpatial {
|
|
12
|
-
static eventPromises = {};
|
|
13
|
-
static transactionStarted = false;
|
|
14
|
-
static transactionCommands = Array();
|
|
15
|
-
// store event receivers
|
|
16
|
-
static eventReceivers = {};
|
|
17
|
-
static registerEventReceiver(resourceId, callback) {
|
|
18
|
-
this.eventReceivers[resourceId] = callback;
|
|
19
|
-
}
|
|
20
|
-
static unregisterEventReceiver(resourceId) {
|
|
21
|
-
delete this.eventReceivers[resourceId];
|
|
22
|
-
}
|
|
23
|
-
static init() {
|
|
24
|
-
;
|
|
25
|
-
window.__SpatialWebEvent = (e) => {
|
|
26
|
-
if (e.resourceId) {
|
|
27
|
-
var callback = WebSpatial.eventReceivers[e.resourceId];
|
|
28
|
-
callback(e.data);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
var p = WebSpatial.eventPromises[e.requestID];
|
|
32
|
-
if (p) {
|
|
33
|
-
if (e.success) {
|
|
34
|
-
p.res(e);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
p.rej(e);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
static startTransaction() {
|
|
44
|
-
WebSpatial.transactionStarted = true;
|
|
45
|
-
WebSpatial.transactionCommands = [];
|
|
46
|
-
}
|
|
47
|
-
static async sendTransaction() {
|
|
48
|
-
WebSpatial.transactionStarted = false;
|
|
49
|
-
var cmd = new RemoteCommand('multiCommand', {
|
|
50
|
-
commandList: WebSpatial.transactionCommands,
|
|
51
|
-
});
|
|
52
|
-
var result = await new Promise((res, rej) => {
|
|
53
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
54
|
-
WebSpatial.sendCommand(cmd);
|
|
55
|
-
});
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
static getBackend() {
|
|
59
|
-
if (window.webkit) {
|
|
60
|
-
return 'AVP';
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return 'UNKNOWN';
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
static async sendCommand(cmd) {
|
|
67
|
-
if (window.__WebSpatialUnloaded) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (WebSpatial.transactionStarted) {
|
|
71
|
-
WebSpatial.transactionCommands.push(cmd);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
var msg = JSON.stringify(cmd);
|
|
75
|
-
if (WebSpatial.getBackend() == 'AVP') {
|
|
76
|
-
;
|
|
77
|
-
window.webkit.messageHandlers.bridge.postMessage(msg);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
;
|
|
82
|
-
window.bridge.nativeMessage(msg);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
static getImmersiveWindowContainer() {
|
|
87
|
-
var wg = new WindowContainer();
|
|
88
|
-
wg.id = 'Immersive';
|
|
89
|
-
return wg;
|
|
90
|
-
}
|
|
91
|
-
static getCurrentWindowContainer() {
|
|
92
|
-
var wg = new WindowContainer();
|
|
93
|
-
wg.id = 'current';
|
|
94
|
-
return wg;
|
|
95
|
-
}
|
|
96
|
-
static getCurrentWebPanel() {
|
|
97
|
-
var wg = new WebSpatialResource();
|
|
98
|
-
wg.id = 'current';
|
|
99
|
-
wg.windowContainerId = WebSpatial.getCurrentWindowContainer().id;
|
|
100
|
-
return wg;
|
|
101
|
-
}
|
|
102
|
-
static async createScene(style = 'Plain', cfg) {
|
|
103
|
-
const { window: newWindow, ...sceneData } = cfg.sceneData;
|
|
104
|
-
const jsbSceneData = {
|
|
105
|
-
...sceneData,
|
|
106
|
-
windowID: newWindow._webSpatialID,
|
|
107
|
-
windowContainerID: newWindow._webSpatialGroupID,
|
|
108
|
-
};
|
|
109
|
-
var cmd = new RemoteCommand('createScene', {
|
|
110
|
-
windowStyle: style,
|
|
111
|
-
sceneData: jsbSceneData,
|
|
112
|
-
windowContainerID: window._webSpatialParentGroupID, // parent WindowContainerID
|
|
113
|
-
});
|
|
114
|
-
try {
|
|
115
|
-
await new Promise((res, rej) => {
|
|
116
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
117
|
-
WebSpatial.sendCommand(cmd);
|
|
118
|
-
});
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
static async createWindowContainer(style = 'Plain', windowContainer, parentWebView) {
|
|
126
|
-
var cmd = new RemoteCommand('createWindowContainer', {
|
|
127
|
-
windowStyle: style,
|
|
128
|
-
windowContainerID: windowContainer ? windowContainer.id : undefined,
|
|
129
|
-
resourceID: parentWebView ? parentWebView.id : undefined,
|
|
130
|
-
});
|
|
131
|
-
var result = await new Promise((res, rej) => {
|
|
132
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
133
|
-
WebSpatial.sendCommand(cmd);
|
|
134
|
-
});
|
|
135
|
-
var res = new WindowContainer();
|
|
136
|
-
res.id = result.data.createdID;
|
|
137
|
-
return res;
|
|
138
|
-
}
|
|
139
|
-
static async destroyResource(resource) {
|
|
140
|
-
const data = {};
|
|
141
|
-
var cmd = new RemoteCommand('destroyResource', {
|
|
142
|
-
windowContainerID: resource.windowContainerId,
|
|
143
|
-
resourceID: resource.id,
|
|
144
|
-
});
|
|
145
|
-
WebSpatial.sendCommand(cmd);
|
|
146
|
-
}
|
|
147
|
-
static async ping(msg) {
|
|
148
|
-
var cmd = new RemoteCommand('ping', {
|
|
149
|
-
windowContainerID: this.getCurrentWindowContainer().id,
|
|
150
|
-
resourceID: this.getCurrentWebPanel().id,
|
|
151
|
-
message: msg,
|
|
152
|
-
});
|
|
153
|
-
if (WebSpatial.transactionStarted) {
|
|
154
|
-
WebSpatial.sendCommand(cmd);
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
var result = await new Promise((res, rej) => {
|
|
159
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
160
|
-
WebSpatial.sendCommand(cmd);
|
|
161
|
-
});
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
static async getStats() {
|
|
166
|
-
var cmd = new RemoteCommand('getStats', {
|
|
167
|
-
windowContainerID: this.getCurrentWindowContainer().id,
|
|
168
|
-
resourceID: this.getCurrentWebPanel().id,
|
|
169
|
-
});
|
|
170
|
-
var result = await new Promise((res, rej) => {
|
|
171
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
172
|
-
WebSpatial.sendCommand(cmd);
|
|
173
|
-
});
|
|
174
|
-
return result.data;
|
|
175
|
-
}
|
|
176
|
-
static async inspect(spatialObjectId) {
|
|
177
|
-
var cmd = new RemoteCommand('inspect', {
|
|
178
|
-
resourceID: spatialObjectId,
|
|
179
|
-
});
|
|
180
|
-
var result = await new Promise((res, rej) => {
|
|
181
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
182
|
-
WebSpatial.sendCommand(cmd);
|
|
183
|
-
});
|
|
184
|
-
return result.data;
|
|
185
|
-
}
|
|
186
|
-
static async inspectRootWindowContainer() {
|
|
187
|
-
return this.inspect('root');
|
|
188
|
-
}
|
|
189
|
-
static async setComponent(entity, resource) {
|
|
190
|
-
var cmd = new RemoteCommand('setComponent', {
|
|
191
|
-
windowContainerID: entity.windowContainerId,
|
|
192
|
-
resourceID: resource.id,
|
|
193
|
-
entityID: entity.id,
|
|
194
|
-
});
|
|
195
|
-
WebSpatial.sendCommand(cmd);
|
|
196
|
-
}
|
|
197
|
-
static async removeComponent(entity, resource) {
|
|
198
|
-
var cmd = new RemoteCommand('removeComponent', {
|
|
199
|
-
windowContainerID: entity.windowContainerId,
|
|
200
|
-
resourceID: resource.id,
|
|
201
|
-
entityID: entity.id,
|
|
202
|
-
});
|
|
203
|
-
WebSpatial.sendCommand(cmd);
|
|
204
|
-
}
|
|
205
|
-
// windowContainer is the group the resource will be tied to (if not provided it will use the current window grou)
|
|
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
|
-
static async createResource(type, windowContainer, parentWebView, params = {}) {
|
|
208
|
-
var cmd = new RemoteCommand('createResource', {
|
|
209
|
-
windowContainerID: windowContainer ? windowContainer.id : undefined,
|
|
210
|
-
resourceID: parentWebView ? parentWebView.id : undefined,
|
|
211
|
-
type: type,
|
|
212
|
-
params: params,
|
|
213
|
-
});
|
|
214
|
-
var result = await new Promise((res, rej) => {
|
|
215
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
216
|
-
WebSpatial.sendCommand(cmd);
|
|
217
|
-
});
|
|
218
|
-
var res = new WebSpatialResource();
|
|
219
|
-
res.id = result.data.createdID;
|
|
220
|
-
res.windowContainerId = cmd.data.windowContainerID;
|
|
221
|
-
return res;
|
|
222
|
-
}
|
|
223
|
-
static async updateWindowContainer(wg, data) {
|
|
224
|
-
var cmd = new RemoteCommand('updateWindowContainer', {
|
|
225
|
-
windowContainerID: wg.id,
|
|
226
|
-
update: data,
|
|
227
|
-
});
|
|
228
|
-
var result = await new Promise((res, rej) => {
|
|
229
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
230
|
-
WebSpatial.sendCommand(cmd);
|
|
231
|
-
});
|
|
232
|
-
return result;
|
|
233
|
-
}
|
|
234
|
-
static async updateResource(resource, data = null) {
|
|
235
|
-
var cmd = new RemoteCommand('updateResource', {
|
|
236
|
-
windowContainerID: resource.windowContainerId,
|
|
237
|
-
resourceID: resource.id,
|
|
238
|
-
update: data || resource.data,
|
|
239
|
-
});
|
|
240
|
-
var result = await new Promise((res, rej) => {
|
|
241
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
242
|
-
WebSpatial.sendCommand(cmd);
|
|
243
|
-
});
|
|
244
|
-
return result;
|
|
245
|
-
}
|
|
246
|
-
static async setLoading(method, style) {
|
|
247
|
-
var cmd = new RemoteCommand('setLoading', {
|
|
248
|
-
windowContainerID: window._webSpatialParentGroupID, // parent WindowContainerID
|
|
249
|
-
loading: {
|
|
250
|
-
method,
|
|
251
|
-
style,
|
|
252
|
-
},
|
|
253
|
-
});
|
|
254
|
-
var result = await new Promise((res, rej) => {
|
|
255
|
-
WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej };
|
|
256
|
-
WebSpatial.sendCommand(cmd);
|
|
257
|
-
});
|
|
258
|
-
return result;
|
|
259
|
-
}
|
|
260
|
-
static async openImmersiveSpace() {
|
|
261
|
-
var cmd = new RemoteCommand('openImmersiveSpace');
|
|
262
|
-
await WebSpatial.sendCommand(cmd);
|
|
263
|
-
}
|
|
264
|
-
static async dismissImmersiveSpace() {
|
|
265
|
-
var cmd = new RemoteCommand('dismissImmersiveSpace');
|
|
266
|
-
await WebSpatial.sendCommand(cmd);
|
|
267
|
-
}
|
|
268
|
-
static onFrame(fn) {
|
|
269
|
-
var dt = 0;
|
|
270
|
-
var loop = async () => {
|
|
271
|
-
var curTime = window.performance.now();
|
|
272
|
-
await fn(curTime);
|
|
273
|
-
var updateTime = window.performance.now() - curTime;
|
|
274
|
-
// Call update loop targetting 60 fps
|
|
275
|
-
setTimeout(() => {
|
|
276
|
-
loop();
|
|
277
|
-
}, Math.max(1000 / 60 - updateTime, 0));
|
|
278
|
-
};
|
|
279
|
-
loop();
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
WebSpatial.init();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteCommand.d.ts","sourceRoot":"","sources":["../../../../src/core/private/remote-command/RemoteCommand.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAI;IAEjC,OAAO,EAAE,MAAM,CAAA;IAEf,IAAI,EAAE,GAAG,CAAA;IAET,SAAS,EAAE,MAAM,CAAA;gBAEL,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAKpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/private/remote-command/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { RemoteCommand } from './RemoteCommand';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialMeshResource.d.ts","sourceRoot":"","sources":["../../../src/core/resource/SpatialMeshResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;CAAG"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { SpatialModelComponent } from '../component';
|
|
2
|
-
import { SpatialObject } from '../SpatialObject';
|
|
3
|
-
/**
|
|
4
|
-
* PBR material which can be set on a SpatialModelComponent
|
|
5
|
-
*/
|
|
6
|
-
export declare class SpatialPhysicallyBasedMaterialResource extends SpatialObject {
|
|
7
|
-
/**
|
|
8
|
-
* Base color of the material containing rgba between 0 and 1
|
|
9
|
-
*/
|
|
10
|
-
baseColor: {
|
|
11
|
-
r: number;
|
|
12
|
-
g: number;
|
|
13
|
-
b: number;
|
|
14
|
-
a: number;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* PBR metalic value between 0 and 1
|
|
18
|
-
*/
|
|
19
|
-
metallic: {
|
|
20
|
-
value: number;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* PBR roughness value between 0 and 1
|
|
24
|
-
*/
|
|
25
|
-
roughness: {
|
|
26
|
-
value: number;
|
|
27
|
-
};
|
|
28
|
-
_modelComponentAttachedTo: {
|
|
29
|
-
[key: string]: SpatialModelComponent;
|
|
30
|
-
};
|
|
31
|
-
_addToComponent(c: SpatialModelComponent): void;
|
|
32
|
-
/**
|
|
33
|
-
* Syncs state of color, metallic, roupghness to the renderer
|
|
34
|
-
*/
|
|
35
|
-
update(): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=SpatialPhysicallyBasedMaterialResource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialPhysicallyBasedMaterialResource.d.ts","sourceRoot":"","sources":["../../../src/core/resource/SpatialPhysicallyBasedMaterialResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;GAEG;AACH,qBAAa,sCAAuC,SAAQ,aAAa;IACvE;;OAEG;IACH,SAAS;;;;;MAAqC;IAC9C;;OAEG;IACH,QAAQ;;MAAiB;IACzB;;OAEG;IACH,SAAS;;MAAiB;IAE1B,yBAAyB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;KAAE,CAAK;IACxE,eAAe,CAAC,CAAC,EAAE,qBAAqB;IAIxC;;OAEG;IACG,MAAM;CAYb"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { WebSpatial } from '../private/WebSpatial';
|
|
2
|
-
import { SpatialObject } from '../SpatialObject';
|
|
3
|
-
/**
|
|
4
|
-
* PBR material which can be set on a SpatialModelComponent
|
|
5
|
-
*/
|
|
6
|
-
export class SpatialPhysicallyBasedMaterialResource extends SpatialObject {
|
|
7
|
-
/**
|
|
8
|
-
* Base color of the material containing rgba between 0 and 1
|
|
9
|
-
*/
|
|
10
|
-
baseColor = { r: 0.0, g: 0.7, b: 0.7, a: 1.0 };
|
|
11
|
-
/**
|
|
12
|
-
* PBR metalic value between 0 and 1
|
|
13
|
-
*/
|
|
14
|
-
metallic = { value: 0.5 };
|
|
15
|
-
/**
|
|
16
|
-
* PBR roughness value between 0 and 1
|
|
17
|
-
*/
|
|
18
|
-
roughness = { value: 0.5 };
|
|
19
|
-
_modelComponentAttachedTo = {};
|
|
20
|
-
_addToComponent(c) {
|
|
21
|
-
this._modelComponentAttachedTo[c._resource.id] = c;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Syncs state of color, metallic, roupghness to the renderer
|
|
25
|
-
*/
|
|
26
|
-
async update() {
|
|
27
|
-
await WebSpatial.updateResource(this._resource, {
|
|
28
|
-
baseColor: this.baseColor,
|
|
29
|
-
metallic: this.metallic,
|
|
30
|
-
roughness: this.roughness,
|
|
31
|
-
});
|
|
32
|
-
// Since realitykit's materials are structs and not references, every time we change a material, we must copy it to all of the components its attached to to observe the update
|
|
33
|
-
for (var key in this._modelComponentAttachedTo) {
|
|
34
|
-
await this._modelComponentAttachedTo[key]._syncMaterials();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/resource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAA"}
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type WindowStyle = 'Plain' | 'Volumetric';
|
|
2
|
-
export interface WindowContainerOptions {
|
|
3
|
-
defaultSize?: {
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
};
|
|
7
|
-
resizability?: 'automatic' | 'contentSize' | 'contentMinSize';
|
|
8
|
-
}
|
|
9
|
-
export type LoadingMethodKind = 'show' | 'hide';
|
|
10
|
-
export interface sceneDataShape {
|
|
11
|
-
method?: 'createRoot' | 'showRoot';
|
|
12
|
-
sceneConfig?: WindowContainerOptions;
|
|
13
|
-
url?: string;
|
|
14
|
-
window: Window;
|
|
15
|
-
}
|
|
16
|
-
export interface sceneDataJSBShape {
|
|
17
|
-
method?: 'createRoot' | 'showRoot';
|
|
18
|
-
sceneConfig?: WindowContainerOptions;
|
|
19
|
-
url?: string;
|
|
20
|
-
windowID?: string;
|
|
21
|
-
windowContainerID?: string;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,YAAY,CAAA;AAEhD,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IAED,YAAY,CAAC,EAAE,WAAW,GAAG,aAAa,GAAG,gBAAgB,CAAA;CAC9D;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAA;AAE/C,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,WAAW,CAAC,EAAE,sBAAsB,CAAA;IACpC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,WAAW,CAAC,EAAE,sBAAsB,CAAA;IACpC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B"}
|
package/dist/core/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|