Preparing search index...

    Plugin class that manages asset instantiation, initialized with a PluginSystem and optional Descriptor.

    // LensStudio:AssetInstantiator.AssetInstantiator is the same class exported
    // at the module root (LensStudio:AssetInstantiator); this entry just
    // documents it under its dotted name. See the module page for the Texture
    // drop flow that imports a bundled plane mesh + material. Below: a generic
    // instantiator that puts every dropped asset under a single named parent
    // SceneObject — handy for AI-tool plugins that stage drops in one bucket
    // for review.
    import { AssetInstantiator, Descriptor } from 'LensStudio:AssetInstantiator';

    const STAGED_PARENT = 'StagedDrops';

    export class StagedAssetInstantiator extends AssetInstantiator {
    static descriptor(): Descriptor {
    const d = new Descriptor();
    d.id = 'com.docs.AssetInstantiatorClassExample';
    d.name = 'Staged Asset Instantiator';
    d.description = 'Drops any asset under a single staging parent';
    d.dependencies = [Editor.Model.IModel];
    d.canInstantiate = (_asset: Editor.Assets.Asset) => true;
    return d;
    }

    async prepareDependencies(
    _asset: Editor.Assets.Asset,
    _manager: Editor.Model.AssetManager,
    ): Promise<Editor.Assets.Asset[]> {
    // Ensure the dedicated parent exists so all drops nest under it.
    const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
    const scene = model.project.scene;
    if (!scene.rootSceneObjects.find(o => o.name === STAGED_PARENT)) {
    scene.createSceneObject(STAGED_PARENT);
    }
    return [];
    }

    instantiate(
    asset: Editor.Assets.Asset,
    scene: Editor.Assets.ObjectOwner,
    target: Editor.Model.SceneObject,
    ): Editor.Model.Prefabable[] {
    const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
    const parent = model.project.scene.rootSceneObjects.find(o => o.name === STAGED_PARENT) ?? target;
    const obj = scene.addSceneObject(parent);
    obj.name = `${asset.name} (staged ${new Date().toISOString().slice(0, 10)})`;
    return [obj as unknown as Editor.Model.Prefabable];
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    id: string
    pluginSystem: PluginSystem

    The plugin system instance this instantiator is registered with.

    Methods

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

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

      Parameters

      Returns boolean