Examples
// WebglRendererPlugin installs disposeDroppedMeshes in Update/PostMain.
app.registerPlugin(new WebglRendererPlugin())
// MeshDropped events then release their cached WebGL vertex arrays.Function
disposeDroppedMeshes(world: World): voidDisposes the WebGL vertex arrays for dropped mesh assets.
WebglRendererPlugin registers this function directly in the repeating
AppSchedule.Update schedule’s
CoreSystems.PostMain
group. It reads the typed Events resource for MeshDropped,
the MeshCache, and the Windows canvas resource.
The system selects the first tuple matching
[[EntityHandle](</api/ecs/others/class/EntityHandle>), [Window](</api/window/component/Window>), [MainWindow](</api/window/component/MainWindow>)] with
Query#single. If no main-window tuple exists, it
warns and returns. If Windows#getWindow finds no canvas for the
matching entity,
it returns silently. If the canvas cannot provide a webgl2 context, it
warns and returns. Each guard exits before the event batch is visited, so no
dropped mesh is processed during that invocation.
For every event in the current readable Events batch, the system
reads the dropped asset id from event.data.id and looks up its VAO in
MeshCache. If no VAO is cached, that event is skipped without a WebGL
deletion or cache mutation. Otherwise it calls
WebGL2RenderingContext#deleteVertexArray and then
removes the id with Map.prototype.delete. The callback return
skips only that event; subsequent dropped events remain eligible for the
same pass.
Events#each reads events but does not clear them, and
this function never calls Events#clear. Event-batch rotation
is owned by the event plugin’s separately scheduled clear system, normally
in CoreSystems.End.
// WebglRendererPlugin installs disposeDroppedMeshes in Update/PostMain.
app.registerPlugin(new WebglRendererPlugin())
// MeshDropped events then release their cached WebGL vertex arrays.