@webspatial/core-sdk 1.3.0 → 1.5.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.
@@ -2,6 +2,8 @@ import {
2
2
  SpatialEntityUserData,
3
3
  SpatialModelEntityCreationOptions,
4
4
  } from '../../types/types'
5
+ import { SetMaterialsOnEntityCommand } from '../../JSBCommand'
6
+ import { SpatialMaterial } from '../material/SpatialMaterial'
5
7
  import { SpatialEntity } from './SpatialEntity'
6
8
 
7
9
  export class SpatialModelEntity extends SpatialEntity {
@@ -12,4 +14,8 @@ export class SpatialModelEntity extends SpatialEntity {
12
14
  ) {
13
15
  super(id, userData)
14
16
  }
17
+
18
+ async setMaterials(materials: SpatialMaterial[]) {
19
+ return new SetMaterialsOnEntityCommand(this.id, materials).execute()
20
+ }
15
21
  }
@@ -76,6 +76,18 @@ class SceneManager {
76
76
  private open = (url?: string, target?: string, features?: string) => {
77
77
  // bypass internal
78
78
  if (url?.startsWith(INTERNAL_SCHEMA_PREFIX)) {
79
+ if (url.includes('createSpatialized2DElement')) {
80
+ const token = window.webSpatial?.genToken?.()
81
+ if (token) {
82
+ const host = window.location.host
83
+ const protocol = window.location.protocol
84
+ const finalURL = `${protocol}//${host}/${token}/?command=createSpatialized2DElement`
85
+ const rid = new URL(url).searchParams.get('rid')
86
+ const final = new URL(finalURL)
87
+ if (rid) final.searchParams.set('rid', rid)
88
+ return this.originalOpen(final.toString(), target, features)
89
+ }
90
+ }
79
91
  return this.originalOpen(url, target, features)
80
92
  }
81
93
 
@@ -1,3 +1,5 @@
1
+ import type { PhysicalMetricsValueShape } from '../physicalMetrics'
2
+
1
3
  declare global {
2
4
  declare const __WEBSPATIAL_CORE_SDK_VERSION__: string
3
5
 
@@ -20,6 +22,11 @@ declare global {
20
22
  webkit: any
21
23
  webspatialBridge: any
22
24
 
25
+ // Project Pico OS browser injects this global object to provide internal capabilities.
26
+ webSpatial?: {
27
+ genToken?: () => string
28
+ }
29
+
23
30
  // Will be removed in favor of __WebSpatialData
24
31
  WebSpatailNativeVersion: string
25
32
 
@@ -28,16 +35,16 @@ declare global {
28
35
  'natvie-version'?: string
29
36
  'react-sdk-version'?: string
30
37
  'core-sdk-version'?: string
38
+ physicalMetrics?: PhysicalMetricsValueShape
31
39
  }
32
40
 
33
- innerDepth: number
34
- outerDepth: number
41
+ xrInnerDepth: number
42
+ xrOuterDepth: number
35
43
  }
36
44
 
37
45
  interface HTMLElement {
38
- offsetBack: number
39
- clientDepth: number
40
- getBoundingClientCube: () => CubeInfo | undefined
46
+ xrOffsetBack: number
47
+ xrClientDepth: number
41
48
  }
42
49
  }
43
50
 
@@ -80,6 +80,11 @@ export interface SpatializedElementProperties {
80
80
  enableRotateEndGesture: boolean
81
81
  enableMagnifyGesture: boolean
82
82
  enableMagnifyEndGesture: boolean
83
+ /**
84
+ * Optional world-space axis for spatial rotate gesture. Omitted or zero vector
85
+ * means unconstrained rotation (platform default).
86
+ */
87
+ rotateConstrainedToAxis?: Vec3
83
88
  }
84
89
 
85
90
  export interface Spatialized2DElementProperties
@@ -115,6 +120,16 @@ export interface SpatialSceneCreationOptions {
115
120
  baseplateVisibility?: BaseplateVisibilityType
116
121
  }
117
122
 
123
+ export type SpatialEntityEventType =
124
+ | 'spatialtap'
125
+ | 'spatialdragstart'
126
+ | 'spatialdrag'
127
+ | 'spatialdragend'
128
+ | 'spatialrotate'
129
+ | 'spatialrotateend'
130
+ | 'spatialmagnify'
131
+ | 'spatialmagnifyend'
132
+
118
133
  export const BaseplateVisibilityValues = [
119
134
  'automatic',
120
135
  'visible',
@@ -186,8 +201,6 @@ export interface SpatialEntityProperties {
186
201
  scale: Vec3
187
202
  }
188
203
 
189
- export type SpatialEntityEventType = 'spatialtap' //| 'drag' | 'rotate' | 'scale'
190
-
191
204
  export type SpatialGeometryType =
192
205
  | 'BoxGeometry'
193
206
  | 'PlaneGeometry'
@@ -391,6 +404,7 @@ export interface AttachmentEntityOptions {
391
404
  parentEntityId: string
392
405
  position?: [number, number, number]
393
406
  size: { width: number; height: number }
407
+ ownerViewId: string
394
408
  }
395
409
 
396
410
  export interface AttachmentEntityUpdateOptions {