@webspatial/core-sdk 1.0.5 → 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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ssr-polyfill.ts","../src/platform-adapter/ssr/SSRPlatform.ts","../src/platform-adapter/CommandResultUtils.ts","../src/SpatialWebEvent.ts","../src/platform-adapter/android/AndroidPlatform.ts","../src/platform-adapter/vision-os/VisionOSPlatform.ts","../src/platform-adapter/index.ts","../src/utils.ts","../src/JSBCommand.ts","../src/SpatialObject.ts","../src/scene-polyfill.ts","../src/SpatialScene.ts","../src/types/types.ts","../src/SpatializedElementCreator.ts","../src/Spatialized2DElement.ts","../src/SpatializedElement.ts","../src/SpatialWebEventCreator.ts","../src/SpatializedStatic3DElement.ts","../src/SpatializedDynamic3DElement.ts","../src/reality/realityCreator.ts","../src/reality/entity/SpatialEntity.ts","../src/reality/entity/SpatialModelEntity.ts","../src/reality/component/SpatialComponent.ts","../src/reality/component/ModelComponent.ts","../src/reality/material/SpatialUnlitMaterial.ts","../src/reality/material/SpatialMaterial.ts","../src/reality/resource/SpatialModelAsset.ts","../src/reality/geometry/SpatialGeometry.ts","../src/reality/geometry/SpatialBoxGeometry.ts","../src/reality/geometry/SpatialSphereGeometry.ts","../src/reality/geometry/SpatialCylinderGeometry.ts","../src/reality/geometry/SpatialPlaneGeometry.ts","../src/reality/geometry/SpatialConeGeometry.ts","../src/SpatialSession.ts","../src/Spatial.ts","../src/index.ts","../src/spatial-window-polyfill.ts"],"sourcesContent":["const isSSR = typeof window === 'undefined'\n\nexport const isSSREnv = () => isSSR\n","import {\n CommandResult,\n PlatformAbility,\n WebSpatialProtocolResult,\n} from '../interface'\n\nexport class SSRPlatform implements PlatformAbility {\n callJSB(cmd: string, msg: string): Promise<CommandResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocol(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<WebSpatialProtocolResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocolSync(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n resultCallback?: (result: CommandResult) => void,\n ): WebSpatialProtocolResult {\n return {\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n }\n }\n}\n","import { CommandResult } from './interface'\n\nexport function CommandResultSuccess(data: any): CommandResult {\n return {\n success: true,\n data,\n errorCode: '',\n errorMessage: '',\n }\n}\n\nexport function CommandResultFailure(\n errorCode: string,\n errorMessage = '',\n): CommandResult {\n return {\n success: false,\n data: undefined,\n errorCode,\n errorMessage,\n }\n}\n","interface SpatialWebEventData {\n id: string\n data: any\n}\n\nexport class SpatialWebEvent {\n static eventReceiver: Record<string, (data: any) => void> = {}\n static init() {\n // inject __SpatialWebEvent\n window.__SpatialWebEvent = ({ id, data }: SpatialWebEventData) => {\n // console.log('__SpatialWebEvent', id, data)\n SpatialWebEvent.eventReceiver[id]?.(data)\n }\n }\n\n static addEventReceiver(id: string, callback: (data: any) => void) {\n SpatialWebEvent.eventReceiver[id] = callback\n }\n\n static removeEventReceiver(id: string) {\n delete SpatialWebEvent.eventReceiver[id]\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { CheckWebViewCanCreateCommand } from '../../JSBCommand'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\n\ninterface JSBResponse {\n success: boolean\n data: any\n}\ntype JSBError = {\n code: string\n message: string\n}\n\nlet creatingElementCount = 0\n\nlet requestId = 0\n\nconst MAX_ID = 100000\n\nfunction nextRequestId() {\n requestId = (requestId + 1) % MAX_ID\n return `rId_${requestId}`\n}\n\nexport class AndroidPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n // android JS Bridge interface only support sync invoking\n // in order to implement promise API, register every request by requestId and remove when resolve/reject.\n return new Promise((resolve, reject) => {\n try {\n const rId = nextRequestId()\n\n SpatialWebEvent.addEventReceiver(rId, (result: JSBResponse) => {\n SpatialWebEvent.removeEventReceiver(rId)\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n\n const ans = window.webspatialBridge.postMessage(rId, cmd, msg)\n if (ans !== '') {\n SpatialWebEvent.removeEventReceiver(rId)\n // sync call\n const result = JSON.parse(ans) as JSBResponse\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n }\n } catch (error: unknown) {\n console.error(\n `AndroidPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`,\n )\n const { code, message } = error as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n async callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n // Waiting for request to create spatial div\n await new Promise(resolve => setTimeout(resolve, 16 * creatingElementCount))\n // Count the current total number of created spatial div queues\n creatingElementCount++\n // Create a spatial div through JSB polling request\n let canCreate = await new CheckWebViewCanCreateCommand().execute()\n while (!canCreate.data.can) {\n await new Promise(resolve => setTimeout(resolve, 16))\n canCreate = await new CheckWebViewCanCreateCommand().execute()\n }\n // Request successful, call window.open\n const { windowProxy } = this.openWindow(command, query, target, features)\n // Polling waiting for windowProxy to convert into a real window object\n while (!windowProxy?.open) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n // Make the page renderable through window.open\n windowProxy?.open('about:blank', '_self')\n // Polling to check if SpatialId injection is successful\n while (!windowProxy?.SpatialId) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n let spatialId = windowProxy?.SpatialId\n creatingElementCount--\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id: spatialId }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n return { spatialId: '', windowProxy }\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\n\n\ntype JSBError = {\n message: string\n}\n\nexport class VisionOSPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n try {\n const result = await window.webkit.messageHandlers.bridge.postMessage(\n `${cmd}::${msg}`,\n )\n return CommandResultSuccess(result)\n } catch (error: unknown) {\n // console.error(`VisionOSPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = JSON.parse((error as JSBError).message)\n return CommandResultFailure(code, message)\n }\n }\n\n callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n const { spatialId: id, windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n const ua = windowProxy?.navigator.userAgent\n const spatialId = ua?.match(\n /\\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\\b/gi,\n )?.[0]\n\n return { spatialId, windowProxy }\n }\n}\n","import { isSSREnv } from '../ssr-polyfill'\nimport { PlatformAbility } from './interface'\nimport { SSRPlatform } from './ssr/SSRPlatform'\n\nexport function createPlatform(): PlatformAbility {\n if (isSSREnv()) {\n return new SSRPlatform()\n }\n\n if (\n window.navigator.userAgent.includes('Android') ||\n window.navigator.userAgent.includes('Linux')\n ) {\n const AndroidPlatform = require('./android/AndroidPlatform').AndroidPlatform\n return new AndroidPlatform()\n } else {\n const VisionOSPlatform =\n require('./vision-os/VisionOSPlatform').VisionOSPlatform\n return new VisionOSPlatform()\n }\n}\n","import { Vec3 } from './types/types'\n\nfunction parseBorderRadius(borderProperty: string, width: number) {\n if (borderProperty === '') {\n return 0\n }\n if (borderProperty.endsWith('%')) {\n return (width * parseFloat(borderProperty)) / 100\n }\n return parseFloat(borderProperty)\n}\n\nexport function parseCornerRadius(computedStyle: CSSStyleDeclaration) {\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n\n const topLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-top-left-radius',\n )\n const topRightPropertyValue = computedStyle.getPropertyValue(\n 'border-top-right-radius',\n )\n const bottomLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-left-radius',\n )\n const bottomRightPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-right-radius',\n )\n\n const cornerRadius = {\n topLeading: parseBorderRadius(topLeftPropertyValue, width),\n bottomLeading: parseBorderRadius(bottomLeftPropertyValue, width),\n topTrailing: parseBorderRadius(topRightPropertyValue, width),\n bottomTrailing: parseBorderRadius(bottomRightPropertyValue, width),\n }\n\n return cornerRadius\n}\n\n/**\n *\n * compose SRT matrix\n * @export\n * @param {Vec3} position meter\n * @param {Vec3} rotation degree\n * @param {Vec3} scale\n * @return {*} {DOMMatrix}\n */\nexport function composeSRT(position: Vec3, rotation: Vec3, scale: Vec3) {\n const { x: px, y: py, z: pz } = position\n const { x: rx, y: ry, z: rz } = rotation\n const { x: sx, y: sy, z: sz } = scale\n\n let m = new DOMMatrix()\n // https://drafts.fxtf.org/geometry/#immutable-transformation-methods\n // as these methods are post-multiplication, the order of transformations is reversed\n // we want SRT = T * R * S\n m = m.translate(px, py, pz)\n m = m.rotate(rx, ry, rz)\n m = m.scale(sx, sy, sz)\n return m\n}\n","import { createPlatform } from './platform-adapter'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialComponent } from './reality/component/SpatialComponent'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\n\nimport {\n Spatialized2DElementProperties,\n SpatializedElementProperties,\n SpatializedStatic3DElementProperties,\n SpatialSceneProperties,\n SpatialSceneCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialGeometryOptions,\n SpatialGeometryType,\n ModelComponentOptions,\n SpatialEntityProperties,\n ModelAssetOptions,\n SpatialModelEntityCreationOptions,\n SpatialEntityEventType,\n Vec3,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport { composeSRT } from './utils'\n\nconst platform = createPlatform()\n\nabstract class JSBCommand {\n commandType: string = ''\n protected abstract getParams(): Record<string, any> | undefined\n\n async execute() {\n const param = this.getParams()\n const msg = param ? JSON.stringify(param) : ''\n return platform.callJSB(this.commandType, msg)\n }\n}\n\nexport class UpdateEntityPropertiesCommand extends JSBCommand {\n commandType = 'UpdateEntityProperties'\n\n constructor(\n public entity: SpatialEntity,\n public properties: Partial<SpatialEntityProperties>,\n ) {\n super()\n }\n\n protected getParams() {\n const transform = composeSRT(\n this.properties.position ?? this.entity.position,\n this.properties.rotation ?? this.entity.rotation,\n this.properties.scale ?? this.entity.scale,\n ).toFloat64Array()\n return {\n entityId: this.entity.id,\n transform,\n }\n }\n}\n\nexport class UpdateEntityEventCommand extends JSBCommand {\n commandType = 'UpdateEntityEvent'\n\n constructor(\n public entity: SpatialEntity,\n public type: SpatialEntityEventType,\n public isEnable: boolean,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n type: this.type,\n entityId: this.entity.id,\n isEnable: this.isEnable,\n }\n }\n}\n\n// todo: to be used in SpatialEntity\nexport class UpdateEntityEventsCommand extends JSBCommand {\n // let types:[String:Bool]\n // let entityId:String\n constructor(\n public entity: SpatialEntity,\n public types: Record<SpatialEntityEventType, boolean>,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n entityId: this.entity.id,\n types: this.types,\n }\n }\n}\n\nexport class UpdateSpatialSceneProperties extends JSBCommand {\n properties: Partial<SpatialSceneProperties>\n commandType = 'UpdateSpatialSceneProperties'\n\n constructor(properties: Partial<SpatialSceneProperties>) {\n super()\n this.properties = properties\n }\n\n protected getParams() {\n return this.properties\n }\n}\n\nexport class UpdateSceneConfig extends JSBCommand {\n config: SpatialSceneCreationOptions\n commandType = 'UpdateSceneConfig'\n\n constructor(config: SpatialSceneCreationOptions) {\n super()\n this.config = config\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { config: this.config }\n }\n}\n\nexport class FocusScene extends JSBCommand {\n commandType = 'FocusScene'\n\n constructor(public id: string) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { id: this.id }\n }\n}\n\nexport class GetSpatialSceneState extends JSBCommand {\n commandType = 'GetSpatialSceneState'\n\n constructor() {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {}\n }\n}\n\nexport abstract class SpatializedElementCommand extends JSBCommand {\n constructor(readonly spatialObject: SpatialObject) {\n super()\n }\n\n protected getParams() {\n const extraParams = this.getExtraParams()\n return { id: this.spatialObject.id, ...extraParams }\n }\n\n protected abstract getExtraParams(): Record<string, any> | undefined\n}\n\nexport class UpdateSpatialized2DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatialized2DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedDynamic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatializedDynamic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return {\n id: this.spatialObject.id,\n ...this.properties,\n }\n }\n}\n\nexport class UpdateUnlitMaterialProperties extends SpatializedElementCommand {\n properties: Partial<SpatialUnlitMaterialOptions>\n commandType = 'UpdateUnlitMaterialProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatialUnlitMaterialOptions>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedElementTransform extends SpatializedElementCommand {\n matrix: DOMMatrix\n commandType = 'UpdateSpatializedElementTransform'\n\n constructor(spatialObject: SpatialObject, matrix: DOMMatrix) {\n super(spatialObject)\n this.matrix = matrix\n }\n\n protected getExtraParams() {\n return { matrix: Array.from(this.matrix.toFloat64Array()) }\n }\n}\n\nexport class UpdateSpatializedStatic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<SpatializedStatic3DElementProperties>\n commandType = 'UpdateSpatializedStatic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class AddSpatializedElementToSpatialized2DElement extends SpatializedElementCommand {\n commandType = 'AddSpatializedElementToSpatialized2DElement'\n spatializedElement: SpatializedElement\n\n constructor(\n spatialObject: SpatialObject,\n spatializedElement: SpatializedElement,\n ) {\n super(spatialObject)\n this.spatializedElement = spatializedElement\n }\n\n protected getExtraParams() {\n return { spatializedElementId: this.spatializedElement.id }\n }\n}\n\nexport class AddSpatializedElementToSpatialScene extends JSBCommand {\n commandType = 'AddSpatializedElementToSpatialScene'\n spatializedElement: SpatializedElement\n\n constructor(spatializedElement: SpatializedElement) {\n super()\n this.spatializedElement = spatializedElement\n }\n\n protected getParams() {\n return {\n spatializedElementId: this.spatializedElement.id,\n }\n }\n}\n\nexport class CreateSpatializedStatic3DElementCommand extends JSBCommand {\n commandType = 'CreateSpatializedStatic3DElement'\n\n constructor(readonly modelURL: string) {\n super()\n this.modelURL = modelURL\n }\n\n protected getParams() {\n return { modelURL: this.modelURL }\n }\n}\n\nexport class CreateSpatializedDynamic3DElementCommand extends JSBCommand {\n protected getParams(): Record<string, any> | undefined {\n return { test: true }\n }\n commandType = 'CreateSpatializedDynamic3DElement'\n}\n\nexport class CreateSpatialEntityCommand extends JSBCommand {\n constructor(private name?: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { name: this.name }\n }\n commandType = 'CreateSpatialEntity'\n}\n\nexport class CreateModelComponentCommand extends JSBCommand {\n constructor(private options: ModelComponentOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n let geometryId = this.options.mesh.id\n let materialIds = this.options.materials.map(material => material.id)\n return { geometryId, materialIds }\n }\n commandType = 'CreateModelComponent'\n}\n\nexport class CreateSpatialModelEntityCommand extends JSBCommand {\n constructor(private options: SpatialModelEntityCreationOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateSpatialModelEntity'\n}\n\nexport class CreateModelAssetCommand extends JSBCommand {\n constructor(private options: ModelAssetOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { url: this.options.url }\n }\n commandType = 'CreateModelAsset'\n}\n\nexport class CreateSpatialGeometryCommand extends JSBCommand {\n constructor(\n private type: SpatialGeometryType,\n private options: SpatialGeometryOptions = {},\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { type: this.type, ...this.options }\n }\n commandType = 'CreateGeometry'\n}\n\nexport class CreateSpatialUnlitMaterialCommand extends JSBCommand {\n constructor(private options: SpatialUnlitMaterialOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateUnlitMaterial'\n}\n\nexport class AddComponentToEntityCommand extends JSBCommand {\n constructor(\n public entity: SpatialEntity,\n public comp: SpatialComponent,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n componentId: this.comp.id,\n }\n }\n commandType = 'AddComponentToEntity'\n}\n\nexport class AddEntityToDynamic3DCommand extends JSBCommand {\n constructor(\n public d3dEle: SpatializedDynamic3DElement,\n public entity: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n dynamic3dId: this.d3dEle.id,\n }\n }\n\n commandType = 'AddEntityToDynamic3D'\n}\n\nexport class AddEntityToEntityCommand extends JSBCommand {\n constructor(\n public parent: SpatialEntity,\n public child: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n parentId: this.parent.id,\n childId: this.child.id,\n }\n }\n commandType = 'AddEntityToEntity'\n}\n\nexport class RemoveEntityFromParentCommand extends JSBCommand {\n constructor(public entity: SpatialEntity) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n }\n }\n commandType = 'RemoveEntityFromParent'\n}\n\nexport class SetParentForEntityCommand extends JSBCommand {\n // childId, parentId\n constructor(\n public childId: string,\n public parentId?: string,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n childId: this.childId,\n parentId: this.parentId,\n }\n }\n commandType = 'SetParentToEntity'\n}\n\nexport class ConvertFromEntityToEntityCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public toEntityId: string,\n public fromPosition: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n toEntityId: this.toEntityId,\n position: this.fromPosition,\n }\n }\n commandType = 'ConvertFromEntityToEntity'\n}\n\nexport class ConvertFromEntityToSceneCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public position: Vec3,\n ) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n position: this.position,\n }\n }\n\n commandType = 'ConvertFromEntityToScene'\n}\n\nexport class ConvertFromSceneToEntityCommand extends JSBCommand {\n // let entityId: String\n // let position:Vec3\n constructor(\n public entityId: string,\n public position: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entityId,\n position: this.position,\n }\n }\n commandType = 'ConvertFromSceneToEntity'\n}\n\nexport class CreateTextureResourceCommand extends JSBCommand {\n constructor(private url: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n url: this.url,\n }\n }\n commandType = 'CreateTextureResource'\n}\n\nexport class InspectCommand extends JSBCommand {\n commandType = 'Inspect'\n\n constructor(readonly id: string = '') {\n super()\n }\n\n protected getParams() {\n return this.id ? { id: this.id } : { id: '' }\n }\n}\n\nexport class DestroyCommand extends JSBCommand {\n commandType = 'Destroy'\n\n constructor(readonly id: string) {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\nexport class CheckWebViewCanCreateCommand extends JSBCommand {\n commandType = 'CheckWebViewCanCreate'\n\n constructor(readonly id: string = \"\") {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\n/* WebSpatial Protocol Begin */\nabstract class WebSpatialProtocolCommand extends JSBCommand {\n target?: string\n features?: string\n\n async execute(): Promise<WebSpatialProtocolResult> {\n const query = this.getQuery()\n return platform.callWebSpatialProtocol(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n executeSync(): WebSpatialProtocolResult {\n const query = this.getQuery()\n return platform.callWebSpatialProtocolSync(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n private getQuery() {\n let query = undefined\n const params = this.getParams()\n if (params) {\n query = Object.keys(params)\n .map(key => {\n const value = params[key]\n const finalValue =\n typeof value === 'object' ? JSON.stringify(value) : value\n return `${key}=${encodeURIComponent(finalValue)}`\n })\n .join('&')\n }\n\n return query\n }\n}\n\nexport class createSpatialized2DElementCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialized2DElement'\n constructor() {\n super()\n }\n protected getParams() {\n return {}\n }\n}\n\nexport class createSpatialSceneCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialScene'\n\n constructor(\n private url: string,\n private config: SpatialSceneCreationOptionsInternal | undefined,\n public target?: string,\n public features?: string,\n ) {\n super()\n }\n protected getParams() {\n return {\n url: this.url,\n config: this.config,\n }\n }\n}\n\n// TODO: Can crypto.randomUUID be used instead including in dev environments without https\nfunction uuid(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n const r = (Math.random() * 16) | 0\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/* WebSpatial Protocol End */\n","import { DestroyCommand, InspectCommand } from './JSBCommand'\n\n/**\n * @hidden\n * Parent class of spatial objects, should not be used directly\n */\nexport class SpatialObject {\n /** @hidden */\n constructor(\n /** @hidden */\n public readonly id: string,\n ) {}\n\n name?: string\n\n isDestroyed = false\n\n async inspect() {\n const ret = await new InspectCommand(this.id).execute()\n if (ret.success) {\n return ret.data\n }\n throw new Error(ret.errorMessage)\n }\n\n async destroy() {\n if (this.isDestroyed) {\n return\n }\n\n const ret = await new DestroyCommand(this.id).execute()\n if (ret.success) {\n this.onDestroy()\n this.isDestroyed = true\n return ret.data\n } else if (this.isDestroyed) {\n // already destroyed\n return\n }\n\n throw new Error(ret.errorMessage)\n }\n\n // override this method to do some cleanup\n protected onDestroy() {}\n}\n","import { createSpatialSceneCommand, FocusScene } from './JSBCommand'\nimport { SpatialScene } from './SpatialScene'\nimport {\n SpatialSceneCreationOptions,\n SpatialSceneType,\n SpatialSceneState,\n isValidSceneUnit,\n isValidSpatialSceneType,\n isValidWorldScalingType,\n isValidWorldAlignmentType,\n isValidBaseplateVisibilityType,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\n\nconst defaultSceneConfig: SpatialSceneCreationOptions = {\n defaultSize: {\n width: 1280,\n height: 720,\n },\n}\n\nconst defaultSceneConfigVolume: SpatialSceneCreationOptions = {\n defaultSize: {\n width: 0.94,\n height: 0.94,\n depth: 0.94,\n },\n}\n\nconst INTERNAL_SCHEMA_PREFIX = 'webspatial://'\n\nclass SceneManager {\n private originalOpen: any\n private static instance: SceneManager\n static getInstance() {\n if (!SceneManager.instance) {\n SceneManager.instance = new SceneManager()\n }\n return SceneManager.instance\n }\n\n init(window: WindowProxy) {\n this.originalOpen = window.open.bind(window)\n ;(window as any).open = this.open\n }\n\n private configMap: Record<string, SpatialSceneCreationOptionsInternal> = {} // name=>config\n private getConfig(name?: string) {\n if (name === undefined || !this.configMap[name]) return undefined\n return this.configMap[name]\n }\n\n private open = (url?: string, target?: string, features?: string) => {\n // bypass internal\n if (url?.startsWith(INTERNAL_SCHEMA_PREFIX)) {\n return this.originalOpen(url, target, features)\n }\n\n // absolute url\n const prefix = `${window.location.protocol}//${window.location.host}`\n if (!url?.startsWith(prefix)) {\n url = prefix + url\n }\n\n // if target is special\n if (target === '_self' || target === '_parent' || target === '_top') {\n const newWindow = this.originalOpen(url, target, features)\n return newWindow\n }\n\n const cfg = target ? this.getConfig(target) : undefined\n const cmd = new createSpatialSceneCommand(url!, cfg, target, features)\n const result = cmd.executeSync()\n\n if (typeof target === 'string' && this.configMap[target]) {\n delete this.configMap[target]\n }\n\n const id = result.data?.id\n\n if (id) {\n // send JSB to focus\n let focusCmd = new FocusScene(id)\n focusCmd.execute()\n }\n\n return result.data?.windowProxy\n }\n initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n ) {\n const sceneType = options?.type ?? 'window'\n const defaultConfig = getSceneDefaultConfig(sceneType)\n const rawReturnVal = callback({ ...defaultConfig })\n const [formattedConfig, errors] = formatSceneConfig(rawReturnVal, sceneType)\n if (errors.length > 0) {\n console.warn(`initScene ${name} with errors: ${errors.join(', ')}`)\n }\n this.configMap[name] = {\n ...formattedConfig,\n type: sceneType,\n }\n }\n}\n\nfunction pxToMeter(px: number): number {\n return px / 1360\n}\n\nfunction meterToPx(meter: number): number {\n return meter * 1360\n}\n\nfunction formatToNumber(\n str: string | number,\n targetUnit: 'px' | 'm',\n defaultUnit: 'px' | 'm',\n): number {\n if (typeof str === 'number') {\n if (\n (defaultUnit === 'px' && targetUnit === 'px') ||\n (defaultUnit === 'm' && targetUnit === 'm')\n ) {\n return str\n }\n // unit not match target\n if (defaultUnit === 'px' && targetUnit === 'm') {\n return pxToMeter(str)\n } else if (defaultUnit === 'm' && targetUnit === 'px') {\n return meterToPx(str)\n }\n // fallback\n return str\n }\n if (targetUnit === 'm') {\n if (str.endsWith('m')) {\n // 1m\n return Number(str.slice(0, -1))\n } else if (str.endsWith('px')) {\n // 100px\n return pxToMeter(Number(str.slice(0, -2)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else if (targetUnit === 'px') {\n if (str.endsWith('px')) {\n // 100px\n return Number(str.slice(0, -2))\n } else if (str.endsWith('m')) {\n // 1m\n return meterToPx(Number(str.slice(0, -1)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else {\n throw new Error('formatToNumber: invalid targetUnit')\n }\n}\n\nexport function formatSceneConfig(\n config: SpatialSceneCreationOptions,\n sceneType: SpatialSceneType,\n): [SpatialSceneCreationOptions, string[]] {\n // defaultSize and resizability's width/height/depth can be 100 or \"100px\" or \"1m\"\n // expect:\n // resizability should format into px\n // defaultSize should format into px if window\n // defaultSize should format into m if volume\n\n const defaultSceneConfig = getSceneDefaultConfig(sceneType)\n\n const errors: string[] = []\n\n const isWindow = sceneType === 'window'\n if (!isValidSpatialSceneType(sceneType)) {\n errors.push(`sceneType`)\n }\n\n // format defaultSize\n if (config.defaultSize) {\n const iterKeys = ['width', 'height', 'depth']\n for (let k of iterKeys) {\n if (!(k in config.defaultSize)) continue\n if (isValidSceneUnit((config.defaultSize as any)[k])) {\n ;(config.defaultSize as any)[k] = formatToNumber(\n (config.defaultSize as any)[k],\n isWindow ? 'px' : 'm',\n isWindow ? 'px' : 'm',\n )\n } else {\n ;(config.defaultSize as any)[k] = (\n defaultSceneConfig.defaultSize as any\n )[k]\n errors.push(`defaultSize.${k}`)\n }\n }\n }\n\n // format resizability\n if (config.resizability) {\n const iterKeys = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight']\n for (let k of iterKeys) {\n if (!(k in config.resizability)) continue\n if (isValidSceneUnit((config.resizability as any)[k])) {\n ;(config.resizability as any)[k] = formatToNumber(\n (config.resizability as any)[k],\n 'px',\n isWindow ? 'px' : 'm',\n )\n } else {\n ;(config.resizability as any)[k] = undefined\n errors.push(`resizability.${k}`)\n }\n }\n }\n\n // check value\n if (config.worldScaling) {\n if (!isValidWorldScalingType(config.worldScaling)) {\n config.worldScaling = 'automatic'\n errors.push('worldScaling')\n }\n }\n\n if (config.worldAlignment) {\n if (!isValidWorldAlignmentType(config.worldAlignment)) {\n config.worldAlignment = 'automatic'\n errors.push('worldAlignment')\n }\n }\n\n if (config.baseplateVisibility) {\n if (!isValidBaseplateVisibilityType(config.baseplateVisibility)) {\n config.baseplateVisibility = 'automatic'\n errors.push('baseplateVisibility')\n }\n }\n\n return [config, errors]\n}\n\nexport function initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n) {\n return SceneManager.getInstance().initScene(name, callback, options)\n}\n\nexport function hijackWindowOpen(window: WindowProxy) {\n SceneManager.getInstance().init(window)\n}\n\nexport function hijackWindowATag(openedWindow: WindowProxy) {\n openedWindow!.document.onclick = function (e) {\n let element = e.target as HTMLElement | null\n let found = false\n\n // Look for <a> element in the clicked elements parents and if found override navigation behavior if needed\n while (!found) {\n if (element && element.tagName == 'A') {\n // When using libraries like react route's <Link> it sets an onclick event, when this happens we should do nothing and let that occur\n\n // if onClick is set for the element, the raw onclick will be noop() trapped so the onclick check is no longer trustable\n // we handle all the scenarios\n\n if (handleATag(e)) {\n return false // prevent default action and stop event propagation\n }\n\n return true\n }\n if (element && element.parentElement) {\n element = element.parentElement\n } else {\n break\n }\n }\n }\n}\n\nfunction handleATag(event: MouseEvent) {\n const targetElement = event.target as HTMLElement\n if (targetElement.tagName === 'A') {\n const link = targetElement as HTMLAnchorElement\n const target = link.target\n const url = link.href\n\n if (target && target !== '_self') {\n event.preventDefault()\n window.open(url, target)\n return true\n }\n }\n}\n\nfunction getSceneDefaultConfig(sceneType: SpatialSceneType) {\n return sceneType === 'window' ? defaultSceneConfig : defaultSceneConfigVolume\n}\n\nasync function injectScenePolyfill() {\n if (!window.opener) return\n\n const state = await SpatialScene.getInstance().getState()\n\n // only run this in pending state\n if (state !== SpatialSceneState.pending) return\n\n function onContentLoaded(callback: any) {\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n callback()\n } else {\n document.addEventListener('DOMContentLoaded', callback)\n }\n }\n\n onContentLoaded(async () => {\n let provideDefaultSceneConfig = getSceneDefaultConfig(\n window.xrCurrentSceneType ?? 'window',\n )\n let cfg = provideDefaultSceneConfig\n if (typeof window.xrCurrentSceneDefaults === 'function') {\n try {\n cfg = await window.xrCurrentSceneDefaults?.(provideDefaultSceneConfig)\n } catch (error) {\n console.error(error)\n }\n }\n // fixme: this duration is too short so that hide and show is at racing, so add a little delay to avoid\n await new Promise((resolve, reject) => {\n setTimeout(() => {\n resolve(null)\n }, 1000)\n })\n\n const sceneType = window.xrCurrentSceneType ?? 'window'\n const [formattedConfig, errors] = formatSceneConfig(cfg, sceneType)\n if (errors.length > 0) {\n console.warn(\n `window.xrCurrentSceneDefaults with errors: ${errors.join(', ')}`,\n )\n }\n await SpatialScene.getInstance().updateSceneCreationConfig({\n ...formattedConfig,\n type: sceneType,\n })\n })\n}\n\nexport function injectSceneHook() {\n hijackWindowOpen(window)\n hijackWindowATag(window)\n injectScenePolyfill()\n}\n","import {\n SpatialSceneCreationOptions,\n SpatialSceneProperties,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from \"./types/internal\"\nimport {\n AddSpatializedElementToSpatialScene,\n GetSpatialSceneState,\n UpdateSceneConfig,\n UpdateSpatialSceneProperties,\n} from './JSBCommand'\n\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialSceneState } from './types/internal'\n\nlet instance: SpatialScene\n\n/**\n * Represents the spatial scene that contains all spatialized elements.\n * This class follows the singleton pattern - only one instance exists per application.\n * The scene manages the overall spatial environment properties and contains all spatial elements.\n */\nexport class SpatialScene extends SpatialObject {\n /**\n * Gets the singleton instance of the SpatialScene.\n * Creates a new instance if one doesn't exist yet.\n * @returns The singleton SpatialScene instance\n */\n static getInstance(): SpatialScene {\n if (!instance) {\n instance = new SpatialScene('')\n }\n return instance\n }\n\n /**\n * Updates the properties of the spatial scene.\n * This can include background settings, lighting, and other scene-wide properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateSpatialProperties(properties: Partial<SpatialSceneProperties>) {\n return new UpdateSpatialSceneProperties(properties).execute()\n }\n\n /**\n * Adds a spatialized element to the scene.\n * This makes the element visible and interactive in the spatial environment.\n * @param element The SpatializedElement to add to the scene\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialScene(element).execute()\n }\n\n /**\n * Updates the scene creation configuration.\n * This allows changing scene parameters after initial creation.\n * @param config The new scene creation configuration\n * @returns Promise resolving when the update is complete\n */\n async updateSceneCreationConfig(config: SpatialSceneCreationOptionsInternal) {\n return new UpdateSceneConfig(config).execute()\n }\n\n /**\n * Gets the current state of the spatial scene.\n * This includes information about active elements and scene configuration.\n * @returns Promise resolving to the current SpatialSceneState\n */\n async getState(): Promise<SpatialSceneState> {\n return (await new GetSpatialSceneState().execute()).data.name\n }\n}","import type { SpatialEntity } from '..'\nimport { SpatialGeometry } from '../reality/geometry/SpatialGeometry'\nimport { SpatialMaterial } from '../reality/material/SpatialMaterial'\nimport type { SpatializedDynamic3DElement } from '../SpatializedDynamic3DElement'\n\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\nexport type Point3D = Vec3\n\n/**\n * Material type for SpatialDiv or HTML document.\n *\n * This type defines the background material options for both SpatialDiv elements and HTML documents.\n *\n * - `'none'`: This is the default value.\n * - For HTML documents, the web page window will have the default native background.\n * - For SpatialDiv, the window will have a transparent background.\n * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).\n * - `'thick'`: Represents a thick material in AVP.\n * - `'regular'`: Represents a regular material in AVP.\n * - `'thin'`: Represents a thin material in AVP.\n * - `'transparent'`: Represents a fully transparent background.\n */\nexport type BackgroundMaterialType =\n | 'none'\n | 'translucent'\n | 'thick'\n | 'regular'\n | 'thin'\n | 'transparent'\n\nexport type CornerRadius = {\n topLeading: number\n bottomLeading: number\n topTrailing: number\n bottomTrailing: number\n}\n\nexport interface SpatialSceneProperties {\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n opacity: number\n}\n\nexport enum SpatializedElementType {\n Spatialized2DElement,\n SpatializedStatic3DElement,\n SpatializedDynamic3DElement,\n}\n\nexport interface SpatializedElementProperties {\n name: string\n clientX: number\n clientY: number\n width: number\n height: number\n depth: number\n opacity: number\n visible: boolean\n scrollWithParent: boolean\n zIndex: number\n backOffset: number\n rotationAnchor: Point3D\n enableTapGesture: boolean\n enableDragStartGesture: boolean\n enableDragGesture: boolean\n enableDragEndGesture: boolean\n enableRotateStartGesture: boolean\n enableRotateGesture: boolean\n enableRotateEndGesture: boolean\n enableMagnifyStartGesture: boolean\n enableMagnifyGesture: boolean\n enableMagnifyEndGesture: boolean\n}\n\nexport interface Spatialized2DElementProperties\n extends SpatializedElementProperties {\n scrollPageEnabled: boolean\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n scrollEdgeInsetsMarginRight: number\n}\n\nexport interface SpatializedStatic3DElementProperties\n extends SpatializedElementProperties {\n modelURL: string\n modelTransform?: number[]\n}\n\nexport interface SpatialSceneCreationOptions {\n defaultSize?: {\n width: number | string // Initial width of the window\n height: number | string // Initial height of the window\n depth?: number | string // Initial depth of the window, only for volume\n }\n\n resizability?: {\n minWidth?: number | string // Minimum width of the window\n minHeight?: number | string // Minimum height of the window\n maxWidth?: number | string // Maximum width of the window\n maxHeight?: number | string // Maximum height of the window\n }\n worldScaling?: WorldScalingType\n worldAlignment?: WorldAlignmentType\n\n baseplateVisibility?: BaseplateVisibilityType\n}\n\nexport const BaseplateVisibilityValues = [\n 'automatic',\n 'visible',\n 'hidden',\n] as const\nexport type BaseplateVisibilityType = (typeof BaseplateVisibilityValues)[number]\n\nexport function isValidBaseplateVisibilityType(type: string): Boolean {\n return BaseplateVisibilityValues.includes(type as BaseplateVisibilityType)\n}\n\nexport const WorldScalingValues = ['automatic', 'dynamic'] as const\nexport type WorldScalingType = (typeof WorldScalingValues)[number]\n\nexport function isValidWorldScalingType(type: string): Boolean {\n return WorldScalingValues.includes(type as WorldScalingType)\n}\n\nexport const WorldAlignmentValues = [\n 'adaptive',\n 'automatic',\n 'gravityAligned',\n] as const\nexport type WorldAlignmentType = (typeof WorldAlignmentValues)[number]\n\nexport function isValidWorldAlignmentType(type: string): Boolean {\n return WorldAlignmentValues.includes(type as WorldAlignmentType)\n}\n\nexport const SpatialSceneValues = ['window', 'volume'] as const\nexport type SpatialSceneType = (typeof SpatialSceneValues)[number]\n\nexport function isValidSpatialSceneType(type: string): Boolean {\n return SpatialSceneValues.includes(type as SpatialSceneType)\n}\n\n/**\n * check px,m and number, number must be >= 0\n *\n * */\nexport function isValidSceneUnit(val: string | number): boolean {\n // only support number or string with unit px or m\n // rpx cm mm not allowed\n if (typeof val === 'number') {\n return val >= 0\n }\n if (typeof val === 'string') {\n if (val.endsWith('px')) {\n // check if number\n if (isNaN(Number(val.slice(0, -2)))) {\n return false\n }\n return Number(val.slice(0, -2)) >= 0\n }\n if (val.endsWith('m')) {\n // check if number\n if (isNaN(Number(val.slice(0, -1)))) {\n return false\n }\n return Number(val.slice(0, -1)) >= 0\n }\n }\n return false\n}\n\nexport interface SpatialEntityProperties {\n position: Vec3\n rotation: Vec3\n scale: Vec3\n}\n\nexport type SpatialEntityEventType = 'spatialtap' //| 'drag' | 'rotate' | 'scale'\n\nexport type SpatialGeometryType =\n | 'BoxGeometry'\n | 'PlaneGeometry'\n | 'SphereGeometry'\n | 'CylinderGeometry'\n | 'ConeGeometry'\n\nexport interface SpatialBoxGeometryOptions {\n width?: number\n height?: number\n depth?: number\n cornerRadius?: number\n splitFaces?: boolean\n}\n\nexport interface SpatialPlaneGeometryOptions {\n width?: number\n height?: number\n cornerRadius?: number\n}\n\nexport interface SpatialSphereGeometryOptions {\n radius?: number\n}\n\nexport interface SpatialConeGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport interface SpatialCylinderGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport type SpatialGeometryOptions =\n | SpatialBoxGeometryOptions\n | SpatialPlaneGeometryOptions\n | SpatialSphereGeometryOptions\n | SpatialCylinderGeometryOptions\n | SpatialConeGeometryOptions\n\nexport type SpatialMaterialType = 'unlit'\n\nexport interface SpatialUnlitMaterialOptions {\n color?: string\n textureId?: string\n transparent?: boolean\n opacity?: number\n}\n\nexport interface ModelComponentOptions {\n mesh: SpatialGeometry\n materials: SpatialMaterial[]\n}\n\nexport interface SpatialEntityUserData {\n id?: string\n name?: string\n}\n\nexport interface SpatialModelEntityCreationOptions {\n modelAssetId: string\n name?: string\n}\n\nexport interface ModelAssetOptions {\n url: string\n}\n\nexport enum SpatialSceneState {\n idle = 'idle',\n pending = 'pending',\n willVisible = 'willVisible',\n visible = 'visible',\n fail = 'fail',\n}\n\n/**\n * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event\n */\nexport type SpatialModelDragEvent = {\n eventType: 'dragstart' | 'dragend' | 'drag'\n translation3D: Vec3\n startLocation3D: Vec3\n}\n\nexport interface Size {\n width: number\n height: number\n}\n\nexport interface Size3D extends Size {\n depth: number\n}\n\nexport class CubeInfo {\n constructor(\n public size: Size3D,\n public origin: Vec3,\n ) {\n this.size = size\n this.origin = origin\n }\n\n get x() {\n return this.origin.x\n }\n\n get y() {\n return this.origin.y\n }\n\n get z() {\n return this.origin.z\n }\n\n get width() {\n return this.size.width\n }\n\n get height() {\n return this.size.height\n }\n\n get depth() {\n return this.size.depth\n }\n\n get left() {\n return this.x\n }\n\n get top() {\n return this.y\n }\n\n get right() {\n return this.x + this.width\n }\n\n get bottom() {\n return this.y + this.height\n }\n\n get back() {\n return this.z\n }\n\n get front() {\n return this.z + this.depth\n }\n}\n\nexport interface SpatialTapEventDetail {\n location3D: Point3D\n}\n\nexport type SpatialTapEvent = CustomEvent<SpatialTapEventDetail>\n\nexport interface SpatialDragEventDetail {\n location3D: Point3D\n startLocation3D: Point3D\n translation3D: Vec3\n predictedEndTranslation3D: Vec3\n predictedEndLocation3D: Point3D\n velocity: Size\n}\n\nexport type SpatialDragEvent = CustomEvent<SpatialDragEventDetail>\n\nexport type SpatialDragEndEvent = SpatialDragEvent\n\nexport interface SpatialRotateEventDetail {\n rotation: { vector: [number, number, number, number] }\n startAnchor3D: Vec3\n startLocation3D: Point3D\n}\n\nexport type SpatialRotateEvent = CustomEvent<SpatialRotateEventDetail>\n\nexport type SpatialRotateEndEvent = SpatialRotateEvent\n\nexport interface SpatialMagnifyEventDetail {\n magnification: number\n velocity: number\n startAnchor3D: Vec3\n startLocation3D: Point3D\n}\n\nexport type SpatialMagnifyEvent = CustomEvent<SpatialMagnifyEventDetail>\n\nexport type SpatialMagnifyEndEvent = SpatialMagnifyEvent\n\nexport type SpatialEntityOrReality = SpatialEntity | SpatializedDynamic3DElement\n","import {\n createSpatialized2DElementCommand,\n CreateSpatializedDynamic3DElementCommand,\n CreateSpatializedStatic3DElementCommand,\n} from './JSBCommand'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\n\nexport async function createSpatialized2DElement(): Promise<Spatialized2DElement> {\n const result = await new createSpatialized2DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatialized2DElement failed')\n } else {\n const { id, windowProxy } = result.data!\n // set base href to make sure the relative url is correct\n windowProxy.document.head.innerHTML = `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <base href=\"${document.baseURI}\">`\n return new Spatialized2DElement(id, windowProxy)\n }\n}\n\nexport async function createSpatializedStatic3DElement(\n modelURL: string,\n): Promise<SpatializedStatic3DElement> {\n const result = await new CreateSpatializedStatic3DElementCommand(\n modelURL,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatializedStatic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedStatic3DElement(id)\n }\n}\n\nexport async function createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n const result = await new CreateSpatializedDynamic3DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatializedDynamic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedDynamic3DElement(id)\n }\n}\n","import {\n AddSpatializedElementToSpatialized2DElement,\n UpdateSpatialized2DElementProperties,\n} from './JSBCommand'\nimport { hijackWindowATag } from './scene-polyfill'\nimport { SpatializedElement } from './SpatializedElement'\nimport { Spatialized2DElementProperties } from './types/types'\n\n/**\n * Represents a 2D HTML element that has been spatialized in 3D space.\n * This class handles the integration between 2D web content and the 3D spatial environment,\n * allowing HTML elements to be positioned and interacted with in spatial applications.\n */\nexport class Spatialized2DElement extends SpatializedElement {\n /**\n * Creates a new spatialized 2D element.\n * @param id Unique identifier for this element\n * @param windowProxy Reference to the window object containing the 2D content\n */\n constructor(\n id: string,\n readonly windowProxy: WindowProxy,\n ) {\n super(id)\n // Hijack anchor tag events to handle navigation within the spatial context\n hijackWindowATag(windowProxy)\n }\n\n /**\n * Updates the properties of this 2D element.\n * This can include size, position, background, and other visual properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(properties: Partial<Spatialized2DElementProperties>) {\n return new UpdateSpatialized2DElementProperties(this, properties).execute()\n }\n\n /**\n * Adds a child spatialized element to this 2D element.\n * This allows for creating hierarchical structures of spatial elements.\n * @param element The child element to add\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialized2DElement(\n this,\n element,\n ).execute()\n }\n}\n","import { UpdateSpatializedElementTransform } from './JSBCommand'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialWebEvent } from './SpatialWebEvent'\nimport { createSpatialEvent } from './SpatialWebEventCreator'\nimport {\n CubeInfo,\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatializedElementProperties,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n SpatialRotateEndEvent,\n SpatialRotateEvent,\n SpatialTapEvent,\n} from './types/types'\nimport {\n CubeInfoMsg,\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n TransformMsg,\n} from './WebMsgCommand'\n\n/**\n * Abstract base class for all spatialized elements in the WebSpatial environment.\n * Provides common functionality for elements that can exist in 3D space,\n * including transformation handling and gesture event processing.\n */\nexport abstract class SpatializedElement extends SpatialObject {\n /**\n * Creates a new spatialized element with the specified ID.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n */\n constructor(public readonly id: string) {\n super(id)\n\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent.bind(this))\n }\n\n /**\n * Updates the properties of this spatialized element.\n * Must be implemented by derived classes to handle specific property updates.\n * @param properties Partial set of properties to update\n * @returns Promise resolving to the result of the update operation\n */\n abstract updateProperties(\n properties: Partial<SpatializedElementProperties>,\n ): Promise<WebSpatialProtocolResult>\n\n /**\n * Updates the transformation matrix of this element in 3D space.\n * This affects the position, rotation, and scale of the element.\n * @param matrix The new transformation matrix\n * @returns Promise resolving when the transform is updated\n */\n async updateTransform(matrix: DOMMatrix) {\n return new UpdateSpatializedElementTransform(this, matrix).execute()\n }\n\n /**\n * Information about the element's bounding cube.\n * Used for spatial calculations and hit testing.\n */\n private _cubeInfo?: CubeInfo\n\n /**\n * Gets the current cube information for this element.\n * @returns The current CubeInfo or undefined if not set\n */\n get cubeInfo() {\n return this._cubeInfo\n }\n\n /**\n * The current transformation matrix of this element.\n */\n private _transform?: DOMMatrix\n\n /**\n * The inverse of the current transformation matrix.\n * Used for converting world coordinates to local coordinates.\n */\n private _transformInv?: DOMMatrix\n\n /**\n * Gets the current transformation matrix.\n * @returns The current transformation matrix or undefined if not set\n */\n get transform() {\n return this._transform\n }\n\n /**\n * Gets the inverse of the current transformation matrix.\n * @returns The inverse transformation matrix or undefined if not set\n */\n get transformInv() {\n return this._transformInv\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles various spatial events like transforms, gestures, and interactions.\n * @param data The event data received from the WebSpatial system\n */\n protected onReceiveEvent(\n data:\n | CubeInfoMsg\n | TransformMsg\n | SpatialTapMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n } else if (type === SpatialWebMsgType.cubeInfo) {\n // Handle cube info updates (bounding box information)\n const cubeInfoMsg = data as CubeInfoMsg\n this._cubeInfo = new CubeInfo(cubeInfoMsg.size, cubeInfoMsg.origin)\n } else if (type === SpatialWebMsgType.transform) {\n // Handle transformation matrix updates\n this._transform = new DOMMatrix([\n data.detail.column0[0],\n data.detail.column0[1],\n data.detail.column0[2],\n 0,\n data.detail.column1[0],\n data.detail.column1[1],\n data.detail.column1[2],\n 0,\n data.detail.column2[0],\n data.detail.column2[1],\n data.detail.column2[2],\n 0,\n data.detail.column3[0],\n data.detail.column3[1],\n data.detail.column3[2],\n 1,\n ])\n this._transformInv = this._transform.inverse()\n } else if (type === SpatialWebMsgType.spatialtap) {\n // Handle tap gestures\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialtap,\n (data as SpatialTapMsg).detail,\n )\n this._onSpatialTap?.(event)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n // Handle drag gestures, with special handling for drag start\n if (!this._isDragging) {\n const dragStartEvent = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n (data as SpatialDragMsg).detail,\n )\n this._onSpatialDragStart?.(dragStartEvent)\n }\n this._isDragging = true\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdrag,\n (data as SpatialDragMsg).detail,\n )\n this._onSpatialDrag?.(event)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n this._isDragging = false\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n (data as SpatialDragEndMsg).detail,\n )\n this._onSpatialDragEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialrotate) {\n if (!this._isRotating) {\n const rotationStartEvent = createSpatialEvent(\n SpatialWebMsgType.spatialrotatestart,\n (data as SpatialRotateMsg).detail,\n )\n this._onSpatialRotateStart?.(rotationStartEvent)\n }\n this._isRotating = true\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n (data as SpatialRotateMsg).detail,\n )\n this._onSpatialRotate?.(event)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n this._isRotating = false\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n (data as SpatialRotateEndMsg).detail,\n )\n this._onSpatialRotateEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnify) {\n if (!this._isMagnify) {\n const magnifyStartEvent = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifystart,\n (data as SpatialMagnifyMsg).detail,\n )\n this._onSpatialMagnifyStart?.(magnifyStartEvent)\n }\n this._isMagnify = true\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n (data as SpatialMagnifyMsg).detail,\n )\n this._onSpatialMagnify?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n this._isMagnify = false\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n (data as SpatialMagnifyEndMsg).detail,\n )\n this._onSpatialMagnifyEnd?.(event)\n }\n }\n\n private _onSpatialTap?: (event: SpatialTapEvent) => void\n set onSpatialTap(value: (event: SpatialTapEvent) => void | undefined) {\n this._onSpatialTap = value\n this.updateProperties({\n enableTapGesture: value !== undefined,\n })\n }\n\n private _isDragging = false\n private _onSpatialDragStart?: (event: SpatialDragEvent) => void\n set onSpatialDragStart(value: (event: SpatialDragEvent) => void | undefined) {\n this._onSpatialDragStart = value\n this.updateProperties({\n enableDragStartGesture: this._onSpatialDragStart !== undefined,\n })\n }\n\n private _onSpatialDrag?: (event: SpatialDragEvent) => void\n set onSpatialDrag(value: (event: SpatialDragEvent) => void | undefined) {\n this._onSpatialDrag = value\n this.updateProperties({\n enableDragGesture: this._onSpatialDrag !== undefined,\n })\n }\n\n private _onSpatialDragEnd?: (event: SpatialDragEndEvent) => void\n set onSpatialDragEnd(\n value: ((event: SpatialDragEndEvent) => void) | undefined,\n ) {\n this._onSpatialDragEnd = value\n this.updateProperties({\n enableDragEndGesture: value !== undefined,\n })\n }\n\n private _isRotating = false\n private _onSpatialRotateStart?: (event: SpatialRotateEvent) => void\n set onSpatialRotateStart(\n value: ((event: SpatialRotateEvent) => void) | undefined,\n ) {\n this._onSpatialRotateStart = value\n this.updateProperties({\n enableRotateStartGesture: this._onSpatialRotateStart !== undefined,\n })\n }\n\n private _onSpatialRotate?: (event: SpatialRotateEvent) => void\n set onSpatialRotate(\n value: ((event: SpatialRotateEvent) => void) | undefined,\n ) {\n this._onSpatialRotate = value\n this.updateProperties({\n enableRotateGesture: this._onSpatialRotate !== undefined,\n })\n }\n\n private _onSpatialRotateEnd?: (event: SpatialRotateEndEvent) => void\n set onSpatialRotateEnd(\n value: ((event: SpatialRotateEndEvent) => void) | undefined,\n ) {\n this._onSpatialRotateEnd = value\n this.updateProperties({\n enableRotateEndGesture: value !== undefined,\n })\n }\n\n private _isMagnify = false\n private _onSpatialMagnifyStart?: (event: SpatialMagnifyEvent) => void\n set onSpatialMagnifyStart(\n value: ((event: SpatialMagnifyEvent) => void) | undefined,\n ) {\n this._onSpatialMagnifyStart = value\n this.updateProperties({\n enableMagnifyStartGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnify?: (event: SpatialMagnifyEvent) => void\n set onSpatialMagnify(\n value: ((event: SpatialMagnifyEvent) => void) | undefined,\n ) {\n this._onSpatialMagnify = value\n this.updateProperties({\n enableMagnifyGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent) => void\n set onSpatialMagnifyEnd(\n value: ((event: SpatialMagnifyEndEvent) => void) | undefined,\n ) {\n this._onSpatialMagnifyEnd = value\n this.updateProperties({\n enableMagnifyEndGesture: value !== undefined,\n })\n }\n\n /**\n * Cleans up resources when this element is destroyed.\n * Removes event receivers to prevent memory leaks.\n */\n override onDestroy() {\n SpatialWebEvent.removeEventReceiver(this.id)\n }\n}\n","import { SpatialWebMsgType } from './WebMsgCommand'\n\nexport function createSpatialEvent<T>(\n type: SpatialWebMsgType,\n detail: T,\n): CustomEvent<T> {\n return new CustomEvent<T>(type, {\n bubbles: true,\n cancelable: false,\n detail,\n })\n}\n","import { UpdateSpatializedStatic3DElementProperties } from './JSBCommand'\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatializedStatic3DElementProperties } from './types/types'\nimport { SpatialWebMsgType } from './WebMsgCommand'\n\n/**\n * Represents a static 3D model element in the spatial environment.\n * This class handles loading and displaying pre-built 3D models from URLs,\n * and provides events for load success and failure.\n */\nexport class SpatializedStatic3DElement extends SpatializedElement {\n /**\n * Promise resolver for the ready state.\n * Used to resolve the ready promise when the model is loaded.\n */\n private _readyResolve?: (success: boolean) => void\n\n /**\n * Caches the last model URL to detect changes.\n * Used to reset the ready promise when the model URL changes.\n */\n private modelURL: string = ''\n\n /**\n * Creates a new promise for tracking the ready state of the model.\n * @returns Promise that resolves when the model is loaded (true) or fails to load (false)\n */\n private createReadyPromise() {\n return new Promise<boolean>(resolve => {\n this._readyResolve = resolve\n })\n }\n\n /**\n * Promise that resolves when the model is loaded.\n * Resolves to true on successful load, false on failure.\n */\n ready: Promise<boolean> = this.createReadyPromise()\n\n /**\n * Updates the properties of this static 3D element.\n * Handles special case for modelURL changes by resetting the ready promise.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n if (properties.modelURL !== undefined) {\n if (this.modelURL !== properties.modelURL) {\n this.modelURL = properties.modelURL\n this.ready = this.createReadyPromise()\n }\n }\n return new UpdateSpatializedStatic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles model loading events in addition to base spatial events.\n * @param data The event data received from the WebSpatial system\n */\n override onReceiveEvent(data: { type: SpatialWebMsgType }) {\n if (data.type === SpatialWebMsgType.modelloaded) {\n // Handle successful model loading\n this._onLoadCallback?.()\n this._readyResolve?.(true)\n } else if (data.type === SpatialWebMsgType.modelloadfailed) {\n // Handle model loading failure\n this._onLoadFailureCallback?.()\n this._readyResolve?.(false)\n } else {\n // Handle other spatial events using the base class implementation\n super.onReceiveEvent(data as any)\n }\n }\n\n /**\n * Callback function for successful model loading.\n */\n private _onLoadCallback?: () => void\n\n /**\n * Sets the callback function for successful model loading.\n * @param callback Function to call when the model is loaded successfully\n */\n set onLoadCallback(callback: undefined | (() => void)) {\n this._onLoadCallback = callback\n }\n\n /**\n * Callback function for model loading failure.\n */\n private _onLoadFailureCallback?: undefined | (() => void)\n\n /**\n * Sets the callback function for model loading failure.\n * @param callback Function to call when the model fails to load\n */\n set onLoadFailureCallback(callback: undefined | (() => void)) {\n this._onLoadFailureCallback = callback\n }\n\n updateModelTransform(transform: DOMMatrix) {\n const modelTransform = Array.from(transform.toFloat64Array())\n this.updateProperties({ modelTransform })\n }\n}\n","import {\n AddEntityToDynamic3DCommand,\n SetParentForEntityCommand,\n UpdateSpatializedDynamic3DElementProperties,\n} from './JSBCommand'\nimport { SpatialEntity } from './reality'\nimport { SpatializedElement } from './SpatializedElement'\nimport {\n SpatialEntityOrReality,\n SpatializedElementProperties,\n} from './types/types'\nexport class SpatializedDynamic3DElement extends SpatializedElement {\n children: SpatialEntityOrReality[] = []\n constructor(id: string) {\n super(id)\n }\n\n async addEntity(entity: SpatialEntity) {\n const ans = new SetParentForEntityCommand(entity.id, this.id).execute()\n this.children.push(entity)\n entity.parent = this\n return ans\n }\n async updateProperties(properties: Partial<SpatializedElementProperties>) {\n return new UpdateSpatializedDynamic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n}\n","import {\n CreateModelComponentCommand,\n CreateModelAssetCommand,\n CreateSpatialEntityCommand,\n CreateSpatialGeometryCommand,\n CreateSpatialModelEntityCommand,\n CreateSpatialUnlitMaterialCommand,\n} from '../JSBCommand'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n} from '../types/types'\nimport { SpatialEntity, SpatialModelEntity } from './entity'\nimport { ModelComponent } from './component'\nimport { SpatialGeometry } from './geometry'\nimport { SpatialUnlitMaterial } from './material'\nimport { SpatialModelAsset } from './resource'\n\nexport async function createSpatialEntity(\n userData?: SpatialEntityUserData,\n): Promise<SpatialEntity> {\n const result = await new CreateSpatialEntityCommand(userData?.name).execute()\n if (!result.success) {\n throw new Error('createSpatialEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialEntity(id, userData)\n }\n}\n\nexport async function createSpatialGeometry<T extends SpatialGeometry>(\n ctor: new (...args: any[]) => T,\n options: SpatialGeometryOptions,\n) {\n const result = await new CreateSpatialGeometryCommand(\n (ctor as any).type,\n options,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatialGeometry failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ctor(id, options) as T\n }\n}\n\nexport async function createSpatialUnlitMaterial(\n options: SpatialUnlitMaterialOptions,\n) {\n const result = await new CreateSpatialUnlitMaterialCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialUnlitMaterial failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialUnlitMaterial(id, options)\n }\n}\n\nexport async function createModelComponent(options: ModelComponentOptions) {\n const result = await new CreateModelComponentCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelComponent failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ModelComponent(id, options)\n }\n}\n\nexport async function createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n) {\n const result = await new CreateSpatialModelEntityCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialModelEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelEntity(id, options, userData)\n }\n}\n\nexport async function createModelAsset(options: ModelAssetOptions) {\n const result = await new CreateModelAssetCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelAsset failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelAsset(id, options)\n }\n}\n","import {\n ConvertFromEntityToEntityCommand,\n ConvertFromEntityToSceneCommand,\n ConvertFromSceneToEntityCommand,\n SetParentForEntityCommand,\n} from './../../JSBCommand'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatialEntityUserData,\n Vec3,\n} from '../../types/types'\nimport {\n AddComponentToEntityCommand,\n AddEntityToEntityCommand,\n RemoveEntityFromParentCommand,\n UpdateEntityEventCommand,\n UpdateEntityPropertiesCommand,\n} from '../../JSBCommand'\nimport { SpatialObject } from '../../SpatialObject'\nimport { SpatialEntityProperties } from '../../types/types'\nimport { SpatialComponent } from '../component/SpatialComponent'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { createSpatialEvent } from '../../SpatialWebEventCreator'\nimport {\n CubeInfoMsg,\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n TransformMsg,\n} from '../../WebMsgCommand'\n\nexport class SpatialEntity extends SpatialObject {\n position: Vec3 = { x: 0, y: 0, z: 0 }\n rotation: Vec3 = { x: 0, y: 0, z: 0 }\n scale: Vec3 = { x: 1, y: 1, z: 1 }\n\n events: Record<string, (data: any) => void> = {}\n children: SpatialEntity[] = []\n parent: SpatialEntityOrReality | null = null\n constructor(\n id: string,\n public userData?: SpatialEntityUserData,\n ) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n async addComponent(component: SpatialComponent) {\n return new AddComponentToEntityCommand(this, component).execute()\n }\n async setPosition(position: Vec3) {\n return this.updateTransform({ position })\n }\n async setRotation(rotation: Vec3) {\n return this.updateTransform({ rotation })\n }\n async setScale(scale: Vec3) {\n return this.updateTransform({ scale })\n }\n\n async addEntity(ent: SpatialEntity) {\n const ans = await new SetParentForEntityCommand(ent.id, this.id).execute()\n this.children.push(ent)\n ent.parent = this\n return ans\n }\n async removeFromParent() {\n const ans = await new SetParentForEntityCommand(\n this.id,\n undefined,\n ).execute()\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n return ans\n }\n\n async updateTransform(properties: Partial<SpatialEntityProperties>) {\n this.position = properties.position ?? this.position\n this.rotation = properties.rotation ?? this.rotation\n this.scale = properties.scale ?? this.scale\n return new UpdateEntityPropertiesCommand(this, properties).execute()\n }\n\n async addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n if (this.events[type]) {\n // replace if exist\n this.events[type] = callback\n } else {\n try {\n await this.updateEntityEvent(type, true)\n this.events[type] = callback\n } catch (error) {\n console.error('addEvent failed', type)\n }\n }\n }\n\n async removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n try {\n await this.updateEntityEvent(eventName, false)\n } catch (error) {\n console.error('removeEvent failed', eventName)\n }\n }\n }\n\n async updateEntityEvent(\n eventName: SpatialEntityEventType,\n isEnable: boolean,\n ) {\n return new UpdateEntityEventCommand(this, eventName, isEnable).execute()\n }\n private onReceiveEvent = (\n data: // | CubeInfoMsg\n // | TransformMsg\n | SpatialTapMsg\n // | SpatialDragMsg\n // | SpatialDragEndMsg\n // | SpatialRotateMsg\n // | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) => {\n // console.log('SpatialEntityEvent', data)\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n // tap\n else if (type === SpatialWebMsgType.spatialtap) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialtap,\n (data as SpatialTapMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n (data as SpatialDragMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdrag,\n (data as SpatialDragMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n (data as SpatialDragEndMsg).detail,\n )\n this.dispatchEvent(evt)\n }\n // rotate\n else if (type === SpatialWebMsgType.spatialrotatestart) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotatestart,\n (data as SpatialRotateMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialrotate) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n (data as SpatialRotateMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n (data as SpatialRotateEndMsg).detail,\n )\n this.dispatchEvent(evt)\n }\n // magnify\n else if (type === SpatialWebMsgType.spatialmagnifystart) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifystart,\n (data as SpatialMagnifyMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialmagnify) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n (data as SpatialMagnifyMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n (data as SpatialMagnifyMsg).detail,\n )\n this.dispatchEvent(evt)\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n this.events[evt.type]?.(evt)\n if (evt.bubbles && !evt.cancelBubble) {\n if (this.parent && this.parent instanceof SpatialEntity) {\n this.parent.dispatchEvent(evt)\n }\n }\n }\n\n protected onDestroy(): void {\n SpatialWebEvent.removeEventReceiver(this.id)\n // handle children\n this.children.forEach(child => {\n child.parent = null\n })\n this.children = []\n // handle parent\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n }\n // onUpdate(properties: SpatialEntityProperties) {\n // this.position = properties.position\n // this.rotation = properties.rotation\n // this.scale = properties.scale\n // }\n async convertFromEntityToEntity(\n fromEntityId: string,\n toEntityId: string,\n position: Vec3,\n ) {\n return new ConvertFromEntityToEntityCommand(\n fromEntityId,\n toEntityId,\n position,\n ).execute()\n }\n\n async convertFromEntityToScene(fromEntityId: string, position: Vec3) {\n return new ConvertFromEntityToSceneCommand(fromEntityId, position).execute()\n }\n async convertFromSceneToEntity(entityId: string, position: Vec3) {\n return new ConvertFromSceneToEntityCommand(entityId, position).execute()\n }\n}\n","import {\n SpatialEntityUserData,\n SpatialModelEntityCreationOptions,\n} from '../../types/types'\nimport { SpatialEntity } from './SpatialEntity'\n\nexport class SpatialModelEntity extends SpatialEntity {\n constructor(\n public id: string,\n public options?: SpatialModelEntityCreationOptions,\n public userData?: SpatialEntityUserData,\n ) {\n super(id, userData)\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { ObjectDestroyMsg, SpatialWebMsgType } from '../../WebMsgCommand'\n\nexport class SpatialComponent extends SpatialObject {\n constructor(id: string) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n private onReceiveEvent = (data: ObjectDestroyMsg) => {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n }\n}\n","import { ModelComponentOptions } from '../../types/types'\nimport { SpatialComponent } from './SpatialComponent'\n\nexport class ModelComponent extends SpatialComponent {\n constructor(\n id: string,\n public options: ModelComponentOptions,\n ) {\n super(id)\n }\n}\n","import { UpdateUnlitMaterialProperties } from '../../JSBCommand'\nimport { SpatialUnlitMaterialOptions } from '../../types/types'\nimport { SpatialMaterial } from './SpatialMaterial'\n\nexport class SpatialUnlitMaterial extends SpatialMaterial {\n constructor(\n public id: string,\n public options: SpatialUnlitMaterialOptions,\n ) {\n super(id, 'unlit')\n }\n\n updateProperties(properties: Partial<SpatialUnlitMaterialOptions>) {\n return new UpdateUnlitMaterialProperties(this, properties).execute()\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialMaterialType } from '../../types/types'\n\nexport abstract class SpatialMaterial extends SpatialObject {\n constructor(\n public id: string,\n public type: SpatialMaterialType,\n ) {\n super(id)\n this.type = type\n }\n\n abstract updateProperties(properties: any): void\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { ModelAssetOptions } from '../../types/types'\n\nexport class SpatialModelAsset extends SpatialObject {\n constructor(\n public id: string,\n public options: ModelAssetOptions,\n ) {\n super(id)\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialGeometryOptions, SpatialGeometryType } from '../../types/types'\n\nexport class SpatialGeometry extends SpatialObject {\n static type: SpatialGeometryType\n constructor(\n public id: string,\n public options: SpatialGeometryOptions,\n ) {\n super(id)\n }\n}\n","import { SpatialBoxGeometryOptions, SpatialGeometryType } from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialBoxGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'BoxGeometry'\n constructor(\n public id: string,\n public options: SpatialBoxGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialSphereGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialSphereGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'SphereGeometry'\n constructor(\n public id: string,\n public options: SpatialSphereGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialCylinderGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialCylinderGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'CylinderGeometry'\n constructor(\n public id: string,\n public options: SpatialCylinderGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialPlaneGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialPlaneGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'PlaneGeometry'\n constructor(\n public id: string,\n public options: SpatialPlaneGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialConeGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialConeGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'ConeGeometry'\n constructor(\n public id: string,\n public options: SpatialConeGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import { initScene } from './scene-polyfill'\nimport { SpatialScene } from './SpatialScene'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport {\n createSpatialized2DElement,\n createSpatializedDynamic3DElement,\n} from './SpatializedElementCreator'\nimport { createSpatializedStatic3DElement } from './SpatializedElementCreator'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialBoxGeometryOptions,\n SpatialConeGeometryOptions,\n SpatialCylinderGeometryOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialPlaneGeometryOptions,\n SpatialSceneCreationOptions,\n SpatialSphereGeometryOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n} from './types/types'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport {\n createModelAsset,\n createModelComponent,\n createSpatialEntity,\n createSpatialGeometry,\n createSpatialModelEntity,\n createSpatialUnlitMaterial,\n} from './reality/realityCreator'\nimport {\n SpatialBoxGeometry,\n SpatialPlaneGeometry,\n SpatialSphereGeometry,\n SpatialConeGeometry,\n SpatialCylinderGeometry,\n} from './reality'\n\n/**\n * Session used to establish a connection to the spatial renderer of the system.\n * All spatial resources must be created through this session object.\n * This class serves as the main factory for creating spatial elements and geometries.\n */\nexport class SpatialSession {\n /**\n * Gets the singleton instance of the spatial scene.\n * The spatial scene is the root container for all spatial elements.\n * @returns The SpatialScene singleton instance\n */\n getSpatialScene(): SpatialScene {\n return SpatialScene.getInstance()\n }\n\n /**\n * Creates a new 2D element that can be spatialized in the 3D environment.\n * 2D elements represent HTML content that can be positioned in 3D space.\n * @returns Promise resolving to a new Spatialized2DElement instance\n */\n createSpatialized2DElement(): Promise<Spatialized2DElement> {\n return createSpatialized2DElement()\n }\n\n /**\n * Creates a new static 3D element with an optional model URL.\n * Static 3D elements represent pre-built 3D models that can be loaded from a URL.\n * @param modelURL Optional URL to the 3D model to load\n * @returns Promise resolving to a new SpatializedStatic3DElement instance\n */\n createSpatializedStatic3DElement(\n modelURL: string = '',\n ): Promise<SpatializedStatic3DElement> {\n return createSpatializedStatic3DElement(modelURL)\n }\n\n /**\n * Initializes the spatial scene with custom configuration.\n * This is a reference to the initScene function from scene-polyfill.\n */\n initScene = initScene\n \n /**\n * Creates a new dynamic 3D element that can be manipulated at runtime.\n * Dynamic 3D elements allow for programmatic creation and modification of 3D content.\n * @returns Promise resolving to a new SpatializedDynamic3DElement instance\n */\n createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n return createSpatializedDynamic3DElement()\n }\n\n /**\n * Creates a new spatial entity with an optional name.\n * Entities are the basic building blocks for creating custom 3D content.\n * @param name Optional name for the entity\n * @returns Promise resolving to a new SpatialEntity instance\n */\n createEntity(userData?: SpatialEntityUserData,): Promise<SpatialEntity> {\n return createSpatialEntity(userData)\n }\n\n /**\n * Creates a box geometry with optional configuration.\n * @param options Configuration options for the box geometry\n * @returns Promise resolving to a new SpatialBoxGeometry instance\n */\n createBoxGeometry(options: SpatialBoxGeometryOptions = {}) {\n return createSpatialGeometry(SpatialBoxGeometry, options)\n }\n\n /**\n * Creates a plane geometry with optional configuration.\n * @param options Configuration options for the plane geometry\n * @returns Promise resolving to a new SpatialPlaneGeometry instance\n */\n createPlaneGeometry(options: SpatialPlaneGeometryOptions = {}) {\n return createSpatialGeometry(SpatialPlaneGeometry, options)\n }\n\n /**\n * Creates a sphere geometry with optional configuration.\n * @param options Configuration options for the sphere geometry\n * @returns Promise resolving to a new SpatialSphereGeometry instance\n */\n createSphereGeometry(options: SpatialSphereGeometryOptions = {}) {\n return createSpatialGeometry(SpatialSphereGeometry, options)\n }\n\n /**\n * Creates a cone geometry with the specified configuration.\n * @param options Configuration options for the cone geometry\n * @returns Promise resolving to a new SpatialConeGeometry instance\n */\n createConeGeometry(options: SpatialConeGeometryOptions) {\n return createSpatialGeometry(SpatialConeGeometry, options)\n }\n\n /**\n * Creates a cylinder geometry with the specified configuration.\n * @param options Configuration options for the cylinder geometry\n * @returns Promise resolving to a new SpatialCylinderGeometry instance\n */\n createCylinderGeometry(options: SpatialCylinderGeometryOptions) {\n return createSpatialGeometry(SpatialCylinderGeometry, options)\n }\n\n /**\n * Creates a model component with the specified configuration.\n * Model components are used to add 3D model rendering capabilities to entities.\n * @param options Configuration options for the model component\n * @returns Promise resolving to a new ModelComponent instance\n */\n createModelComponent(options: ModelComponentOptions) {\n return createModelComponent(options)\n }\n\n /**\n * Creates an unlit material with the specified configuration.\n * Unlit materials don't respond to lighting in the scene.\n * @param options Configuration options for the unlit material\n * @returns Promise resolving to a new SpatialUnlitMaterial instance\n */\n createUnlitMaterial(options: SpatialUnlitMaterialOptions) {\n return createSpatialUnlitMaterial(options)\n }\n \n /**\n * Creates a model asset with the specified configuration.\n * Model assets represent 3D model resources that can be used by entities.\n * @param options Configuration options for the model asset\n * @returns Promise resolving to a new SpatialModelAsset instance\n */\n createModelAsset(options: ModelAssetOptions) {\n return createModelAsset(options)\n }\n\n /**\n * Creates a spatial model entity with the specified configuration.\n * This is a convenience method for creating an entity with a model component.\n * @param options Configuration options for the spatial model entity\n * @returns Promise resolving to a new SpatialModelEntity instance\n */\n createSpatialModelEntity(options: SpatialModelEntityCreationOptions, userData?: SpatialEntityUserData) {\n return createSpatialModelEntity(options, userData)\n }\n}\n","import { SpatialSession } from './SpatialSession'\nimport { SpatialWebEvent } from './SpatialWebEvent'\n\n/**\n * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr.\n * This is the main entry point for the WebSpatial SDK, providing access to spatial capabilities.\n */\nexport class Spatial {\n /**\n * Requests a spatial session object from the browser.\n * This is the primary method to initialize spatial functionality.\n * @returns The SpatialSession instance or null if not available in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n if (this.runInSpatialWeb()) {\n SpatialWebEvent.init()\n return new SpatialSession()\n } else {\n return null\n }\n }\n\n /**\n * Checks if the current page is running in a spatial web environment.\n * This method detects if the application is running in a WebSpatial-compatible browser.\n * @returns True if running in a spatial web environment, false otherwise\n */\n runInSpatialWeb() {\n if (navigator.userAgent.indexOf('WebSpatial/') > 0) {\n return true\n }\n return false\n }\n\n /** @deprecated\n * Checks if WebSpatial is supported in the current environment.\n * Verifies compatibility between native and client versions.\n * @returns True if web spatial is supported by this webpage\n */\n isSupported() {\n return true\n }\n\n /** @deprecated\n * Gets the native WebSpatial version from the browser environment.\n * The version format follows semantic versioning (x.x.x).\n * @returns Native version string in format \"x.x.x\"\n */\n getNativeVersion() {\n if (window.__WebSpatialData && window.__WebSpatialData.getNativeVersion) {\n return window.__WebSpatialData.getNativeVersion()\n }\n return window.WebSpatailNativeVersion === 'PACKAGE_VERSION'\n ? this.getClientVersion()\n : window.WebSpatailNativeVersion\n }\n\n /** @deprecated\n * Gets the client SDK version.\n * The version format follows semantic versioning (x.x.x).\n * @returns Client SDK version string in format \"x.x.x\"\n */\n getClientVersion() {\n // @ts-ignore\n return __WEBSPATIAL_CORE_SDK_VERSION__\n }\n}\n","export { SpatialObject } from './SpatialObject'\nexport { Spatial } from './Spatial'\nexport { SpatialSession } from './SpatialSession'\nexport { SpatialScene } from './SpatialScene'\nexport { SpatializedElement } from './SpatializedElement'\nexport { Spatialized2DElement } from './Spatialized2DElement'\nexport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nexport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nexport * from './reality'\nexport * from './types/types'\nexport * from './types/global.d'\n\n// side effects\nimport { injectSceneHook } from './scene-polyfill'\nimport { isSSREnv } from './ssr-polyfill'\nimport { spatialWindowPolyfill } from './spatial-window-polyfill'\n\nexport { isSSREnv }\n\nif (!isSSREnv() && navigator.userAgent.indexOf('WebSpatial/') > 0) {\n injectSceneHook()\n spatialWindowPolyfill()\n}\n","import { parseCornerRadius } from './utils'\nimport { Spatial } from './Spatial'\nimport { SpatialSession } from './SpatialSession'\nimport { BackgroundMaterialType } from './types/types'\n\nconst spatial = new Spatial()\nlet session: SpatialSession | undefined = undefined\n\nconst SpatialGlobalCustomVars = {\n backgroundMaterial: '--xr-background-material',\n}\n\n// keep track of current html background material\nlet htmlBackgroundMaterial = ''\nfunction setCurrentWindowStyle(backgroundMaterial: string) {\n if (backgroundMaterial !== htmlBackgroundMaterial) {\n session?.getSpatialScene()?.updateSpatialProperties({\n material: backgroundMaterial as BackgroundMaterialType,\n })\n htmlBackgroundMaterial = backgroundMaterial\n }\n}\n\nfunction checkHtmlBackgroundMaterial() {\n const computedStyle = getComputedStyle(document.documentElement)\n\n const backgroundMaterial = computedStyle.getPropertyValue(\n SpatialGlobalCustomVars.backgroundMaterial,\n )\n\n setCurrentWindowStyle(backgroundMaterial || 'none')\n}\n\n// keep track of current corner radius\nlet htmlCornerRadius = {\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n}\n\nfunction checkCornerRadius() {\n const computedStyle = getComputedStyle(document.documentElement)\n const cornerRadius = parseCornerRadius(computedStyle)\n setCornerRadius(cornerRadius)\n}\n\nfunction setCornerRadius(cornerRadius: any) {\n if (\n htmlCornerRadius.topLeading !== cornerRadius.topLeading ||\n htmlCornerRadius.bottomLeading !== cornerRadius.bottomLeading ||\n htmlCornerRadius.topTrailing !== cornerRadius.topTrailing ||\n htmlCornerRadius.bottomTrailing !== cornerRadius.bottomTrailing\n ) {\n session?.getSpatialScene()?.updateSpatialProperties({\n cornerRadius,\n })\n htmlCornerRadius.topLeading = cornerRadius.topLeading\n htmlCornerRadius.bottomLeading = cornerRadius.bottomLeading\n htmlCornerRadius.topTrailing = cornerRadius.topTrailing\n htmlCornerRadius.bottomTrailing = cornerRadius.bottomTrailing\n }\n}\n\nfunction setOpacity(opacity: number) {\n session?.getSpatialScene().updateSpatialProperties({\n opacity,\n })\n}\n\nfunction checkOpacity() {\n const computedStyle = getComputedStyle(document.documentElement)\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n setOpacity(opacity)\n}\n\nfunction hijackDocumentElementStyle() {\n const rawDocumentStyle = document.documentElement.style\n const styleProxy = new Proxy(rawDocumentStyle, {\n set: function (target, key, value) {\n const ret = Reflect.set(target, key, value)\n\n if (key === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n\n if (\n key === 'border-radius' ||\n key === 'borderRadius' ||\n key === 'border-top-left-radius' ||\n key === 'borderTopLeftRadius' ||\n key === 'border-top-right-radius' ||\n key === 'borderTopRightRadius' ||\n key === 'border-bottom-left-radius' ||\n key === 'borderBottomLeftRadius' ||\n key === 'border-bottom-right-radius' ||\n key === 'borderBottomRightRadius'\n ) {\n checkCornerRadius()\n }\n\n if (key === 'opacity') {\n checkOpacity()\n }\n\n return ret\n },\n get: function (target, prop: string) {\n if (typeof target[prop as keyof CSSStyleDeclaration] === 'function') {\n return function (this: any, ...args: any[]) {\n if (prop === 'setProperty') {\n const [property, value] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n } else if (prop === 'removeProperty') {\n const [property] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle('none')\n }\n }\n return (target[prop as keyof CSSStyleDeclaration] as Function)(\n ...args,\n )\n }\n }\n return Reflect.get(target, prop)\n },\n })\n Object.defineProperty(document.documentElement, 'style', {\n get: function () {\n return styleProxy\n },\n })\n}\n\nfunction monitorExternalStyleChange() {\n const headObserver = new MutationObserver(checkCSSProperties)\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n}\n\nfunction checkCSSProperties() {\n checkHtmlBackgroundMaterial()\n checkCornerRadius()\n checkOpacity()\n}\n\nfunction monitorHTMLAttributeChange() {\n const observer = new MutationObserver(mutations => {\n mutations.forEach(mutation => {\n if (mutation.type === 'attributes' && mutation.attributeName) {\n checkCSSProperties()\n }\n })\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['style', 'class'],\n })\n}\n\nexport async function spatialWindowPolyfill() {\n if (!spatial.runInSpatialWeb()) {\n return\n }\n\n session = await spatial.requestSession()!\n\n if (document.readyState === 'complete') {\n checkCSSProperties()\n } else {\n window.addEventListener('load', () => {\n checkCSSProperties()\n })\n }\n\n hijackDocumentElementStyle()\n monitorExternalStyleChange()\n monitorHTMLAttributeChange()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,OAEO;AAFb;AAAA;AAAA;AAAA,IAAM,QAAQ,OAAO,WAAW;AAEzB,IAAM,WAAW,MAAM;AAAA;AAAA;;;ACF9B,IAMa;AANb;AAAA;AAAA;AAMO,IAAM,cAAN,MAA6C;AAAA,MAClD,QAAQ,KAAa,KAAqC;AACxD,eAAO,QAAQ,QAAQ;AAAA,UACrB,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MACA,uBACE,QACA,OACA,QACA,UACmC;AACnC,eAAO,QAAQ,QAAQ;AAAA,UACrB,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MACA,2BACE,QACA,OACA,QACA,UACA,gBAC0B;AAC1B,eAAO;AAAA,UACL,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA;AAAA;;;ACxCO,SAAS,qBAAqB,MAA0B;AAC7D,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AACF;AAEO,SAAS,qBACd,WACA,eAAe,IACA;AACf,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;AArBA;AAAA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AAAA,IACvD,KAAK,WAAY;AACf,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAEA,SAAS,6BAA6B;AACpC,QAAM,eAAe,IAAI,iBAAiB,kBAAkB;AAE5D,eAAa,QAAQ,SAAS,MAAM,EAAE,WAAW,MAAM,SAAS,KAAK,CAAC;AACxE;AAEA,SAAS,qBAAqB;AAC5B,8BAA4B;AAC5B,oBAAkB;AAClB,eAAa;AACf;AAEA,SAAS,6BAA6B;AACpC,QAAM,WAAW,IAAI,iBAAiB,eAAa;AACjD,cAAU,QAAQ,cAAY;AAC5B,UAAI,SAAS,SAAS,gBAAgB,SAAS,eAAe;AAC5D,2BAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,WAAS,QAAQ,SAAS,iBAAiB;AAAA,IACzC,YAAY;AAAA,IACZ,iBAAiB,CAAC,SAAS,OAAO;AAAA,EACpC,CAAC;AACH;AAEA,eAAsB,wBAAwB;AAC5C,MAAI,CAAC,QAAQ,gBAAgB,GAAG;AAC9B;AAAA,EACF;AAEA,YAAU,MAAM,QAAQ,eAAe;AAEvC,MAAI,SAAS,eAAe,YAAY;AACtC,uBAAmB;AAAA,EACrB,OAAO;AACL,WAAO,iBAAiB,QAAQ,MAAM;AACpC,yBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AAEA,6BAA2B;AAC3B,6BAA2B;AAC3B,6BAA2B;AAC7B;;;ADlKA,IAAI,CAAC,SAAS,KAAK,UAAU,UAAU,QAAQ,aAAa,IAAI,GAAG;AACjE,kBAAgB;AAChB,wBAAsB;AACxB;","names":["AndroidPlatform","VisionOSPlatform","SpatializedElementType","SpatialSceneState","window","defaultSceneConfig"]}
1
+ {"version":3,"sources":["../src/ssr-polyfill.ts","../src/platform-adapter/ssr/SSRPlatform.ts","../src/platform-adapter/CommandResultUtils.ts","../src/SpatialWebEvent.ts","../src/platform-adapter/xr/XRPlatform.ts","../src/platform-adapter/android/AndroidPlatform.ts","../src/platform-adapter/vision-os/VisionOSPlatform.ts","../src/platform-adapter/index.ts","../src/utils.ts","../src/JSBCommand.ts","../src/SpatialObject.ts","../src/scene-polyfill.ts","../src/SpatialScene.ts","../src/types/types.ts","../src/SpatializedElementCreator.ts","../src/Spatialized2DElement.ts","../src/SpatializedElement.ts","../src/SpatialWebEventCreator.ts","../src/SpatializedStatic3DElement.ts","../src/SpatializedDynamic3DElement.ts","../src/reality/realityCreator.ts","../src/reality/entity/SpatialEntity.ts","../src/reality/entity/SpatialModelEntity.ts","../src/reality/component/SpatialComponent.ts","../src/reality/component/ModelComponent.ts","../src/reality/material/SpatialUnlitMaterial.ts","../src/reality/material/SpatialMaterial.ts","../src/reality/resource/SpatialModelAsset.ts","../src/reality/geometry/SpatialGeometry.ts","../src/reality/geometry/SpatialBoxGeometry.ts","../src/reality/geometry/SpatialSphereGeometry.ts","../src/reality/geometry/SpatialCylinderGeometry.ts","../src/reality/geometry/SpatialPlaneGeometry.ts","../src/reality/geometry/SpatialConeGeometry.ts","../src/SpatialSession.ts","../src/Spatial.ts","../src/index.ts","../src/spatial-window-polyfill.ts"],"sourcesContent":["const isSSR = typeof window === 'undefined'\n\nexport const isSSREnv = () => isSSR\n","import {\n CommandResult,\n PlatformAbility,\n WebSpatialProtocolResult,\n} from '../interface'\n\nexport class SSRPlatform implements PlatformAbility {\n callJSB(cmd: string, msg: string): Promise<CommandResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocol(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<WebSpatialProtocolResult> {\n return Promise.resolve({\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n })\n }\n callWebSpatialProtocolSync(\n schema: string,\n query?: string,\n target?: string,\n features?: string,\n resultCallback?: (result: CommandResult) => void,\n ): WebSpatialProtocolResult {\n return {\n success: true,\n data: undefined,\n errorCode: undefined,\n errorMessage: undefined,\n }\n }\n}\n","import { CommandResult } from './interface'\n\nexport function CommandResultSuccess(data: any): CommandResult {\n return {\n success: true,\n data,\n errorCode: '',\n errorMessage: '',\n }\n}\n\nexport function CommandResultFailure(\n errorCode: string,\n errorMessage = '',\n): CommandResult {\n return {\n success: false,\n data: undefined,\n errorCode,\n errorMessage,\n }\n}\n","interface SpatialWebEventData {\n id: string\n data: any\n}\n\nexport class SpatialWebEvent {\n static eventReceiver: Record<string, (data: any) => void> = {}\n static init() {\n // inject __SpatialWebEvent\n window.__SpatialWebEvent = ({ id, data }: SpatialWebEventData) => {\n // console.log('__SpatialWebEvent', id, data)\n SpatialWebEvent.eventReceiver[id]?.(data)\n }\n }\n\n static addEventReceiver(id: string, callback: (data: any) => void) {\n SpatialWebEvent.eventReceiver[id] = callback\n }\n\n static removeEventReceiver(id: string) {\n delete SpatialWebEvent.eventReceiver[id]\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\n\ninterface JSBResponse {\n success: boolean\n data: any\n}\ntype JSBError = {\n code: string\n message: string\n}\n\nlet requestId = 0\n\nconst MAX_ID = 100000\n\nfunction nextRequestId() {\n requestId = (requestId + 1) % MAX_ID\n return `rId_${requestId}`\n}\n\nexport class XRPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n // android JS Bridge interface only support sync invoking\n // in order to implement promise API, register every request by requestId and remove when resolve/reject.\n return new Promise((resolve, reject) => {\n try {\n const rId = nextRequestId()\n\n SpatialWebEvent.addEventReceiver(rId, (result: JSBResponse) => {\n SpatialWebEvent.removeEventReceiver(rId)\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n\n const ans = window.webspatialBridge.postMessage(rId, cmd, msg)\n if (ans !== '') {\n SpatialWebEvent.removeEventReceiver(rId)\n // sync call\n const result = JSON.parse(ans) as JSBResponse\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n }\n } catch (error: unknown) {\n console.error(`XRPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = error as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n async callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n // Waiting for request to create spatial div\n return new Promise((resolve, reject) => {\n const createdId = nextRequestId()\n try {\n let windowProxy: any = null\n SpatialWebEvent.addEventReceiver(\n createdId,\n (result: { spatialId: string }) => {\n console.log('createdId', createdId, result.spatialId)\n resolve(\n CommandResultSuccess({\n windowProxy: windowProxy,\n id: result.spatialId,\n }),\n )\n SpatialWebEvent.removeEventReceiver(createdId)\n },\n )\n windowProxy = this.openWindow(\n command,\n query,\n target,\n features,\n ).windowProxy\n windowProxy?.open(`about:blank?rid=${createdId}`, '_self')\n } catch (error: unknown) {\n console.error(`open window error: ${error}`)\n const { code, message } = error as JSBError\n SpatialWebEvent.removeEventReceiver(createdId)\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n return { spatialId: '', windowProxy }\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { CheckWebViewCanCreateCommand } from '../../JSBCommand'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\n\ninterface JSBResponse {\n success: boolean\n data: any\n}\ntype JSBError = {\n code: string\n message: string\n}\n\nlet creatingElementCount = 0\n\nlet requestId = 0\n\nconst MAX_ID = 100000\n\nfunction nextRequestId() {\n requestId = (requestId + 1) % MAX_ID\n return `rId_${requestId}`\n}\n\nexport class AndroidPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n // android JS Bridge interface only support sync invoking\n // in order to implement promise API, register every request by requestId and remove when resolve/reject.\n return new Promise((resolve, reject) => {\n try {\n const rId = nextRequestId()\n\n SpatialWebEvent.addEventReceiver(rId, (result: JSBResponse) => {\n SpatialWebEvent.removeEventReceiver(rId)\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n\n const ans = window.webspatialBridge.postMessage(rId, cmd, msg)\n if (ans !== '') {\n SpatialWebEvent.removeEventReceiver(rId)\n // sync call\n const result = JSON.parse(ans) as JSBResponse\n if (result.success) {\n resolve(CommandResultSuccess(result.data))\n } else {\n const { code, message } = result.data as JSBError\n resolve(CommandResultFailure(code, message))\n }\n }\n } catch (error: unknown) {\n console.error(\n `AndroidPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`,\n )\n const { code, message } = error as JSBError\n resolve(CommandResultFailure(code, message))\n }\n })\n }\n\n async callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n // Waiting for request to create spatial div\n await new Promise(resolve => setTimeout(resolve, 16 * creatingElementCount))\n // Count the current total number of created spatial div queues\n creatingElementCount++\n // Create a spatial div through JSB polling request\n let canCreate = await new CheckWebViewCanCreateCommand().execute()\n while (!canCreate.data.can) {\n await new Promise(resolve => setTimeout(resolve, 16))\n canCreate = await new CheckWebViewCanCreateCommand().execute()\n }\n // Request successful, call window.open\n const { windowProxy } = this.openWindow(command, query, target, features)\n // Polling waiting for windowProxy to convert into a real window object\n while (!windowProxy?.open) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n // Make the page renderable through window.open\n windowProxy?.open('about:blank', '_self')\n // Polling to check if SpatialId injection is successful\n while (!windowProxy?.__SpatialId) {\n await new Promise(resolve => setTimeout(resolve, 16))\n }\n let spatialId = windowProxy?.__SpatialId\n creatingElementCount--\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id: spatialId }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n return { spatialId: '', windowProxy }\n }\n}\n","import { PlatformAbility, CommandResult } from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\n\ntype JSBError = {\n message: string\n}\n\nexport class VisionOSPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n try {\n const result = await window.webkit.messageHandlers.bridge.postMessage(\n `${cmd}::${msg}`,\n )\n return CommandResultSuccess(result)\n } catch (error: unknown) {\n // console.error(`VisionOSPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = JSON.parse((error as JSBError).message)\n return CommandResultFailure(code, message)\n }\n }\n\n callWebSpatialProtocol(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): Promise<CommandResult> {\n const { spatialId: id, windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n return Promise.resolve(\n CommandResultSuccess({ windowProxy: windowProxy, id }),\n )\n }\n\n callWebSpatialProtocolSync(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): CommandResult {\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ) {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n const ua = windowProxy?.navigator.userAgent\n const spatialId = ua?.match(\n /\\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\\b/gi,\n )?.[0]\n\n return { spatialId, windowProxy }\n }\n}\n","import { isSSREnv } from '../ssr-polyfill'\nimport { PlatformAbility } from './interface'\nimport { SSRPlatform } from './ssr/SSRPlatform'\n\nfunction getWebSpatialVersion(ua: string): number[] | null {\n const match = ua.match(/WebSpatial\\/(\\d+)\\.(\\d+)\\.(\\d+)/)\n if (!match) {\n return null\n }\n return [Number(match[1]), Number(match[2]), Number(match[3])]\n}\n\nfunction isVersionGreater(a: number[] | null, b: number[]): boolean {\n if (!a) {\n return false\n }\n for (let index = 0; index < 3; index += 1) {\n const diff = a[index] - b[index]\n if (diff > 0) {\n return true\n }\n if (diff < 0) {\n return false\n }\n }\n return false\n}\n\nexport function createPlatform(): PlatformAbility {\n if (isSSREnv()) {\n return new SSRPlatform()\n }\n const userAgent = window.navigator.userAgent\n const webSpatialVersion = getWebSpatialVersion(userAgent)\n if (\n userAgent.includes('PicoWebApp') &&\n isVersionGreater(webSpatialVersion, [0, 0, 1])\n ) {\n const XRPlatform = require('./xr/XRPlatform').XRPlatform\n return new XRPlatform()\n } else if (userAgent.includes('Android') || userAgent.includes('Linux')) {\n const AndroidPlatform = require('./android/AndroidPlatform').AndroidPlatform\n return new AndroidPlatform()\n } else {\n const VisionOSPlatform =\n require('./vision-os/VisionOSPlatform').VisionOSPlatform\n return new VisionOSPlatform()\n }\n}\n","import { Vec3 } from './types/types'\n\nfunction parseBorderRadius(borderProperty: string, width: number) {\n if (borderProperty === '') {\n return 0\n }\n if (borderProperty.endsWith('%')) {\n return (width * parseFloat(borderProperty)) / 100\n }\n return parseFloat(borderProperty)\n}\n\nexport function parseCornerRadius(computedStyle: CSSStyleDeclaration) {\n const width = parseFloat(computedStyle.getPropertyValue('width'))\n\n const topLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-top-left-radius',\n )\n const topRightPropertyValue = computedStyle.getPropertyValue(\n 'border-top-right-radius',\n )\n const bottomLeftPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-left-radius',\n )\n const bottomRightPropertyValue = computedStyle.getPropertyValue(\n 'border-bottom-right-radius',\n )\n\n const cornerRadius = {\n topLeading: parseBorderRadius(topLeftPropertyValue, width),\n bottomLeading: parseBorderRadius(bottomLeftPropertyValue, width),\n topTrailing: parseBorderRadius(topRightPropertyValue, width),\n bottomTrailing: parseBorderRadius(bottomRightPropertyValue, width),\n }\n\n return cornerRadius\n}\n\n/**\n *\n * compose SRT matrix\n * @export\n * @param {Vec3} position meter\n * @param {Vec3} rotation degree\n * @param {Vec3} scale\n * @return {*} {DOMMatrix}\n */\nexport function composeSRT(position: Vec3, rotation: Vec3, scale: Vec3) {\n const { x: px, y: py, z: pz } = position\n const { x: rx, y: ry, z: rz } = rotation\n const { x: sx, y: sy, z: sz } = scale\n\n let m = new DOMMatrix()\n // https://drafts.fxtf.org/geometry/#immutable-transformation-methods\n // as these methods are post-multiplication, the order of transformations is reversed\n // we want SRT = T * R * S\n m = m.translate(px, py, pz)\n m = m.rotate(rx, ry, rz)\n m = m.scale(sx, sy, sz)\n return m\n}\n","import { createPlatform } from './platform-adapter'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialComponent } from './reality/component/SpatialComponent'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\n\nimport {\n Spatialized2DElementProperties,\n SpatializedElementProperties,\n SpatializedStatic3DElementProperties,\n SpatialSceneProperties,\n SpatialSceneCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialGeometryOptions,\n SpatialGeometryType,\n ModelComponentOptions,\n SpatialEntityProperties,\n ModelAssetOptions,\n SpatialModelEntityCreationOptions,\n SpatialEntityEventType,\n Vec3,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport { composeSRT } from './utils'\n\nconst platform = createPlatform()\n\nabstract class JSBCommand {\n commandType: string = ''\n protected abstract getParams(): Record<string, any> | undefined\n\n async execute() {\n const param = this.getParams()\n const msg = param ? JSON.stringify(param) : ''\n return platform.callJSB(this.commandType, msg)\n }\n}\n\nexport class UpdateEntityPropertiesCommand extends JSBCommand {\n commandType = 'UpdateEntityProperties'\n\n constructor(\n public entity: SpatialEntity,\n public properties: Partial<SpatialEntityProperties>,\n ) {\n super()\n }\n\n protected getParams() {\n const transform = composeSRT(\n this.properties.position ?? this.entity.position,\n this.properties.rotation ?? this.entity.rotation,\n this.properties.scale ?? this.entity.scale,\n ).toFloat64Array()\n return {\n entityId: this.entity.id,\n transform,\n }\n }\n}\n\nexport class UpdateEntityEventCommand extends JSBCommand {\n commandType = 'UpdateEntityEvent'\n\n constructor(\n public entity: SpatialEntity,\n public type: SpatialEntityEventType,\n public isEnable: boolean,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n type: this.type,\n entityId: this.entity.id,\n isEnable: this.isEnable,\n }\n }\n}\n\n// todo: to be used in SpatialEntity\nexport class UpdateEntityEventsCommand extends JSBCommand {\n // let types:[String:Bool]\n // let entityId:String\n constructor(\n public entity: SpatialEntity,\n public types: Record<SpatialEntityEventType, boolean>,\n ) {\n super()\n }\n\n protected getParams() {\n return {\n entityId: this.entity.id,\n types: this.types,\n }\n }\n}\n\nexport class UpdateSpatialSceneProperties extends JSBCommand {\n properties: Partial<SpatialSceneProperties>\n commandType = 'UpdateSpatialSceneProperties'\n\n constructor(properties: Partial<SpatialSceneProperties>) {\n super()\n this.properties = properties\n }\n\n protected getParams() {\n return this.properties\n }\n}\n\nexport class UpdateSceneConfig extends JSBCommand {\n config: SpatialSceneCreationOptions\n commandType = 'UpdateSceneConfig'\n\n constructor(config: SpatialSceneCreationOptions) {\n super()\n this.config = config\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { config: this.config }\n }\n}\n\nexport class FocusScene extends JSBCommand {\n commandType = 'FocusScene'\n\n constructor(public id: string) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return { id: this.id }\n }\n}\n\nexport class GetSpatialSceneState extends JSBCommand {\n commandType = 'GetSpatialSceneState'\n\n constructor() {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {}\n }\n}\n\nexport abstract class SpatializedElementCommand extends JSBCommand {\n constructor(readonly spatialObject: SpatialObject) {\n super()\n }\n\n protected getParams() {\n const extraParams = this.getExtraParams()\n return { id: this.spatialObject.id, ...extraParams }\n }\n\n protected abstract getExtraParams(): Record<string, any> | undefined\n}\n\nexport class UpdateSpatialized2DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatialized2DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedDynamic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<Spatialized2DElementProperties>\n commandType = 'UpdateSpatializedDynamic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return {\n id: this.spatialObject.id,\n ...this.properties,\n }\n }\n}\n\nexport class UpdateUnlitMaterialProperties extends SpatializedElementCommand {\n properties: Partial<SpatialUnlitMaterialOptions>\n commandType = 'UpdateUnlitMaterialProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatialUnlitMaterialOptions>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class UpdateSpatializedElementTransform extends SpatializedElementCommand {\n matrix: DOMMatrix\n commandType = 'UpdateSpatializedElementTransform'\n\n constructor(spatialObject: SpatialObject, matrix: DOMMatrix) {\n super(spatialObject)\n this.matrix = matrix\n }\n\n protected getExtraParams() {\n return { matrix: Array.from(this.matrix.toFloat64Array()) }\n }\n}\n\nexport class UpdateSpatializedStatic3DElementProperties extends SpatializedElementCommand {\n properties: Partial<SpatializedStatic3DElementProperties>\n commandType = 'UpdateSpatializedStatic3DElementProperties'\n\n constructor(\n spatialObject: SpatialObject,\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n super(spatialObject)\n this.properties = properties\n }\n\n protected getExtraParams() {\n return this.properties\n }\n}\n\nexport class AddSpatializedElementToSpatialized2DElement extends SpatializedElementCommand {\n commandType = 'AddSpatializedElementToSpatialized2DElement'\n spatializedElement: SpatializedElement\n\n constructor(\n spatialObject: SpatialObject,\n spatializedElement: SpatializedElement,\n ) {\n super(spatialObject)\n this.spatializedElement = spatializedElement\n }\n\n protected getExtraParams() {\n return { spatializedElementId: this.spatializedElement.id }\n }\n}\n\nexport class AddSpatializedElementToSpatialScene extends JSBCommand {\n commandType = 'AddSpatializedElementToSpatialScene'\n spatializedElement: SpatializedElement\n\n constructor(spatializedElement: SpatializedElement) {\n super()\n this.spatializedElement = spatializedElement\n }\n\n protected getParams() {\n return {\n spatializedElementId: this.spatializedElement.id,\n }\n }\n}\n\nexport class CreateSpatializedStatic3DElementCommand extends JSBCommand {\n commandType = 'CreateSpatializedStatic3DElement'\n\n constructor(readonly modelURL: string) {\n super()\n this.modelURL = modelURL\n }\n\n protected getParams() {\n return { modelURL: this.modelURL }\n }\n}\n\nexport class CreateSpatializedDynamic3DElementCommand extends JSBCommand {\n protected getParams(): Record<string, any> | undefined {\n return { test: true }\n }\n commandType = 'CreateSpatializedDynamic3DElement'\n}\n\nexport class CreateSpatialEntityCommand extends JSBCommand {\n constructor(private name?: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { name: this.name }\n }\n commandType = 'CreateSpatialEntity'\n}\n\nexport class CreateModelComponentCommand extends JSBCommand {\n constructor(private options: ModelComponentOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n let geometryId = this.options.mesh.id\n let materialIds = this.options.materials.map(material => material.id)\n return { geometryId, materialIds }\n }\n commandType = 'CreateModelComponent'\n}\n\nexport class CreateSpatialModelEntityCommand extends JSBCommand {\n constructor(private options: SpatialModelEntityCreationOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateSpatialModelEntity'\n}\n\nexport class CreateModelAssetCommand extends JSBCommand {\n constructor(private options: ModelAssetOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { url: this.options.url }\n }\n commandType = 'CreateModelAsset'\n}\n\nexport class CreateSpatialGeometryCommand extends JSBCommand {\n constructor(\n private type: SpatialGeometryType,\n private options: SpatialGeometryOptions = {},\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return { type: this.type, ...this.options }\n }\n commandType = 'CreateGeometry'\n}\n\nexport class CreateSpatialUnlitMaterialCommand extends JSBCommand {\n constructor(private options: SpatialUnlitMaterialOptions) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return this.options\n }\n commandType = 'CreateUnlitMaterial'\n}\n\nexport class AddComponentToEntityCommand extends JSBCommand {\n constructor(\n public entity: SpatialEntity,\n public comp: SpatialComponent,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n componentId: this.comp.id,\n }\n }\n commandType = 'AddComponentToEntity'\n}\n\nexport class AddEntityToDynamic3DCommand extends JSBCommand {\n constructor(\n public d3dEle: SpatializedDynamic3DElement,\n public entity: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n dynamic3dId: this.d3dEle.id,\n }\n }\n\n commandType = 'AddEntityToDynamic3D'\n}\n\nexport class AddEntityToEntityCommand extends JSBCommand {\n constructor(\n public parent: SpatialEntity,\n public child: SpatialEntity,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n parentId: this.parent.id,\n childId: this.child.id,\n }\n }\n commandType = 'AddEntityToEntity'\n}\n\nexport class RemoveEntityFromParentCommand extends JSBCommand {\n constructor(public entity: SpatialEntity) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entity.id,\n }\n }\n commandType = 'RemoveEntityFromParent'\n}\n\nexport class SetParentForEntityCommand extends JSBCommand {\n // childId, parentId\n constructor(\n public childId: string,\n public parentId?: string,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n childId: this.childId,\n parentId: this.parentId,\n }\n }\n commandType = 'SetParentToEntity'\n}\n\nexport class ConvertFromEntityToEntityCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public toEntityId: string,\n public fromPosition: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n toEntityId: this.toEntityId,\n position: this.fromPosition,\n }\n }\n commandType = 'ConvertFromEntityToEntity'\n}\n\nexport class ConvertFromEntityToSceneCommand extends JSBCommand {\n constructor(\n public fromEntityId: string,\n public position: Vec3,\n ) {\n super()\n }\n\n protected getParams(): Record<string, any> | undefined {\n return {\n fromEntityId: this.fromEntityId,\n position: this.position,\n }\n }\n\n commandType = 'ConvertFromEntityToScene'\n}\n\nexport class ConvertFromSceneToEntityCommand extends JSBCommand {\n // let entityId: String\n // let position:Vec3\n constructor(\n public entityId: string,\n public position: Vec3,\n ) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n entityId: this.entityId,\n position: this.position,\n }\n }\n commandType = 'ConvertFromSceneToEntity'\n}\n\nexport class CreateTextureResourceCommand extends JSBCommand {\n constructor(private url: string) {\n super()\n }\n protected getParams(): Record<string, any> | undefined {\n return {\n url: this.url,\n }\n }\n commandType = 'CreateTextureResource'\n}\n\nexport class InspectCommand extends JSBCommand {\n commandType = 'Inspect'\n\n constructor(readonly id: string = '') {\n super()\n }\n\n protected getParams() {\n return this.id ? { id: this.id } : { id: '' }\n }\n}\n\nexport class DestroyCommand extends JSBCommand {\n commandType = 'Destroy'\n\n constructor(readonly id: string) {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\nexport class CheckWebViewCanCreateCommand extends JSBCommand {\n commandType = 'CheckWebViewCanCreate'\n\n constructor(readonly id: string = '') {\n super()\n }\n\n protected getParams() {\n return { id: this.id }\n }\n}\n\n/* WebSpatial Protocol Begin */\nabstract class WebSpatialProtocolCommand extends JSBCommand {\n target?: string\n features?: string\n\n async execute(): Promise<WebSpatialProtocolResult> {\n const query = this.getQuery()\n return platform.callWebSpatialProtocol(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n executeSync(): WebSpatialProtocolResult {\n const query = this.getQuery()\n return platform.callWebSpatialProtocolSync(\n this.commandType,\n query,\n this.target,\n this.features,\n )\n }\n\n private getQuery() {\n let query = undefined\n const params = this.getParams()\n if (params) {\n query = Object.keys(params)\n .map(key => {\n const value = params[key]\n const finalValue =\n typeof value === 'object' ? JSON.stringify(value) : value\n return `${key}=${encodeURIComponent(finalValue)}`\n })\n .join('&')\n }\n\n return query\n }\n}\n\nexport class createSpatialized2DElementCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialized2DElement'\n constructor() {\n super()\n }\n protected getParams() {\n return {}\n }\n}\n\nexport class createSpatialSceneCommand extends WebSpatialProtocolCommand {\n commandType = 'createSpatialScene'\n\n constructor(\n private url: string,\n private config: SpatialSceneCreationOptionsInternal | undefined,\n public target?: string,\n public features?: string,\n ) {\n super()\n }\n protected getParams() {\n return {\n url: this.url,\n config: this.config,\n }\n }\n}\n\n// TODO: Can crypto.randomUUID be used instead including in dev environments without https\nfunction uuid(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n const r = (Math.random() * 16) | 0\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/* WebSpatial Protocol End */\n","import { DestroyCommand, InspectCommand } from './JSBCommand'\n\n/**\n * @hidden\n * Parent class of spatial objects, should not be used directly\n */\nexport class SpatialObject {\n /** @hidden */\n constructor(\n /** @hidden */\n public readonly id: string,\n ) {}\n\n name?: string\n\n isDestroyed = false\n\n async inspect() {\n const ret = await new InspectCommand(this.id).execute()\n if (ret.success) {\n return ret.data\n }\n throw new Error(ret.errorMessage)\n }\n\n async destroy() {\n if (this.isDestroyed) {\n return\n }\n\n const ret = await new DestroyCommand(this.id).execute()\n if (ret.success) {\n this.onDestroy()\n this.isDestroyed = true\n return ret.data\n } else if (this.isDestroyed) {\n // already destroyed\n return\n }\n\n throw new Error(ret.errorMessage)\n }\n\n // override this method to do some cleanup\n protected onDestroy() {}\n}\n","import { createSpatialSceneCommand, FocusScene } from './JSBCommand'\nimport { SpatialScene } from './SpatialScene'\nimport {\n SpatialSceneCreationOptions,\n SpatialSceneType,\n SpatialSceneState,\n isValidSceneUnit,\n isValidSpatialSceneType,\n isValidWorldScalingType,\n isValidWorldAlignmentType,\n isValidBaseplateVisibilityType,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\n\nconst defaultSceneConfig: SpatialSceneCreationOptions = {\n defaultSize: {\n width: 1280,\n height: 720,\n },\n}\n\nconst defaultSceneConfigVolume: SpatialSceneCreationOptions = {\n defaultSize: {\n width: 0.94,\n height: 0.94,\n depth: 0.94,\n },\n}\n\nconst INTERNAL_SCHEMA_PREFIX = 'webspatial://'\n\nclass SceneManager {\n private originalOpen: any\n private static instance: SceneManager\n static getInstance() {\n if (!SceneManager.instance) {\n SceneManager.instance = new SceneManager()\n }\n return SceneManager.instance\n }\n\n init(window: WindowProxy) {\n this.originalOpen = window.open.bind(window)\n ;(window as any).open = this.open\n }\n\n private configMap: Record<string, SpatialSceneCreationOptionsInternal> = {} // name=>config\n private getConfig(name?: string) {\n if (name === undefined || !this.configMap[name]) return undefined\n return this.configMap[name]\n }\n\n // Ensure URL is absolute; only convert when a relative path is provided\n // - Keep external and special schemes untouched (http, https, data, blob, about, file, mailto, etc.)\n // - Handle protocol-relative URLs (//example.com/path)\n // - Resolve relative paths against document.baseURI (respects <base href>)\n private ensureAbsoluteUrl(raw?: string): string | undefined {\n if (!raw) return raw\n // Already has a scheme (includes internal webspatial:// which is handled earlier)\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(raw)) {\n return raw\n }\n // Protocol-relative URL\n if (raw.startsWith('//')) {\n return `${window.location.protocol}${raw}`\n }\n // Resolve against base URI\n try {\n return new URL(raw, document.baseURI).toString()\n } catch {\n // Fallback: leave unchanged\n return raw\n }\n }\n\n private open = (url?: string, target?: string, features?: string) => {\n // bypass internal\n if (url?.startsWith(INTERNAL_SCHEMA_PREFIX)) {\n return this.originalOpen(url, target, features)\n }\n\n // Normalize only relative URLs to absolute for platform handling\n url = this.ensureAbsoluteUrl(url)\n\n // if target is special\n if (target === '_self' || target === '_parent' || target === '_top') {\n const newWindow = this.originalOpen(url, target, features)\n return newWindow\n }\n\n const cfg = target ? this.getConfig(target) : undefined\n const cmd = new createSpatialSceneCommand(url!, cfg, target, features)\n const result = cmd.executeSync()\n\n const id = result.data?.id\n\n if (id) {\n // send JSB to focus\n let focusCmd = new FocusScene(id)\n focusCmd.execute()\n }\n\n return result.data?.windowProxy\n }\n initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n ) {\n const sceneType = options?.type ?? 'window'\n const defaultConfig = getSceneDefaultConfig(sceneType)\n const rawReturnVal = callback({ ...defaultConfig })\n const [formattedConfig, errors] = formatSceneConfig(rawReturnVal, sceneType)\n if (errors.length > 0) {\n console.warn(`initScene ${name} with errors: ${errors.join(', ')}`)\n }\n this.configMap[name] = {\n ...formattedConfig,\n type: sceneType,\n }\n }\n}\n\nfunction pxToMeter(px: number): number {\n return px / 1360\n}\n\nfunction meterToPx(meter: number): number {\n return meter * 1360\n}\n\nfunction formatToNumber(\n str: string | number,\n targetUnit: 'px' | 'm',\n defaultUnit: 'px' | 'm',\n): number {\n if (typeof str === 'number') {\n if (\n (defaultUnit === 'px' && targetUnit === 'px') ||\n (defaultUnit === 'm' && targetUnit === 'm')\n ) {\n return str\n }\n // unit not match target\n if (defaultUnit === 'px' && targetUnit === 'm') {\n return pxToMeter(str)\n } else if (defaultUnit === 'm' && targetUnit === 'px') {\n return meterToPx(str)\n }\n // fallback\n return str\n }\n if (targetUnit === 'm') {\n if (str.endsWith('m')) {\n // 1m\n return Number(str.slice(0, -1))\n } else if (str.endsWith('px')) {\n // 100px\n return pxToMeter(Number(str.slice(0, -2)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else if (targetUnit === 'px') {\n if (str.endsWith('px')) {\n // 100px\n return Number(str.slice(0, -2))\n } else if (str.endsWith('m')) {\n // 1m\n return meterToPx(Number(str.slice(0, -1)))\n } else {\n throw new Error('formatToNumber: invalid str')\n }\n } else {\n throw new Error('formatToNumber: invalid targetUnit')\n }\n}\n\nexport function formatSceneConfig(\n config: SpatialSceneCreationOptions,\n sceneType: SpatialSceneType,\n): [SpatialSceneCreationOptions, string[]] {\n // defaultSize and resizability's width/height/depth can be 100 or \"100px\" or \"1m\"\n // expect:\n // resizability should format into px\n // defaultSize should format into px if window\n // defaultSize should format into m if volume\n\n const defaultSceneConfig = getSceneDefaultConfig(sceneType)\n\n const errors: string[] = []\n\n const isWindow = sceneType === 'window'\n if (!isValidSpatialSceneType(sceneType)) {\n errors.push(`sceneType`)\n }\n\n // format defaultSize\n if (config.defaultSize) {\n const iterKeys = ['width', 'height', 'depth']\n for (let k of iterKeys) {\n if (!(k in config.defaultSize)) continue\n if (isValidSceneUnit((config.defaultSize as any)[k])) {\n ;(config.defaultSize as any)[k] = formatToNumber(\n (config.defaultSize as any)[k],\n isWindow ? 'px' : 'm',\n isWindow ? 'px' : 'm',\n )\n } else {\n ;(config.defaultSize as any)[k] = (\n defaultSceneConfig.defaultSize as any\n )[k]\n errors.push(`defaultSize.${k}`)\n }\n }\n }\n\n // format resizability\n if (config.resizability) {\n const iterKeys = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight']\n for (let k of iterKeys) {\n if (!(k in config.resizability)) continue\n if (isValidSceneUnit((config.resizability as any)[k])) {\n ;(config.resizability as any)[k] = formatToNumber(\n (config.resizability as any)[k],\n 'px',\n isWindow ? 'px' : 'm',\n )\n } else {\n ;(config.resizability as any)[k] = undefined\n errors.push(`resizability.${k}`)\n }\n }\n }\n\n // check value\n if (config.worldScaling) {\n if (!isValidWorldScalingType(config.worldScaling)) {\n config.worldScaling = 'automatic'\n errors.push('worldScaling')\n }\n }\n\n if (config.worldAlignment) {\n if (!isValidWorldAlignmentType(config.worldAlignment)) {\n config.worldAlignment = 'automatic'\n errors.push('worldAlignment')\n }\n }\n\n if (config.baseplateVisibility) {\n if (!isValidBaseplateVisibilityType(config.baseplateVisibility)) {\n config.baseplateVisibility = 'automatic'\n errors.push('baseplateVisibility')\n }\n }\n\n return [config, errors]\n}\n\nexport function initScene(\n name: string,\n callback: (pre: SpatialSceneCreationOptions) => SpatialSceneCreationOptions,\n options?: { type: SpatialSceneType },\n) {\n return SceneManager.getInstance().initScene(name, callback, options)\n}\n\nexport function hijackWindowOpen(window: WindowProxy) {\n SceneManager.getInstance().init(window)\n}\n\nexport function hijackWindowATag(openedWindow: WindowProxy) {\n openedWindow!.document.onclick = function (e) {\n let element = e.target as HTMLElement | null\n let found = false\n\n // Look for <a> element in the clicked elements parents and if found override navigation behavior if needed\n while (!found) {\n if (element && element.tagName == 'A') {\n // When using libraries like react route's <Link> it sets an onclick event, when this happens we should do nothing and let that occur\n\n // if onClick is set for the element, the raw onclick will be noop() trapped so the onclick check is no longer trustable\n // we handle all the scenarios\n\n if (handleATag(e)) {\n return false // prevent default action and stop event propagation\n }\n\n return true\n }\n if (element && element.parentElement) {\n element = element.parentElement\n } else {\n break\n }\n }\n }\n}\n\nfunction handleATag(event: MouseEvent) {\n const targetElement = event.target as HTMLElement\n if (targetElement.tagName === 'A') {\n const link = targetElement as HTMLAnchorElement\n const target = link.target\n const url = link.href\n\n if (target && target !== '_self') {\n event.preventDefault()\n window.open(url, target)\n return true\n }\n }\n}\n\nfunction getSceneDefaultConfig(sceneType: SpatialSceneType) {\n return sceneType === 'window' ? defaultSceneConfig : defaultSceneConfigVolume\n}\n\nasync function injectScenePolyfill() {\n if (!window.opener) return\n\n const state = await SpatialScene.getInstance().getState()\n\n // only run this in pending state\n if (state !== SpatialSceneState.pending) return\n\n function onContentLoaded(callback: any) {\n if (\n document.readyState === 'interactive' ||\n document.readyState === 'complete'\n ) {\n callback()\n } else {\n document.addEventListener('DOMContentLoaded', callback)\n }\n }\n\n onContentLoaded(async () => {\n let provideDefaultSceneConfig = getSceneDefaultConfig(\n window.xrCurrentSceneType ?? 'window',\n )\n let cfg = provideDefaultSceneConfig\n if (typeof window.xrCurrentSceneDefaults === 'function') {\n try {\n cfg = await window.xrCurrentSceneDefaults?.(provideDefaultSceneConfig)\n } catch (error) {\n console.error(error)\n }\n }\n // fixme: this duration is too short so that hide and show is at racing, so add a little delay to avoid\n await new Promise((resolve, reject) => {\n setTimeout(() => {\n resolve(null)\n }, 1000)\n })\n\n const sceneType = window.xrCurrentSceneType ?? 'window'\n const [formattedConfig, errors] = formatSceneConfig(cfg, sceneType)\n if (errors.length > 0) {\n console.warn(\n `window.xrCurrentSceneDefaults with errors: ${errors.join(', ')}`,\n )\n }\n await SpatialScene.getInstance().updateSceneCreationConfig({\n ...formattedConfig,\n type: sceneType,\n })\n })\n}\n\nexport function injectSceneHook() {\n hijackWindowOpen(window)\n hijackWindowATag(window)\n injectScenePolyfill()\n}\n","import {\n SpatialSceneCreationOptions,\n SpatialSceneProperties,\n} from './types/types'\nimport { SpatialSceneCreationOptionsInternal } from './types/internal'\nimport {\n AddSpatializedElementToSpatialScene,\n GetSpatialSceneState,\n UpdateSceneConfig,\n UpdateSpatialSceneProperties,\n} from './JSBCommand'\n\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialSceneState } from './types/internal'\n\nlet instance: SpatialScene\n\n/**\n * Represents the spatial scene that contains all spatialized elements.\n * This class follows the singleton pattern - only one instance exists per application.\n * The scene manages the overall spatial environment properties and contains all spatial elements.\n */\nexport class SpatialScene extends SpatialObject {\n /**\n * Gets the singleton instance of the SpatialScene.\n * Creates a new instance if one doesn't exist yet.\n * @returns The singleton SpatialScene instance\n */\n static getInstance(): SpatialScene {\n if (!instance) {\n instance = new SpatialScene('')\n }\n return instance\n }\n\n /**\n * Updates the properties of the spatial scene.\n * This can include background settings, lighting, and other scene-wide properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateSpatialProperties(properties: Partial<SpatialSceneProperties>) {\n return new UpdateSpatialSceneProperties(properties).execute()\n }\n\n /**\n * Adds a spatialized element to the scene.\n * This makes the element visible and interactive in the spatial environment.\n * @param element The SpatializedElement to add to the scene\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialScene(element).execute()\n }\n\n /**\n * Updates the scene creation configuration.\n * This allows changing scene parameters after initial creation.\n * @param config The new scene creation configuration\n * @returns Promise resolving when the update is complete\n */\n async updateSceneCreationConfig(config: SpatialSceneCreationOptionsInternal) {\n return new UpdateSceneConfig(config).execute()\n }\n\n /**\n * Gets the current state of the spatial scene.\n * This includes information about active elements and scene configuration.\n * @returns Promise resolving to the current SpatialSceneState\n */\n async getState(): Promise<SpatialSceneState> {\n return (await new GetSpatialSceneState().execute()).data.name\n }\n}\n","import type { SpatialEntity } from '..'\nimport { SpatialGeometry } from '../reality/geometry/SpatialGeometry'\nimport { SpatialMaterial } from '../reality/material/SpatialMaterial'\nimport type { SpatializedDynamic3DElement } from '../SpatializedDynamic3DElement'\n\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\nexport type Point3D = Vec3\n\nexport interface Quaternion {\n x: number\n y: number\n z: number\n w: number\n}\n\n/**\n * Material type for SpatialDiv or HTML document.\n *\n * This type defines the background material options for both SpatialDiv elements and HTML documents.\n *\n * - `'none'`: This is the default value.\n * - For HTML documents, the web page window will have the default native background.\n * - For SpatialDiv, the window will have a transparent background.\n * - `'translucent'`: Represents a glass-like material in AVP (Apple Vision Pro).\n * - `'thick'`: Represents a thick material in AVP.\n * - `'regular'`: Represents a regular material in AVP.\n * - `'thin'`: Represents a thin material in AVP.\n * - `'transparent'`: Represents a fully transparent background.\n */\nexport type BackgroundMaterialType =\n | 'none'\n | 'translucent'\n | 'thick'\n | 'regular'\n | 'thin'\n | 'transparent'\n\nexport type CornerRadius = {\n topLeading: number\n bottomLeading: number\n topTrailing: number\n bottomTrailing: number\n}\n\nexport interface SpatialSceneProperties {\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n opacity: number\n}\n\nexport enum SpatializedElementType {\n Spatialized2DElement,\n SpatializedStatic3DElement,\n SpatializedDynamic3DElement,\n}\n\nexport interface SpatializedElementProperties {\n name: string\n clientX: number\n clientY: number\n width: number\n height: number\n depth: number\n opacity: number\n visible: boolean\n scrollWithParent: boolean\n zIndex: number\n backOffset: number\n rotationAnchor: Point3D\n enableTapGesture: boolean\n enableDragStartGesture: boolean\n enableDragGesture: boolean\n enableDragEndGesture: boolean\n enableRotateGesture: boolean\n enableRotateEndGesture: boolean\n enableMagnifyGesture: boolean\n enableMagnifyEndGesture: boolean\n}\n\nexport interface Spatialized2DElementProperties\n extends SpatializedElementProperties {\n scrollPageEnabled: boolean\n cornerRadius: CornerRadius\n material: BackgroundMaterialType\n scrollEdgeInsetsMarginRight: number\n}\n\nexport interface SpatializedStatic3DElementProperties\n extends SpatializedElementProperties {\n modelURL: string\n modelTransform?: number[]\n}\n\nexport interface SpatialSceneCreationOptions {\n defaultSize?: {\n width: number | string // Initial width of the window\n height: number | string // Initial height of the window\n depth?: number | string // Initial depth of the window, only for volume\n }\n\n resizability?: {\n minWidth?: number | string // Minimum width of the window\n minHeight?: number | string // Minimum height of the window\n maxWidth?: number | string // Maximum width of the window\n maxHeight?: number | string // Maximum height of the window\n }\n worldScaling?: WorldScalingType\n worldAlignment?: WorldAlignmentType\n\n baseplateVisibility?: BaseplateVisibilityType\n}\n\nexport const BaseplateVisibilityValues = [\n 'automatic',\n 'visible',\n 'hidden',\n] as const\nexport type BaseplateVisibilityType = (typeof BaseplateVisibilityValues)[number]\n\nexport function isValidBaseplateVisibilityType(type: string): Boolean {\n return BaseplateVisibilityValues.includes(type as BaseplateVisibilityType)\n}\n\nexport const WorldScalingValues = ['automatic', 'dynamic'] as const\nexport type WorldScalingType = (typeof WorldScalingValues)[number]\n\nexport function isValidWorldScalingType(type: string): Boolean {\n return WorldScalingValues.includes(type as WorldScalingType)\n}\n\nexport const WorldAlignmentValues = [\n 'adaptive',\n 'automatic',\n 'gravityAligned',\n] as const\nexport type WorldAlignmentType = (typeof WorldAlignmentValues)[number]\n\nexport function isValidWorldAlignmentType(type: string): Boolean {\n return WorldAlignmentValues.includes(type as WorldAlignmentType)\n}\n\nexport const SpatialSceneValues = ['window', 'volume'] as const\nexport type SpatialSceneType = (typeof SpatialSceneValues)[number]\n\nexport function isValidSpatialSceneType(type: string): Boolean {\n return SpatialSceneValues.includes(type as SpatialSceneType)\n}\n\n/**\n * check px,m and number, number must be >= 0\n *\n * */\nexport function isValidSceneUnit(val: string | number): boolean {\n // only support number or string with unit px or m\n // rpx cm mm not allowed\n if (typeof val === 'number') {\n return val >= 0\n }\n if (typeof val === 'string') {\n if (val.endsWith('px')) {\n // check if number\n if (isNaN(Number(val.slice(0, -2)))) {\n return false\n }\n return Number(val.slice(0, -2)) >= 0\n }\n if (val.endsWith('m')) {\n // check if number\n if (isNaN(Number(val.slice(0, -1)))) {\n return false\n }\n return Number(val.slice(0, -1)) >= 0\n }\n }\n return false\n}\n\nexport interface SpatialEntityProperties {\n position: Vec3\n rotation: Vec3\n scale: Vec3\n}\n\nexport type SpatialEntityEventType = 'spatialtap' //| 'drag' | 'rotate' | 'scale'\n\nexport type SpatialGeometryType =\n | 'BoxGeometry'\n | 'PlaneGeometry'\n | 'SphereGeometry'\n | 'CylinderGeometry'\n | 'ConeGeometry'\n\nexport interface SpatialBoxGeometryOptions {\n width?: number\n height?: number\n depth?: number\n cornerRadius?: number\n splitFaces?: boolean\n}\n\nexport interface SpatialPlaneGeometryOptions {\n width?: number\n height?: number\n cornerRadius?: number\n}\n\nexport interface SpatialSphereGeometryOptions {\n radius?: number\n}\n\nexport interface SpatialConeGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport interface SpatialCylinderGeometryOptions {\n radius?: number\n height?: number\n}\n\nexport type SpatialGeometryOptions =\n | SpatialBoxGeometryOptions\n | SpatialPlaneGeometryOptions\n | SpatialSphereGeometryOptions\n | SpatialCylinderGeometryOptions\n | SpatialConeGeometryOptions\n\nexport type SpatialMaterialType = 'unlit'\n\nexport interface SpatialUnlitMaterialOptions {\n color?: string\n textureId?: string\n transparent?: boolean\n opacity?: number\n}\n\nexport interface ModelComponentOptions {\n mesh: SpatialGeometry\n materials: SpatialMaterial[]\n}\n\nexport interface SpatialEntityUserData {\n id?: string\n name?: string\n}\n\nexport interface SpatialModelEntityCreationOptions {\n modelAssetId: string\n name?: string\n}\n\nexport interface ModelAssetOptions {\n url: string\n}\n\nexport enum SpatialSceneState {\n idle = 'idle',\n pending = 'pending',\n willVisible = 'willVisible',\n visible = 'visible',\n fail = 'fail',\n}\n\n/**\n * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event\n */\nexport type SpatialModelDragEvent = {\n eventType: 'dragstart' | 'dragend' | 'drag'\n translation3D: Vec3\n startLocation3D: Vec3\n}\n\nexport interface Size {\n width: number\n height: number\n}\n\nexport interface Size3D extends Size {\n depth: number\n}\n\nexport class CubeInfo {\n constructor(\n public size: Size3D,\n public origin: Vec3,\n ) {\n this.size = size\n this.origin = origin\n }\n\n get x() {\n return this.origin.x\n }\n\n get y() {\n return this.origin.y\n }\n\n get z() {\n return this.origin.z\n }\n\n get width() {\n return this.size.width\n }\n\n get height() {\n return this.size.height\n }\n\n get depth() {\n return this.size.depth\n }\n\n get left() {\n return this.x\n }\n\n get top() {\n return this.y\n }\n\n get right() {\n return this.x + this.width\n }\n\n get bottom() {\n return this.y + this.height\n }\n\n get back() {\n return this.z\n }\n\n get front() {\n return this.z + this.depth\n }\n}\n\nexport interface SpatialTapEventDetail {\n location3D: Point3D\n}\n\nexport type SpatialTapEvent = CustomEvent<SpatialTapEventDetail>\n\nexport interface SpatialDragStartEventDetail {\n startLocation3D: Point3D\n}\n\nexport interface SpatialDragEventDetail {\n translation3D: Vec3\n}\n\nexport interface SpatialDragEndEventDetail {}\n\nexport type SpatialDragStartEvent = CustomEvent<SpatialDragStartEventDetail>\n\nexport type SpatialDragEvent = CustomEvent<SpatialDragEventDetail>\n\nexport type SpatialDragEndEvent = CustomEvent<SpatialDragEndEventDetail>\nexport interface SpatialRotateEventDetail {\n quaternion: Quaternion\n}\n\nexport interface SpatialRotateEndEventDetail {}\n\nexport type SpatialRotateEvent = CustomEvent<SpatialRotateEventDetail>\n\nexport type SpatialRotateEndEvent = CustomEvent<SpatialRotateEndEventDetail>\n\nexport interface SpatialMagnifyEventDetail {\n magnification: number\n}\n\nexport interface SpatialMagnifyEndEventDetail {}\n\nexport type SpatialMagnifyEvent = CustomEvent<SpatialMagnifyEventDetail>\n\nexport type SpatialMagnifyEndEvent = CustomEvent<SpatialMagnifyEndEventDetail>\n\nexport type SpatialEntityOrReality = SpatialEntity | SpatializedDynamic3DElement\n","import {\n createSpatialized2DElementCommand,\n CreateSpatializedDynamic3DElementCommand,\n CreateSpatializedStatic3DElementCommand,\n} from './JSBCommand'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\n\nexport async function createSpatialized2DElement(): Promise<Spatialized2DElement> {\n const result = await new createSpatialized2DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatialized2DElement failed')\n } else {\n const { id, windowProxy } = result.data!\n // set base href to make sure the relative url is correct\n windowProxy.document.head.innerHTML = `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <base href=\"${document.baseURI}\">`\n return new Spatialized2DElement(id, windowProxy)\n }\n}\n\nexport async function createSpatializedStatic3DElement(\n modelURL: string,\n): Promise<SpatializedStatic3DElement> {\n const result = await new CreateSpatializedStatic3DElementCommand(\n modelURL,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatializedStatic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedStatic3DElement(id)\n }\n}\n\nexport async function createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n const result = await new CreateSpatializedDynamic3DElementCommand().execute()\n if (!result.success) {\n throw new Error('createSpatializedDynamic3DElement failed')\n } else {\n const { id } = result.data\n return new SpatializedDynamic3DElement(id)\n }\n}\n","import {\n AddSpatializedElementToSpatialized2DElement,\n UpdateSpatialized2DElementProperties,\n} from './JSBCommand'\nimport { hijackWindowATag } from './scene-polyfill'\nimport { SpatializedElement } from './SpatializedElement'\nimport { Spatialized2DElementProperties } from './types/types'\n\n/**\n * Represents a 2D HTML element that has been spatialized in 3D space.\n * This class handles the integration between 2D web content and the 3D spatial environment,\n * allowing HTML elements to be positioned and interacted with in spatial applications.\n */\nexport class Spatialized2DElement extends SpatializedElement {\n /**\n * Creates a new spatialized 2D element.\n * @param id Unique identifier for this element\n * @param windowProxy Reference to the window object containing the 2D content\n */\n constructor(\n id: string,\n readonly windowProxy: WindowProxy,\n ) {\n super(id)\n // Hijack anchor tag events to handle navigation within the spatial context\n hijackWindowATag(windowProxy)\n }\n\n /**\n * Updates the properties of this 2D element.\n * This can include size, position, background, and other visual properties.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(properties: Partial<Spatialized2DElementProperties>) {\n return new UpdateSpatialized2DElementProperties(this, properties).execute()\n }\n\n /**\n * Adds a child spatialized element to this 2D element.\n * This allows for creating hierarchical structures of spatial elements.\n * @param element The child element to add\n * @returns Promise resolving when the element is added\n */\n async addSpatializedElement(element: SpatializedElement) {\n return new AddSpatializedElementToSpatialized2DElement(\n this,\n element,\n ).execute()\n }\n}\n","import { UpdateSpatializedElementTransform } from './JSBCommand'\nimport { WebSpatialProtocolResult } from './platform-adapter/interface'\nimport { SpatialObject } from './SpatialObject'\nimport { SpatialWebEvent } from './SpatialWebEvent'\nimport { createSpatialEvent } from './SpatialWebEventCreator'\nimport {\n CubeInfo,\n SpatialDragEndEvent,\n SpatialDragEvent,\n SpatialDragStartEvent,\n SpatializedElementProperties,\n SpatialMagnifyEndEvent,\n SpatialMagnifyEvent,\n SpatialRotateEndEvent,\n SpatialRotateEvent,\n SpatialTapEvent,\n} from './types/types'\nimport {\n CubeInfoMsg,\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialDragStartMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n TransformMsg,\n} from './WebMsgCommand'\n\n/**\n * Abstract base class for all spatialized elements in the WebSpatial environment.\n * Provides common functionality for elements that can exist in 3D space,\n * including transformation handling and gesture event processing.\n */\nexport abstract class SpatializedElement extends SpatialObject {\n /**\n * Creates a new spatialized element with the specified ID.\n * Registers the element to receive spatial events.\n * @param id Unique identifier for this element\n */\n constructor(public readonly id: string) {\n super(id)\n\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent.bind(this))\n }\n\n /**\n * Updates the properties of this spatialized element.\n * Must be implemented by derived classes to handle specific property updates.\n * @param properties Partial set of properties to update\n * @returns Promise resolving to the result of the update operation\n */\n abstract updateProperties(\n properties: Partial<SpatializedElementProperties>,\n ): Promise<WebSpatialProtocolResult>\n\n /**\n * Updates the transformation matrix of this element in 3D space.\n * This affects the position, rotation, and scale of the element.\n * @param matrix The new transformation matrix\n * @returns Promise resolving when the transform is updated\n */\n async updateTransform(matrix: DOMMatrix) {\n return new UpdateSpatializedElementTransform(this, matrix).execute()\n }\n\n /**\n * Information about the element's bounding cube.\n * Used for spatial calculations and hit testing.\n */\n private _cubeInfo?: CubeInfo\n\n /**\n * Gets the current cube information for this element.\n * @returns The current CubeInfo or undefined if not set\n */\n get cubeInfo() {\n return this._cubeInfo\n }\n\n /**\n * The current transformation matrix of this element.\n */\n private _transform?: DOMMatrix\n\n /**\n * The inverse of the current transformation matrix.\n * Used for converting world coordinates to local coordinates.\n */\n private _transformInv?: DOMMatrix\n\n /**\n * Gets the current transformation matrix.\n * @returns The current transformation matrix or undefined if not set\n */\n get transform() {\n return this._transform\n }\n\n /**\n * Gets the inverse of the current transformation matrix.\n * @returns The inverse transformation matrix or undefined if not set\n */\n get transformInv() {\n return this._transformInv\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles various spatial events like transforms, gestures, and interactions.\n * @param data The event data received from the WebSpatial system\n */\n protected onReceiveEvent(\n data:\n | CubeInfoMsg\n | TransformMsg\n | SpatialTapMsg\n | SpatialDragStartMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n } else if (type === SpatialWebMsgType.cubeInfo) {\n // Handle cube info updates (bounding box information)\n const cubeInfoMsg = data as CubeInfoMsg\n this._cubeInfo = new CubeInfo(cubeInfoMsg.size, cubeInfoMsg.origin)\n } else if (type === SpatialWebMsgType.transform) {\n // Handle transformation matrix updates\n this._transform = new DOMMatrix([\n data.detail.column0[0],\n data.detail.column0[1],\n data.detail.column0[2],\n 0,\n data.detail.column1[0],\n data.detail.column1[1],\n data.detail.column1[2],\n 0,\n data.detail.column2[0],\n data.detail.column2[1],\n data.detail.column2[2],\n 0,\n data.detail.column3[0],\n data.detail.column3[1],\n data.detail.column3[2],\n 1,\n ])\n this._transformInv = this._transform.inverse()\n } else if (type === SpatialWebMsgType.spatialtap) {\n // Handle tap gestures\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialtap,\n (data as SpatialTapMsg).detail,\n )\n this._onSpatialTap?.(event)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const dragStartEvent = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n (data as SpatialDragStartMsg).detail,\n )\n this._onSpatialDragStart?.(dragStartEvent)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdrag,\n (data as SpatialDragMsg).detail,\n )\n this._onSpatialDrag?.(event)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n (data as SpatialDragEndMsg).detail,\n )\n this._onSpatialDragEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialrotate) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n (data as SpatialRotateMsg).detail,\n )\n this._onSpatialRotate?.(event)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n (data as SpatialRotateEndMsg).detail,\n )\n this._onSpatialRotateEnd?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnify) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n (data as SpatialMagnifyMsg).detail,\n )\n this._onSpatialMagnify?.(event)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const event = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n (data as SpatialMagnifyEndMsg).detail,\n )\n this._onSpatialMagnifyEnd?.(event)\n }\n }\n\n private _onSpatialTap?: (event: SpatialTapEvent) => void\n set onSpatialTap(value: (event: SpatialTapEvent) => void | undefined) {\n this._onSpatialTap = value\n this.updateProperties({\n enableTapGesture: value !== undefined,\n })\n }\n\n private _onSpatialDragStart?: (event: SpatialDragStartEvent) => void\n set onSpatialDragStart(\n value: (event: SpatialDragStartEvent) => void | undefined,\n ) {\n this._onSpatialDragStart = value\n this.updateProperties({\n enableDragStartGesture: this._onSpatialDragStart !== undefined,\n })\n }\n\n private _onSpatialDrag?: (event: SpatialDragEvent) => void\n set onSpatialDrag(value: (event: SpatialDragEvent) => void | undefined) {\n this._onSpatialDrag = value\n this.updateProperties({\n enableDragGesture: this._onSpatialDrag !== undefined,\n })\n }\n\n private _onSpatialDragEnd?: (event: SpatialDragEndEvent) => void\n set onSpatialDragEnd(\n value: ((event: SpatialDragEndEvent) => void) | undefined,\n ) {\n this._onSpatialDragEnd = value\n this.updateProperties({\n enableDragEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialRotate?: (event: SpatialRotateEvent) => void\n set onSpatialRotate(\n value: ((event: SpatialRotateEvent) => void) | undefined,\n ) {\n this._onSpatialRotate = value\n this.updateProperties({\n enableRotateGesture: this._onSpatialRotate !== undefined,\n })\n }\n\n private _onSpatialRotateEnd?: (event: SpatialRotateEndEvent) => void\n set onSpatialRotateEnd(\n value: ((event: SpatialRotateEndEvent) => void) | undefined,\n ) {\n this._onSpatialRotateEnd = value\n this.updateProperties({\n enableRotateEndGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnify?: (event: SpatialMagnifyEvent) => void\n set onSpatialMagnify(\n value: ((event: SpatialMagnifyEvent) => void) | undefined,\n ) {\n this._onSpatialMagnify = value\n this.updateProperties({\n enableMagnifyGesture: value !== undefined,\n })\n }\n\n private _onSpatialMagnifyEnd?: (event: SpatialMagnifyEndEvent) => void\n set onSpatialMagnifyEnd(\n value: ((event: SpatialMagnifyEndEvent) => void) | undefined,\n ) {\n this._onSpatialMagnifyEnd = value\n this.updateProperties({\n enableMagnifyEndGesture: value !== undefined,\n })\n }\n\n /**\n * Cleans up resources when this element is destroyed.\n * Removes event receivers to prevent memory leaks.\n */\n override onDestroy() {\n SpatialWebEvent.removeEventReceiver(this.id)\n }\n}\n","import { SpatialWebMsgType } from './WebMsgCommand'\n\nexport function createSpatialEvent<T>(\n type: SpatialWebMsgType,\n detail: T,\n): CustomEvent<T> {\n return new CustomEvent<T>(type, {\n bubbles: true,\n cancelable: false,\n detail,\n })\n}\n","import { UpdateSpatializedStatic3DElementProperties } from './JSBCommand'\nimport { SpatializedElement } from './SpatializedElement'\nimport { SpatializedStatic3DElementProperties } from './types/types'\nimport { SpatialWebMsgType } from './WebMsgCommand'\n\n/**\n * Represents a static 3D model element in the spatial environment.\n * This class handles loading and displaying pre-built 3D models from URLs,\n * and provides events for load success and failure.\n */\nexport class SpatializedStatic3DElement extends SpatializedElement {\n /**\n * Promise resolver for the ready state.\n * Used to resolve the ready promise when the model is loaded.\n */\n private _readyResolve?: (success: boolean) => void\n\n /**\n * Caches the last model URL to detect changes.\n * Used to reset the ready promise when the model URL changes.\n */\n private modelURL: string = ''\n\n /**\n * Creates a new promise for tracking the ready state of the model.\n * @returns Promise that resolves when the model is loaded (true) or fails to load (false)\n */\n private createReadyPromise() {\n return new Promise<boolean>(resolve => {\n this._readyResolve = resolve\n })\n }\n\n /**\n * Promise that resolves when the model is loaded.\n * Resolves to true on successful load, false on failure.\n */\n ready: Promise<boolean> = this.createReadyPromise()\n\n /**\n * Updates the properties of this static 3D element.\n * Handles special case for modelURL changes by resetting the ready promise.\n * @param properties Partial set of properties to update\n * @returns Promise resolving when the update is complete\n */\n async updateProperties(\n properties: Partial<SpatializedStatic3DElementProperties>,\n ) {\n if (properties.modelURL !== undefined) {\n if (this.modelURL !== properties.modelURL) {\n this.modelURL = properties.modelURL\n this.ready = this.createReadyPromise()\n }\n }\n return new UpdateSpatializedStatic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n\n /**\n * Processes events received from the WebSpatial environment.\n * Handles model loading events in addition to base spatial events.\n * @param data The event data received from the WebSpatial system\n */\n override onReceiveEvent(data: { type: SpatialWebMsgType }) {\n if (data.type === SpatialWebMsgType.modelloaded) {\n // Handle successful model loading\n this._onLoadCallback?.()\n this._readyResolve?.(true)\n } else if (data.type === SpatialWebMsgType.modelloadfailed) {\n // Handle model loading failure\n this._onLoadFailureCallback?.()\n this._readyResolve?.(false)\n } else {\n // Handle other spatial events using the base class implementation\n super.onReceiveEvent(data as any)\n }\n }\n\n /**\n * Callback function for successful model loading.\n */\n private _onLoadCallback?: () => void\n\n /**\n * Sets the callback function for successful model loading.\n * @param callback Function to call when the model is loaded successfully\n */\n set onLoadCallback(callback: undefined | (() => void)) {\n this._onLoadCallback = callback\n }\n\n /**\n * Callback function for model loading failure.\n */\n private _onLoadFailureCallback?: undefined | (() => void)\n\n /**\n * Sets the callback function for model loading failure.\n * @param callback Function to call when the model fails to load\n */\n set onLoadFailureCallback(callback: undefined | (() => void)) {\n this._onLoadFailureCallback = callback\n }\n\n updateModelTransform(transform: DOMMatrixReadOnly) {\n const modelTransform = Array.from(transform.toFloat64Array())\n this.updateProperties({ modelTransform })\n }\n}\n","import {\n AddEntityToDynamic3DCommand,\n SetParentForEntityCommand,\n UpdateSpatializedDynamic3DElementProperties,\n} from './JSBCommand'\nimport { SpatialEntity } from './reality'\nimport { SpatializedElement } from './SpatializedElement'\nimport {\n SpatialEntityOrReality,\n SpatializedElementProperties,\n} from './types/types'\nexport class SpatializedDynamic3DElement extends SpatializedElement {\n children: SpatialEntityOrReality[] = []\n constructor(id: string) {\n super(id)\n }\n\n async addEntity(entity: SpatialEntity) {\n const ans = new SetParentForEntityCommand(entity.id, this.id).execute()\n this.children.push(entity)\n entity.parent = this\n return ans\n }\n async updateProperties(properties: Partial<SpatializedElementProperties>) {\n return new UpdateSpatializedDynamic3DElementProperties(\n this,\n properties,\n ).execute()\n }\n}\n","import {\n CreateModelComponentCommand,\n CreateModelAssetCommand,\n CreateSpatialEntityCommand,\n CreateSpatialGeometryCommand,\n CreateSpatialModelEntityCommand,\n CreateSpatialUnlitMaterialCommand,\n} from '../JSBCommand'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n} from '../types/types'\nimport { SpatialEntity, SpatialModelEntity } from './entity'\nimport { ModelComponent } from './component'\nimport { SpatialGeometry } from './geometry'\nimport { SpatialUnlitMaterial } from './material'\nimport { SpatialModelAsset } from './resource'\n\nexport async function createSpatialEntity(\n userData?: SpatialEntityUserData,\n): Promise<SpatialEntity> {\n const result = await new CreateSpatialEntityCommand(userData?.name).execute()\n if (!result.success) {\n throw new Error('createSpatialEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialEntity(id, userData)\n }\n}\n\nexport async function createSpatialGeometry<T extends SpatialGeometry>(\n ctor: new (...args: any[]) => T,\n options: SpatialGeometryOptions,\n) {\n const result = await new CreateSpatialGeometryCommand(\n (ctor as any).type,\n options,\n ).execute()\n if (!result.success) {\n throw new Error('createSpatialGeometry failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ctor(id, options) as T\n }\n}\n\nexport async function createSpatialUnlitMaterial(\n options: SpatialUnlitMaterialOptions,\n) {\n const result = await new CreateSpatialUnlitMaterialCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialUnlitMaterial failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialUnlitMaterial(id, options)\n }\n}\n\nexport async function createModelComponent(options: ModelComponentOptions) {\n const result = await new CreateModelComponentCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelComponent failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new ModelComponent(id, options)\n }\n}\n\nexport async function createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n) {\n const result = await new CreateSpatialModelEntityCommand(options).execute()\n if (!result.success) {\n throw new Error('createSpatialModelEntity failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelEntity(id, options, userData)\n }\n}\n\nexport async function createModelAsset(options: ModelAssetOptions) {\n const result = await new CreateModelAssetCommand(options).execute()\n if (!result.success) {\n throw new Error('createModelAsset failed:' + result?.errorMessage)\n } else {\n const { id } = result.data\n return new SpatialModelAsset(id, options)\n }\n}\n","import {\n ConvertFromEntityToEntityCommand,\n ConvertFromEntityToSceneCommand,\n ConvertFromSceneToEntityCommand,\n SetParentForEntityCommand,\n} from './../../JSBCommand'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatialEntityUserData,\n Vec3,\n} from '../../types/types'\nimport {\n AddComponentToEntityCommand,\n AddEntityToEntityCommand,\n RemoveEntityFromParentCommand,\n UpdateEntityEventCommand,\n UpdateEntityPropertiesCommand,\n} from '../../JSBCommand'\nimport { SpatialObject } from '../../SpatialObject'\nimport { SpatialEntityProperties } from '../../types/types'\nimport { SpatialComponent } from '../component/SpatialComponent'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { createSpatialEvent } from '../../SpatialWebEventCreator'\nimport {\n CubeInfoMsg,\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n TransformMsg,\n} from '../../WebMsgCommand'\n\nexport class SpatialEntity extends SpatialObject {\n position: Vec3 = { x: 0, y: 0, z: 0 }\n rotation: Vec3 = { x: 0, y: 0, z: 0 }\n scale: Vec3 = { x: 1, y: 1, z: 1 }\n\n events: Record<string, (data: any) => void> = {}\n children: SpatialEntity[] = []\n parent: SpatialEntityOrReality | null = null\n constructor(\n id: string,\n public userData?: SpatialEntityUserData,\n ) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n async addComponent(component: SpatialComponent) {\n return new AddComponentToEntityCommand(this, component).execute()\n }\n async setPosition(position: Vec3) {\n return this.updateTransform({ position })\n }\n async setRotation(rotation: Vec3) {\n return this.updateTransform({ rotation })\n }\n async setScale(scale: Vec3) {\n return this.updateTransform({ scale })\n }\n\n async addEntity(ent: SpatialEntity) {\n const ans = await new SetParentForEntityCommand(ent.id, this.id).execute()\n this.children.push(ent)\n ent.parent = this\n return ans\n }\n async removeFromParent() {\n const ans = await new SetParentForEntityCommand(\n this.id,\n undefined,\n ).execute()\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n return ans\n }\n\n async updateTransform(properties: Partial<SpatialEntityProperties>) {\n this.position = properties.position ?? this.position\n this.rotation = properties.rotation ?? this.rotation\n this.scale = properties.scale ?? this.scale\n return new UpdateEntityPropertiesCommand(this, properties).execute()\n }\n\n async addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n if (this.events[type]) {\n // replace if exist\n this.events[type] = callback\n } else {\n try {\n await this.updateEntityEvent(type, true)\n this.events[type] = callback\n } catch (error) {\n console.error('addEvent failed', type)\n }\n }\n }\n\n async removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n try {\n await this.updateEntityEvent(eventName, false)\n } catch (error) {\n console.error('removeEvent failed', eventName)\n }\n }\n }\n\n async updateEntityEvent(\n eventName: SpatialEntityEventType,\n isEnable: boolean,\n ) {\n return new UpdateEntityEventCommand(this, eventName, isEnable).execute()\n }\n private onReceiveEvent = (\n data: // | CubeInfoMsg\n // | TransformMsg\n | SpatialTapMsg\n // | SpatialDragMsg\n // | SpatialDragEndMsg\n // | SpatialRotateMsg\n // | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) => {\n // console.log('SpatialEntityEvent', data)\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n // tap\n else if (type === SpatialWebMsgType.spatialtap) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialtap,\n (data as SpatialTapMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n (data as SpatialDragMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdrag,\n (data as SpatialDragMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n (data as SpatialDragEndMsg).detail,\n )\n this.dispatchEvent(evt)\n }\n // rotate\n else if (type === SpatialWebMsgType.spatialrotate) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n (data as SpatialRotateMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n (data as SpatialRotateEndMsg).detail,\n )\n this.dispatchEvent(evt)\n }\n // magnify\n else if (type === SpatialWebMsgType.spatialmagnify) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n (data as SpatialMagnifyMsg).detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n (data as SpatialMagnifyMsg).detail,\n )\n this.dispatchEvent(evt)\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n // Set origin once at the first dispatch in the bubbling chain\n if (!(evt as any).__origin) {\n Object.defineProperty(evt, '__origin', { value: this, enumerable: false })\n }\n this.events[evt.type]?.(evt)\n if (evt.bubbles && !evt.cancelBubble) {\n if (this.parent && this.parent instanceof SpatialEntity) {\n this.parent.dispatchEvent(evt)\n }\n }\n }\n\n protected onDestroy(): void {\n SpatialWebEvent.removeEventReceiver(this.id)\n // handle children\n this.children.forEach(child => {\n child.parent = null\n })\n this.children = []\n // handle parent\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n }\n // onUpdate(properties: SpatialEntityProperties) {\n // this.position = properties.position\n // this.rotation = properties.rotation\n // this.scale = properties.scale\n // }\n async convertFromEntityToEntity(\n fromEntityId: string,\n toEntityId: string,\n position: Vec3,\n ) {\n return new ConvertFromEntityToEntityCommand(\n fromEntityId,\n toEntityId,\n position,\n ).execute()\n }\n\n async convertFromEntityToScene(fromEntityId: string, position: Vec3) {\n return new ConvertFromEntityToSceneCommand(fromEntityId, position).execute()\n }\n async convertFromSceneToEntity(entityId: string, position: Vec3) {\n return new ConvertFromSceneToEntityCommand(entityId, position).execute()\n }\n}\n","import {\n SpatialEntityUserData,\n SpatialModelEntityCreationOptions,\n} from '../../types/types'\nimport { SpatialEntity } from './SpatialEntity'\n\nexport class SpatialModelEntity extends SpatialEntity {\n constructor(\n public id: string,\n public options?: SpatialModelEntityCreationOptions,\n public userData?: SpatialEntityUserData,\n ) {\n super(id, userData)\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { ObjectDestroyMsg, SpatialWebMsgType } from '../../WebMsgCommand'\n\nexport class SpatialComponent extends SpatialObject {\n constructor(id: string) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n private onReceiveEvent = (data: ObjectDestroyMsg) => {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n }\n}\n","import { ModelComponentOptions } from '../../types/types'\nimport { SpatialComponent } from './SpatialComponent'\n\nexport class ModelComponent extends SpatialComponent {\n constructor(\n id: string,\n public options: ModelComponentOptions,\n ) {\n super(id)\n }\n}\n","import { UpdateUnlitMaterialProperties } from '../../JSBCommand'\nimport { SpatialUnlitMaterialOptions } from '../../types/types'\nimport { SpatialMaterial } from './SpatialMaterial'\n\nexport class SpatialUnlitMaterial extends SpatialMaterial {\n constructor(\n public id: string,\n public options: SpatialUnlitMaterialOptions,\n ) {\n super(id, 'unlit')\n }\n\n updateProperties(properties: Partial<SpatialUnlitMaterialOptions>) {\n return new UpdateUnlitMaterialProperties(this, properties).execute()\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialMaterialType } from '../../types/types'\n\nexport abstract class SpatialMaterial extends SpatialObject {\n constructor(\n public id: string,\n public type: SpatialMaterialType,\n ) {\n super(id)\n this.type = type\n }\n\n abstract updateProperties(properties: any): void\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { ModelAssetOptions } from '../../types/types'\n\nexport class SpatialModelAsset extends SpatialObject {\n constructor(\n public id: string,\n public options: ModelAssetOptions,\n ) {\n super(id)\n }\n}\n","import { SpatialObject } from '../../SpatialObject'\nimport { SpatialGeometryOptions, SpatialGeometryType } from '../../types/types'\n\nexport class SpatialGeometry extends SpatialObject {\n static type: SpatialGeometryType\n constructor(\n public id: string,\n public options: SpatialGeometryOptions,\n ) {\n super(id)\n }\n}\n","import {\n SpatialBoxGeometryOptions,\n SpatialGeometryType,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialBoxGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'BoxGeometry'\n constructor(\n public id: string,\n public options: SpatialBoxGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialSphereGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialSphereGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'SphereGeometry'\n constructor(\n public id: string,\n public options: SpatialSphereGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialCylinderGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialCylinderGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'CylinderGeometry'\n constructor(\n public id: string,\n public options: SpatialCylinderGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialPlaneGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialPlaneGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'PlaneGeometry'\n constructor(\n public id: string,\n public options: SpatialPlaneGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import {\n SpatialGeometryType,\n SpatialConeGeometryOptions,\n} from '../../types/types'\nimport { SpatialGeometry } from './SpatialGeometry'\n\nexport class SpatialConeGeometry extends SpatialGeometry {\n static type: SpatialGeometryType = 'ConeGeometry'\n constructor(\n public id: string,\n public options: SpatialConeGeometryOptions,\n ) {\n super(id, options)\n }\n}\n","import { initScene } from './scene-polyfill'\nimport { SpatialScene } from './SpatialScene'\nimport { Spatialized2DElement } from './Spatialized2DElement'\nimport {\n createSpatialized2DElement,\n createSpatializedDynamic3DElement,\n} from './SpatializedElementCreator'\nimport { createSpatializedStatic3DElement } from './SpatializedElementCreator'\nimport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nimport {\n ModelComponentOptions,\n ModelAssetOptions,\n SpatialBoxGeometryOptions,\n SpatialConeGeometryOptions,\n SpatialCylinderGeometryOptions,\n SpatialGeometryOptions,\n SpatialModelEntityCreationOptions,\n SpatialPlaneGeometryOptions,\n SpatialSceneCreationOptions,\n SpatialSphereGeometryOptions,\n SpatialUnlitMaterialOptions,\n SpatialEntityUserData,\n} from './types/types'\nimport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nimport { SpatialEntity } from './reality/entity/SpatialEntity'\nimport {\n createModelAsset,\n createModelComponent,\n createSpatialEntity,\n createSpatialGeometry,\n createSpatialModelEntity,\n createSpatialUnlitMaterial,\n} from './reality/realityCreator'\nimport {\n SpatialBoxGeometry,\n SpatialPlaneGeometry,\n SpatialSphereGeometry,\n SpatialConeGeometry,\n SpatialCylinderGeometry,\n} from './reality'\n\n/**\n * Session used to establish a connection to the spatial renderer of the system.\n * All spatial resources must be created through this session object.\n * This class serves as the main factory for creating spatial elements and geometries.\n */\nexport class SpatialSession {\n /**\n * Gets the singleton instance of the spatial scene.\n * The spatial scene is the root container for all spatial elements.\n * @returns The SpatialScene singleton instance\n */\n getSpatialScene(): SpatialScene {\n return SpatialScene.getInstance()\n }\n\n /**\n * Creates a new 2D element that can be spatialized in the 3D environment.\n * 2D elements represent HTML content that can be positioned in 3D space.\n * @returns Promise resolving to a new Spatialized2DElement instance\n */\n createSpatialized2DElement(): Promise<Spatialized2DElement> {\n return createSpatialized2DElement()\n }\n\n /**\n * Creates a new static 3D element with an optional model URL.\n * Static 3D elements represent pre-built 3D models that can be loaded from a URL.\n * @param modelURL Optional URL to the 3D model to load\n * @returns Promise resolving to a new SpatializedStatic3DElement instance\n */\n createSpatializedStatic3DElement(\n modelURL: string = '',\n ): Promise<SpatializedStatic3DElement> {\n return createSpatializedStatic3DElement(modelURL)\n }\n\n /**\n * Initializes the spatial scene with custom configuration.\n * This is a reference to the initScene function from scene-polyfill.\n */\n initScene = initScene\n\n /**\n * Creates a new dynamic 3D element that can be manipulated at runtime.\n * Dynamic 3D elements allow for programmatic creation and modification of 3D content.\n * @returns Promise resolving to a new SpatializedDynamic3DElement instance\n */\n createSpatializedDynamic3DElement(): Promise<SpatializedDynamic3DElement> {\n return createSpatializedDynamic3DElement()\n }\n\n /**\n * Creates a new spatial entity with an optional name.\n * Entities are the basic building blocks for creating custom 3D content.\n * @param name Optional name for the entity\n * @returns Promise resolving to a new SpatialEntity instance\n */\n createEntity(userData?: SpatialEntityUserData): Promise<SpatialEntity> {\n return createSpatialEntity(userData)\n }\n\n /**\n * Creates a box geometry with optional configuration.\n * @param options Configuration options for the box geometry\n * @returns Promise resolving to a new SpatialBoxGeometry instance\n */\n createBoxGeometry(options: SpatialBoxGeometryOptions = {}) {\n return createSpatialGeometry(SpatialBoxGeometry, options)\n }\n\n /**\n * Creates a plane geometry with optional configuration.\n * @param options Configuration options for the plane geometry\n * @returns Promise resolving to a new SpatialPlaneGeometry instance\n */\n createPlaneGeometry(options: SpatialPlaneGeometryOptions = {}) {\n return createSpatialGeometry(SpatialPlaneGeometry, options)\n }\n\n /**\n * Creates a sphere geometry with optional configuration.\n * @param options Configuration options for the sphere geometry\n * @returns Promise resolving to a new SpatialSphereGeometry instance\n */\n createSphereGeometry(options: SpatialSphereGeometryOptions = {}) {\n return createSpatialGeometry(SpatialSphereGeometry, options)\n }\n\n /**\n * Creates a cone geometry with the specified configuration.\n * @param options Configuration options for the cone geometry\n * @returns Promise resolving to a new SpatialConeGeometry instance\n */\n createConeGeometry(options: SpatialConeGeometryOptions) {\n return createSpatialGeometry(SpatialConeGeometry, options)\n }\n\n /**\n * Creates a cylinder geometry with the specified configuration.\n * @param options Configuration options for the cylinder geometry\n * @returns Promise resolving to a new SpatialCylinderGeometry instance\n */\n createCylinderGeometry(options: SpatialCylinderGeometryOptions) {\n return createSpatialGeometry(SpatialCylinderGeometry, options)\n }\n\n /**\n * Creates a model component with the specified configuration.\n * Model components are used to add 3D model rendering capabilities to entities.\n * @param options Configuration options for the model component\n * @returns Promise resolving to a new ModelComponent instance\n */\n createModelComponent(options: ModelComponentOptions) {\n return createModelComponent(options)\n }\n\n /**\n * Creates an unlit material with the specified configuration.\n * Unlit materials don't respond to lighting in the scene.\n * @param options Configuration options for the unlit material\n * @returns Promise resolving to a new SpatialUnlitMaterial instance\n */\n createUnlitMaterial(options: SpatialUnlitMaterialOptions) {\n return createSpatialUnlitMaterial(options)\n }\n\n /**\n * Creates a model asset with the specified configuration.\n * Model assets represent 3D model resources that can be used by entities.\n * @param options Configuration options for the model asset\n * @returns Promise resolving to a new SpatialModelAsset instance\n */\n createModelAsset(options: ModelAssetOptions) {\n return createModelAsset(options)\n }\n\n /**\n * Creates a spatial model entity with the specified configuration.\n * This is a convenience method for creating an entity with a model component.\n * @param options Configuration options for the spatial model entity\n * @returns Promise resolving to a new SpatialModelEntity instance\n */\n createSpatialModelEntity(\n options: SpatialModelEntityCreationOptions,\n userData?: SpatialEntityUserData,\n ) {\n return createSpatialModelEntity(options, userData)\n }\n}\n","import { SpatialSession } from './SpatialSession'\nimport { SpatialWebEvent } from './SpatialWebEvent'\n\n/**\n * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr.\n * This is the main entry point for the WebSpatial SDK, providing access to spatial capabilities.\n */\nexport class Spatial {\n /**\n * Requests a spatial session object from the browser.\n * This is the primary method to initialize spatial functionality.\n * @returns The SpatialSession instance or null if not available in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n if (this.runInSpatialWeb()) {\n SpatialWebEvent.init()\n return new SpatialSession()\n } else {\n return null\n }\n }\n\n /**\n * Checks if the current page is running in a spatial web environment.\n * This method detects if the application is running in a WebSpatial-compatible browser.\n * @returns True if running in a spatial web environment, false otherwise\n */\n runInSpatialWeb() {\n if (navigator.userAgent.indexOf('WebSpatial/') > 0) {\n return true\n }\n return false\n }\n\n /** @deprecated\n * Checks if WebSpatial is supported in the current environment.\n * Verifies compatibility between native and client versions.\n * @returns True if web spatial is supported by this webpage\n */\n isSupported() {\n return true\n }\n\n /** @deprecated\n * Gets the native WebSpatial version from the browser environment.\n * The version format follows semantic versioning (x.x.x).\n * @returns Native version string in format \"x.x.x\"\n */\n getNativeVersion() {\n if (window.__WebSpatialData && window.__WebSpatialData.getNativeVersion) {\n return window.__WebSpatialData.getNativeVersion()\n }\n return window.WebSpatailNativeVersion === 'PACKAGE_VERSION'\n ? this.getClientVersion()\n : window.WebSpatailNativeVersion\n }\n\n /** @deprecated\n * Gets the client SDK version.\n * The version format follows semantic versioning (x.x.x).\n * @returns Client SDK version string in format \"x.x.x\"\n */\n getClientVersion() {\n // @ts-ignore\n return __WEBSPATIAL_CORE_SDK_VERSION__\n }\n}\n","export { SpatialObject } from './SpatialObject'\nexport { Spatial } from './Spatial'\nexport { SpatialSession } from './SpatialSession'\nexport { SpatialScene } from './SpatialScene'\nexport { SpatializedElement } from './SpatializedElement'\nexport { Spatialized2DElement } from './Spatialized2DElement'\nexport { SpatializedStatic3DElement } from './SpatializedStatic3DElement'\nexport { SpatializedDynamic3DElement } from './SpatializedDynamic3DElement'\nexport * from './reality'\nexport * from './types/types'\nexport * from './types/global.d'\n\n// side effects\nimport { injectSceneHook } from './scene-polyfill'\nimport { isSSREnv } from './ssr-polyfill'\nimport { spatialWindowPolyfill } from './spatial-window-polyfill'\n\nexport { isSSREnv }\n\nif (!isSSREnv() && navigator.userAgent.indexOf('WebSpatial/') > 0) {\n injectSceneHook()\n spatialWindowPolyfill()\n}\n","import { parseCornerRadius } from './utils'\nimport { Spatial } from './Spatial'\nimport { SpatialSession } from './SpatialSession'\nimport { BackgroundMaterialType } from './types/types'\n\nconst spatial = new Spatial()\nlet session: SpatialSession | undefined = undefined\n\nconst SpatialGlobalCustomVars = {\n backgroundMaterial: '--xr-background-material',\n}\n\n// keep track of current html background material\nlet htmlBackgroundMaterial = ''\nfunction setCurrentWindowStyle(backgroundMaterial: string) {\n if (backgroundMaterial !== htmlBackgroundMaterial) {\n session?.getSpatialScene()?.updateSpatialProperties({\n material: backgroundMaterial as BackgroundMaterialType,\n })\n htmlBackgroundMaterial = backgroundMaterial\n }\n}\n\nfunction checkHtmlBackgroundMaterial() {\n const computedStyle = getComputedStyle(document.documentElement)\n\n const backgroundMaterial = computedStyle.getPropertyValue(\n SpatialGlobalCustomVars.backgroundMaterial,\n )\n\n setCurrentWindowStyle(backgroundMaterial || 'none')\n}\n\n// keep track of current corner radius\nlet htmlCornerRadius = {\n topLeading: 0,\n bottomLeading: 0,\n topTrailing: 0,\n bottomTrailing: 0,\n}\n\nfunction checkCornerRadius() {\n const computedStyle = getComputedStyle(document.documentElement)\n const cornerRadius = parseCornerRadius(computedStyle)\n setCornerRadius(cornerRadius)\n}\n\nfunction setCornerRadius(cornerRadius: any) {\n if (\n htmlCornerRadius.topLeading !== cornerRadius.topLeading ||\n htmlCornerRadius.bottomLeading !== cornerRadius.bottomLeading ||\n htmlCornerRadius.topTrailing !== cornerRadius.topTrailing ||\n htmlCornerRadius.bottomTrailing !== cornerRadius.bottomTrailing\n ) {\n session?.getSpatialScene()?.updateSpatialProperties({\n cornerRadius,\n })\n htmlCornerRadius.topLeading = cornerRadius.topLeading\n htmlCornerRadius.bottomLeading = cornerRadius.bottomLeading\n htmlCornerRadius.topTrailing = cornerRadius.topTrailing\n htmlCornerRadius.bottomTrailing = cornerRadius.bottomTrailing\n }\n}\n\nfunction setOpacity(opacity: number) {\n session?.getSpatialScene().updateSpatialProperties({\n opacity,\n })\n}\n\nfunction checkOpacity() {\n const computedStyle = getComputedStyle(document.documentElement)\n const opacity = parseFloat(computedStyle.getPropertyValue('opacity'))\n setOpacity(opacity)\n}\n\nfunction hijackDocumentElementStyle() {\n const rawDocumentStyle = document.documentElement.style\n const styleProxy = new Proxy(rawDocumentStyle, {\n set: function (target, key, value) {\n const ret = Reflect.set(target, key, value)\n\n if (key === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n\n if (\n key === 'border-radius' ||\n key === 'borderRadius' ||\n key === 'border-top-left-radius' ||\n key === 'borderTopLeftRadius' ||\n key === 'border-top-right-radius' ||\n key === 'borderTopRightRadius' ||\n key === 'border-bottom-left-radius' ||\n key === 'borderBottomLeftRadius' ||\n key === 'border-bottom-right-radius' ||\n key === 'borderBottomRightRadius'\n ) {\n checkCornerRadius()\n }\n\n if (key === 'opacity') {\n checkOpacity()\n }\n\n return ret\n },\n get: function (target, prop: string) {\n if (typeof target[prop as keyof CSSStyleDeclaration] === 'function') {\n return function (this: any, ...args: any[]) {\n if (prop === 'setProperty') {\n const [property, value] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle(value)\n }\n } else if (prop === 'removeProperty') {\n const [property] = args\n if (property === SpatialGlobalCustomVars.backgroundMaterial) {\n setCurrentWindowStyle('none')\n }\n }\n return (target[prop as keyof CSSStyleDeclaration] as Function)(\n ...args,\n )\n }\n }\n return Reflect.get(target, prop)\n },\n })\n Object.defineProperty(document.documentElement, 'style', {\n get: function () {\n return styleProxy\n },\n })\n}\n\nfunction monitorExternalStyleChange() {\n const headObserver = new MutationObserver(checkCSSProperties)\n\n headObserver.observe(document.head, { childList: true, subtree: true })\n}\n\nfunction checkCSSProperties() {\n checkHtmlBackgroundMaterial()\n checkCornerRadius()\n checkOpacity()\n}\n\nfunction monitorHTMLAttributeChange() {\n const observer = new MutationObserver(mutations => {\n mutations.forEach(mutation => {\n if (mutation.type === 'attributes' && mutation.attributeName) {\n checkCSSProperties()\n }\n })\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['style', 'class'],\n })\n}\n\nexport async function spatialWindowPolyfill() {\n if (!spatial.runInSpatialWeb()) {\n return\n }\n\n session = await spatial.requestSession()!\n\n if (document.readyState === 'complete') {\n checkCSSProperties()\n } else {\n window.addEventListener('load', () => {\n checkCSSProperties()\n })\n }\n\n hijackDocumentElementStyle()\n monitorExternalStyleChange()\n monitorHTMLAttributeChange()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,OAEO;AAFb;AAAA;AAAA;AAAA,IAAM,QAAQ,OAAO,WAAW;AAEzB,IAAM,WAAW,MAAM;AAAA;AAAA;;;ACF9B,IAMa;AANb;AAAA;AAAA;AAMO,IAAM,cAAN,MAA6C;AAAA,MAClD,QAAQ,KAAa,KAAqC;AACxD,eAAO,QAAQ,QAAQ;AAAA,UACrB,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MACA,uBACE,QACA,OACA,QACA,UACmC;AACnC,eAAO,QAAQ,QAAQ;AAAA,UACrB,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,MACA,2BACE,QACA,OACA,QACA,UACA,gBAC0B;AAC1B,eAAO;AAAA,UACL,SAAS;AAAA,UACT,MAAM;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA;AAAA;;;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,YAC9C,GAAG;AAAA,UACL;AAAA,QACF;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,IAAI;AAAA,IACjC;AAAA,EACF,CAAC;AACD,SAAO,eAAe,SAAS,iBAAiB,SAAS;AAAA,IACvD,KAAK,WAAY;AACf,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAEA,SAAS,6BAA6B;AACpC,QAAM,eAAe,IAAI,iBAAiB,kBAAkB;AAE5D,eAAa,QAAQ,SAAS,MAAM,EAAE,WAAW,MAAM,SAAS,KAAK,CAAC;AACxE;AAEA,SAAS,qBAAqB;AAC5B,8BAA4B;AAC5B,oBAAkB;AAClB,eAAa;AACf;AAEA,SAAS,6BAA6B;AACpC,QAAM,WAAW,IAAI,iBAAiB,eAAa;AACjD,cAAU,QAAQ,cAAY;AAC5B,UAAI,SAAS,SAAS,gBAAgB,SAAS,eAAe;AAC5D,2BAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,WAAS,QAAQ,SAAS,iBAAiB;AAAA,IACzC,YAAY;AAAA,IACZ,iBAAiB,CAAC,SAAS,OAAO;AAAA,EACpC,CAAC;AACH;AAEA,eAAsB,wBAAwB;AAC5C,MAAI,CAAC,QAAQ,gBAAgB,GAAG;AAC9B;AAAA,EACF;AAEA,YAAU,MAAM,QAAQ,eAAe;AAEvC,MAAI,SAAS,eAAe,YAAY;AACtC,uBAAmB;AAAA,EACrB,OAAO;AACL,WAAO,iBAAiB,QAAQ,MAAM;AACpC,yBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AAEA,6BAA2B;AAC3B,6BAA2B;AAC3B,6BAA2B;AAC7B;;;ADlKA,IAAI,CAAC,SAAS,KAAK,UAAU,UAAU,QAAQ,aAAa,IAAI,GAAG;AACjE,kBAAgB;AAChB,wBAAsB;AACxB;","names":["nextRequestId","requestId","MAX_ID","XRPlatform","AndroidPlatform","VisionOSPlatform","SpatializedElementType","SpatialSceneState","window","defaultSceneConfig"]}