LensStudio:EntityGenerator.EntityGenerator
ClassConstructs a new entity generator plugin with an optional descriptor.
Index
Properties
Methods
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
| Parameter | Type |
|---|---|
pluginSystem | PluginSystem |
descriptor? | Descriptor |
Returns
EntityGenerator
Overrides
Editor.IPlugin.constructor
Properties
id
readonlyid:string
Unique string identifier of the plugin instance.
Inherited from
pluginSystem
readonlypluginSystem: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()
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