Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

io.export (procNode)

Save a value as the asset its type states: a Geometry as a mesh, points carrying a Mesh as a population, a Texture record as a texture, one element holding a record (what a material node answers) as the asset its record kind saves as (a material as a .material), a Prefab as a bundle or a scene. With as set to "bundle" or "scene", a Geometry (with primitives one entity, points one entity each), a list of Geometries or an asset reference is written as the entities it stands as. The value is read back from the device first, and the asset is created through its type's graph contract. Answers the AssetRef and the number of entities the value stands as.

Built from op.transfer.readback of the value, then io.engine with writeAsset, which writes the asset (a bundle writes the meshes, materials, textures and populations its entities use inside its own folder, a scene inside its prefabs folder, as mesh<n>, material<n>, texture<n>, population<n>, one per distinct value; a mesh or material the value already holds as a reference stays a reference and nothing is written for it), and countEntities. Writing the same name again re-bakes the asset in place and keeps its guid.

local written = g.io.export({ value = mesh, name = "crate", folder = "kit" })
local ref = written.ref
local village = g.io.export({ value = prefab, name = "village", as = "scene" })

Inputs

  • value (Value). The value to save: a Geometry, a list of Geometries, an asset reference, a Texture, an element holding a record (a material node's answer), points carrying a Mesh, or a Prefab.
  • name (String, default ""). The asset's name: a bare identifier. Writing the same name again re-bakes that asset.
  • folder (String, default ""). A subfolder under the world source to write into; empty uses generated.
  • as (String, default "", one of "", "mesh", "texture", "material", "population", "bundle", "scene"). The asset type to write. Empty takes the type the value states: a Prefab saves as a bundle, and "scene" saves its entities as a loadable scene.

Outputs

  • ref: the AssetRef of the asset written.
  • entityCount: how many entities the value stands as when written as a bundle or scene: the records of a Prefab; 1 for a Geometry with primitives or an asset reference; a root and one per point for a Geometry of points; a root and one per Geometry for a list; 0 for one element holding a record saved as its kind's asset, and for any other value.