3D Engine Scripts

Available Elements

The available elements to work with using the scripting language are as below:

entity

The entity object holds data related to the entity the script is attached to. This will follow the standard structure of the scene objects but there will be different fields depending on what the script is attached to.

{
  id: '<string>',
  type: '<string>',
  attributes: {
    title: '<string>',
    scene_id: '<uuid>',
    ...
  }
}

memory

The memory object allows you to store data which is shared between the engine and the 2D UI layer. More info in the memory page

Triggering an animation

In order to trigger an animation on a 3D object in your scene you can use the following code:

PLATTAR.eventHandler.send('wgl', 'triggeranimation', {
	animation_id: <animation_id> // Name of the animation in the 3d model
	id: <?uuid>, // Optional ID of the object to trigger animation for
	title: <?string>, // Optional title of the object to trigger animation for
	state: <?play|pause>, // Optional parameter to pause the animation
	loop: <?boolean> // Optional parameter to set if the animation should loop or not
});

Triggering audio/video

In order to trigger a video or audio element in your scene to play/pause you can use the following:

PLATTAR.eventHandler.send('wgl', 'triggermedia', { 
	title: '<?video_title>', // Optional title of the object to target
	id: '<?uuid>', // Optional id of the object to target
	state: '<play|pause>', // Set whether to play or pause the object.
});

Loading a new scene

There are two methods for loading a new scene in place of the existing one, the difference being whether it is a marker based or markerless scene you are replacing.

// Used for markerless scenes
PLATTAR.Actions.loadReplacementScene(<new_sceneid>, <current_sceneid>);

// Used for marker tracked scenes (including snap-lock scenes)
PLATTAR.Actions.loadOverrideScene(<new_sceneid>, <current_sceneid>);  

Opening a page

To open an app page:

PLATTAR.eventHandler.send('tui', 'openPage', {
	page_link_id: '<page_id>'
});

To open an external URL:

PLATTAR.eventHandler.send('sdk', 'onOpenExternalUrl', {
	url: '<external_url>'
});