Skip to main content

LensStudio:EntityGenerator

Module

Module for generating entities within Lens Studio projects.

Example

// The LensStudio:EntityGenerator module provides the EntityGenerator base class
// for plugins that create new entities (SceneObjects, Assets, or Components)
// in the Lens Studio scene hierarchy.
//
// Descriptor fields:
// entityType: string — 'SceneObject', 'Asset', or 'Component'
// displayOrder: number — position in the UI relative to other generators
// icon: Editor.Icon — icon for the generator in the UI
//
// EntityGenerator class:
// generate(): Promise<Editor.Model.Entity> — override to create entities

export class EntityGeneratorExampleGenerator extends EntityGenerator {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.EntityGeneratorExample';
d.name = 'Empty Object Generator';
d.description = 'Creates an empty scene object';
d.entityType = 'SceneObject';
d.displayOrder = 100;
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 Object';
return obj;
}
}

Classes

ClassDescription
DescriptorConfiguration descriptor for an entity generator, specifying entity type and icon.
EntityGeneratorConstructs a new entity generator plugin with an optional descriptor.