Skip to main content

LensStudio:Preset.Preset

Class

Base preset class to extend when defining a plugin that creates scene objects, assets, or components; requires a static descriptor() and an async createAsync…

Base preset class to extend when defining a plugin that creates scene objects, assets, or components; requires a static descriptor() and an async createAsync() method.

Index

Example

// Preset is the base class for plugins that add object/asset presets
// to Lens Studio menus.
//
// Key members:
// create(destination: SceneObject | Path, importSettings?): Entity
// Synchronous — add scene objects or configure assets under destination.
// createAsync(destination: SceneObject | Path, importSettings?): Promise<Entity>
// Async — use when the preset needs to load resources before finishing.
// pluginSystem (readonly) — resolves interface dependencies.

export class PresetClassExamplePreset extends Preset {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.PresetClassExample';
d.name = 'Light Rig Preset';
d.description = 'Creates a scene object configured as a light rig';
d.entityType = 'SceneObject';
d.section = 'Lighting';
d.dependencies = [Editor.Model.IModel];
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
}
async createAsync(destination: Editor.Model.SceneObject | Editor.Path): Promise<Editor.Model.Entity> {
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as unknown as Editor.Model.IModel;
const scene = model.project.scene;
const rig = scene.addSceneObject(destination as Editor.Model.SceneObject);
rig.name = 'Light Rig';
return rig;
}
}

Extends

Constructors

Constructor

new Preset(pluginSystem, descriptor?): Preset

Constructs a new Preset instance for defining a custom editor preset that creates scene objects, assets, or components.

Parameters

ParameterType
pluginSystemPluginSystem
descriptor?Descriptor

Returns

Preset

Overrides

Editor.IPlugin.constructor

Properties

id

readonly id: string

Unique string identifier of the plugin instance.

Inherited from

IPlugin.id


pluginSystem

readonly pluginSystem: PluginSystem

The plugin system instance used to resolve interface dependencies.

Methods

create()

create(destination, importSettings?): Entity

Synchronously creates and places a pre-configured entity at the given destination scene object or path.

Parameters

ParameterType
destinationPath | SceneObject
importSettings?any

Returns

Entity


createAsync()

createAsync(destination, importSettings?): Promise<Entity>

Asynchronously creates and places a pre-configured entity at the given destination scene object or path.

Parameters

ParameterType
destinationPath | SceneObject
importSettings?any

Returns

Promise<Entity>


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

IPlugin.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

IPlugin.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

IPlugin.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

IPlugin.isSame