@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.
- package/CHANGELOG.md +8 -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,318 +0,0 @@
|
|
|
1
|
-
import { SpatialEntity } from './SpatialEntity';
|
|
2
|
-
import { SpatialWindowContainer } from './SpatialWindowContainer';
|
|
3
|
-
import { WebSpatial, WebSpatialResource, } from './private/WebSpatial';
|
|
4
|
-
import { SpatialMeshResource, SpatialPhysicallyBasedMaterialResource, } from './resource';
|
|
5
|
-
import { SpatialModelComponent, SpatialInputComponent, SpatialWindowComponent, SpatialViewComponent, SpatialModel3DComponent, } from './component';
|
|
6
|
-
import { RemoteCommand } from './private/remote-command';
|
|
7
|
-
/**
|
|
8
|
-
* Parses the resource owners of the created object. If unedfined, will use the current window container and web panel. If null the created resource will not be destroyed unless explicitly destroyed.
|
|
9
|
-
* @param options
|
|
10
|
-
* @returns parsed results
|
|
11
|
-
*/
|
|
12
|
-
function _parseParentResources(options) {
|
|
13
|
-
var parentWindowContainer = null;
|
|
14
|
-
if (options?.windowContainer !== null) {
|
|
15
|
-
parentWindowContainer = options?.windowContainer
|
|
16
|
-
? options?.windowContainer._wg
|
|
17
|
-
: WebSpatial.getCurrentWindowContainer();
|
|
18
|
-
}
|
|
19
|
-
var parentWindow = null;
|
|
20
|
-
if (options?.windowComponent !== null) {
|
|
21
|
-
parentWindow = options?.windowComponent
|
|
22
|
-
? options?.windowComponent._resource
|
|
23
|
-
: WebSpatial.getCurrentWebPanel();
|
|
24
|
-
}
|
|
25
|
-
return [parentWindowContainer, parentWindow];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Session use to establish a connection to the spatial renderer of the system. All resources must be created by the session
|
|
29
|
-
*/
|
|
30
|
-
export class SpatialSession {
|
|
31
|
-
/** @hidden */
|
|
32
|
-
_engineUpdateListeners = Array();
|
|
33
|
-
/** @hidden */
|
|
34
|
-
_frameLoopStarted = false;
|
|
35
|
-
/**
|
|
36
|
-
* Add event listener callback to be called each frame
|
|
37
|
-
* @param callback callback to be called each update
|
|
38
|
-
*/
|
|
39
|
-
addOnEngineUpdateEventListener(callback) {
|
|
40
|
-
this._engineUpdateListeners.push(callback);
|
|
41
|
-
if (!this._frameLoopStarted) {
|
|
42
|
-
this._frameLoopStarted = true;
|
|
43
|
-
WebSpatial.onFrame(async (time) => {
|
|
44
|
-
await Promise.all(this._engineUpdateListeners.map(cb => {
|
|
45
|
-
return cb(time);
|
|
46
|
-
}));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Creates a Entity
|
|
52
|
-
* @returns Entity
|
|
53
|
-
*/
|
|
54
|
-
async createEntity(options) {
|
|
55
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
56
|
-
let entity = await WebSpatial.createResource('Entity', parentWindowContainer, parentWindow);
|
|
57
|
-
return new SpatialEntity(entity);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Creates a WindowComponent
|
|
61
|
-
* [TODO] should creation of components be moved to entity? and these made private?
|
|
62
|
-
* @returns WindowComponent
|
|
63
|
-
*/
|
|
64
|
-
async createWindowComponent(options) {
|
|
65
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
66
|
-
let entity = await WebSpatial.createResource('SpatialWebView', parentWindowContainer, parentWindow);
|
|
67
|
-
return new SpatialWindowComponent(entity);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Creates a ViewComponent used to display 3D content within the entity
|
|
71
|
-
* @returns SpatialViewComponent
|
|
72
|
-
*/
|
|
73
|
-
async createViewComponent(options) {
|
|
74
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
75
|
-
let entity = await WebSpatial.createResource('SpatialView', parentWindowContainer, parentWindow);
|
|
76
|
-
return new SpatialViewComponent(entity);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Creates a ModelComponent used to display geometry + material of a 3D model
|
|
80
|
-
* @returns ModelComponent
|
|
81
|
-
*/
|
|
82
|
-
async createModelComponent(options) {
|
|
83
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
84
|
-
var opts = undefined;
|
|
85
|
-
if (options) {
|
|
86
|
-
opts = { modelURL: options.url };
|
|
87
|
-
}
|
|
88
|
-
let entity = await WebSpatial.createResource('ModelComponent', parentWindowContainer, parentWindow, opts);
|
|
89
|
-
return new SpatialModelComponent(entity);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Creates a Model3DComponent
|
|
93
|
-
* @returns Model3DComponent
|
|
94
|
-
*/
|
|
95
|
-
async createModel3DComponent(options) {
|
|
96
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
97
|
-
var opts = undefined;
|
|
98
|
-
if (options) {
|
|
99
|
-
opts = { modelURL: options.url };
|
|
100
|
-
}
|
|
101
|
-
let entity = await WebSpatial.createResource('Model3DComponent', parentWindowContainer, parentWindow, opts);
|
|
102
|
-
return new SpatialModel3DComponent(entity);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Creates a InputComponent
|
|
106
|
-
* [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model
|
|
107
|
-
* @returns InputComponent
|
|
108
|
-
*/
|
|
109
|
-
async createInputComponent(options) {
|
|
110
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
111
|
-
let entity = await WebSpatial.createResource('InputComponent', parentWindowContainer, parentWindow);
|
|
112
|
-
return new SpatialInputComponent(entity);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Creates a MeshResource containing geometry data
|
|
116
|
-
* @returns MeshResource
|
|
117
|
-
*/
|
|
118
|
-
async createMeshResource(options) {
|
|
119
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
120
|
-
let entity = await WebSpatial.createResource('MeshResource', parentWindowContainer, parentWindow, options);
|
|
121
|
-
return new SpatialMeshResource(entity);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Creates a PhysicallyBasedMaterial containing PBR material data
|
|
125
|
-
* @returns PhysicallyBasedMaterial
|
|
126
|
-
*/
|
|
127
|
-
async createPhysicallyBasedMaterialResource(options) {
|
|
128
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
129
|
-
let entity = await WebSpatial.createResource('PhysicallyBasedMaterial', parentWindowContainer, parentWindow, options);
|
|
130
|
-
return new SpatialPhysicallyBasedMaterialResource(entity);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Creates a WindowContainer
|
|
134
|
-
* @returns SpatialWindowContainer
|
|
135
|
-
* */
|
|
136
|
-
async createWindowContainer(options) {
|
|
137
|
-
var style = options?.style ? options?.style : 'Plain';
|
|
138
|
-
var [parentWindowContainer, parentWindow] = _parseParentResources(options);
|
|
139
|
-
return new SpatialWindowContainer(await WebSpatial.createWindowContainer(style, parentWindowContainer, parentWindow));
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Creates a Scene to display content within an anchored area managed by the OS
|
|
143
|
-
* @hidden
|
|
144
|
-
* @param {WindowStyle} [style='Plain'] - The style of the Scene container to be created with. Defaults to 'Plain'.
|
|
145
|
-
* @param {Object} [cfg={}] - Configuration object for the Scene.
|
|
146
|
-
* @returns Boolean
|
|
147
|
-
*/
|
|
148
|
-
async _createScene(style = 'Plain', cfg) {
|
|
149
|
-
return await WebSpatial.createScene(style, cfg);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Retrieves the window for this page
|
|
153
|
-
* @returns the window component corresponding to the js running on this page
|
|
154
|
-
* [TODO] discuss implications of this not being async
|
|
155
|
-
*/
|
|
156
|
-
getCurrentWindowComponent() {
|
|
157
|
-
return new SpatialWindowComponent(WebSpatial.getCurrentWebPanel());
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Retrieves the parent window for this page or null if this is the root page
|
|
161
|
-
* @returns the window component or null
|
|
162
|
-
*/
|
|
163
|
-
async getParentWindowComponent() {
|
|
164
|
-
let parentResp = await WebSpatial.updateResource(WebSpatial.getCurrentWebPanel(), { getParentID: '' });
|
|
165
|
-
if (parentResp.data.parentID === '') {
|
|
166
|
-
return new Promise((res, rej) => {
|
|
167
|
-
res(null);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
var res = new WebSpatialResource();
|
|
172
|
-
res.id = parentResp.data.parentID;
|
|
173
|
-
return new SpatialWindowComponent(res);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Logs a message to the native apps console
|
|
178
|
-
* @param msg mesage to log
|
|
179
|
-
*/
|
|
180
|
-
async log(...msg) {
|
|
181
|
-
await WebSpatial.sendCommand(new RemoteCommand('log', {
|
|
182
|
-
logString: msg.map(x => {
|
|
183
|
-
return JSON.stringify(x);
|
|
184
|
-
}),
|
|
185
|
-
}));
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* @hidden
|
|
189
|
-
* Debugging only, used to ping the native renderer
|
|
190
|
-
*/
|
|
191
|
-
async _ping(msg) {
|
|
192
|
-
return await WebSpatial.ping(msg);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* @hidden
|
|
196
|
-
* Debugging to get internal state from native code
|
|
197
|
-
* @returns data as a js object
|
|
198
|
-
*/
|
|
199
|
-
async _getStats() {
|
|
200
|
-
return (await WebSpatial.getStats());
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* @hidden
|
|
204
|
-
*/
|
|
205
|
-
async _inspect(spatialObjectId = WebSpatial.getCurrentWebPanel().id) {
|
|
206
|
-
return WebSpatial.inspect(spatialObjectId);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* @hidden
|
|
210
|
-
*/
|
|
211
|
-
async _inspectRootWindowContainer() {
|
|
212
|
-
return WebSpatial.inspectRootWindowContainer();
|
|
213
|
-
}
|
|
214
|
-
/** Opens the immersive space */
|
|
215
|
-
async openImmersiveSpace() {
|
|
216
|
-
return await WebSpatial.openImmersiveSpace();
|
|
217
|
-
}
|
|
218
|
-
/** Closes the immersive space */
|
|
219
|
-
async dismissImmersiveSpace() {
|
|
220
|
-
return await WebSpatial.dismissImmersiveSpace();
|
|
221
|
-
}
|
|
222
|
-
static _immersiveWindowContainer = null;
|
|
223
|
-
/**
|
|
224
|
-
* Retreives the window container corresponding to the Immersive space
|
|
225
|
-
* @returns the immersive window container
|
|
226
|
-
*/
|
|
227
|
-
async getImmersiveWindowContainer() {
|
|
228
|
-
if (SpatialSession._immersiveWindowContainer) {
|
|
229
|
-
return SpatialSession._immersiveWindowContainer;
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
SpatialSession._immersiveWindowContainer = new SpatialWindowContainer(WebSpatial.getImmersiveWindowContainer());
|
|
233
|
-
return SpatialSession._immersiveWindowContainer;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
// Retreives the window container that is the parent to this spatial web page
|
|
237
|
-
static _currentWindowContainer = null;
|
|
238
|
-
/**
|
|
239
|
-
* Gets the current window container for the window
|
|
240
|
-
* [TODO] discuss what happens if it doesnt yet have a window container
|
|
241
|
-
* @returns the current window container for the window
|
|
242
|
-
*/
|
|
243
|
-
getCurrentWindowContainer() {
|
|
244
|
-
if (SpatialSession._currentWindowContainer) {
|
|
245
|
-
return SpatialSession._currentWindowContainer;
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
SpatialSession._currentWindowContainer = new SpatialWindowContainer(WebSpatial.getCurrentWindowContainer());
|
|
249
|
-
return SpatialSession._currentWindowContainer;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Start a transaction that queues up commands to submit them all at once to reduce ipc overhead
|
|
254
|
-
* @param fn function to be run, within this function, promises will not resolve
|
|
255
|
-
* @returns promise for the entire transaction completion
|
|
256
|
-
*/
|
|
257
|
-
transaction(fn) {
|
|
258
|
-
WebSpatial.startTransaction();
|
|
259
|
-
fn();
|
|
260
|
-
return WebSpatial.sendTransaction();
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Creates a window context object that is compatable with SpatialWindowComponent's setFromWindow API
|
|
264
|
-
* @returns window context
|
|
265
|
-
*/
|
|
266
|
-
async createWindowContext() {
|
|
267
|
-
let openedWindow = window.open('webspatial://createWindowContext');
|
|
268
|
-
if (WebSpatial.getBackend() != 'AVP') {
|
|
269
|
-
// Currently there is a bug with webview which requires us to trigger a navigation before native code can interact with created webview
|
|
270
|
-
var counter = 0;
|
|
271
|
-
while (openedWindow.window.testAPI == null) {
|
|
272
|
-
if (counter > 15) {
|
|
273
|
-
openedWindow?.close();
|
|
274
|
-
openedWindow = window.open('about:blank');
|
|
275
|
-
counter = 0;
|
|
276
|
-
this.log('unexpected error when trying to open new window, retrying.');
|
|
277
|
-
}
|
|
278
|
-
var locName = 'about:blank?x' + counter;
|
|
279
|
-
openedWindow.location.href = locName;
|
|
280
|
-
counter++;
|
|
281
|
-
await new Promise(resolve => setTimeout(resolve, 10));
|
|
282
|
-
}
|
|
283
|
-
;
|
|
284
|
-
openedWindow._webSpatialID = openedWindow.window.testAPI.getWindowID();
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
while (openedWindow.window._webSpatialID == undefined) {
|
|
288
|
-
await new Promise(resolve => setTimeout(resolve, 10));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
openedWindow.document.head.innerHTML =
|
|
292
|
-
'<meta name="viewport" content="width=device-width, initial-scale=1">';
|
|
293
|
-
return openedWindow;
|
|
294
|
-
}
|
|
295
|
-
// Get Entity by id. Currently for debugging only.
|
|
296
|
-
/** @hidden */
|
|
297
|
-
async _getEntity(id) {
|
|
298
|
-
const entityInfo = await WebSpatial.inspect(id);
|
|
299
|
-
const [_, x, y, z] = entityInfo.position.match(/(\d+\.?\d*)/g);
|
|
300
|
-
const [__, sx, sy, sz] = entityInfo.scale.match(/(\d+\.?\d*)/g);
|
|
301
|
-
var res = new WebSpatialResource();
|
|
302
|
-
res.id = id;
|
|
303
|
-
res.windowContainerId = WebSpatial.getCurrentWindowContainer().id;
|
|
304
|
-
const entity = new SpatialEntity(res);
|
|
305
|
-
entity.transform.position.x = parseFloat(x);
|
|
306
|
-
entity.transform.position.y = parseFloat(y);
|
|
307
|
-
entity.transform.position.z = parseFloat(z);
|
|
308
|
-
entity.transform.scale.x = parseFloat(sx);
|
|
309
|
-
entity.transform.scale.y = parseFloat(sy);
|
|
310
|
-
entity.transform.scale.z = parseFloat(sz);
|
|
311
|
-
return entity;
|
|
312
|
-
}
|
|
313
|
-
// set loading view.
|
|
314
|
-
/** @hidden */
|
|
315
|
-
async setLoading(method, style) {
|
|
316
|
-
return WebSpatial.setLoading(method, style);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export declare class Vec3 {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
z: number;
|
|
5
|
-
constructor(x?: number, y?: number, z?: number);
|
|
6
|
-
}
|
|
7
|
-
export declare class Vec4 {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
z: number;
|
|
11
|
-
w: number;
|
|
12
|
-
constructor(x?: number, y?: number, z?: number, w?: number);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Transform containing position, orientation and scale
|
|
16
|
-
*/
|
|
17
|
-
export declare class SpatialTransform {
|
|
18
|
-
position: Vec3;
|
|
19
|
-
/** Quaternion value for x,y,z,w */
|
|
20
|
-
orientation: Vec4;
|
|
21
|
-
scale: Vec3;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=SpatialTransform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialTransform.d.ts","sourceRoot":"","sources":["../../src/core/SpatialTransform.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;IAEN,CAAC;IACD,CAAC;IACD,CAAC;gBAFD,CAAC,SAAI,EACL,CAAC,SAAI,EACL,CAAC,SAAI;CAEf;AAED,qBAAa,IAAI;IAEN,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;gBAHD,CAAC,SAAI,EACL,CAAC,SAAI,EACL,CAAC,SAAI,EACL,CAAC,SAAI;CAEf;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,OAAoB;IAC5B,mCAAmC;IACnC,WAAW,OAAuB;IAClC,KAAK,OAAoB;CAC1B"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export class Vec3 {
|
|
2
|
-
x;
|
|
3
|
-
y;
|
|
4
|
-
z;
|
|
5
|
-
constructor(x = 0, y = 0, z = 0) {
|
|
6
|
-
this.x = x;
|
|
7
|
-
this.y = y;
|
|
8
|
-
this.z = z;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export class Vec4 {
|
|
12
|
-
x;
|
|
13
|
-
y;
|
|
14
|
-
z;
|
|
15
|
-
w;
|
|
16
|
-
constructor(x = 0, y = 0, z = 0, w = 1) {
|
|
17
|
-
this.x = x;
|
|
18
|
-
this.y = y;
|
|
19
|
-
this.z = z;
|
|
20
|
-
this.w = w;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Transform containing position, orientation and scale
|
|
25
|
-
*/
|
|
26
|
-
export class SpatialTransform {
|
|
27
|
-
position = new Vec3(0, 0, 0);
|
|
28
|
-
/** Quaternion value for x,y,z,w */
|
|
29
|
-
orientation = new Vec4(0, 0, 0, 1);
|
|
30
|
-
scale = new Vec3(1, 1, 1);
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { WindowContainer } from './private/WebSpatial';
|
|
2
|
-
import { SpatialEntity } from './SpatialEntity';
|
|
3
|
-
/**
|
|
4
|
-
* Anchored window managed by the OS
|
|
5
|
-
*/
|
|
6
|
-
export declare class SpatialWindowContainer {
|
|
7
|
-
/** @hidden */
|
|
8
|
-
_wg: WindowContainer;
|
|
9
|
-
/** @hidden */
|
|
10
|
-
constructor(
|
|
11
|
-
/** @hidden */
|
|
12
|
-
_wg: WindowContainer);
|
|
13
|
-
/**
|
|
14
|
-
* @hidden
|
|
15
|
-
* Sets sets the open configuration for opening new window containers
|
|
16
|
-
* @param options style options
|
|
17
|
-
*/
|
|
18
|
-
_setOpenSettings(options: {
|
|
19
|
-
resolution: {
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
};
|
|
23
|
-
}): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the root entity of the windowContainer
|
|
26
|
-
* @returns the root entity of the windowContainer if one exists
|
|
27
|
-
*/
|
|
28
|
-
getRootEntity(): Promise<SpatialEntity | null>;
|
|
29
|
-
setRootEntity(entity: SpatialEntity): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=SpatialWindowContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialWindowContainer.d.ts","sourceRoot":"","sources":["../../src/core/SpatialWindowContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAChB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;GAEG;AACH,qBAAa,sBAAsB;IAG/B,cAAc;IACP,GAAG,EAAE,eAAe;IAH7B,cAAc;;IAEZ,cAAc;IACP,GAAG,EAAE,eAAe;IAE7B;;;;OAIG;IACG,gBAAgB,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;IAMjF;;;OAGG;IACG,aAAa;IAgBb,aAAa,CAAC,MAAM,EAAE,aAAa;CAG1C"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { WebSpatial, WebSpatialResource, } from './private/WebSpatial';
|
|
2
|
-
import { SpatialEntity } from './SpatialEntity';
|
|
3
|
-
/**
|
|
4
|
-
* Anchored window managed by the OS
|
|
5
|
-
*/
|
|
6
|
-
export class SpatialWindowContainer {
|
|
7
|
-
_wg;
|
|
8
|
-
/** @hidden */
|
|
9
|
-
constructor(
|
|
10
|
-
/** @hidden */
|
|
11
|
-
_wg) {
|
|
12
|
-
this._wg = _wg;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @hidden
|
|
16
|
-
* Sets sets the open configuration for opening new window containers
|
|
17
|
-
* @param options style options
|
|
18
|
-
*/
|
|
19
|
-
async _setOpenSettings(options) {
|
|
20
|
-
await WebSpatial.updateWindowContainer(this._wg, {
|
|
21
|
-
nextOpenSettings: options,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the root entity of the windowContainer
|
|
26
|
-
* @returns the root entity of the windowContainer if one exists
|
|
27
|
-
*/
|
|
28
|
-
async getRootEntity() {
|
|
29
|
-
let reqResp = await WebSpatial.updateWindowContainer(this._wg, {
|
|
30
|
-
getRootEntityID: '',
|
|
31
|
-
});
|
|
32
|
-
if (reqResp.data.rootEntId === '') {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
var res = new WebSpatialResource();
|
|
37
|
-
res.id = reqResp.data.rootEntId;
|
|
38
|
-
return new SpatialEntity(res);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/*
|
|
42
|
-
* Sets the root entity that this windowContainer will display (this does not effect resource ownership)
|
|
43
|
-
* @param entity to display
|
|
44
|
-
*/
|
|
45
|
-
async setRootEntity(entity) {
|
|
46
|
-
await entity._setParentWindowContainer(this);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { WebSpatialResource } from '../private/WebSpatial';
|
|
2
|
-
import { SpatialComponent } from './SpatialComponent';
|
|
3
|
-
/**
|
|
4
|
-
* @description
|
|
5
|
-
* Represents a spatial component that handles events related to spatial interactions.
|
|
6
|
-
* This class extends `SpatialComponent` and provides additional functionality for managing
|
|
7
|
-
* event-driven spatial behaviors.
|
|
8
|
-
*
|
|
9
|
-
* @hidden
|
|
10
|
-
* This class is intended for internal use and should not be exposed in the public API.
|
|
11
|
-
*/
|
|
12
|
-
export declare abstract class EventSpatialComponent extends SpatialComponent {
|
|
13
|
-
constructor(_resource: WebSpatialResource);
|
|
14
|
-
/**
|
|
15
|
-
* @description
|
|
16
|
-
* Abstract method to be implemented by subclasses. Called when a spatial event is received.
|
|
17
|
-
* @param data The data associated with the received event.
|
|
18
|
-
*/
|
|
19
|
-
protected abstract onRecvEvent(data: any): void;
|
|
20
|
-
protected onDestroy(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=EventSpatialComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventSpatialComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/EventSpatialComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;;;;;GAQG;AACH,8BAAsB,qBAAsB,SAAQ,gBAAgB;gBAEtD,SAAS,EAAE,kBAAkB;IAOzC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;cAEtB,SAAS;CAGnC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { WebSpatial } from '../private/WebSpatial';
|
|
2
|
-
import { SpatialComponent } from './SpatialComponent';
|
|
3
|
-
/**
|
|
4
|
-
* @description
|
|
5
|
-
* Represents a spatial component that handles events related to spatial interactions.
|
|
6
|
-
* This class extends `SpatialComponent` and provides additional functionality for managing
|
|
7
|
-
* event-driven spatial behaviors.
|
|
8
|
-
*
|
|
9
|
-
* @hidden
|
|
10
|
-
* This class is intended for internal use and should not be exposed in the public API.
|
|
11
|
-
*/
|
|
12
|
-
export class EventSpatialComponent extends SpatialComponent {
|
|
13
|
-
// Class implementation goes here
|
|
14
|
-
constructor(_resource) {
|
|
15
|
-
super(_resource);
|
|
16
|
-
WebSpatial.registerEventReceiver(_resource.id, (data) => {
|
|
17
|
-
this.onRecvEvent(data);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async onDestroy() {
|
|
21
|
-
WebSpatial.unregisterEventReceiver(this._resource.id);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SpatialEntity } from '../SpatialEntity';
|
|
2
|
-
import { SpatialObject } from '../SpatialObject';
|
|
3
|
-
/** @hidden */
|
|
4
|
-
export declare class SpatialComponent extends SpatialObject {
|
|
5
|
-
/**
|
|
6
|
-
* Gets the entity this component is attached to
|
|
7
|
-
* @returns entity or null
|
|
8
|
-
*/
|
|
9
|
-
getEntity(): Promise<SpatialEntity | null>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=SpatialComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,cAAc;AACd,qBAAa,gBAAiB,SAAQ,aAAa;IACjD;;;OAGG;IACG,SAAS;CAehB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { WebSpatial, WebSpatialResource } from '../private/WebSpatial';
|
|
2
|
-
import { SpatialEntity } from '../SpatialEntity';
|
|
3
|
-
import { SpatialObject } from '../SpatialObject';
|
|
4
|
-
/** @hidden */
|
|
5
|
-
export class SpatialComponent extends SpatialObject {
|
|
6
|
-
/**
|
|
7
|
-
* Gets the entity this component is attached to
|
|
8
|
-
* @returns entity or null
|
|
9
|
-
*/
|
|
10
|
-
async getEntity() {
|
|
11
|
-
let reqResp = await WebSpatial.updateResource(WebSpatial.getCurrentWebPanel(), { getEntityID: '' });
|
|
12
|
-
if (reqResp.data.parentID === '') {
|
|
13
|
-
return new Promise((res, rej) => {
|
|
14
|
-
res(null);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
var res = new WebSpatialResource();
|
|
19
|
-
res.id = reqResp.data.parentID;
|
|
20
|
-
return new SpatialEntity(res);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Vec3 } from '../SpatialTransform';
|
|
2
|
-
import { EventSpatialComponent } from './EventSpatialComponent';
|
|
3
|
-
/**
|
|
4
|
-
* Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
|
|
5
|
-
*/
|
|
6
|
-
type TranslateEvent = {
|
|
7
|
-
eventType: 'dragstart' | 'dragend' | 'drag';
|
|
8
|
-
translate?: Vec3;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Used to handle input events on an entity
|
|
12
|
-
*/
|
|
13
|
-
export declare class SpatialInputComponent extends EventSpatialComponent {
|
|
14
|
-
protected onRecvEvent(data: any): void;
|
|
15
|
-
/**
|
|
16
|
-
* Callback fired when a translate event occurs
|
|
17
|
-
* @param data translate event data
|
|
18
|
-
*/
|
|
19
|
-
onTranslate(data: TranslateEvent): void;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=SpatialInputComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialInputComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialInputComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D;;GAEG;AACH,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAA;IAC3C,SAAS,CAAC,EAAE,IAAI,CAAA;CACjB,CAAA;AACD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,qBAAqB;cAC3C,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAI/C;;;OAGG;IACI,WAAW,CAAC,IAAI,EAAE,cAAc;CACxC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { EventSpatialComponent } from './EventSpatialComponent';
|
|
2
|
-
/**
|
|
3
|
-
* Used to handle input events on an entity
|
|
4
|
-
*/
|
|
5
|
-
export class SpatialInputComponent extends EventSpatialComponent {
|
|
6
|
-
onRecvEvent(data) {
|
|
7
|
-
this.onTranslate(data);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Callback fired when a translate event occurs
|
|
11
|
-
* @param data translate event data
|
|
12
|
-
*/
|
|
13
|
-
onTranslate(data) { }
|
|
14
|
-
}
|