Skip to main content

LensStudio:EntityGenerator.EntityGenerator

Class

Constructs a new entity generator plugin with an optional descriptor.

Index

Example

// The EntityGenerator class (from LensStudio:EntityGenerator) is the base class
// for plugins that add new entity creation options to the editor.
//
// Members:
// generate(): Promise<Entity> — override to create and return a new entity
// pluginSystem (readonly) — access to the plugin system

export class EntityGeneratorEntityGeneratorExampleGenerator extends EntityGenerator {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.EntityGeneratorEntityGeneratorExample';
d.name = 'Named Object Generator';
d.description = 'Demonstrates EntityGenerator with generate() override';
d.entityType = 'SceneObject';
d.displayOrder = 10;
d.dependencies = [Editor.Model.IModel];
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
}
async generate(): Promise<Editor.Model.Entity> {
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as unknown as Editor.Model.IModel;
const scene = model.project.scene;
const obj = scene.addSceneObject(null as unknown as Editor.Model.SceneObject);
obj.name = `Generated_${Date.now()}`;
console.log(`Created scene object: ${obj.name}`);
return obj;
}
}

Extends

Constructors

Constructor

new EntityGenerator(pluginSystem, descriptor?): EntityGenerator

Constructs an EntityGenerator plugin instance with the given plugin system and optional descriptor.

Parameters

ParameterType
pluginSystemPluginSystem
descriptor?Descriptor

Returns

EntityGenerator

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 PluginSystem instance associated with this plugin.

Methods

generate()

generate(): Promise<Entity>

Generates a new Entity and returns it as a Promise.

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