Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdf78e4f826

README.md

assets.new

Persist a live runtime GPU resource — a mesh or texture handle from renderer.mesh.create / renderer.texture.create, which has no asset behind it — into a durable, guid-anchored asset.

A runtime resource lives only on the GPU: nothing references it by a stable identity, so anything keyed to it (a GI bake, a saved scene, a material slot) is session-only and regenerates with a fresh identity on the next reload. assets.new reads the resource back from the GPU, encodes it, and writes a real asset via asset.create, so it survives a reload.

asset.create itself is disk-only — it writes supplied bytes or pixels and never reads the GPU back. So for raw in-hand geometry or pixels, call asset.create(<type>, name, data) directly; assets.new is the tool for freezing a resource that only exists as a live handle.

Reify in edit mode to make content durable — in play mode the asset lands in the ephemeral runtime store.

local h = renderer.mesh.create({ positions = p, indices = i })
assets.new(h, "tree")                               -- persist the runtime mesh
assets.new(meshGuid, "terrain", { category = "mesh" })  -- a bare guid string needs opts.category

Reifiable categories: mesh, texture. See assets.fromEntity to reify every runtime resource an entity carries in one call.