The Space API provides methods to interact with a 3D space.
Overview
To work with 3D spaces, you can use the Space API to open existing spaces, create new ones,
and obtain shareable space handles.
Quick Start
// User A: Gets a shareable handle for the current spaceconstspaceHandle = awaitwebvis.getContext().requestSpaceHandle();// User B: Opens an existing space using the handle of user Aawaitwebvis.getContext().openSpace(spaceHandle); // You're now in the existing space// You can also create a new, empty spaceawaitwebvis.getContext().openSpace(); // You're now in a new, empty space
Space Handles
A space handle is a URL that can be used to open a specific 3D space. It contains the space ID and an optional access
token for a specific member role. You can obtain a space handle for the current space using the requestSpaceHandle
method.
// Get the webvis contextconstcontext = awaitwebvis.getContext();// Get a space handle for the current space with the default role (Viewer)constviewerHandle = awaitcontext.requestSpaceHandle();// Get a space handle for the current space with a certain roleconsteditorHandle = awaitcontext.requestSpaceHandle(MemberRole.EDITOR);
Cloning Spaces
You can create a new 3D space by cloning the current space using the cloneIntoNewSpace method.
This creates a new space with the same content as the current one, allowing you to make changes
without affecting the original space.
// Clone the current space into a new spaceawaitcontext.cloneIntoNewSpace(); // You're now in the cloned space
Opens a new 3D space by cloning the current space.
Returns Promise<void>
A promise that resolves when the new space has been opened.
openSpace
openSpace(spaceHandle?:string):Promise<void>
Experimental
Opens a 3D space.
If a space handle is specified and it exists, switches to the 3D space referenced by the handle.
If a space handle is specified and it does not exist, throws an error.
If no space handle is specified, creates a new 3D space and clears the content.
Parameters
OptionalspaceHandle: string
The handle of the space to open. If undefined, a new space is created.
Returns Promise<void>
A promise that resolves when the space has been opened.
Requests a shareable space handle for the current 3D space.
A space handle is a URL that can be used to open the current 3D space. It has the following format:
<HUB_URL>/api/space/v2/<SPACE_ID> if no role is specified.
<HUB_URL>/api/space/v2/<SPACE_ID>?token=<TOKEN> if a role is specified.
where <HUB_URL> is the URL of the hub, <SPACE_ID> is the ID of the current space, and <TOKEN> is the
access token for the specified role.
The role to assign when the space is opened via the handle. If undefined, the MemberRole.VIEWER
role will be assigned when opening the space via the handle.
Space API
The Space API provides methods to interact with a 3D space.
Overview
To work with 3D spaces, you can use the Space API to open existing spaces, create new ones, and obtain shareable space handles.
Quick Start
Space Handles
A space handle is a URL that can be used to open a specific 3D space. It contains the space ID and an optional access token for a specific member role. You can obtain a space handle for the current space using the
requestSpaceHandlemethod.Cloning Spaces
You can create a new 3D space by cloning the current space using the
cloneIntoNewSpacemethod. This creates a new space with the same content as the current one, allowing you to make changes without affecting the original space.Events
The Space API emits the following events: