@webspatial/core-sdk 1.1.0 → 1.2.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 +10 -0
- package/dist/iife/index.d.ts +29 -32
- package/dist/iife/index.global.js +3 -3
- package/dist/iife/index.global.js.map +1 -1
- package/dist/index.d.ts +29 -32
- package/dist/index.js +146 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/JSBCommand.ts +1 -1
- package/src/SpatialScene.ts +2 -2
- package/src/SpatialSession.ts +7 -4
- package/src/SpatializedElement.ts +13 -53
- package/src/SpatializedStatic3DElement.ts +1 -1
- package/src/WebMsgCommand.ts +8 -3
- package/src/coverage-boost.test.ts +1060 -0
- package/src/jsbcommand.coverage.test.ts +542 -0
- package/src/platform-adapter/index.ts +31 -3
- package/src/platform-adapter/vision-os/VisionOSPlatform.ts +0 -1
- package/src/platform-adapter/xr/XRPlatform.ts +133 -0
- package/src/reality/component/index.ts +1 -1
- package/src/reality/entity/SpatialEntity.ts +2 -14
- package/src/reality/entity/index.ts +1 -1
- package/src/reality/geometry/SpatialBoxGeometry.ts +4 -1
- package/src/reality/geometry/index.ts +1 -1
- package/src/reality/material/index.ts +1 -1
- package/src/reality/resource/index.ts +1 -1
- package/src/scene-polyfill.ts +0 -4
- package/src/types/internal.ts +5 -5
- package/src/types/types.ts +23 -17
package/package.json
CHANGED
package/src/JSBCommand.ts
CHANGED
|
@@ -539,7 +539,7 @@ export class DestroyCommand extends JSBCommand {
|
|
|
539
539
|
export class CheckWebViewCanCreateCommand extends JSBCommand {
|
|
540
540
|
commandType = 'CheckWebViewCanCreate'
|
|
541
541
|
|
|
542
|
-
constructor(readonly id: string =
|
|
542
|
+
constructor(readonly id: string = '') {
|
|
543
543
|
super()
|
|
544
544
|
}
|
|
545
545
|
|
package/src/SpatialScene.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SpatialSceneCreationOptions,
|
|
3
3
|
SpatialSceneProperties,
|
|
4
4
|
} from './types/types'
|
|
5
|
-
import { SpatialSceneCreationOptionsInternal } from
|
|
5
|
+
import { SpatialSceneCreationOptionsInternal } from './types/internal'
|
|
6
6
|
import {
|
|
7
7
|
AddSpatializedElementToSpatialScene,
|
|
8
8
|
GetSpatialSceneState,
|
|
@@ -72,4 +72,4 @@ export class SpatialScene extends SpatialObject {
|
|
|
72
72
|
async getState(): Promise<SpatialSceneState> {
|
|
73
73
|
return (await new GetSpatialSceneState().execute()).data.name
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|
package/src/SpatialSession.ts
CHANGED
|
@@ -80,7 +80,7 @@ export class SpatialSession {
|
|
|
80
80
|
* This is a reference to the initScene function from scene-polyfill.
|
|
81
81
|
*/
|
|
82
82
|
initScene = initScene
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
/**
|
|
85
85
|
* Creates a new dynamic 3D element that can be manipulated at runtime.
|
|
86
86
|
* Dynamic 3D elements allow for programmatic creation and modification of 3D content.
|
|
@@ -96,7 +96,7 @@ export class SpatialSession {
|
|
|
96
96
|
* @param name Optional name for the entity
|
|
97
97
|
* @returns Promise resolving to a new SpatialEntity instance
|
|
98
98
|
*/
|
|
99
|
-
createEntity(userData?: SpatialEntityUserData
|
|
99
|
+
createEntity(userData?: SpatialEntityUserData): Promise<SpatialEntity> {
|
|
100
100
|
return createSpatialEntity(userData)
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -164,7 +164,7 @@ export class SpatialSession {
|
|
|
164
164
|
createUnlitMaterial(options: SpatialUnlitMaterialOptions) {
|
|
165
165
|
return createSpatialUnlitMaterial(options)
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
/**
|
|
169
169
|
* Creates a model asset with the specified configuration.
|
|
170
170
|
* Model assets represent 3D model resources that can be used by entities.
|
|
@@ -181,7 +181,10 @@ export class SpatialSession {
|
|
|
181
181
|
* @param options Configuration options for the spatial model entity
|
|
182
182
|
* @returns Promise resolving to a new SpatialModelEntity instance
|
|
183
183
|
*/
|
|
184
|
-
createSpatialModelEntity(
|
|
184
|
+
createSpatialModelEntity(
|
|
185
|
+
options: SpatialModelEntityCreationOptions,
|
|
186
|
+
userData?: SpatialEntityUserData,
|
|
187
|
+
) {
|
|
185
188
|
return createSpatialModelEntity(options, userData)
|
|
186
189
|
}
|
|
187
190
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CubeInfo,
|
|
8
8
|
SpatialDragEndEvent,
|
|
9
9
|
SpatialDragEvent,
|
|
10
|
+
SpatialDragStartEvent,
|
|
10
11
|
SpatializedElementProperties,
|
|
11
12
|
SpatialMagnifyEndEvent,
|
|
12
13
|
SpatialMagnifyEvent,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
ObjectDestroyMsg,
|
|
20
21
|
SpatialDragEndMsg,
|
|
21
22
|
SpatialDragMsg,
|
|
23
|
+
SpatialDragStartMsg,
|
|
22
24
|
SpatialMagnifyEndMsg,
|
|
23
25
|
SpatialMagnifyMsg,
|
|
24
26
|
SpatialRotateEndMsg,
|
|
@@ -116,6 +118,7 @@ export abstract class SpatializedElement extends SpatialObject {
|
|
|
116
118
|
| CubeInfoMsg
|
|
117
119
|
| TransformMsg
|
|
118
120
|
| SpatialTapMsg
|
|
121
|
+
| SpatialDragStartMsg
|
|
119
122
|
| SpatialDragMsg
|
|
120
123
|
| SpatialDragEndMsg
|
|
121
124
|
| SpatialRotateMsg
|
|
@@ -157,65 +160,43 @@ export abstract class SpatializedElement extends SpatialObject {
|
|
|
157
160
|
(data as SpatialTapMsg).detail,
|
|
158
161
|
)
|
|
159
162
|
this._onSpatialTap?.(event)
|
|
163
|
+
} else if (type === SpatialWebMsgType.spatialdragstart) {
|
|
164
|
+
const dragStartEvent = createSpatialEvent(
|
|
165
|
+
SpatialWebMsgType.spatialdragstart,
|
|
166
|
+
(data as SpatialDragStartMsg).detail,
|
|
167
|
+
)
|
|
168
|
+
this._onSpatialDragStart?.(dragStartEvent)
|
|
160
169
|
} else if (type === SpatialWebMsgType.spatialdrag) {
|
|
161
|
-
// Handle drag gestures, with special handling for drag start
|
|
162
|
-
if (!this._isDragging) {
|
|
163
|
-
const dragStartEvent = createSpatialEvent(
|
|
164
|
-
SpatialWebMsgType.spatialdragstart,
|
|
165
|
-
(data as SpatialDragMsg).detail,
|
|
166
|
-
)
|
|
167
|
-
this._onSpatialDragStart?.(dragStartEvent)
|
|
168
|
-
}
|
|
169
|
-
this._isDragging = true
|
|
170
170
|
const event = createSpatialEvent(
|
|
171
171
|
SpatialWebMsgType.spatialdrag,
|
|
172
172
|
(data as SpatialDragMsg).detail,
|
|
173
173
|
)
|
|
174
174
|
this._onSpatialDrag?.(event)
|
|
175
175
|
} else if (type === SpatialWebMsgType.spatialdragend) {
|
|
176
|
-
this._isDragging = false
|
|
177
176
|
const event = createSpatialEvent(
|
|
178
177
|
SpatialWebMsgType.spatialdragend,
|
|
179
178
|
(data as SpatialDragEndMsg).detail,
|
|
180
179
|
)
|
|
181
180
|
this._onSpatialDragEnd?.(event)
|
|
182
181
|
} else if (type === SpatialWebMsgType.spatialrotate) {
|
|
183
|
-
if (!this._isRotating) {
|
|
184
|
-
const rotationStartEvent = createSpatialEvent(
|
|
185
|
-
SpatialWebMsgType.spatialrotatestart,
|
|
186
|
-
(data as SpatialRotateMsg).detail,
|
|
187
|
-
)
|
|
188
|
-
this._onSpatialRotateStart?.(rotationStartEvent)
|
|
189
|
-
}
|
|
190
|
-
this._isRotating = true
|
|
191
182
|
const event = createSpatialEvent(
|
|
192
183
|
SpatialWebMsgType.spatialrotate,
|
|
193
184
|
(data as SpatialRotateMsg).detail,
|
|
194
185
|
)
|
|
195
186
|
this._onSpatialRotate?.(event)
|
|
196
187
|
} else if (type === SpatialWebMsgType.spatialrotateend) {
|
|
197
|
-
this._isRotating = false
|
|
198
188
|
const event = createSpatialEvent(
|
|
199
189
|
SpatialWebMsgType.spatialrotateend,
|
|
200
190
|
(data as SpatialRotateEndMsg).detail,
|
|
201
191
|
)
|
|
202
192
|
this._onSpatialRotateEnd?.(event)
|
|
203
193
|
} else if (type === SpatialWebMsgType.spatialmagnify) {
|
|
204
|
-
if (!this._isMagnify) {
|
|
205
|
-
const magnifyStartEvent = createSpatialEvent(
|
|
206
|
-
SpatialWebMsgType.spatialmagnifystart,
|
|
207
|
-
(data as SpatialMagnifyMsg).detail,
|
|
208
|
-
)
|
|
209
|
-
this._onSpatialMagnifyStart?.(magnifyStartEvent)
|
|
210
|
-
}
|
|
211
|
-
this._isMagnify = true
|
|
212
194
|
const event = createSpatialEvent(
|
|
213
195
|
SpatialWebMsgType.spatialmagnify,
|
|
214
196
|
(data as SpatialMagnifyMsg).detail,
|
|
215
197
|
)
|
|
216
198
|
this._onSpatialMagnify?.(event)
|
|
217
199
|
} else if (type === SpatialWebMsgType.spatialmagnifyend) {
|
|
218
|
-
this._isMagnify = false
|
|
219
200
|
const event = createSpatialEvent(
|
|
220
201
|
SpatialWebMsgType.spatialmagnifyend,
|
|
221
202
|
(data as SpatialMagnifyEndMsg).detail,
|
|
@@ -232,9 +213,10 @@ export abstract class SpatializedElement extends SpatialObject {
|
|
|
232
213
|
})
|
|
233
214
|
}
|
|
234
215
|
|
|
235
|
-
private
|
|
236
|
-
|
|
237
|
-
|
|
216
|
+
private _onSpatialDragStart?: (event: SpatialDragStartEvent) => void
|
|
217
|
+
set onSpatialDragStart(
|
|
218
|
+
value: (event: SpatialDragStartEvent) => void | undefined,
|
|
219
|
+
) {
|
|
238
220
|
this._onSpatialDragStart = value
|
|
239
221
|
this.updateProperties({
|
|
240
222
|
enableDragStartGesture: this._onSpatialDragStart !== undefined,
|
|
@@ -259,17 +241,6 @@ export abstract class SpatializedElement extends SpatialObject {
|
|
|
259
241
|
})
|
|
260
242
|
}
|
|
261
243
|
|
|
262
|
-
private _isRotating = false
|
|
263
|
-
private _onSpatialRotateStart?: (event: SpatialRotateEvent) => void
|
|
264
|
-
set onSpatialRotateStart(
|
|
265
|
-
value: ((event: SpatialRotateEvent) => void) | undefined,
|
|
266
|
-
) {
|
|
267
|
-
this._onSpatialRotateStart = value
|
|
268
|
-
this.updateProperties({
|
|
269
|
-
enableRotateStartGesture: this._onSpatialRotateStart !== undefined,
|
|
270
|
-
})
|
|
271
|
-
}
|
|
272
|
-
|
|
273
244
|
private _onSpatialRotate?: (event: SpatialRotateEvent) => void
|
|
274
245
|
set onSpatialRotate(
|
|
275
246
|
value: ((event: SpatialRotateEvent) => void) | undefined,
|
|
@@ -290,17 +261,6 @@ export abstract class SpatializedElement extends SpatialObject {
|
|
|
290
261
|
})
|
|
291
262
|
}
|
|
292
263
|
|
|
293
|
-
private _isMagnify = false
|
|
294
|
-
private _onSpatialMagnifyStart?: (event: SpatialMagnifyEvent) => void
|
|
295
|
-
set onSpatialMagnifyStart(
|
|
296
|
-
value: ((event: SpatialMagnifyEvent) => void) | undefined,
|
|
297
|
-
) {
|
|
298
|
-
this._onSpatialMagnifyStart = value
|
|
299
|
-
this.updateProperties({
|
|
300
|
-
enableMagnifyStartGesture: value !== undefined,
|
|
301
|
-
})
|
|
302
|
-
}
|
|
303
|
-
|
|
304
264
|
private _onSpatialMagnify?: (event: SpatialMagnifyEvent) => void
|
|
305
265
|
set onSpatialMagnify(
|
|
306
266
|
value: ((event: SpatialMagnifyEvent) => void) | undefined,
|
|
@@ -104,7 +104,7 @@ export class SpatializedStatic3DElement extends SpatializedElement {
|
|
|
104
104
|
this._onLoadFailureCallback = callback
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
updateModelTransform(transform:
|
|
107
|
+
updateModelTransform(transform: DOMMatrixReadOnly) {
|
|
108
108
|
const modelTransform = Array.from(transform.toFloat64Array())
|
|
109
109
|
this.updateProperties({ modelTransform })
|
|
110
110
|
}
|
package/src/WebMsgCommand.ts
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
SpatialTapEventDetail,
|
|
6
6
|
SpatialRotateEventDetail,
|
|
7
7
|
SpatialMagnifyEventDetail,
|
|
8
|
+
SpatialDragStartEventDetail,
|
|
9
|
+
SpatialDragEndEventDetail,
|
|
8
10
|
} from './types/types'
|
|
9
11
|
|
|
10
12
|
export enum SpatialWebMsgType {
|
|
@@ -16,10 +18,8 @@ export enum SpatialWebMsgType {
|
|
|
16
18
|
spatialdragstart = 'spatialdragstart',
|
|
17
19
|
spatialdrag = 'spatialdrag',
|
|
18
20
|
spatialdragend = 'spatialdragend',
|
|
19
|
-
spatialrotatestart = 'spatialrotatestart',
|
|
20
21
|
spatialrotate = 'spatialrotate',
|
|
21
22
|
spatialrotateend = 'spatialrotateend',
|
|
22
|
-
spatialmagnifystart = 'spatialmagnifystart',
|
|
23
23
|
spatialmagnify = 'spatialmagnify',
|
|
24
24
|
spatialmagnifyend = 'spatialmagnifyend',
|
|
25
25
|
|
|
@@ -57,6 +57,11 @@ export interface SpatialTapMsg {
|
|
|
57
57
|
detail: SpatialTapEventDetail
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export interface SpatialDragStartMsg {
|
|
61
|
+
type: SpatialWebMsgType.spatialdragstart
|
|
62
|
+
detail: SpatialDragStartEventDetail
|
|
63
|
+
}
|
|
64
|
+
|
|
60
65
|
export interface SpatialDragMsg {
|
|
61
66
|
type: SpatialWebMsgType.spatialdrag
|
|
62
67
|
detail: SpatialDragEventDetail
|
|
@@ -64,7 +69,7 @@ export interface SpatialDragMsg {
|
|
|
64
69
|
|
|
65
70
|
export interface SpatialDragEndMsg {
|
|
66
71
|
type: SpatialWebMsgType.spatialdragend
|
|
67
|
-
detail:
|
|
72
|
+
detail: SpatialDragEndEventDetail
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
export interface SpatialRotateMsg {
|