Skip to main content

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

Color: object

An RGB represenation of a color. Each property is normalized to the range [0, 1]

PropertyType
bnumber
gnumber
rnumber

ConditionCallback

ConditionCallback<DataT>: function

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

ConnectOptions: object

Options to provide when connecting the sdk

PropertyType
authstring
A token to provide access to a model
providerstring
sdkTypestring
Used for tracking how the sdk is being integrated with other applications.

EulerAngle

EulerAngle: object

An orientation described with Euler-like angles in degrees in YXZ order.

PropertyType
xnumber
ynumber
znumber

ObserverCallback

ObserverCallback<DataT>: function

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

Orientation: object

An orientation described with Euler-like angles in degrees.

PropertyType
pitchnumber
rollnumber
yawnumber

Quaternion

Quaternion: object
PropertyType
wnumber
xnumber
ynumber
znumber

Rotation

Rotation: object
PropertyType
xnumber
ynumber
z?number | undefined

ShowcaseBundleWindow

ShowcaseBundleWindow: Window & typeof globalThis & { MP_SDK: MP_SDK; }

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

ShowcaseEmbedWindow: Window & typeof globalThis & { MP_SDK: MP_SDK; }

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; }

Size

Size: object
PropertyType
hnumber
wnumber

Vector2

Vector2: object
PropertyType
xnumber
ynumber

Vector3

Vector3: object
PropertyType
xnumber
ynumber
znumber

Functions

disconnect

disconnect(): void

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

off(event: any, callback: (...any: any[]) => void): Emitter

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);
ParameterType
eventany
The event to stop.
callback(...any: any[]) => void
The original callback.

Returns: Emitter

on

on: function17 overloads
on(event: App.Event.PHASE_CHANGE, callback: (app: App.Phase) => void): Emitter
deprecated Use the App.state observable to get phase change notifications.
ParameterType
eventApp.Event.PHASE_CHANGE
callback(app: App.Phase) => void

Returns: Emitter

on(event: Camera.Event.MOVE, callback: (pose: Camera.Pose) => void): Emitter
deprecated Use the Camera.pose observable to get camera pose change notifications.
ParameterType
eventCamera.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);
}
);
ParameterType
eventFloor.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');
}
);
ParameterType
eventFloor.Event.CHANGE_END
callback(floorIndex: number, floorName: string) => void

Returns: Emitter

on(event: Label.Event.POSITION_UPDATED, callback: (labelData: Label.Label[]) => void): Emitter
deprecated Use the Label observable instead

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));
}
);
ParameterType
eventLabel.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);
}
}
);
ParameterType
eventMattertag.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');
}
);
ParameterType
eventMattertag.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);
}
);
ParameterType
eventMattertag.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);
}
);
ParameterType
eventMode.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);
}
);
ParameterType
eventMode.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);
}
);
ParameterType
eventModel.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);
}
);
ParameterType
eventSweep.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.

ParameterType
eventSweep.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!');
}
);
ParameterType
eventTour.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!');
}
);
ParameterType
eventTour.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!');
}
);
ParameterType
eventTour.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);
}
);
ParameterType
eventTour.Event.STEPPED
callback(activeIndex: number) => void

Returns: Emitter