LensStudio:Preset.Preset
ClassBase 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
Properties
Methods
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
| Parameter | Type |
|---|---|
pluginSystem | PluginSystem |
descriptor? | Descriptor |
Returns
Preset
Overrides
Editor.IPlugin.constructor
Properties
id
readonlyid:string
Unique string identifier of the plugin instance.
Inherited from
pluginSystem
readonlypluginSystem: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
| Parameter | Type |
|---|---|
destination | Path | SceneObject |
importSettings? | any |
Returns
createAsync()
createAsync(
destination,importSettings?):Promise<Entity>
Asynchronously creates and places a pre-configured entity at the given destination scene object or path.
Parameters
| Parameter | Type |
|---|---|
destination | Path | SceneObject |
importSettings? | any |
Returns
Promise<Entity>
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean