MpSdk
The entire MP Sdk returned from a successful call to MP_SDK.connect.
The Scene namespace is only available when connecting using the Bundle SDK
// for the Embed SDK
const sdk: MpSdk = await showcaseEmbeddingWindow.MP_SDK.connect(...);
// for the Bundle SDK
const sdk: MpSdk = await bundleWindow.MP_SDK.connect(...);
Types
Color
An RGB represenation of a color. Each property is normalized to the range [0, 1]
| Property | Type |
|---|---|
| b | number |
| g | number |
| r | number |
ConditionCallback
A callback that describes a condition of an IObservable to wait for.
Returning true will resolve the promise returned by IObservable.waitUntil
The functional style version of the ICondition
type ConditionCallback<DataT> = (data: DataT) => boolean
ConnectOptions
Options to provide when connecting the sdk
| Property | Type |
|---|---|
| auth | string A token to provide access to a model |
| provider | string |
| sdkType | string Used for tracking how the sdk is being integrated with other applications. |
EulerAngle
An orientation described with Euler-like angles in degrees in YXZ order.
| Property | Type |
|---|---|
| x | number |
| y | number |
| z | number |
ObserverCallback
A callback that can be subscribed to changes of an IObservable
The functional style version of the IObserver
type ObserverCallback<DataT> = (data: DataT) => void
Orientation
An orientation described with Euler-like angles in degrees.
| Property | Type |
|---|---|
| pitch | number |
| roll | number |
| yaw | number |
ShowcaseBundleWindow
A Window type that can be used to cast the bundle's iframe's contentWindow to hint at the existance of the MP_SDK object.
const bundleIframe = document.getElementById<HTMLIFrameElement>('showcase');
const showcaseWindow = bundleIframe.contentWindow as ShowcaseBundleWindow;
showcaseWindow.MP_SDK.connect(showcaseWindow);
type ShowcaseBundleWindow = Window & typeof globalThis & { MP_SDK: MP_SDK; }
ShowcaseEmbedWindow
When including the sdk script (``) on your page,
an MP_SDK will be attached to the window object.
This type can be used to cast the window object to access the types available on the MP_SDK object.
const showcaseEmbeddingWindow = window as ShowcaseEmbedWindow;
showcaseEmbeddingWindow.MP_SDK.connect( ... )
type ShowcaseEmbedWindow = Window & typeof globalThis & { MP_SDK: MP_SDK; }
Functions
disconnect
Stop sending and receiving messages and cleanup any resources associated with the sdk
mpSdk.disconnect();
// mpSdk can no longer make function calls, receive any callbacks to event, observable, or collection
// all sdk functionality should throw errors
try {
await mpSdk.Mode.moveTo( ... );
} catch (e) {
console.error(e);
}
off
Unsubscribes from an event.
const callback = (model) => {
console.log('My model loaded!');
};
// Start listening to the event.
mpSdk.on(mpSdk.Event.MODEL_LOADED, callback);
// Stop listening to the event.
mpSdk.off(mpSdk.Event.MODEL_LOADED, callback);
| Parameter | Type |
|---|---|
| event | any The event to stop. |
| callback | (...any: any[]) => void The original callback. |
Returns: Emitter
on
on(event: App.Event.PHASE_CHANGE, callback: (app: App.Phase) => void): Emitter
App.state observable to get phase change notifications.| Parameter | Type |
|---|---|
| event | App.Event.PHASE_CHANGE |
| callback | (app: App.Phase) => void |
Returns: Emitter
on(event: Camera.Event.MOVE, callback: (pose: Camera.Pose) => void): Emitter
Camera.pose observable to get camera pose change notifications.| Parameter | Type |
|---|---|
| event | Camera.Event.MOVE |
| callback | (pose: Camera.Pose) => void |
Returns: Emitter
on(event: Floor.Event.CHANGE_START, callback: (to: number, from: number) => void): Emitter
This event fires when a floor change is starting.
the callback returns the floor index that we are moving to, and the floor index we are moving from.
mpSdk.on(mpSdk.Floor.Event.CHANGE_START,
function(to, from) {
console.log('Starting to move to floor ' + to + ' from floor ' + from);
}
);
| Parameter | Type |
|---|---|
| event | Floor.Event.CHANGE_START |
| callback | (to: number, from: number) => void |
Returns: Emitter
on(event: Floor.Event.CHANGE_END, callback: (floorIndex: number, floorName: string) => void): Emitter
This event fires when a floor change is ending.
the callback returns the floor index (0 based, counting from the bottom) and the floorName, as set in workshop, or defaulting to the same as floorIndex
mpSdk.on(mpSdk.Floor.Event.CHANGE_END,
function(floorIndex, floorName) {
console.log('Arrived at floor ' + floorName);
console.log('it is the ' + floorIndex+1 + 'th floor from the bottom');
}
);
| Parameter | Type |
|---|---|
| event | Floor.Event.CHANGE_END |
| callback | (floorIndex: number, floorName: string) => void |
Returns: Emitter
on(event: Label.Event.POSITION_UPDATED, callback: (labelData: Label.Label[]) => void): Emitter
This event fires when the labels' on screen position has changed.
mpSdk.on(Label.Event.POSITION_UPDATED,
function(labels) {
// Label data updated.
console.log('On-screen position of first label: ' + JSON.stringify(labels[0].position));
}
);
| Parameter | Type |
|---|---|
| event | Label.Event.POSITION_UPDATED |
| callback | (labelData: Label.Label[]) => void |
Returns: Emitter
on(event: Mattertag.Event.HOVER, callback: (tagSid: string, hovering: boolean) => void): Emitter
This event fires when the input pointer hovers onto or out of a mattertag disc.
mpSdk.on(mpSdk.Mattertag.Event.HOVER,
function (tagSid, hovering) {
if (hovering) {
console.log('Begin Hovering on', tagSid);
} else {
console.log('End Hovering on', tagSid);
}
}
);
| Parameter | Type |
|---|---|
| event | Mattertag.Event.HOVER |
| callback | (tagSid: string, hovering: boolean) => void |
Returns: Emitter
on(event: Mattertag.Event.CLICK, callback: (tagSid: string) => void): Emitter
This event fires when the input pointer clicks a Mattertag disc.
mpSdk.on(mpSdk.Mattertag.Event.CLICK,
function (tagSid) {
console.log(tagSid + ' was selected');
}
);
| Parameter | Type |
|---|---|
| event | Mattertag.Event.CLICK |
| callback | (tagSid: string) => void |
Returns: Emitter
on(event: Mattertag.Event.LINK_OPEN, callback: (tagSid: string, url: string) => void): Emitter
This event fires when a mattertag link is opened.
mpSdk.on(mpSdk.Mattertag.Event.LINK_OPEN,
function (tagSid, url) {
console.log('The link ' + url + ' opened for sid ' + tagSid);
}
);
| Parameter | Type |
|---|---|
| event | Mattertag.Event.LINK_OPEN |
| callback | (tagSid: string, url: string) => void |
Returns: Emitter
on(event: Mode.Event.CHANGE_START, callback: (oldMode: string, newMode: string) => void): Emitter
This event fires when the camera is starting to transition to a mode.
mpSdk.on(mpSdk.Mode.Event.CHANGE_START,
function(oldMode, newMode){
console.log('Mode changing from ' + oldMode);
console.log('Mode changing to ' + newMode);
}
);
| Parameter | Type |
|---|---|
| event | Mode.Event.CHANGE_START |
| callback | (oldMode: string, newMode: string) => void |
Returns: Emitter
on(event: Mode.Event.CHANGE_END, callback: (oldMode: string, newMode: string) => void): Emitter
This event fires when the camera has completed a transition to a mode.
mpSdk.on(mpSdk.Mode.Event.CHANGE_END,
function(oldMode, newMode){
console.log('Mode changed from ' + oldMode);
console.log('Mode changed to ' + newMode);
}
);
| Parameter | Type |
|---|---|
| event | Mode.Event.CHANGE_END |
| callback | (oldMode: string, newMode: string) => void |
Returns: Emitter
on(event: Model.Event.MODEL_LOADED, callback: (model: Model.ModelData) => void): Emitter
This event fires when the model has been loaded.
mpSdk.on(mpSdk.Model.Event.MODEL_LOADED,
function(model){
console.log('Model sid:' + model.sid);
}
);
| Parameter | Type |
|---|---|
| event | Model.Event.MODEL_LOADED |
| callback | (model: Model.ModelData) => void |
Returns: Emitter
on(event: Sweep.Event.ENTER, callback: (oldSweep: string, newSweep: string) => void): Emitter
This event fires when first entering a sweep.
mpSdk.on(mpSdk.Sweep.Event.ENTER,
function(oldSweep, newSweep){
console.log('Leaving sweep ' + oldSweep);
console.log('Entering sweep ' + newSweep);
}
);
| Parameter | Type |
|---|---|
| event | Sweep.Event.ENTER |
| callback | (oldSweep: string, newSweep: string) => void |
Returns: Emitter
on(event: Sweep.Event.EXIT, callback: (fromSweep: string, toSweep: string | undefined) => void): Emitter
This event fires when exiting a sweep.
mpSdk.on(mpSdk.Sweep.Event.EXIT,
function(fromSweep, toSweep){
console.log('Leaving sweep ' + fromSweep);
console.log('Transitioning to sweep ' + toSweep);
}
);
The callback receives fromSweep (the exit sweep) and toSweep (the destination sweep).
The toSweep value is only valid for inside mode. It is undefined for floorplan and dollhouse mode.
| Parameter | Type |
|---|---|
| event | Sweep.Event.EXIT |
| callback | (fromSweep: string, toSweep: string | undefined) => void |
Returns: Emitter
on(event: Tour.Event.STARTED, callback: () => void): Emitter
This event fires when the tour has started.
mpSdk.on(mpSdk.Tour.Event.STARTED,
function() {
console.log('Tour started!');
}
);
| Parameter | Type |
|---|---|
| event | Tour.Event.STARTED |
| callback | () => void |
Returns: Emitter
on(event: Tour.Event.STOPPED, callback: () => void): Emitter
This event fires when the tour has stopped.
mpSdk.on(mpSdk.Tour.Event.STOPPED,
function() {
console.log('Tour stopped!');
}
);
| Parameter | Type |
|---|---|
| event | Tour.Event.STOPPED |
| callback | () => void |
Returns: Emitter
on(event: Tour.Event.ENDED, callback: () => void): Emitter
This event fires when the tour has ended.
mpSdk.on(mpSdk.Tour.Event.ENDED,
function() {
console.log('Tour ended!');
}
);
| Parameter | Type |
|---|---|
| event | Tour.Event.ENDED |
| callback | () => void |
Returns: Emitter
on(event: Tour.Event.STEPPED, callback: (activeIndex: number) => void): Emitter
This event fires when the tour has stepped.
mpSdk.on(mpSdk.Tour.Event.STEPPED,
function(activeIndex) {
console.log('Tour has reached step ' + activeIndex);
}
);
| Parameter | Type |
|---|---|
| event | Tour.Event.STEPPED |
| callback | (activeIndex: number) => void |
Returns: Emitter