@webspatial/core-sdk 0.1.10 → 0.1.13

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/core/private/remote-command/RemoteCommand.ts","../src/core/private/WebSpatial.ts","../src/core/SpatialObject.ts","../src/core/SpatialTransform.ts","../src/core/SpatialEntity.ts","../src/core/component/SpatialComponent.ts","../src/core/component/SpatialWindowComponent.ts","../src/core/component/EventSpatialComponent.ts","../src/core/component/SpatialInputComponent.ts","../src/core/component/SpatialModelComponent.ts","../src/core/component/SpatialViewComponent.ts","../src/core/component/SpatialModel3DComponent.ts","../src/core/resource/SpatialMeshResource.ts","../src/core/resource/SpatialPhysicallyBasedMaterialResource.ts","../src/core/SpatialWindowContainer.ts","../src/core/SpatialSession.ts","../src/core/Spatial.ts","../src/core/SpatialHelper.ts"],"sourcesContent":["export class RemoteCommand {\n private static requestCounter = 0\n\n command: string\n\n data: any\n\n requestID: number\n\n constructor(cmd: string, data?: any) {\n this.command = cmd\n this.data = data\n this.requestID = ++RemoteCommand.requestCounter\n }\n}\n","import { RemoteCommand } from './remote-command'\nimport {\n WindowStyle,\n WindowContainerOptions,\n LoadingMethodKind,\n sceneDataShape,\n sceneDataJSBShape,\n} from '../types'\n\nexport class WindowContainer {\n id = ''\n}\n\nexport class WebSpatialResource {\n id = ''\n windowContainerId = ''\n data = {} as any\n\n receiveEvent() {}\n}\n\nexport class WebSpatial {\n public static eventPromises: any = {}\n\n public static transactionStarted = false\n public static transactionCommands = Array<RemoteCommand>()\n\n // store event receivers\n private static eventReceivers: { [resourceId: string]: (data: any) => void } =\n {}\n\n public static registerEventReceiver(\n resourceId: string,\n callback: (data: any) => void,\n ) {\n this.eventReceivers[resourceId] = callback\n }\n\n public static unregisterEventReceiver(resourceId: string) {\n delete this.eventReceivers[resourceId]\n }\n\n static init() {\n ;(window as any).__SpatialWebEvent = (e: any) => {\n if (e.resourceId) {\n var callback = WebSpatial.eventReceivers[e.resourceId]\n callback(e.data)\n } else {\n var p = WebSpatial.eventPromises[e.requestID]\n if (p) {\n if (e.success) {\n p.res(e)\n } else {\n p.rej(e)\n }\n }\n }\n }\n }\n\n static startTransaction() {\n WebSpatial.transactionStarted = true\n WebSpatial.transactionCommands = []\n }\n\n static async sendTransaction() {\n WebSpatial.transactionStarted = false\n var cmd = new RemoteCommand('multiCommand', {\n commandList: WebSpatial.transactionCommands,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static getBackend() {\n if ((window as any).webkit) {\n return 'AVP'\n } else {\n return 'UNKNOWN'\n }\n }\n\n static async sendCommand(cmd: RemoteCommand) {\n if ((window as any).__WebSpatialUnloaded) {\n return\n }\n if (WebSpatial.transactionStarted) {\n WebSpatial.transactionCommands.push(cmd as any)\n return\n }\n\n var msg = JSON.stringify(cmd)\n\n if (WebSpatial.getBackend() == 'AVP') {\n ;(window as any).webkit.messageHandlers.bridge.postMessage(msg)\n return\n } else {\n ;(window as any).bridge.nativeMessage(msg)\n return\n }\n }\n\n static getImmersiveWindowContainer() {\n var wg = new WindowContainer()\n wg.id = 'Immersive'\n return wg\n }\n\n static getCurrentWindowContainer() {\n var wg = new WindowContainer()\n wg.id = 'current'\n return wg\n }\n\n static getCurrentWebPanel() {\n var wg = new WebSpatialResource()\n wg.id = 'current'\n wg.windowContainerId = WebSpatial.getCurrentWindowContainer().id\n return wg\n }\n\n static async createScene(\n style: WindowStyle = 'Plain',\n cfg: {\n sceneData: sceneDataShape\n },\n ) {\n const { window: newWindow, ...sceneData } = cfg.sceneData\n const jsbSceneData: sceneDataJSBShape = {\n ...sceneData,\n windowID: (newWindow as any)._webSpatialID,\n windowContainerID: (newWindow as any)._webSpatialGroupID,\n }\n var cmd = new RemoteCommand('createScene', {\n windowStyle: style,\n sceneData: jsbSceneData,\n windowContainerID: (window as any)._webSpatialParentGroupID, // parent WindowContainerID\n })\n\n try {\n await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return true\n } catch (error) {\n return false\n }\n }\n\n static async createWindowContainer(\n style: WindowStyle = 'Plain',\n windowContainer: WindowContainer | null,\n parentWebView: WebSpatialResource | null,\n ) {\n var cmd = new RemoteCommand('createWindowContainer', {\n windowStyle: style,\n windowContainerID: windowContainer ? windowContainer.id : undefined,\n resourceID: parentWebView ? parentWebView.id : undefined,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n var res = new WindowContainer()\n res.id = (result as any).data.createdID\n return res\n }\n\n static async destroyResource(resource: WebSpatialResource) {\n const data = {}\n var cmd = new RemoteCommand('destroyResource', {\n windowContainerID: resource.windowContainerId,\n resourceID: resource.id,\n })\n\n WebSpatial.sendCommand(cmd)\n }\n\n static async ping(msg: string) {\n var cmd = new RemoteCommand('ping', {\n windowContainerID: this.getCurrentWindowContainer().id,\n resourceID: this.getCurrentWebPanel().id,\n message: msg,\n })\n\n if (WebSpatial.transactionStarted) {\n WebSpatial.sendCommand(cmd)\n return null\n } else {\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n }\n\n static async getStats() {\n var cmd = new RemoteCommand('getStats', {\n windowContainerID: this.getCurrentWindowContainer().id,\n resourceID: this.getCurrentWebPanel().id,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return (result as any).data\n }\n\n static async inspect(spatialObjectId: string) {\n var cmd = new RemoteCommand('inspect', {\n resourceID: spatialObjectId,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n\n return (result as any).data\n }\n\n static async inspectRootWindowContainer() {\n return this.inspect('root')\n }\n\n static async setComponent(\n entity: WebSpatialResource,\n resource: WebSpatialResource,\n ) {\n var cmd = new RemoteCommand('setComponent', {\n windowContainerID: entity.windowContainerId,\n resourceID: resource.id,\n entityID: entity.id,\n })\n\n WebSpatial.sendCommand(cmd)\n }\n\n static async removeComponent(\n entity: WebSpatialResource,\n resource: WebSpatialResource,\n ) {\n var cmd = new RemoteCommand('removeComponent', {\n windowContainerID: entity.windowContainerId,\n resourceID: resource.id,\n entityID: entity.id,\n })\n\n WebSpatial.sendCommand(cmd)\n }\n\n // windowContainer is the group the resource will be tied to (if not provided it will use the current window grou)\n // parentWebView is the SpatialWebView that the resource will be tied to (if not provided, resource will continue to exist even if this page is unloaded)\n static async createResource(\n type: string,\n windowContainer: WindowContainer | null,\n parentWebView: WebSpatialResource | null,\n params = {} as any,\n ) {\n var cmd = new RemoteCommand('createResource', {\n windowContainerID: windowContainer ? windowContainer.id : undefined,\n resourceID: parentWebView ? parentWebView.id : undefined,\n type: type,\n params: params,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n var res = new WebSpatialResource()\n res.id = (result as any).data.createdID\n res.windowContainerId = cmd.data.windowContainerID\n return res\n }\n\n static async updateWindowContainer(wg: WindowContainer, data: any) {\n var cmd = new RemoteCommand('updateWindowContainer', {\n windowContainerID: wg.id,\n update: data,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static async updateResource(resource: WebSpatialResource, data: any = null) {\n var cmd = new RemoteCommand('updateResource', {\n windowContainerID: resource.windowContainerId,\n resourceID: resource.id,\n update: data || resource.data,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static async setLoading(method: LoadingMethodKind, style?: string) {\n var cmd = new RemoteCommand('setLoading', {\n windowContainerID: (window as any)._webSpatialParentGroupID, // parent WindowContainerID\n loading: {\n method,\n style,\n },\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static async openImmersiveSpace() {\n var cmd = new RemoteCommand('openImmersiveSpace')\n await WebSpatial.sendCommand(cmd)\n }\n\n static async dismissImmersiveSpace() {\n var cmd = new RemoteCommand('dismissImmersiveSpace')\n await WebSpatial.sendCommand(cmd)\n }\n\n static onFrame(fn: (curTime: number) => Promise<any>) {\n var dt = 0\n var loop = async () => {\n var curTime = window.performance.now()\n await fn(curTime)\n var updateTime = window.performance.now() - curTime\n\n // Call update loop targetting 60 fps\n setTimeout(\n () => {\n loop()\n },\n Math.max(1000 / 60 - updateTime, 0),\n )\n }\n loop()\n }\n}\nWebSpatial.init()\n","import { WebSpatial } from './private/WebSpatial'\nimport { WebSpatialResource } from './private/WebSpatial'\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 _resource: WebSpatialResource,\n ) {}\n\n /**\n * Marks resource to be released (it should no longer be used)\n */\n async destroy() {\n await WebSpatial.destroyResource(this._resource)\n await this.onDestroy()\n }\n\n public name: string = ''\n\n protected async onDestroy() {}\n}\n","export class Vec3 {\n constructor(\n public x = 0,\n public y = 0,\n public z = 0,\n ) {}\n}\n\nexport class Vec4 {\n constructor(\n public x = 0,\n public y = 0,\n public z = 0,\n public w = 1,\n ) {}\n}\n\n/**\n * Transform containing position, orientation and scale\n */\nexport class SpatialTransform {\n position = new Vec3(0, 0, 0)\n /** Quaternion value for x,y,z,w */\n orientation = new Vec4(0, 0, 0, 1)\n scale = new Vec3(1, 1, 1)\n}\n","import { SpatialObject } from './SpatialObject'\nimport { SpatialTransform } from './SpatialTransform'\nimport { SpatialWindowContainer } from './SpatialWindowContainer'\nimport { WebSpatial } from './private/WebSpatial'\nimport { SpatialComponent } from './component'\n\n/**\n * Entity used to describe an object that can be added to the scene\n */\nexport class SpatialEntity extends SpatialObject {\n /**\n * Transform corresponding to the entity\n * note: updateTransform must be called for transform to be synced to rendering\n */\n transform = new SpatialTransform()\n\n /** @hidden */\n private _destroyed = false\n /** @hidden */\n private get _entity() {\n return this._resource\n }\n\n /**\n * Syncs the transform with the renderer, must be called to observe updates\n */\n async updateTransform() {\n await WebSpatial.updateResource(this._entity, this.transform)\n }\n\n /**\n * Syncs the zIndex with the renderer\n */\n async updateZIndex(zIndex: number) {\n await WebSpatial.updateResource(this._entity, { zIndex })\n }\n\n private components: Map<Function, SpatialComponent> = new Map()\n\n /**\n * Attaches a component to the entity to be displayed\n * [TODO] review pass by value vs ref and ownership model for this\n */\n async setComponent(component: SpatialComponent) {\n await WebSpatial.setComponent(this._entity, component._resource)\n this.components.set(component.constructor, component)\n }\n\n /**\n * Removes a component from the entity\n */\n async removeComponent<T extends SpatialComponent>(\n type: new (...args: any[]) => T,\n ) {\n var c = this.getComponent(type)\n if (c != undefined) {\n await WebSpatial.removeComponent(this._entity, c._resource)\n this.components.delete(c.constructor)\n }\n }\n\n /**\n * Gets a component from the entity\n */\n getComponent<T extends SpatialComponent>(\n type: new (...args: any[]) => T,\n ): T | undefined {\n return this.components.get(type) as T | undefined\n }\n\n /**\n * @hidden\n * Sets the window container that this entity should be rendered by (this does not effect resource ownership)\n * @param wg the window container that should render this entity\n */\n async _setParentWindowContainer(wg: SpatialWindowContainer) {\n await WebSpatial.updateResource(this._entity, {\n setParentWindowContainerID: wg._wg.id,\n })\n }\n\n /**\n * Sets a parent entity, if that entity or its parents are attached to a window container, this entity will be displayed\n * @param e parent entity or null to remove current parent\n */\n async setParent(e: SpatialEntity | null) {\n await WebSpatial.updateResource(this._entity, {\n setParent: e ? e._entity.id : '',\n })\n }\n\n /**\n * Sets the coordinate space of this entity (Default: App)\n * \"App\" = game engine style coordinates in meters\n * \"Dom\" = Windowing coordinates in dom units (eg. 0,0,0 is top left of window)\n * \"Root\" = Coordinate space is ignored and content is displayed and updated as window container's root object, window containers can only have one root entity\n * [TODO] review this api\n * @param space coordinate space mode\n */\n async setCoordinateSpace(space: 'App' | 'Dom' | 'Root') {\n await WebSpatial.updateResource(this._entity, { setCoordinateSpace: space })\n }\n\n /**\n * Query the 3d boudning box of the entity\n * @returns The bounding box of the entity\n */\n async getBoundingBox() {\n var res: any = await WebSpatial.updateResource(this._entity, {\n getBoundingBox: true,\n })\n return res.data as {\n center: { x: number; y: number; z: number }\n extents: { x: number; y: number; z: number }\n }\n }\n\n /**\n * Sets if the entity should be visible (default: True)\n * @param visible\n */\n async setVisible(visible: boolean) {\n await WebSpatial.updateResource(this._entity, { visible })\n }\n\n /**\n * Removes a reference to the entity by the renderer and this object should no longer be used. [TODO] Attached components will not be destroyed\n */\n async destroy() {\n this._destroyed = true\n await WebSpatial.destroyResource(this._entity)\n }\n\n /**\n * Check if destroy has been called\n */\n isDestroyed() {\n return this._destroyed\n }\n\n // Set Entity name. Currently for debugging only.\n /** @hidden */\n async _setName(name: string) {\n this.name = name\n return WebSpatial.updateResource(this._entity, { name })\n }\n}\n","import { WebSpatial, WebSpatialResource } from '../private/WebSpatial'\nimport { SpatialEntity } from '../SpatialEntity'\nimport { SpatialObject } from '../SpatialObject'\n\n/** @hidden */\nexport class SpatialComponent extends SpatialObject {\n /**\n * Gets the entity this component is attached to\n * @returns entity or null\n */\n async getEntity() {\n let reqResp: any = await WebSpatial.updateResource(\n WebSpatial.getCurrentWebPanel(),\n { getEntityID: '' },\n )\n if (reqResp.data.parentID === '') {\n return new Promise<SpatialEntity | null>((res, rej) => {\n res(null)\n })\n } else {\n var res = new WebSpatialResource()\n res.id = reqResp.data.parentID\n return new SpatialEntity(res)\n }\n }\n}\n","import { SpatialComponent } from './SpatialComponent'\nimport { WebSpatial } from '../private/WebSpatial'\nimport { Vec3 } from '../SpatialTransform'\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 type StyleParam = {\n material?: {\n type: BackgroundMaterialType\n }\n cornerRadius?: number | CornerRadius\n}\n\n/**\n * Used to position an web window in 3D space\n */\nexport class SpatialWindowComponent extends SpatialComponent {\n /**\n * Loads a url page in the window\n * @param url url to load\n */\n async loadURL(url: string) {\n await WebSpatial.updateResource(this._resource, { url: url })\n }\n\n async setFromWindow(window: any) {\n if (window._webSpatialID) {\n await WebSpatial.updateResource(this._resource, {\n windowID: window._webSpatialID,\n })\n } else {\n await console.warn(\n 'failed to call setFromWindow, window provided is not valid',\n )\n }\n }\n\n /**\n * Sets the resolution of the window, the resulting dimensions when rendered will be equal to 1/1360 units\n * eg. if the resolution is set to 1360x1360 it will be a 1x1 plane\n * See 1360 in spatialViewUI.swift for how this ratio works\n * @param width width in pixels\n * @param height height in pixels\n */\n async setResolution(width: number, height: number) {\n await WebSpatial.updateResource(this._resource, {\n resolution: { x: width, y: height },\n })\n }\n\n /**\n * [Experimental] Sets the anchor which the entity this is attached to will rotate around\n * @param rotationAnchor\n */\n async setRotationAnchor(rotationAnchor: Vec3) {\n await WebSpatial.updateResource(this._resource, {\n rotationAnchor: rotationAnchor,\n })\n }\n\n /**\n * [Experimental] Sets the opacity of the window after apply material\n * @param opacity\n */\n async setOpacity(opacity: number) {\n await WebSpatial.updateResource(this._resource, {\n opacity,\n })\n }\n\n /**\n * Sets the style that should be applied to the window\n * @param options style options\n */\n async setStyle(styleParam: StyleParam) {\n const { material, cornerRadius } = styleParam\n const options: any = {}\n if (material?.type) {\n options.backgroundMaterial = material.type\n }\n\n if (cornerRadius !== undefined) {\n if (typeof cornerRadius === 'number') {\n options.cornerRadius = {\n topLeading: cornerRadius,\n bottomLeading: cornerRadius,\n topTrailing: cornerRadius,\n bottomTrailing: cornerRadius,\n }\n } else {\n options.cornerRadius = { ...cornerRadius }\n }\n }\n\n if (document && document.readyState == 'loading') {\n // Avoid flash of unstyled content by sending style command via a link element\n var encoded = encodeURIComponent(JSON.stringify(options))\n var x = document.createElement('link')\n x.rel = 'stylesheet'\n x.href = 'forceStyle://mystyle.css?' + 'style=' + encoded\n document.head.appendChild(x)\n }\n\n await WebSpatial.updateResource(this._resource, { style: options })\n }\n\n /**\n * Modifies the amount the spatial window can be scrolled\n * Should only be used internally\n * See https://developer.apple.com/documentation/uikit/1624475-uiedgeinsetsmake?language=objc\n * @param insets margin to modify scroll distances by\n */\n async setScrollEdgeInsets(insets: {\n top: number\n left: number\n bottom: number\n right: number\n }) {\n await WebSpatial.updateResource(this._resource, {\n setScrollEdgeInsets: insets,\n })\n }\n\n /**\n * Enable/Disable scrolling in the window (defaults to enabled), if disabled, scrolling will be applied to the root page\n * @param enabled value to set\n */\n async setScrollEnabled(enabled: boolean) {\n await WebSpatial.updateResource(this._resource, { scrollEnabled: enabled })\n }\n\n /**\n * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements\n * @param scrollWithParent value to set\n */\n async setScrollWithParent(scrollWithParent: boolean) {\n await WebSpatial.updateResource(this._resource, {\n scrollWithParent: scrollWithParent,\n })\n }\n}\n","import { WebSpatial, WebSpatialResource } from '../private/WebSpatial'\nimport { SpatialComponent } from './SpatialComponent'\n\n/**\n * @description\n * Represents a spatial component that handles events related to spatial interactions.\n * This class extends `SpatialComponent` and provides additional functionality for managing\n * event-driven spatial behaviors.\n *\n * @hidden\n * This class is intended for internal use and should not be exposed in the public API.\n */\nexport abstract class EventSpatialComponent extends SpatialComponent {\n // Class implementation goes here\n constructor(_resource: WebSpatialResource) {\n super(_resource)\n WebSpatial.registerEventReceiver(_resource.id, (data: any) => {\n this.onRecvEvent(data)\n })\n }\n\n /**\n * @description\n * Abstract method to be implemented by subclasses. Called when a spatial event is received.\n * @param data The data associated with the received event.\n */\n protected abstract onRecvEvent(data: any): void\n\n protected override async onDestroy() {\n WebSpatial.unregisterEventReceiver(this._resource.id)\n }\n}\n","import { Vec3 } from '../SpatialTransform'\nimport { EventSpatialComponent } from './EventSpatialComponent'\n\n/**\n * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event\n */\ntype TranslateEvent = {\n eventType: 'dragstart' | 'dragend' | 'drag'\n translate?: Vec3\n}\n/**\n * Used to handle input events on an entity\n */\nexport class SpatialInputComponent extends EventSpatialComponent {\n protected override onRecvEvent(data: any): void {\n this.onTranslate(data)\n }\n\n /**\n * Callback fired when a translate event occurs\n * @param data translate event data\n */\n public onTranslate(data: TranslateEvent) {}\n}\n","import { SpatialMeshResource } from '../resource/SpatialMeshResource'\nimport { SpatialPhysicallyBasedMaterialResource } from '../resource/SpatialPhysicallyBasedMaterialResource'\nimport { SpatialComponent } from './SpatialComponent'\nimport { WebSpatial } from '../private/WebSpatial'\n\n/**\n * Used to position a model in 3D space, made up of a mesh and materials to be applied to the mesh\n */\nexport class SpatialModelComponent extends SpatialComponent {\n private cachedMaterials = new Array<SpatialPhysicallyBasedMaterialResource>()\n /**\n * Sets the mesh to be displayed by the component\n * @param mesh mesh to set\n */\n async setMesh(mesh: SpatialMeshResource) {\n await WebSpatial.updateResource(this._resource, {\n meshResource: mesh._resource.id,\n })\n }\n\n /**\n * Sets the materials that should be applied to the mesh\n * @param materials array of materials to set\n */\n async setMaterials(materials: Array<SpatialPhysicallyBasedMaterialResource>) {\n this.cachedMaterials = materials\n await WebSpatial.updateResource(this._resource, {\n materials: materials.map(m => {\n m._addToComponent(this)\n return m._resource.id\n }),\n })\n }\n\n /** @hidden */\n async _syncMaterials() {\n await this.setMaterials(this.cachedMaterials)\n }\n}\n","import { WebSpatial } from '../private/WebSpatial'\nimport { SpatialComponent } from './SpatialComponent'\n\n/**\n * Represenets a volume that can be added to the webpage\n * Child entities will be added within this volume's space\n * Defaults to having 1x1x1 meter dimensions\n * Resolution defaults to 100x100 pixels\n * Only will be displayed on entities in \"ROOT\" or \"DOM\" space\n * If the resolution of the spatial view is not a square, the volume will be larger based on the ratio with the shortest side being 1 meter.\n * (eg. 200x100 = 2m x 1m x 1m volume)\n */\nexport class SpatialViewComponent extends SpatialComponent {\n /**\n * Sets the resolution of the spatial view in dom pixels\n */\n async setResolution(width: number, height: number) {\n await WebSpatial.updateResource(this._resource, {\n resolution: { x: width, y: height },\n })\n }\n\n /**\n * Sets if content of the spatialView should be within a portal\n * If true, volume will be behind the page, if false, it will be in front of the page\n */\n async setIsPortal(isPortal: Boolean) {\n await WebSpatial.updateResource(this._resource, {\n isPortal: isPortal,\n })\n }\n}\n","import { EventSpatialComponent } from './EventSpatialComponent'\nimport { WebSpatial } from '../private/WebSpatial'\nimport { Vec3 } from '../SpatialTransform'\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 type TapEvent = {\n eventType: 'tap'\n}\n\n/**\n * Used to position a model3d in 3D space\n */\nexport class SpatialModel3DComponent extends EventSpatialComponent {\n protected override onRecvEvent(data: any): void {\n const { eventType, value, error } = data\n switch (eventType) {\n case 'phase':\n if (value === 'success') {\n this.onSuccess?.()\n } else {\n this.onFailure?.(error as string)\n }\n break\n case 'dragstart':\n this._onDragStart?.(value)\n break\n case 'dragend':\n this._onDragEnd?.(value)\n break\n case 'drag':\n this._onDrag?.(value)\n break\n case 'tap':\n this._onTap?.()\n break\n case 'doubletap':\n this._onDoubleTap?.()\n break\n case 'longpress':\n this._onLongPress?.()\n break\n\n default:\n break\n }\n }\n /**\n * Sets the resolution of the spatial view in dom pixels\n */\n async setResolution(width: number, height: number) {\n await WebSpatial.updateResource(this._resource, {\n resolution: { x: width, y: height },\n })\n }\n\n async setRotationAnchor(rotationAnchor: Vec3) {\n await WebSpatial.updateResource(this._resource, {\n rotationAnchor: rotationAnchor,\n })\n }\n\n /**\n * Sets the opacity of the model\n * @param opacity\n */\n async setOpacity(opacity: number) {\n await WebSpatial.updateResource(this._resource, {\n opacity,\n })\n }\n\n /**\n * Sets how the model fill the rect\n * @param contentMode\n */\n async setContentMode(contentMode: 'fill' | 'fit') {\n await WebSpatial.updateResource(this._resource, {\n contentMode,\n })\n }\n\n /**\n * Constrains this model dimensions to the specified aspect ratio.\n * with a value of 0, the model will use the original aspect ratio.\n *\n * @param aspectRatio number\n */\n async setAspectRatio(aspectRatio: number) {\n await WebSpatial.updateResource(this._resource, {\n aspectRatio,\n })\n }\n\n /**\n * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements\n * @param scrollWithParent value to set\n */\n async setScrollWithParent(scrollWithParent: boolean) {\n await WebSpatial.updateResource(this._resource, {\n scrollWithParent: scrollWithParent,\n })\n }\n\n /**\n * Sets whether the model appear in original size or fit the rect\n * @param resizable\n */\n async setResizable(resizable: boolean) {\n await WebSpatial.updateResource(this._resource, {\n resizable,\n })\n }\n\n /**\n * Callback fired when model load success\n */\n public onSuccess?: () => void\n\n /**\n * Callback fired when model load failure\n * @param errorReason\n */\n public onFailure?: (errorReason: string) => void\n\n /**\n * Callback fired when model was dragged at the beginning\n * @param dragEvent\n */\n private _onDragStart?: (dragEvent: SpatialModelDragEvent) => void\n public set onDragStart(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this._onDragStart !== callback) {\n this._onDragStart = callback\n WebSpatial.updateResource(this._resource, {\n enableDragEvent: this.enableDragEvent,\n })\n }\n }\n\n /**\n * Callback fired when model was dragged\n * @param dragEvent\n */\n private _onDrag?: (dragEvent: SpatialModelDragEvent) => void\n public set onDrag(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this._onDrag !== callback) {\n this._onDrag = callback\n WebSpatial.updateResource(this._resource, {\n enableDragEvent: this.enableDragEvent,\n })\n }\n }\n\n /**\n * Callback fired when model was dragged at the ending\n * @param dragEvent\n */\n private _onDragEnd?: (dragEvent: SpatialModelDragEvent) => void\n public set onDragEnd(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this._onDragEnd !== callback) {\n this._onDragEnd = callback\n WebSpatial.updateResource(this._resource, {\n enableDragEvent: this.enableDragEvent,\n })\n }\n }\n\n private get enableDragEvent(): boolean {\n return (\n undefined !== this._onDrag ||\n undefined !== this._onDragStart ||\n undefined !== this._onDragEnd\n )\n }\n\n /**\n * Callback fired when model was tapped\n */\n private _onTap?: () => void\n public set onTap(callback: (() => void) | undefined) {\n if (this._onTap !== callback) {\n this._onTap = callback\n WebSpatial.updateResource(this._resource, {\n enableTapEvent: undefined !== callback,\n })\n }\n }\n\n /** Callback fired when model was double tapped */\n private _onDoubleTap?: () => void\n public set onDoubleTap(callback: (() => void) | undefined) {\n if (this._onDoubleTap !== callback) {\n this._onDoubleTap = callback\n WebSpatial.updateResource(this._resource, {\n enableDoubleTapEvent: undefined !== callback,\n })\n }\n }\n\n /** Callback fired when model was long pressed */\n private _onLongPress?: () => void\n public set onLongPress(callback: (() => void) | undefined) {\n if (this._onLongPress !== callback) {\n this._onLongPress = callback\n WebSpatial.updateResource(this._resource, {\n enableLongPressEvent: undefined !== callback,\n })\n }\n }\n}\n","import { SpatialObject } from '../SpatialObject'\n\n/**\n * Mesh asset containing geometry\n */\nexport class SpatialMeshResource extends SpatialObject {}\n","import { SpatialModelComponent } from '../component'\nimport { WebSpatial } from '../private/WebSpatial'\nimport { SpatialObject } from '../SpatialObject'\n\n/**\n * PBR material which can be set on a SpatialModelComponent\n */\nexport class SpatialPhysicallyBasedMaterialResource extends SpatialObject {\n /**\n * Base color of the material containing rgba between 0 and 1\n */\n baseColor = { r: 0.0, g: 0.7, b: 0.7, a: 1.0 }\n /**\n * PBR metalic value between 0 and 1\n */\n metallic = { value: 0.5 }\n /**\n * PBR roughness value between 0 and 1\n */\n roughness = { value: 0.5 }\n\n _modelComponentAttachedTo: { [key: string]: SpatialModelComponent } = {}\n _addToComponent(c: SpatialModelComponent) {\n this._modelComponentAttachedTo[c._resource.id] = c\n }\n\n /**\n * Syncs state of color, metallic, roupghness to the renderer\n */\n async update() {\n await WebSpatial.updateResource(this._resource, {\n baseColor: this.baseColor,\n metallic: this.metallic,\n roughness: this.roughness,\n })\n\n // Since realitykit's materials are structs and not references, every time we change a material, we must copy it to all of the components its attached to to observe the update\n for (var key in this._modelComponentAttachedTo) {\n await this._modelComponentAttachedTo[key]._syncMaterials()\n }\n }\n}\n","import {\n WebSpatial,\n WebSpatialResource,\n WindowContainer,\n} from './private/WebSpatial'\nimport { SpatialEntity } from './SpatialEntity'\n\n/**\n * Anchored window managed by the OS\n */\nexport class SpatialWindowContainer {\n /** @hidden */\n constructor(\n /** @hidden */\n public _wg: WindowContainer,\n ) {}\n /**\n * @hidden\n * Sets sets the open configuration for opening new window containers\n * @param options style options\n */\n async _setOpenSettings(options: {\n resolution: { width: number; height: number }\n }) {\n await WebSpatial.updateWindowContainer(this._wg, {\n nextOpenSettings: options,\n })\n }\n\n /**\n * Retrieves the root entity of the windowContainer\n * @returns the root entity of the windowContainer if one exists\n */\n async getRootEntity() {\n let reqResp: any = await WebSpatial.updateWindowContainer(this._wg, {\n getRootEntityID: '',\n })\n if (reqResp.data.rootEntId === '') {\n return null\n } else {\n var res = new WebSpatialResource()\n res.id = reqResp.data.rootEntId\n return new SpatialEntity(res)\n }\n }\n /*\n * Sets the root entity that this windowContainer will display (this does not effect resource ownership)\n * @param entity to display\n */\n async setRootEntity(entity: SpatialEntity) {\n await entity._setParentWindowContainer(this)\n }\n}\n","import { SpatialEntity } from './SpatialEntity'\nimport { SpatialWindowContainer } from './SpatialWindowContainer'\nimport {\n WebSpatial,\n WebSpatialResource,\n WindowContainer,\n} from './private/WebSpatial'\nimport {\n LoadingMethodKind,\n sceneDataShape,\n WindowContainerOptions,\n WindowStyle,\n} from './types'\n\nimport {\n SpatialMeshResource,\n SpatialPhysicallyBasedMaterialResource,\n} from './resource'\nimport {\n SpatialModelComponent,\n SpatialInputComponent,\n SpatialWindowComponent,\n SpatialViewComponent,\n SpatialModel3DComponent,\n} from './component'\nimport { RemoteCommand } from './private/remote-command'\n\ntype CreateResourceOptions = {\n windowContainer?: SpatialWindowContainer | null\n windowComponent?: SpatialWindowComponent | null\n}\n\n/**\n * Animation callback with timestamp\n */\ntype animCallback = (time: DOMHighResTimeStamp) => Promise<any>\n\n/**\n * Parses the resource owners of the created object. If unedfined, will use the current window container and web panel. If null the created resource will not be destroyed unless explicitly destroyed.\n * @param options\n * @returns parsed results\n */\nfunction _parseParentResources(\n options?: CreateResourceOptions,\n): [WindowContainer | null, WebSpatialResource | null] {\n var parentWindowContainer: WindowContainer | null = null\n if (options?.windowContainer !== null) {\n parentWindowContainer = options?.windowContainer\n ? options?.windowContainer._wg\n : WebSpatial.getCurrentWindowContainer()\n }\n\n var parentWindow: WebSpatialResource | null = null\n if (options?.windowComponent !== null) {\n parentWindow = options?.windowComponent\n ? options?.windowComponent._resource\n : WebSpatial.getCurrentWebPanel()\n }\n\n return [parentWindowContainer, parentWindow]\n}\n\n/**\n * Session use to establish a connection to the spatial renderer of the system. All resources must be created by the session\n */\nexport class SpatialSession {\n /** @hidden */\n _engineUpdateListeners = Array<animCallback>()\n /** @hidden */\n _frameLoopStarted = false\n\n /**\n * Add event listener callback to be called each frame\n * @param callback callback to be called each update\n */\n addOnEngineUpdateEventListener(callback: animCallback) {\n this._engineUpdateListeners.push(callback)\n\n if (!this._frameLoopStarted) {\n this._frameLoopStarted = true\n WebSpatial.onFrame(async (time: number) => {\n await Promise.all(\n this._engineUpdateListeners.map(cb => {\n return cb(time)\n }),\n )\n })\n }\n }\n\n /**\n * Creates a Entity\n * @returns Entity\n */\n async createEntity(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'Entity',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialEntity(entity)\n }\n\n /**\n * Creates a WindowComponent\n * [TODO] should creation of components be moved to entity? and these made private?\n * @returns WindowComponent\n */\n async createWindowComponent(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'SpatialWebView',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialWindowComponent(entity)\n }\n\n /**\n * Creates a ViewComponent used to display 3D content within the entity\n * @returns SpatialViewComponent\n */\n async createViewComponent(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'SpatialView',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialViewComponent(entity)\n }\n\n /**\n * Creates a ModelComponent used to display geometry + material of a 3D model\n * @returns ModelComponent\n */\n async createModelComponent(\n options?: { url: string } & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n var opts = undefined\n if (options) {\n opts = { modelURL: options.url }\n }\n let entity = await WebSpatial.createResource(\n 'ModelComponent',\n parentWindowContainer,\n parentWindow,\n opts,\n )\n return new SpatialModelComponent(entity)\n }\n\n /**\n * Creates a Model3DComponent\n * @returns Model3DComponent\n */\n async createModel3DComponent(\n options?: { url: string } & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n var opts = undefined\n if (options) {\n opts = { modelURL: options.url }\n }\n let entity = await WebSpatial.createResource(\n 'Model3DComponent',\n parentWindowContainer,\n parentWindow,\n opts,\n )\n return new SpatialModel3DComponent(entity)\n }\n\n /**\n * Creates a InputComponent\n * [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model\n * @returns InputComponent\n */\n async createInputComponent(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'InputComponent',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialInputComponent(entity)\n }\n\n /**\n * Creates a MeshResource containing geometry data\n * @returns MeshResource\n */\n async createMeshResource(\n options?: { shape?: string } & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'MeshResource',\n parentWindowContainer,\n parentWindow,\n options,\n )\n return new SpatialMeshResource(entity)\n }\n\n /**\n * Creates a PhysicallyBasedMaterial containing PBR material data\n * @returns PhysicallyBasedMaterial\n */\n async createPhysicallyBasedMaterialResource(\n options?: {} & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'PhysicallyBasedMaterial',\n parentWindowContainer,\n parentWindow,\n options,\n )\n return new SpatialPhysicallyBasedMaterialResource(entity)\n }\n /**\n * Creates a WindowContainer\n * @returns SpatialWindowContainer\n * */\n async createWindowContainer(\n options?: {\n style: WindowStyle\n } & CreateResourceOptions,\n ) {\n var style = options?.style ? options?.style : 'Plain'\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n return new SpatialWindowContainer(\n await WebSpatial.createWindowContainer(\n style,\n parentWindowContainer,\n parentWindow,\n ),\n )\n }\n\n /**\n * Creates a Scene to display content within an anchored area managed by the OS\n * @hidden\n * @param {WindowStyle} [style='Plain'] - The style of the Scene container to be created with. Defaults to 'Plain'.\n * @param {Object} [cfg={}] - Configuration object for the Scene.\n * @returns Boolean\n */\n async _createScene(\n style: WindowStyle = 'Plain',\n cfg: {\n sceneData: sceneDataShape\n },\n ) {\n return await WebSpatial.createScene(style, cfg)\n }\n\n /**\n * Retrieves the window for this page\n * @returns the window component corresponding to the js running on this page\n * [TODO] discuss implications of this not being async\n */\n getCurrentWindowComponent() {\n return new SpatialWindowComponent(WebSpatial.getCurrentWebPanel())\n }\n\n /**\n * Retrieves the parent window for this page or null if this is the root page\n * @returns the window component or null\n */\n async getParentWindowComponent() {\n let parentResp: any = await WebSpatial.updateResource(\n WebSpatial.getCurrentWebPanel(),\n { getParentID: '' },\n )\n if (parentResp.data.parentID === '') {\n return new Promise<SpatialWindowComponent | null>((res, rej) => {\n res(null)\n })\n } else {\n var res = new WebSpatialResource()\n res.id = parentResp.data.parentID\n return new SpatialWindowComponent(res)\n }\n }\n\n /**\n * Logs a message to the native apps console\n * @param msg mesage to log\n */\n async log(...msg: any[]) {\n await WebSpatial.sendCommand(\n new RemoteCommand('log', {\n logString: msg.map(x => {\n return JSON.stringify(x)\n }),\n }),\n )\n }\n\n /**\n * @hidden\n * Debugging only, used to ping the native renderer\n */\n async _ping(msg: string) {\n return await WebSpatial.ping(msg)\n }\n\n /**\n * @hidden\n * Debugging to get internal state from native code\n * @returns data as a js object\n */\n async _getStats() {\n return (await WebSpatial.getStats()) as { objects: any; refObjects: any }\n }\n\n /**\n * @hidden\n */\n async _inspect(spatialObjectId: string = WebSpatial.getCurrentWebPanel().id) {\n return WebSpatial.inspect(spatialObjectId)\n }\n\n /**\n * @hidden\n */\n async _inspectRootWindowContainer() {\n return WebSpatial.inspectRootWindowContainer()\n }\n\n /** Opens the immersive space */\n async openImmersiveSpace() {\n return await WebSpatial.openImmersiveSpace()\n }\n\n /** Closes the immersive space */\n async dismissImmersiveSpace() {\n return await WebSpatial.dismissImmersiveSpace()\n }\n\n private static _immersiveWindowContainer =\n null as null | SpatialWindowContainer\n /**\n * Retreives the window container corresponding to the Immersive space\n * @returns the immersive window container\n */\n async getImmersiveWindowContainer() {\n if (SpatialSession._immersiveWindowContainer) {\n return SpatialSession._immersiveWindowContainer\n } else {\n SpatialSession._immersiveWindowContainer = new SpatialWindowContainer(\n WebSpatial.getImmersiveWindowContainer(),\n )\n return SpatialSession._immersiveWindowContainer\n }\n }\n\n // Retreives the window container that is the parent to this spatial web page\n private static _currentWindowContainer = null as null | SpatialWindowContainer\n\n /**\n * Gets the current window container for the window\n * [TODO] discuss what happens if it doesnt yet have a window container\n * @returns the current window container for the window\n */\n getCurrentWindowContainer() {\n if (SpatialSession._currentWindowContainer) {\n return SpatialSession._currentWindowContainer\n } else {\n SpatialSession._currentWindowContainer = new SpatialWindowContainer(\n WebSpatial.getCurrentWindowContainer(),\n )\n return SpatialSession._currentWindowContainer\n }\n }\n\n /**\n * Start a transaction that queues up commands to submit them all at once to reduce ipc overhead\n * @param fn function to be run, within this function, promises will not resolve\n * @returns promise for the entire transaction completion\n */\n transaction(fn: Function) {\n WebSpatial.startTransaction()\n fn()\n return WebSpatial.sendTransaction()\n }\n\n /**\n * Creates a window context object that is compatable with SpatialWindowComponent's setFromWindow API\n * @returns window context\n */\n async createWindowContext() {\n let openedWindow = window.open('webspatial://createWindowContext')\n if (WebSpatial.getBackend() != 'AVP') {\n // Currently there is a bug with webview which requires us to trigger a navigation before native code can interact with created webview\n var counter = 0\n while ((openedWindow!.window as any).testAPI == null) {\n if (counter > 15) {\n openedWindow?.close()\n openedWindow = window.open('about:blank')\n counter = 0\n this.log('unexpected error when trying to open new window, retrying.')\n }\n var locName = 'about:blank?x' + counter\n openedWindow!!.location.href = locName\n counter++\n\n await new Promise(resolve => setTimeout(resolve, 10))\n }\n ;(openedWindow! as any)._webSpatialID = (\n openedWindow!.window as any\n ).testAPI.getWindowID()\n } else {\n while ((openedWindow!.window as any)._webSpatialID == undefined) {\n await new Promise(resolve => setTimeout(resolve, 10))\n }\n }\n openedWindow!.document.head.innerHTML = `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <base href=\"${document.baseURI}\">\n `\n return openedWindow\n }\n\n // Get Entity by id. Currently for debugging only.\n /** @hidden */\n async _getEntity(id: string) {\n const entityInfo = await WebSpatial.inspect(id)\n const [_, x, y, z] = entityInfo.position.match(/(\\d+\\.?\\d*)/g)\n const [__, sx, sy, sz] = entityInfo.scale.match(/(\\d+\\.?\\d*)/g)\n\n var res = new WebSpatialResource()\n res.id = id\n res.windowContainerId = WebSpatial.getCurrentWindowContainer().id\n const entity = new SpatialEntity(res)\n entity.transform.position.x = parseFloat(x)\n entity.transform.position.y = parseFloat(y)\n entity.transform.position.z = parseFloat(z)\n\n entity.transform.scale.x = parseFloat(sx)\n entity.transform.scale.y = parseFloat(sy)\n entity.transform.scale.z = parseFloat(sz)\n\n return entity\n }\n // set loading view.\n /** @hidden */\n async setLoading(method: LoadingMethodKind, style?: string) {\n return WebSpatial.setLoading(method, style)\n }\n}\n","import { SpatialSession } from './SpatialSession'\n\n/**\n * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr\n */\nexport class Spatial {\n /**\n * Requests a session object from the browser\n * @returns The session or null if not availible in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n if (\n this.isSupported() &&\n this.getNativeVersion() === this.getClientVersion()\n ) {\n return new SpatialSession()\n } else {\n return null\n }\n }\n\n /**\n * @returns true if web spatial is supported by this webpage\n */\n isSupported() {\n return (\n (window as any).WebSpatailEnabled &&\n this.getNativeVersion() === this.getClientVersion()\n )\n }\n\n /**\n * Gets the native version, format is \"x.x.x\"\n * @returns native version string\n */\n getNativeVersion() {\n return (window as any).WebSpatailNativeVersion\n }\n\n /**\n * Gets the client version, format is \"x.x.x\"\n * @returns client version string\n */\n getClientVersion() {\n return '0.0.1'\n }\n}\n","import { SpatialViewComponent, StyleParam } from './component'\nimport { Spatial } from './Spatial'\nimport { SpatialEntity } from './SpatialEntity'\nimport { SpatialSession } from './SpatialSession'\nimport { Vec3 } from './SpatialTransform'\n\n/**\n * Helper class used to quickly add spatial content to standard web pages\n * [Experimental] expect APIs to potentially change in future versions\n */\nexport class SpatialHelper {\n private static _instance: SpatialHelper | null = null\n static get instance() {\n if (this._instance) {\n return this._instance\n } else {\n let spatial = new Spatial()\n if (spatial.isSupported()) {\n let session = spatial.requestSession()\n if (session) {\n this._instance = new SpatialHelper(session)\n return this._instance\n }\n }\n }\n return null\n }\n\n constructor(public session: SpatialSession) {}\n\n shape = {\n createShapeEntity: async (shape = 'box') => {\n var box = await this.session.createMeshResource({ shape: shape })\n var mat = await this.session.createPhysicallyBasedMaterialResource()\n await mat.update()\n\n var customModel = await this.session.createModelComponent()\n customModel.setMaterials([mat])\n customModel.setMesh(box)\n\n var boxEntity = await this.session.createEntity()\n await boxEntity.setComponent(customModel)\n boxEntity.transform.position.z = 0\n boxEntity.transform.scale = new Vec3(0.5, 0.5, 0.5)\n await boxEntity.updateTransform()\n return boxEntity\n },\n createModelEntity: async (url: string) => {\n var customModel = await this.session.createModelComponent({ url })\n var boxEntity = await this.session.createEntity()\n await boxEntity.setComponent(customModel)\n await boxEntity.updateTransform()\n return boxEntity\n },\n wrapInBoundingBoxEntity: async (entityToWrap: SpatialEntity) => {\n var bb = await entityToWrap.getBoundingBox()\n\n // Scale to fit\n var targetSize = 1.0\n var scale =\n targetSize / Math.max(bb.extents.x, bb.extents.y, bb.extents.z)\n entityToWrap.transform.scale.x = scale\n entityToWrap.transform.scale.y = scale\n entityToWrap.transform.scale.z = scale\n\n // Center within view\n entityToWrap.transform.position.x = -bb.center.x * scale\n entityToWrap.transform.position.y = -bb.center.y * scale\n entityToWrap.transform.position.z = -bb.center.z * scale\n await entityToWrap.updateTransform()\n\n // wrap in boudning box\n var boudningEntity = await SpatialHelper.instance?.session.createEntity()!\n await entityToWrap.setParent(boudningEntity!)\n return boudningEntity\n },\n }\n\n navigation = {\n openPanel: async (\n url: string,\n options?: { resolution: { width: number; height: number } },\n ) => {\n if (options?.resolution) {\n await this.session\n .getCurrentWindowContainer()\n ._setOpenSettings({ resolution: options.resolution })\n }\n\n // Create window container\n var wg = await this.session.createWindowContainer({\n style: 'Plain',\n windowComponent: null,\n windowContainer: null,\n })\n\n // Create a root entity displaying a webpage\n var ent = await this.session!.createEntity({\n windowComponent: null,\n windowContainer: wg,\n })\n var i = await this.session!.createWindowComponent({\n windowComponent: null,\n windowContainer: wg,\n })\n await i.loadURL(url)\n await ent.setCoordinateSpace('Root')\n await ent.setComponent(i)\n\n // Add enitity the window container\n await wg.setRootEntity(ent)\n\n // Restore default size\n await this.session\n .getCurrentWindowContainer()\n ._setOpenSettings({ resolution: { width: 900, height: 700 } })\n },\n openVolume: async (\n url: string,\n options?: { resolution: { width: number; height: number } },\n ) => {\n var wg = await this.session.createWindowContainer({\n style: 'Volumetric',\n windowComponent: null,\n windowContainer: null,\n })\n\n // Create a root view entity within the window container\n var rootEnt = await this.session!.createEntity({\n windowComponent: null,\n windowContainer: wg,\n })\n await rootEnt.setComponent(\n await this.session!.createViewComponent({\n windowComponent: null,\n windowContainer: wg,\n }),\n )\n await rootEnt.setCoordinateSpace('Root')\n await wg.setRootEntity(rootEnt)\n\n // Add webpage to the window container\n var ent = await this.session!.createEntity({\n windowComponent: null,\n windowContainer: wg,\n })\n var i = await this.session!.createWindowComponent({\n windowComponent: null,\n windowContainer: wg,\n })\n await i.loadURL(url)\n if (options?.resolution) {\n await i.setResolution(\n options.resolution.width,\n options.resolution.height,\n )\n } else {\n await i.setResolution(1000, 1000)\n }\n ent.transform.position.z = -0.49\n await ent.updateTransform()\n await ent.setCoordinateSpace('App')\n await ent.setComponent(i)\n await ent.setParent(rootEnt)\n },\n }\n\n dom = {\n attachSpatialView: async (divOnPage: HTMLElement) => {\n // Create SpatialView\n var viewEnt = await this.session.createEntity()\n await viewEnt.setCoordinateSpace('Dom') // Set coordinate space so its transform is relative to the webpage's pixels\n await viewEnt.setComponent(await this.session.createViewComponent())\n\n // Add to the root window component to display\n var wc = await this.session.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await viewEnt.setParent(ent!)\n\n // Keep spatialView positioned where the div is\n var update = () => {\n var rect = divOnPage.getBoundingClientRect()\n viewEnt.transform.position.x = rect.x + rect.width / 2\n viewEnt.transform.position.y = rect.y + rect.height / 2 + window.scrollY\n viewEnt.updateTransform()\n viewEnt\n .getComponent(SpatialViewComponent)!\n .setResolution(rect.width, rect.height)\n }\n var mo = new MutationObserver(update)\n mo.observe(divOnPage, { attributes: true })\n var ro = new ResizeObserver(update)\n ro.observe(divOnPage)\n const addRemoveObserver = new MutationObserver(mutations => {\n mutations.forEach(mutation => {\n mutation.removedNodes.forEach(node => {\n if (node instanceof HTMLElement) {\n update()\n }\n })\n mutation.addedNodes.forEach(node => {\n if (node instanceof HTMLElement) {\n update()\n }\n })\n })\n })\n addRemoveObserver.observe(document.body, {\n childList: true,\n subtree: true,\n })\n update()\n return {\n entity: viewEnt,\n }\n },\n }\n\n setBackgroundStyle = async (\n style: StyleParam,\n backgroundColor = '#00000000',\n ) => {\n document.documentElement.style.backgroundColor = backgroundColor\n await this.session!.getCurrentWindowComponent().setStyle(style)\n }\n}\n"],"mappings":";AAAO,IAAM,gBAAN,MAAM,eAAc;AAAA,EACzB,OAAe,iBAAiB;AAAA,EAEhC;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA,YAAY,KAAa,MAAY;AACnC,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,SAAK,YAAY,EAAE,eAAc;AAAA,EACnC;AACF;;;ACLO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,KAAK;AACP;AAEO,IAAM,qBAAN,MAAyB;AAAA,EAC9B,KAAK;AAAA,EACL,oBAAoB;AAAA,EACpB,OAAO,CAAC;AAAA,EAER,eAAe;AAAA,EAAC;AAClB;AAEO,IAAM,aAAN,MAAM,YAAW;AAAA,EACtB,OAAc,gBAAqB,CAAC;AAAA,EAEpC,OAAc,qBAAqB;AAAA,EACnC,OAAc,sBAAsB,MAAqB;AAAA;AAAA,EAGzD,OAAe,iBACb,CAAC;AAAA,EAEH,OAAc,sBACZ,YACA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,cAAc,KAAK,OAAO,KAAK,MAAM;AAAA,MAC1C;AACA,UAAI,KAAK,IAAI,iBAAiB,MAAM;AACpC,SAAG,QAAQ,WAAW,EAAE,YAAY,KAAK,CAAC;AAC1C,UAAI,KAAK,IAAI,eAAe,MAAM;AAClC,SAAG,QAAQ,SAAS;AACpB,YAAM,oBAAoB,IAAI,iBAAiB,eAAa;AAC1D,kBAAU,QAAQ,cAAY;AAC5B,mBAAS,aAAa,QAAQ,UAAQ;AACpC,gBAAI,gBAAgB,aAAa;AAC/B,qBAAO;AAAA,YACT;AAAA,UACF,CAAC;AACD,mBAAS,WAAW,QAAQ,UAAQ;AAClC,gBAAI,gBAAgB,aAAa;AAC/B,qBAAO;AAAA,YACT;AAAA,UACF,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AACD,wBAAkB,QAAQ,SAAS,MAAM;AAAA,QACvC,WAAW;AAAA,QACX,SAAS;AAAA,MACX,CAAC;AACD,aAAO;AACP,aAAO;AAAA,QACL,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA,EAEA,qBAAqB,OACnB,OACA,kBAAkB,gBACf;AACH,aAAS,gBAAgB,MAAM,kBAAkB;AACjD,UAAM,KAAK,QAAS,0BAA0B,EAAE,SAAS,KAAK;AAAA,EAChE;AACF;","names":["res","res","window","res"]}
1
+ {"version":3,"sources":["../src/core/private/remote-command/RemoteCommand.ts","../src/core/private/WebSpatial.ts","../src/core/SpatialObject.ts","../src/core/SpatialTransform.ts","../src/core/SpatialEntity.ts","../src/core/component/SpatialComponent.ts","../src/core/SpatialWindowContainer.ts","../src/core/resource/SpatialMeshResource.ts","../src/core/resource/SpatialPhysicallyBasedMaterialResource.ts","../src/core/SpatialSession.ts","../src/core/Spatial.ts","../src/core/SpatialHelper.ts","../src/core/component/SpatialWindowComponent.ts","../src/core/component/EventSpatialComponent.ts","../src/core/component/SpatialInputComponent.ts","../src/core/component/SpatialModelComponent.ts","../src/core/component/SpatialViewComponent.ts","../src/core/component/SpatialModel3DComponent.ts"],"sourcesContent":["export class RemoteCommand {\n private static requestCounter = 0\n\n command: string\n\n data: any\n\n requestID: number\n\n constructor(cmd: string, data?: any) {\n this.command = cmd\n this.data = data\n this.requestID = ++RemoteCommand.requestCounter\n }\n}\n","import { RemoteCommand } from './remote-command'\nimport {\n WindowStyle,\n WindowContainerOptions,\n LoadingMethodKind,\n sceneDataShape,\n sceneDataJSBShape,\n} from '../types'\n\ndeclare global {\n interface Window {\n // Location for webspatial custom functions\n __WebSpatialData: {\n androidNativeMessage: Function\n getNativeVersion: Function\n }\n\n // Location for webspatial internal callbacks (eg. completion events)\n __SpatialWebEvent: Function\n\n // Used to access webkit specific api\n webkit: any\n\n // Marks the page as unloaded so it doesn't send additional events\n __WebSpatialUnloaded: boolean\n\n // Internal id information mapping to internal state about the native window\n _webSpatialID: string\n _webSpatialGroupID: string\n _webSpatialParentGroupID: string\n\n // Will be removed in favor of __WebSpatialData\n WebSpatailNativeVersion: string\n }\n}\n\nexport class WindowContainer {\n id = ''\n}\n\nexport class WebSpatialResource {\n id = ''\n windowContainerId = ''\n data = {} as any\n\n receiveEvent() {}\n}\n\nexport class WebSpatial {\n public static eventPromises: any = {}\n\n public static transactionStarted = false\n public static transactionCommands = Array<RemoteCommand>()\n\n // store event receivers\n private static eventReceivers: { [resourceId: string]: (data: any) => void } =\n {}\n\n public static registerEventReceiver(\n resourceId: string,\n callback: (data: any) => void,\n ) {\n this.eventReceivers[resourceId] = callback\n }\n\n public static unregisterEventReceiver(resourceId: string) {\n delete this.eventReceivers[resourceId]\n }\n\n static init() {\n window.__SpatialWebEvent = (e: any) => {\n if (e.resourceId) {\n var callback = WebSpatial.eventReceivers[e.resourceId]\n callback(e.data)\n } else {\n var p = WebSpatial.eventPromises[e.requestID]\n if (p) {\n if (e.success) {\n p.res(e)\n } else {\n p.rej(e)\n }\n }\n }\n }\n }\n\n static startTransaction() {\n WebSpatial.transactionStarted = true\n WebSpatial.transactionCommands = []\n }\n\n static async sendTransaction() {\n WebSpatial.transactionStarted = false\n var cmd = new RemoteCommand('multiCommand', {\n commandList: WebSpatial.transactionCommands,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static getBackend() {\n if (window.webkit) {\n return 'AVP'\n } else {\n return 'UNKNOWN'\n }\n }\n\n static async sendCommand(cmd: RemoteCommand) {\n if (window.__WebSpatialUnloaded) {\n return\n }\n if (WebSpatial.transactionStarted) {\n WebSpatial.transactionCommands.push(cmd as any)\n return\n }\n\n var msg = JSON.stringify(cmd)\n\n if (WebSpatial.getBackend() == 'AVP') {\n window.webkit.messageHandlers.bridge.postMessage(msg)\n return\n } else {\n window.__WebSpatialData.androidNativeMessage(msg)\n return\n }\n }\n\n static getImmersiveWindowContainer() {\n var wg = new WindowContainer()\n wg.id = 'Immersive'\n return wg\n }\n\n static getCurrentWindowContainer() {\n var wg = new WindowContainer()\n wg.id = 'current'\n return wg\n }\n\n static getCurrentWebPanel() {\n var wg = new WebSpatialResource()\n wg.id = 'current'\n wg.windowContainerId = WebSpatial.getCurrentWindowContainer().id\n return wg\n }\n\n static async createScene(\n style: WindowStyle = 'Plain',\n cfg: {\n sceneData: sceneDataShape\n },\n ) {\n const { window: newWindow, ...sceneData } = cfg.sceneData\n const jsbSceneData: sceneDataJSBShape = {\n ...sceneData,\n windowID: newWindow._webSpatialID,\n windowContainerID: newWindow._webSpatialGroupID,\n }\n var cmd = new RemoteCommand('createScene', {\n windowStyle: style,\n sceneData: jsbSceneData,\n windowContainerID: window._webSpatialParentGroupID, // parent WindowContainerID\n })\n\n try {\n await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return true\n } catch (error) {\n return false\n }\n }\n\n static async createWindowContainer(\n style: WindowStyle = 'Plain',\n windowContainer: WindowContainer | null,\n parentWebView: WebSpatialResource | null,\n ) {\n var cmd = new RemoteCommand('createWindowContainer', {\n windowStyle: style,\n windowContainerID: windowContainer ? windowContainer.id : undefined,\n resourceID: parentWebView ? parentWebView.id : undefined,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n var res = new WindowContainer()\n res.id = (result as any).data.createdID\n return res\n }\n\n static async destroyResource(resource: WebSpatialResource) {\n const data = {}\n var cmd = new RemoteCommand('destroyResource', {\n windowContainerID: resource.windowContainerId,\n resourceID: resource.id,\n })\n\n WebSpatial.sendCommand(cmd)\n }\n\n static async ping(msg: string) {\n var cmd = new RemoteCommand('ping', {\n windowContainerID: this.getCurrentWindowContainer().id,\n resourceID: this.getCurrentWebPanel().id,\n message: msg,\n })\n\n if (WebSpatial.transactionStarted) {\n WebSpatial.sendCommand(cmd)\n return null\n } else {\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n }\n\n static async getStats() {\n var cmd = new RemoteCommand('getStats', {\n windowContainerID: this.getCurrentWindowContainer().id,\n resourceID: this.getCurrentWebPanel().id,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return (result as any).data\n }\n\n static async inspect(spatialObjectId: string) {\n var cmd = new RemoteCommand('inspect', {\n resourceID: spatialObjectId,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n\n return (result as any).data\n }\n\n static async inspectRootWindowContainer() {\n return this.inspect('root')\n }\n\n static async setComponent(\n entity: WebSpatialResource,\n resource: WebSpatialResource,\n ) {\n var cmd = new RemoteCommand('setComponent', {\n windowContainerID: entity.windowContainerId,\n resourceID: resource.id,\n entityID: entity.id,\n })\n\n WebSpatial.sendCommand(cmd)\n }\n\n static async removeComponent(\n entity: WebSpatialResource,\n resource: WebSpatialResource,\n ) {\n var cmd = new RemoteCommand('removeComponent', {\n windowContainerID: entity.windowContainerId,\n resourceID: resource.id,\n entityID: entity.id,\n })\n\n WebSpatial.sendCommand(cmd)\n }\n\n // windowContainer is the group the resource will be tied to (if not provided it will use the current window grou)\n // parentWebView is the SpatialWebView that the resource will be tied to (if not provided, resource will continue to exist even if this page is unloaded)\n static async createResource(\n type: string,\n windowContainer: WindowContainer | null,\n parentWebView: WebSpatialResource | null,\n params = {} as any,\n ) {\n var cmd = new RemoteCommand('createResource', {\n windowContainerID: windowContainer ? windowContainer.id : undefined,\n resourceID: parentWebView ? parentWebView.id : undefined,\n type: type,\n params: params,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n var res = new WebSpatialResource()\n res.id = (result as any).data.createdID\n res.windowContainerId = cmd.data.windowContainerID\n return res\n }\n\n static async updateWindowContainer(wg: WindowContainer, data: any) {\n var cmd = new RemoteCommand('updateWindowContainer', {\n windowContainerID: wg.id,\n update: data,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static async updateResource(resource: WebSpatialResource, data: any = null) {\n var cmd = new RemoteCommand('updateResource', {\n windowContainerID: resource.windowContainerId,\n resourceID: resource.id,\n update: data || resource.data,\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static async setLoading(method: LoadingMethodKind, style?: string) {\n var cmd = new RemoteCommand('setLoading', {\n windowContainerID: window._webSpatialParentGroupID, // parent WindowContainerID\n loading: {\n method,\n style,\n },\n })\n\n var result = await new Promise((res, rej) => {\n WebSpatial.eventPromises[cmd.requestID] = { res: res, rej: rej }\n WebSpatial.sendCommand(cmd)\n })\n return result\n }\n\n static async openImmersiveSpace() {\n var cmd = new RemoteCommand('openImmersiveSpace')\n await WebSpatial.sendCommand(cmd)\n }\n\n static async dismissImmersiveSpace() {\n var cmd = new RemoteCommand('dismissImmersiveSpace')\n await WebSpatial.sendCommand(cmd)\n }\n\n static onFrame(fn: (curTime: number) => Promise<any>) {\n var dt = 0\n var loop = async () => {\n var curTime = window.performance.now()\n await fn(curTime)\n var updateTime = window.performance.now() - curTime\n\n // Call update loop targetting 60 fps\n setTimeout(\n () => {\n loop()\n },\n Math.max(1000 / 60 - updateTime, 0),\n )\n }\n loop()\n }\n}\nWebSpatial.init()\n","import { WebSpatial } from './private/WebSpatial'\nimport { WebSpatialResource } from './private/WebSpatial'\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 _resource: WebSpatialResource,\n ) {}\n\n /**\n * Marks resource to be released (it should no longer be used)\n */\n async destroy() {\n await WebSpatial.destroyResource(this._resource)\n await this.onDestroy()\n }\n\n public name: string = ''\n\n protected async onDestroy() {}\n}\n","export class Vec3 {\n constructor(\n public x = 0,\n public y = 0,\n public z = 0,\n ) {}\n}\n\nexport class Vec4 {\n constructor(\n public x = 0,\n public y = 0,\n public z = 0,\n public w = 1,\n ) {}\n}\n\n/**\n * Transform containing position, orientation and scale\n */\nexport class SpatialTransform {\n position = new Vec3(0, 0, 0)\n /** Quaternion value for x,y,z,w */\n orientation = new Vec4(0, 0, 0, 1)\n scale = new Vec3(1, 1, 1)\n}\n","import { SpatialObject } from './SpatialObject'\nimport { SpatialTransform } from './SpatialTransform'\nimport { SpatialWindowContainer } from './SpatialWindowContainer'\nimport { WebSpatial } from './private/WebSpatial'\nimport { SpatialComponent } from './component'\n\n/**\n * Entity used to describe an object that can be added to the scene\n */\nexport class SpatialEntity extends SpatialObject {\n /**\n * Transform corresponding to the entity\n * note: updateTransform must be called for transform to be synced to rendering\n */\n transform = new SpatialTransform()\n\n /** @hidden */\n private _destroyed = false\n /** @hidden */\n private get _entity() {\n return this._resource\n }\n\n /**\n * Syncs the transform with the renderer, must be called to observe updates\n */\n async updateTransform() {\n await WebSpatial.updateResource(this._entity, this.transform)\n }\n\n /**\n * Syncs the zIndex with the renderer\n */\n async updateZIndex(zIndex: number) {\n await WebSpatial.updateResource(this._entity, { zIndex })\n }\n\n private components: Map<Function, SpatialComponent> = new Map()\n\n /**\n * Attaches a component to the entity to be displayed\n * [TODO] review pass by value vs ref and ownership model for this\n */\n async setComponent(component: SpatialComponent) {\n await WebSpatial.setComponent(this._entity, component._resource)\n this.components.set(component.constructor, component)\n }\n\n /**\n * Removes a component from the entity\n */\n async removeComponent<T extends SpatialComponent>(\n type: new (...args: any[]) => T,\n ) {\n var c = this.getComponent(type)\n if (c != undefined) {\n await WebSpatial.removeComponent(this._entity, c._resource)\n this.components.delete(c.constructor)\n }\n }\n\n /**\n * Gets a component from the entity\n */\n getComponent<T extends SpatialComponent>(\n type: new (...args: any[]) => T,\n ): T | undefined {\n return this.components.get(type) as T | undefined\n }\n\n /**\n * @hidden\n * Sets the window container that this entity should be rendered by (this does not effect resource ownership)\n * @param wg the window container that should render this entity\n */\n async _setParentWindowContainer(wg: SpatialWindowContainer) {\n await WebSpatial.updateResource(this._entity, {\n setParentWindowContainerID: wg._wg.id,\n })\n }\n\n /**\n * Sets a parent entity, if that entity or its parents are attached to a window container, this entity will be displayed\n * @param e parent entity or null to remove current parent\n */\n async setParent(e: SpatialEntity | null) {\n await WebSpatial.updateResource(this._entity, {\n setParent: e ? e._entity.id : '',\n })\n }\n\n /**\n * Sets the coordinate space of this entity (Default: App)\n * \"App\" = game engine style coordinates in meters\n * \"Dom\" = Windowing coordinates in dom units (eg. 0,0,0 is top left of window)\n * \"Root\" = Coordinate space is ignored and content is displayed and updated as window container's root object, window containers can only have one root entity\n * [TODO] review this api\n * @param space coordinate space mode\n */\n async setCoordinateSpace(space: 'App' | 'Dom' | 'Root') {\n await WebSpatial.updateResource(this._entity, { setCoordinateSpace: space })\n }\n\n /**\n * Query the 3d boudning box of the entity\n * @returns The bounding box of the entity\n */\n async getBoundingBox() {\n var res: any = await WebSpatial.updateResource(this._entity, {\n getBoundingBox: true,\n })\n return res.data as {\n center: { x: number; y: number; z: number }\n extents: { x: number; y: number; z: number }\n }\n }\n\n /**\n * Sets if the entity should be visible (default: True)\n * @param visible\n */\n async setVisible(visible: boolean) {\n await WebSpatial.updateResource(this._entity, { visible })\n }\n\n /**\n * Removes a reference to the entity by the renderer and this object should no longer be used. [TODO] Attached components will not be destroyed\n */\n async destroy() {\n this._destroyed = true\n await WebSpatial.destroyResource(this._entity)\n }\n\n /**\n * Check if destroy has been called\n */\n isDestroyed() {\n return this._destroyed\n }\n\n // Set Entity name. Currently for debugging only.\n /** @hidden */\n async _setName(name: string) {\n this.name = name\n return WebSpatial.updateResource(this._entity, { name })\n }\n}\n","import { WebSpatial, WebSpatialResource } from '../private/WebSpatial'\nimport { SpatialEntity } from '../SpatialEntity'\nimport { SpatialObject } from '../SpatialObject'\n\n/** @hidden */\nexport class SpatialComponent extends SpatialObject {\n /**\n * Gets the entity this component is attached to\n * @returns entity or null\n */\n async getEntity() {\n let reqResp: any = await WebSpatial.updateResource(\n WebSpatial.getCurrentWebPanel(),\n { getEntityID: '' },\n )\n if (reqResp.data.parentID === '') {\n return new Promise<SpatialEntity | null>((res, rej) => {\n res(null)\n })\n } else {\n var res = new WebSpatialResource()\n res.id = reqResp.data.parentID\n return new SpatialEntity(res)\n }\n }\n}\n","import {\n WebSpatial,\n WebSpatialResource,\n WindowContainer,\n} from './private/WebSpatial'\nimport { SpatialEntity } from './SpatialEntity'\n\n/**\n * Anchored window managed by the OS\n */\nexport class SpatialWindowContainer {\n /** @hidden */\n constructor(\n /** @hidden */\n public _wg: WindowContainer,\n ) {}\n /**\n * @hidden\n * Sets sets the open configuration for opening new window containers\n * @param options style options\n */\n async _setOpenSettings(options: {\n resolution: { width: number; height: number }\n }) {\n await WebSpatial.updateWindowContainer(this._wg, {\n nextOpenSettings: options,\n })\n }\n\n /**\n * Retrieves the root entity of the windowContainer\n * @returns the root entity of the windowContainer if one exists\n */\n async getRootEntity() {\n let reqResp: any = await WebSpatial.updateWindowContainer(this._wg, {\n getRootEntityID: '',\n })\n if (reqResp.data.rootEntId === '') {\n return null\n } else {\n var res = new WebSpatialResource()\n res.id = reqResp.data.rootEntId\n return new SpatialEntity(res)\n }\n }\n /*\n * Sets the root entity that this windowContainer will display (this does not effect resource ownership)\n * @param entity to display\n */\n async setRootEntity(entity: SpatialEntity) {\n await entity._setParentWindowContainer(this)\n }\n\n async close() {\n await WebSpatial.updateWindowContainer(this._wg, {\n close: true,\n })\n }\n}\n","import { SpatialObject } from '../SpatialObject'\n\n/**\n * Mesh asset containing geometry\n */\nexport class SpatialMeshResource extends SpatialObject {}\n","import { SpatialModelComponent } from '../component'\nimport { WebSpatial } from '../private/WebSpatial'\nimport { SpatialObject } from '../SpatialObject'\n\n/**\n * PBR material which can be set on a SpatialModelComponent\n */\nexport class SpatialPhysicallyBasedMaterialResource extends SpatialObject {\n /**\n * Base color of the material containing rgba between 0 and 1\n */\n baseColor = { r: 0.0, g: 0.7, b: 0.7, a: 1.0 }\n /**\n * PBR metalic value between 0 and 1\n */\n metallic = { value: 0.5 }\n /**\n * PBR roughness value between 0 and 1\n */\n roughness = { value: 0.5 }\n\n _modelComponentAttachedTo: { [key: string]: SpatialModelComponent } = {}\n _addToComponent(c: SpatialModelComponent) {\n this._modelComponentAttachedTo[c._resource.id] = c\n }\n\n /**\n * Syncs state of color, metallic, roupghness to the renderer\n */\n async update() {\n await WebSpatial.updateResource(this._resource, {\n baseColor: this.baseColor,\n metallic: this.metallic,\n roughness: this.roughness,\n })\n\n // Since realitykit's materials are structs and not references, every time we change a material, we must copy it to all of the components its attached to to observe the update\n for (var key in this._modelComponentAttachedTo) {\n await this._modelComponentAttachedTo[key]._syncMaterials()\n }\n }\n}\n","import { SpatialEntity } from './SpatialEntity'\nimport { SpatialWindowContainer } from './SpatialWindowContainer'\nimport {\n WebSpatial,\n WebSpatialResource,\n WindowContainer,\n} from './private/WebSpatial'\nimport {\n LoadingMethodKind,\n sceneDataShape,\n WindowContainerOptions,\n WindowStyle,\n} from './types'\n\nimport {\n SpatialMeshResource,\n SpatialPhysicallyBasedMaterialResource,\n} from './resource'\nimport {\n SpatialModelComponent,\n SpatialInputComponent,\n SpatialWindowComponent,\n SpatialViewComponent,\n SpatialModel3DComponent,\n} from './component'\nimport { RemoteCommand } from './private/remote-command'\n\ntype CreateResourceOptions = {\n windowContainer?: SpatialWindowContainer | null\n windowComponent?: SpatialWindowComponent | null\n}\n\n/**\n * Animation callback with timestamp\n */\ntype animCallback = (time: DOMHighResTimeStamp) => Promise<any>\n\n/**\n * Parses the resource owners of the created object. If unedfined, will use the current window container and web panel. If null the created resource will not be destroyed unless explicitly destroyed.\n * @param options\n * @returns parsed results\n */\nfunction _parseParentResources(\n options?: CreateResourceOptions,\n): [WindowContainer | null, WebSpatialResource | null] {\n var parentWindowContainer: WindowContainer | null = null\n if (options?.windowContainer !== null) {\n parentWindowContainer = options?.windowContainer\n ? options?.windowContainer._wg\n : WebSpatial.getCurrentWindowContainer()\n }\n\n var parentWindow: WebSpatialResource | null = null\n if (options?.windowComponent !== null) {\n parentWindow = options?.windowComponent\n ? options?.windowComponent._resource\n : WebSpatial.getCurrentWebPanel()\n }\n\n return [parentWindowContainer, parentWindow]\n}\n\n/**\n * Session use to establish a connection to the spatial renderer of the system. All resources must be created by the session\n */\nexport class SpatialSession {\n /** @hidden */\n _engineUpdateListeners = Array<animCallback>()\n /** @hidden */\n _frameLoopStarted = false\n\n /**\n * Add event listener callback to be called each frame\n * @param callback callback to be called each update\n */\n addOnEngineUpdateEventListener(callback: animCallback) {\n this._engineUpdateListeners.push(callback)\n\n if (!this._frameLoopStarted) {\n this._frameLoopStarted = true\n WebSpatial.onFrame(async (time: number) => {\n await Promise.all(\n this._engineUpdateListeners.map(cb => {\n return cb(time)\n }),\n )\n })\n }\n }\n\n /**\n * Creates a Entity\n * @returns Entity\n */\n async createEntity(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'Entity',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialEntity(entity)\n }\n\n /**\n * Creates a WindowComponent\n * [TODO] should creation of components be moved to entity? and these made private?\n * @returns WindowComponent\n */\n async createWindowComponent(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'SpatialWebView',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialWindowComponent(entity)\n }\n\n /**\n * Creates a ViewComponent used to display 3D content within the entity\n * @returns SpatialViewComponent\n */\n async createViewComponent(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'SpatialView',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialViewComponent(entity)\n }\n\n /**\n * Creates a ModelComponent used to display geometry + material of a 3D model\n * @returns ModelComponent\n */\n async createModelComponent(\n options?: { url: string } & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n var opts = undefined\n if (options) {\n opts = { modelURL: options.url }\n }\n let entity = await WebSpatial.createResource(\n 'ModelComponent',\n parentWindowContainer,\n parentWindow,\n opts,\n )\n return new SpatialModelComponent(entity)\n }\n\n /**\n * Creates a Model3DComponent\n * @returns Model3DComponent\n */\n async createModel3DComponent(\n options?: { url: string } & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n var opts = undefined\n if (options) {\n opts = { modelURL: options.url }\n }\n let entity = await WebSpatial.createResource(\n 'Model3DComponent',\n parentWindowContainer,\n parentWindow,\n opts,\n )\n return new SpatialModel3DComponent(entity)\n }\n\n /**\n * Creates a InputComponent\n * [Experimental] Creates a InputComponent used to handle click and drag events of the entity containing a model\n * @returns InputComponent\n */\n async createInputComponent(options?: CreateResourceOptions) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'InputComponent',\n parentWindowContainer,\n parentWindow,\n )\n return new SpatialInputComponent(entity)\n }\n\n /**\n * Creates a MeshResource containing geometry data\n * @returns MeshResource\n */\n async createMeshResource(\n options?: { shape?: string } & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'MeshResource',\n parentWindowContainer,\n parentWindow,\n options,\n )\n return new SpatialMeshResource(entity)\n }\n\n /**\n * Creates a PhysicallyBasedMaterial containing PBR material data\n * @returns PhysicallyBasedMaterial\n */\n async createPhysicallyBasedMaterialResource(\n options?: {} & CreateResourceOptions,\n ) {\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n let entity = await WebSpatial.createResource(\n 'PhysicallyBasedMaterial',\n parentWindowContainer,\n parentWindow,\n options,\n )\n return new SpatialPhysicallyBasedMaterialResource(entity)\n }\n /**\n * Creates a WindowContainer\n * @returns SpatialWindowContainer\n * */\n async createWindowContainer(\n options?: {\n style: WindowStyle\n } & CreateResourceOptions,\n ) {\n var style = options?.style ? options?.style : 'Plain'\n var [parentWindowContainer, parentWindow] = _parseParentResources(options)\n return new SpatialWindowContainer(\n await WebSpatial.createWindowContainer(\n style,\n parentWindowContainer,\n parentWindow,\n ),\n )\n }\n\n /**\n * Creates a Scene to display content within an anchored area managed by the OS\n * @hidden\n * @param {WindowStyle} [style='Plain'] - The style of the Scene container to be created with. Defaults to 'Plain'.\n * @param {Object} [cfg={}] - Configuration object for the Scene.\n * @returns Boolean\n */\n async _createScene(\n style: WindowStyle = 'Plain',\n cfg: {\n sceneData: sceneDataShape\n },\n ) {\n return await WebSpatial.createScene(style, cfg)\n }\n\n /**\n * Retrieves the window for this page\n * @returns the window component corresponding to the js running on this page\n * [TODO] discuss implications of this not being async\n */\n getCurrentWindowComponent() {\n return new SpatialWindowComponent(WebSpatial.getCurrentWebPanel())\n }\n\n /**\n * Retrieves the parent window for this page or null if this is the root page\n * @returns the window component or null\n */\n async getParentWindowComponent() {\n let parentResp: any = await WebSpatial.updateResource(\n WebSpatial.getCurrentWebPanel(),\n { getParentID: '' },\n )\n if (parentResp.data.parentID === '') {\n return new Promise<SpatialWindowComponent | null>((res, rej) => {\n res(null)\n })\n } else {\n var res = new WebSpatialResource()\n res.id = parentResp.data.parentID\n return new SpatialWindowComponent(res)\n }\n }\n\n /**\n * Logs a message to the native apps console\n * @param msg mesage to log\n */\n async log(...msg: any[]) {\n await WebSpatial.sendCommand(\n new RemoteCommand('log', {\n logString: msg.map(x => {\n return JSON.stringify(x)\n }),\n }),\n )\n }\n\n /**\n * @hidden\n * Debugging only, used to ping the native renderer\n */\n async _ping(msg: string) {\n return await WebSpatial.ping(msg)\n }\n\n /**\n * @hidden\n * Debugging to get internal state from native code\n * @returns data as a js object\n */\n async _getStats() {\n return (await WebSpatial.getStats()) as { objects: any; refObjects: any }\n }\n\n /**\n * @hidden\n */\n async _inspect(spatialObjectId: string = WebSpatial.getCurrentWebPanel().id) {\n return WebSpatial.inspect(spatialObjectId)\n }\n\n /**\n * @hidden\n */\n async _inspectRootWindowContainer() {\n return WebSpatial.inspectRootWindowContainer()\n }\n\n /** Opens the immersive space */\n async openImmersiveSpace() {\n return await WebSpatial.openImmersiveSpace()\n }\n\n /** Closes the immersive space */\n async dismissImmersiveSpace() {\n return await WebSpatial.dismissImmersiveSpace()\n }\n\n private static _immersiveWindowContainer =\n null as null | SpatialWindowContainer\n /**\n * Retreives the window container corresponding to the Immersive space\n * @returns the immersive window container\n */\n async getImmersiveWindowContainer() {\n if (SpatialSession._immersiveWindowContainer) {\n return SpatialSession._immersiveWindowContainer\n } else {\n SpatialSession._immersiveWindowContainer = new SpatialWindowContainer(\n WebSpatial.getImmersiveWindowContainer(),\n )\n return SpatialSession._immersiveWindowContainer\n }\n }\n\n // Retreives the window container that is the parent to this spatial web page\n private static _currentWindowContainer = null as null | SpatialWindowContainer\n\n /**\n * Gets the current window container for the window\n * [TODO] discuss what happens if it doesnt yet have a window container\n * @returns the current window container for the window\n */\n getCurrentWindowContainer() {\n if (SpatialSession._currentWindowContainer) {\n return SpatialSession._currentWindowContainer\n } else {\n SpatialSession._currentWindowContainer = new SpatialWindowContainer(\n WebSpatial.getCurrentWindowContainer(),\n )\n return SpatialSession._currentWindowContainer\n }\n }\n\n /**\n * Start a transaction that queues up commands to submit them all at once to reduce ipc overhead\n * @param fn function to be run, within this function, promises will not resolve\n * @returns promise for the entire transaction completion\n */\n transaction(fn: Function) {\n WebSpatial.startTransaction()\n fn()\n return WebSpatial.sendTransaction()\n }\n\n /**\n * Creates a window context object that is compatable with SpatialWindowComponent's setFromWindow API\n * @returns window context\n */\n async createWindowContext() {\n let openedWindow = window.open('webspatial://createWindowContext')\n if (WebSpatial.getBackend() != 'AVP') {\n // Currently there is a bug with webview which requires us to trigger a navigation before native code can interact with created webview\n var counter = 0\n while ((openedWindow!.window as any).testAPI == null) {\n if (counter > 15) {\n openedWindow?.close()\n openedWindow = window.open('about:blank')\n counter = 0\n this.log('unexpected error when trying to open new window, retrying.')\n }\n var locName = 'about:blank?x' + counter\n openedWindow!!.location.href = locName\n counter++\n\n await new Promise(resolve => setTimeout(resolve, 10))\n }\n ;(openedWindow! as any)._webSpatialID = (\n openedWindow!.window as any\n ).testAPI.getWindowID()\n } else {\n while ((openedWindow!.window as any)._webSpatialID == undefined) {\n await new Promise(resolve => setTimeout(resolve, 10))\n }\n }\n openedWindow!.document.head.innerHTML = `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <base href=\"${document.baseURI}\">\n `\n return openedWindow\n }\n\n // Get Entity by id. Currently for debugging only.\n /** @hidden */\n async _getEntity(id: string) {\n const entityInfo = await WebSpatial.inspect(id)\n const [_, x, y, z] = entityInfo.position.match(/(\\d+\\.?\\d*)/g)\n const [__, sx, sy, sz] = entityInfo.scale.match(/(\\d+\\.?\\d*)/g)\n\n var res = new WebSpatialResource()\n res.id = id\n res.windowContainerId = WebSpatial.getCurrentWindowContainer().id\n const entity = new SpatialEntity(res)\n entity.transform.position.x = parseFloat(x)\n entity.transform.position.y = parseFloat(y)\n entity.transform.position.z = parseFloat(z)\n\n entity.transform.scale.x = parseFloat(sx)\n entity.transform.scale.y = parseFloat(sy)\n entity.transform.scale.z = parseFloat(sz)\n\n return entity\n }\n // set loading view.\n /** @hidden */\n async setLoading(method: LoadingMethodKind, style?: string) {\n return WebSpatial.setLoading(method, style)\n }\n}\n","import { SpatialSession } from './SpatialSession'\n\n/**\n * Base object designed to be placed on navigator.spatial to mirror navigator.xr for webxr\n */\nexport class Spatial {\n /**\n * Requests a session object from the browser\n * @returns The session or null if not availible in the current browser\n * [TODO] discuss implications of this not being async\n */\n requestSession() {\n if (\n this.isSupported() &&\n this.getNativeVersion() === this.getClientVersion()\n ) {\n return new SpatialSession()\n } else {\n return null\n }\n }\n\n /**\n * @returns true if web spatial is supported by this webpage\n */\n isSupported() {\n return this.getNativeVersion() === this.getClientVersion()\n }\n\n /**\n * Gets the native version, format is \"x.x.x\"\n * @returns native version string\n */\n getNativeVersion() {\n if (window.__WebSpatialData && window.__WebSpatialData.getNativeVersion) {\n return window.__WebSpatialData.getNativeVersion()\n }\n return window.WebSpatailNativeVersion\n }\n\n /**\n * Gets the client version, format is \"x.x.x\"\n * @returns client version string\n */\n getClientVersion() {\n return '0.0.1' //__WEBSPATIAL_CORE_SDK_VERSION__\n }\n}\n","import { SpatialViewComponent, StyleParam } from './component'\nimport { Spatial } from './Spatial'\nimport { SpatialEntity } from './SpatialEntity'\nimport { SpatialSession } from './SpatialSession'\nimport { Vec3 } from './SpatialTransform'\n\n/**\n * Helper class used to quickly add spatial content to standard web pages\n * [Experimental] expect APIs to potentially change in future versions\n */\nexport class SpatialHelper {\n private static _instance: SpatialHelper | null = null\n static get instance() {\n if (this._instance) {\n return this._instance\n } else {\n let spatial = new Spatial()\n if (spatial.isSupported()) {\n let session = spatial.requestSession()\n if (session) {\n this._instance = new SpatialHelper(session)\n return this._instance\n }\n }\n }\n return null\n }\n\n constructor(public session: SpatialSession) {}\n\n shape = {\n createShapeEntity: async (shape = 'box') => {\n var box = await this.session.createMeshResource({ shape: shape })\n var mat = await this.session.createPhysicallyBasedMaterialResource()\n await mat.update()\n\n var customModel = await this.session.createModelComponent()\n customModel.setMaterials([mat])\n customModel.setMesh(box)\n\n var boxEntity = await this.session.createEntity()\n await boxEntity.setComponent(customModel)\n boxEntity.transform.position.z = 0\n boxEntity.transform.scale = new Vec3(0.5, 0.5, 0.5)\n await boxEntity.updateTransform()\n return boxEntity\n },\n createModelEntity: async (url: string) => {\n var customModel = await this.session.createModelComponent({ url })\n var boxEntity = await this.session.createEntity()\n await boxEntity.setComponent(customModel)\n await boxEntity.updateTransform()\n return boxEntity\n },\n wrapInBoundingBoxEntity: async (entityToWrap: SpatialEntity) => {\n var bb = await entityToWrap.getBoundingBox()\n\n // Scale to fit\n var targetSize = 1.0\n var scale =\n targetSize / Math.max(bb.extents.x, bb.extents.y, bb.extents.z)\n entityToWrap.transform.scale.x = scale\n entityToWrap.transform.scale.y = scale\n entityToWrap.transform.scale.z = scale\n\n // Center within view\n entityToWrap.transform.position.x = -bb.center.x * scale\n entityToWrap.transform.position.y = -bb.center.y * scale\n entityToWrap.transform.position.z = -bb.center.z * scale\n await entityToWrap.updateTransform()\n\n // wrap in boudning box\n var boudningEntity = await SpatialHelper.instance?.session.createEntity()!\n await entityToWrap.setParent(boudningEntity!)\n return boudningEntity\n },\n }\n\n navigation = {\n openPanel: async (\n url: string,\n options?: { resolution: { width: number; height: number } },\n ) => {\n if (options?.resolution) {\n await this.session\n .getCurrentWindowContainer()\n ._setOpenSettings({ resolution: options.resolution })\n }\n\n // Create window container\n var wg = await this.session.createWindowContainer({\n style: 'Plain',\n windowComponent: null,\n windowContainer: null,\n })\n\n // Create a root entity displaying a webpage\n var ent = await this.session!.createEntity({\n windowComponent: null,\n windowContainer: wg,\n })\n var i = await this.session!.createWindowComponent({\n windowComponent: null,\n windowContainer: wg,\n })\n await i.loadURL(url)\n await ent.setCoordinateSpace('Root')\n await ent.setComponent(i)\n\n // Add enitity the window container\n await wg.setRootEntity(ent)\n\n // Restore default size\n await this.session\n .getCurrentWindowContainer()\n ._setOpenSettings({ resolution: { width: 900, height: 700 } })\n\n return {\n windowContainer: wg,\n }\n },\n openVolume: async (\n url: string,\n options?: { resolution: { width: number; height: number } },\n ) => {\n var wg = await this.session.createWindowContainer({\n style: 'Volumetric',\n windowComponent: null,\n windowContainer: null,\n })\n\n // Create a root view entity within the window container\n var rootEnt = await this.session!.createEntity({\n windowComponent: null,\n windowContainer: wg,\n })\n await rootEnt.setComponent(\n await this.session!.createViewComponent({\n windowComponent: null,\n windowContainer: wg,\n }),\n )\n await rootEnt.setCoordinateSpace('Root')\n await wg.setRootEntity(rootEnt)\n\n // Add webpage to the window container\n var ent = await this.session!.createEntity({\n windowComponent: null,\n windowContainer: wg,\n })\n var i = await this.session!.createWindowComponent({\n windowComponent: null,\n windowContainer: wg,\n })\n await i.loadURL(url)\n if (options?.resolution) {\n await i.setResolution(\n options.resolution.width,\n options.resolution.height,\n )\n } else {\n await i.setResolution(1000, 1000)\n }\n ent.transform.position.z = -0.49\n await ent.updateTransform()\n await ent.setCoordinateSpace('App')\n await ent.setComponent(i)\n await ent.setParent(rootEnt)\n },\n }\n\n dom = {\n attachSpatialView: async (divOnPage: HTMLElement) => {\n // Create SpatialView\n var viewEnt = await this.session.createEntity()\n await viewEnt.setCoordinateSpace('Dom') // Set coordinate space so its transform is relative to the webpage's pixels\n await viewEnt.setComponent(await this.session.createViewComponent())\n\n // Add to the root window component to display\n var wc = await this.session.getCurrentWindowComponent()\n var ent = await wc.getEntity()\n await viewEnt.setParent(ent!)\n\n // Keep spatialView positioned where the div is\n var update = () => {\n var rect = divOnPage.getBoundingClientRect()\n viewEnt.transform.position.x = rect.x + rect.width / 2\n viewEnt.transform.position.y = rect.y + rect.height / 2 + window.scrollY\n viewEnt.updateTransform()\n viewEnt\n .getComponent(SpatialViewComponent)!\n .setResolution(rect.width, rect.height)\n }\n var mo = new MutationObserver(update)\n mo.observe(divOnPage, { attributes: true })\n var ro = new ResizeObserver(update)\n ro.observe(divOnPage)\n const addRemoveObserver = new MutationObserver(mutations => {\n mutations.forEach(mutation => {\n mutation.removedNodes.forEach(node => {\n if (node instanceof HTMLElement) {\n update()\n }\n })\n mutation.addedNodes.forEach(node => {\n if (node instanceof HTMLElement) {\n update()\n }\n })\n })\n })\n addRemoveObserver.observe(document.body, {\n childList: true,\n subtree: true,\n })\n update()\n return {\n entity: viewEnt,\n }\n },\n }\n\n setBackgroundStyle = async (\n style: StyleParam,\n backgroundColor = '#00000000',\n ) => {\n document.documentElement.style.backgroundColor = backgroundColor\n await this.session!.getCurrentWindowComponent().setStyle(style)\n }\n}\n","import { SpatialComponent } from './SpatialComponent'\nimport { WebSpatial } from '../private/WebSpatial'\nimport { Vec3 } from '../SpatialTransform'\nimport { SpatialHelper } from '../SpatialHelper'\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 type StyleParam = {\n material?: {\n type: BackgroundMaterialType\n }\n cornerRadius?: number | CornerRadius\n}\n\n/**\n * Used to position an web window in 3D space\n */\nexport class SpatialWindowComponent extends SpatialComponent {\n /**\n * Loads a url page in the window\n * @param url url to load\n */\n async loadURL(url: string) {\n await WebSpatial.updateResource(this._resource, { url: url })\n }\n\n async setFromWindow(window: any) {\n if (window._webSpatialID) {\n await WebSpatial.updateResource(this._resource, {\n windowID: window._webSpatialID,\n })\n } else {\n await console.warn(\n 'failed to call setFromWindow, window provided is not valid',\n )\n }\n }\n\n /**\n * Sets the resolution of the window, the resulting dimensions when rendered will be equal to 1/1360 units\n * eg. if the resolution is set to 1360x1360 it will be a 1x1 plane\n * See 1360 in spatialViewUI.swift for how this ratio works\n * @param width width in pixels\n * @param height height in pixels\n */\n async setResolution(width: number, height: number) {\n await WebSpatial.updateResource(this._resource, {\n resolution: { x: width, y: height },\n })\n }\n\n /**\n * [Experimental] Sets the anchor which the entity this is attached to will rotate around\n * @param rotationAnchor\n */\n async setRotationAnchor(rotationAnchor: Vec3) {\n await WebSpatial.updateResource(this._resource, {\n rotationAnchor: rotationAnchor,\n })\n }\n\n /**\n * [Experimental] Sets the opacity of the window after apply material\n * @param opacity\n */\n async setOpacity(opacity: number) {\n await WebSpatial.updateResource(this._resource, {\n opacity,\n })\n }\n\n /**\n * Sets the style that should be applied to the window\n * @param options style options\n */\n async setStyle(styleParam: StyleParam) {\n const currentWindowComponent =\n SpatialHelper.instance?.session.getCurrentWindowComponent()\n const isSettingSelfStyle =\n currentWindowComponent?._resource.id == this._resource.id\n\n const { material, cornerRadius } = styleParam\n const options: any = {}\n if (material?.type) {\n options.backgroundMaterial = material.type\n }\n\n if (cornerRadius !== undefined) {\n if (typeof cornerRadius === 'number') {\n options.cornerRadius = {\n topLeading: cornerRadius,\n bottomLeading: cornerRadius,\n topTrailing: cornerRadius,\n bottomTrailing: cornerRadius,\n }\n } else {\n options.cornerRadius = { ...cornerRadius }\n }\n }\n\n if (isSettingSelfStyle && document && document.readyState == 'loading') {\n // Avoid flash of unstyled content by sending style command via a link element\n var encoded = encodeURIComponent(JSON.stringify(options))\n var x = document.createElement('link')\n x.rel = 'stylesheet'\n x.href = 'forceStyle://mystyle.css?' + 'style=' + encoded\n document.head.appendChild(x)\n // remove this style after trigger forceStyle action\n x.remove()\n } else {\n await WebSpatial.updateResource(this._resource, { style: options })\n }\n }\n\n /**\n * Modifies the amount the spatial window can be scrolled\n * Should only be used internally\n * See https://developer.apple.com/documentation/uikit/1624475-uiedgeinsetsmake?language=objc\n * @param insets margin to modify scroll distances by\n */\n async setScrollEdgeInsets(insets: {\n top: number\n left: number\n bottom: number\n right: number\n }) {\n await WebSpatial.updateResource(this._resource, {\n setScrollEdgeInsets: insets,\n })\n }\n\n /**\n * Enable/Disable scrolling in the window (defaults to enabled), if disabled, scrolling will be applied to the root page\n * @param enabled value to set\n */\n async setScrollEnabled(enabled: boolean) {\n await WebSpatial.updateResource(this._resource, { scrollEnabled: enabled })\n }\n\n /**\n * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements\n * @param scrollWithParent value to set\n */\n async setScrollWithParent(scrollWithParent: boolean) {\n await WebSpatial.updateResource(this._resource, {\n scrollWithParent: scrollWithParent,\n })\n }\n}\n","import { WebSpatial, WebSpatialResource } from '../private/WebSpatial'\nimport { SpatialComponent } from './SpatialComponent'\n\n/**\n * @description\n * Represents a spatial component that handles events related to spatial interactions.\n * This class extends `SpatialComponent` and provides additional functionality for managing\n * event-driven spatial behaviors.\n *\n * @hidden\n * This class is intended for internal use and should not be exposed in the public API.\n */\nexport abstract class EventSpatialComponent extends SpatialComponent {\n // Class implementation goes here\n constructor(_resource: WebSpatialResource) {\n super(_resource)\n WebSpatial.registerEventReceiver(_resource.id, (data: any) => {\n this.onRecvEvent(data)\n })\n }\n\n /**\n * @description\n * Abstract method to be implemented by subclasses. Called when a spatial event is received.\n * @param data The data associated with the received event.\n */\n protected abstract onRecvEvent(data: any): void\n\n protected override async onDestroy() {\n WebSpatial.unregisterEventReceiver(this._resource.id)\n }\n}\n","import { Vec3 } from '../SpatialTransform'\nimport { EventSpatialComponent } from './EventSpatialComponent'\n\n/**\n * Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event\n */\ntype TranslateEvent = {\n eventType: 'dragstart' | 'dragend' | 'drag'\n translate?: Vec3\n}\n/**\n * Used to handle input events on an entity\n */\nexport class SpatialInputComponent extends EventSpatialComponent {\n protected override onRecvEvent(data: any): void {\n this.onTranslate(data)\n }\n\n /**\n * Callback fired when a translate event occurs\n * @param data translate event data\n */\n public onTranslate(data: TranslateEvent) {}\n}\n","import { SpatialMeshResource } from '../resource/SpatialMeshResource'\nimport { SpatialPhysicallyBasedMaterialResource } from '../resource/SpatialPhysicallyBasedMaterialResource'\nimport { SpatialComponent } from './SpatialComponent'\nimport { WebSpatial } from '../private/WebSpatial'\n\n/**\n * Used to position a model in 3D space, made up of a mesh and materials to be applied to the mesh\n */\nexport class SpatialModelComponent extends SpatialComponent {\n private cachedMaterials = new Array<SpatialPhysicallyBasedMaterialResource>()\n /**\n * Sets the mesh to be displayed by the component\n * @param mesh mesh to set\n */\n async setMesh(mesh: SpatialMeshResource) {\n await WebSpatial.updateResource(this._resource, {\n meshResource: mesh._resource.id,\n })\n }\n\n /**\n * Sets the materials that should be applied to the mesh\n * @param materials array of materials to set\n */\n async setMaterials(materials: Array<SpatialPhysicallyBasedMaterialResource>) {\n this.cachedMaterials = materials\n await WebSpatial.updateResource(this._resource, {\n materials: materials.map(m => {\n m._addToComponent(this)\n return m._resource.id\n }),\n })\n }\n\n /** @hidden */\n async _syncMaterials() {\n await this.setMaterials(this.cachedMaterials)\n }\n}\n","import { WebSpatial } from '../private/WebSpatial'\nimport { SpatialComponent } from './SpatialComponent'\n\n/**\n * Represenets a volume that can be added to the webpage\n * Child entities will be added within this volume's space\n * Defaults to having 1x1x1 meter dimensions\n * Resolution defaults to 100x100 pixels\n * Only will be displayed on entities in \"ROOT\" or \"DOM\" space\n * If the resolution of the spatial view is not a square, the volume will be larger based on the ratio with the shortest side being 1 meter.\n * (eg. 200x100 = 2m x 1m x 1m volume)\n */\nexport class SpatialViewComponent extends SpatialComponent {\n /**\n * Sets the resolution of the spatial view in dom pixels\n */\n async setResolution(width: number, height: number) {\n await WebSpatial.updateResource(this._resource, {\n resolution: { x: width, y: height },\n })\n }\n\n /**\n * Sets if content of the spatialView should be within a portal\n * If true, volume will be behind the page, if false, it will be in front of the page\n */\n async setIsPortal(isPortal: Boolean) {\n await WebSpatial.updateResource(this._resource, {\n isPortal: isPortal,\n })\n }\n}\n","import { EventSpatialComponent } from './EventSpatialComponent'\nimport { WebSpatial } from '../private/WebSpatial'\nimport { Vec3 } from '../SpatialTransform'\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 type TapEvent = {\n eventType: 'tap'\n}\n\n/**\n * Used to position a model3d in 3D space\n */\nexport class SpatialModel3DComponent extends EventSpatialComponent {\n protected override onRecvEvent(data: any): void {\n const { eventType, value, error } = data\n switch (eventType) {\n case 'phase':\n if (value === 'success') {\n this.onSuccess?.()\n } else {\n this.onFailure?.(error as string)\n }\n break\n case 'dragstart':\n this._onDragStart?.(value)\n break\n case 'dragend':\n this._onDragEnd?.(value)\n break\n case 'drag':\n this._onDrag?.(value)\n break\n case 'tap':\n this._onTap?.()\n break\n case 'doubletap':\n this._onDoubleTap?.()\n break\n case 'longpress':\n this._onLongPress?.()\n break\n\n default:\n break\n }\n }\n /**\n * Sets the resolution of the spatial view in dom pixels\n */\n async setResolution(width: number, height: number) {\n await WebSpatial.updateResource(this._resource, {\n resolution: { x: width, y: height },\n })\n }\n\n async setRotationAnchor(rotationAnchor: Vec3) {\n await WebSpatial.updateResource(this._resource, {\n rotationAnchor: rotationAnchor,\n })\n }\n\n /**\n * Sets the opacity of the model\n * @param opacity\n */\n async setOpacity(opacity: number) {\n await WebSpatial.updateResource(this._resource, {\n opacity,\n })\n }\n\n /**\n * Sets how the model fill the rect\n * @param contentMode\n */\n async setContentMode(contentMode: 'fill' | 'fit') {\n await WebSpatial.updateResource(this._resource, {\n contentMode,\n })\n }\n\n /**\n * Constrains this model dimensions to the specified aspect ratio.\n * with a value of 0, the model will use the original aspect ratio.\n *\n * @param aspectRatio number\n */\n async setAspectRatio(aspectRatio: number) {\n await WebSpatial.updateResource(this._resource, {\n aspectRatio,\n })\n }\n\n /**\n * Defaults to false. If set to true, scrolling the parent page will also scroll this window with it like other dom elements\n * @param scrollWithParent value to set\n */\n async setScrollWithParent(scrollWithParent: boolean) {\n await WebSpatial.updateResource(this._resource, {\n scrollWithParent: scrollWithParent,\n })\n }\n\n /**\n * Sets whether the model appear in original size or fit the rect\n * @param resizable\n */\n async setResizable(resizable: boolean) {\n await WebSpatial.updateResource(this._resource, {\n resizable,\n })\n }\n\n /**\n * Callback fired when model load success\n */\n public onSuccess?: () => void\n\n /**\n * Callback fired when model load failure\n * @param errorReason\n */\n public onFailure?: (errorReason: string) => void\n\n /**\n * Callback fired when model was dragged at the beginning\n * @param dragEvent\n */\n private _onDragStart?: (dragEvent: SpatialModelDragEvent) => void\n public set onDragStart(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this._onDragStart !== callback) {\n this._onDragStart = callback\n WebSpatial.updateResource(this._resource, {\n enableDragEvent: this.enableDragEvent,\n })\n }\n }\n\n /**\n * Callback fired when model was dragged\n * @param dragEvent\n */\n private _onDrag?: (dragEvent: SpatialModelDragEvent) => void\n public set onDrag(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this._onDrag !== callback) {\n this._onDrag = callback\n WebSpatial.updateResource(this._resource, {\n enableDragEvent: this.enableDragEvent,\n })\n }\n }\n\n /**\n * Callback fired when model was dragged at the ending\n * @param dragEvent\n */\n private _onDragEnd?: (dragEvent: SpatialModelDragEvent) => void\n public set onDragEnd(\n callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,\n ) {\n if (this._onDragEnd !== callback) {\n this._onDragEnd = callback\n WebSpatial.updateResource(this._resource, {\n enableDragEvent: this.enableDragEvent,\n })\n }\n }\n\n private get enableDragEvent(): boolean {\n return (\n undefined !== this._onDrag ||\n undefined !== this._onDragStart ||\n undefined !== this._onDragEnd\n )\n }\n\n /**\n * Callback fired when model was tapped\n */\n private _onTap?: () => void\n public set onTap(callback: (() => void) | undefined) {\n if (this._onTap !== callback) {\n this._onTap = callback\n WebSpatial.updateResource(this._resource, {\n enableTapEvent: undefined !== callback,\n })\n }\n }\n\n /** Callback fired when model was double tapped */\n private _onDoubleTap?: () => void\n public set onDoubleTap(callback: (() => void) | undefined) {\n if (this._onDoubleTap !== callback) {\n this._onDoubleTap = callback\n WebSpatial.updateResource(this._resource, {\n enableDoubleTapEvent: undefined !== callback,\n })\n }\n }\n\n /** Callback fired when model was long pressed */\n private _onLongPress?: () => void\n public set onLongPress(callback: (() => void) | undefined) {\n if (this._onLongPress !== callback) {\n this._onLongPress = callback\n WebSpatial.updateResource(this._resource, {\n enableLongPressEvent: undefined !== callback,\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAO,IAAM,gBAAN,MAAM,eAAc;AAAA,EACzB,OAAe,iBAAiB;AAAA,EAEhC;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA,YAAY,KAAa,MAAY;AACnC,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,SAAK,YAAY,EAAE,eAAc;AAAA,EACnC;AACF;;;ACsBO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,KAAK;AACP;AAEO,IAAM,qBAAN,MAAyB;AAAA,EAC9B,KAAK;AAAA,EACL,oBAAoB;AAAA,EACpB,OAAO,CAAC;AAAA,EAER,eAAe;AAAA,EAAC;AAClB;AAEO,IAAM,aAAN,MAAM,YAAW;AAAA,EACtB,OAAc,gBAAqB,CAAC;AAAA,EAEpC,OAAc,qBAAqB;AAAA,EACnC,OAAc,sBAA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","res","res","window"]}
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "@webspatial/core-sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.13",
4
4
  "description": "this is the core js API for webspatial",
5
5
  "main": "dist/index.js",
6
- "types": "dist/index.d.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
7
14
  "type": "module",
8
15
  "sideEffects": false,
9
16
  "repository": {
@@ -24,10 +24,7 @@ export class Spatial {
24
24
  * @returns true if web spatial is supported by this webpage
25
25
  */
26
26
  isSupported() {
27
- return (
28
- (window as any).WebSpatailEnabled &&
29
- this.getNativeVersion() === this.getClientVersion()
30
- )
27
+ return this.getNativeVersion() === this.getClientVersion()
31
28
  }
32
29
 
33
30
  /**
@@ -35,7 +32,10 @@ export class Spatial {
35
32
  * @returns native version string
36
33
  */
37
34
  getNativeVersion() {
38
- return (window as any).WebSpatailNativeVersion
35
+ if (window.__WebSpatialData && window.__WebSpatialData.getNativeVersion) {
36
+ return window.__WebSpatialData.getNativeVersion()
37
+ }
38
+ return window.WebSpatailNativeVersion
39
39
  }
40
40
 
41
41
  /**
@@ -43,6 +43,6 @@ export class Spatial {
43
43
  * @returns client version string
44
44
  */
45
45
  getClientVersion() {
46
- return '0.0.1'
46
+ return '0.0.1' //__WEBSPATIAL_CORE_SDK_VERSION__
47
47
  }
48
48
  }
@@ -114,6 +114,10 @@ export class SpatialHelper {
114
114
  await this.session
115
115
  .getCurrentWindowContainer()
116
116
  ._setOpenSettings({ resolution: { width: 900, height: 700 } })
117
+
118
+ return {
119
+ windowContainer: wg,
120
+ }
117
121
  },
118
122
  openVolume: async (
119
123
  url: string,
@@ -50,4 +50,10 @@ export class SpatialWindowContainer {
50
50
  async setRootEntity(entity: SpatialEntity) {
51
51
  await entity._setParentWindowContainer(this)
52
52
  }
53
+
54
+ async close() {
55
+ await WebSpatial.updateWindowContainer(this._wg, {
56
+ close: true,
57
+ })
58
+ }
53
59
  }
@@ -1,6 +1,7 @@
1
1
  import { SpatialComponent } from './SpatialComponent'
2
2
  import { WebSpatial } from '../private/WebSpatial'
3
3
  import { Vec3 } from '../SpatialTransform'
4
+ import { SpatialHelper } from '../SpatialHelper'
4
5
 
5
6
  /**
6
7
  * Material type for SpatialDiv or HTML document.
@@ -100,6 +101,11 @@ export class SpatialWindowComponent extends SpatialComponent {
100
101
  * @param options style options
101
102
  */
102
103
  async setStyle(styleParam: StyleParam) {
104
+ const currentWindowComponent =
105
+ SpatialHelper.instance?.session.getCurrentWindowComponent()
106
+ const isSettingSelfStyle =
107
+ currentWindowComponent?._resource.id == this._resource.id
108
+
103
109
  const { material, cornerRadius } = styleParam
104
110
  const options: any = {}
105
111
  if (material?.type) {
@@ -119,16 +125,18 @@ export class SpatialWindowComponent extends SpatialComponent {
119
125
  }
120
126
  }
121
127
 
122
- if (document && document.readyState == 'loading') {
128
+ if (isSettingSelfStyle && document && document.readyState == 'loading') {
123
129
  // Avoid flash of unstyled content by sending style command via a link element
124
130
  var encoded = encodeURIComponent(JSON.stringify(options))
125
131
  var x = document.createElement('link')
126
132
  x.rel = 'stylesheet'
127
133
  x.href = 'forceStyle://mystyle.css?' + 'style=' + encoded
128
134
  document.head.appendChild(x)
135
+ // remove this style after trigger forceStyle action
136
+ x.remove()
137
+ } else {
138
+ await WebSpatial.updateResource(this._resource, { style: options })
129
139
  }
130
-
131
- await WebSpatial.updateResource(this._resource, { style: options })
132
140
  }
133
141
 
134
142
  /**