MaterialInstancePlugin

View source

ExtendsPlugin

Connects one material asset type to one concrete material component.

Registering this plugin associates the material asset constructor in asset with the component constructor in component. It releases material handles when the component is removed, makes the typed handle and component metadata available to reflection, and keeps matching 2D and 3D entities in the appropriate camera render lists. RenderCorePlugin creates the built-in pairing for BasicMaterial and BasicMaterialInstance.

Examples

import { App } from '@wimaengine/app'
import { BasicMaterial, BasicMaterialInstance, RenderCorePlugin } from '@wimaengine/render-core'

const app = new App()
app.registerPlugin(new RenderCorePlugin())

// RenderCorePlugin registers the equivalent of:
// new MaterialInstancePlugin({
//   asset: BasicMaterial,
//   component: BasicMaterialInstance
// })

Constructor


Properties


readonlycomponent: object

View source

Component constructor for entities bound to the material type T.

MaterialInstancePlugin#register uses this constructor for handle cleanup, reflection metadata, and render-list integration.

readonlyasset: Constructor<T>

View source

Material asset constructor handled by this plugin.

Its type ID distinguishes the material in reflected handle metadata and render-list entries. It also contributes to this plugin’s generic identity.

Methods


register(app: App): void

View source

Registers this material pair with an App.

When an entity carrying the component is removed, its material handle is released; no add or insert hook is installed.

The typed Handle value and component metadata become available to reflection during app startup, including supported static component methods.

As the app updates, matching entities with GlobalTransform2D, Meshed, and this component are included in camera RenderLists2D opaque passes. Matching 3D entities use GlobalTransform3D, Meshed, and this component and are included in RenderLists3D opaque passes. Entries use the material and mesh handle IDs, and each camera’s matching render lists are rebuilt from the current entities.

Parameters

NameDescriptionDefault
app

App receiving the hook and render-list registrations.

—

name(): TypeId

View source

Returns this plugin’s generic identity for its material asset type.

Plugins configured with the same asset constructor receive the same ID, even when their component constructors differ.

Returns

Generic TypeId for this material asset type.