Log inGet started
Package

prefab.nodebox

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

prefab.from_geometry (procNode)

A prefab of one entity drawing a geometry: a root entity record carrying the native Mesh and Material components, the reusable entity template a spawn copies. A spawned copy costs what a drawn mesh costs. Use it to turn one mesh a graph built into something the output node stands or the export node saves as a bundle. prefab.place puts it under an entity of another prefab at a local pose. The parts a graph builds and parents itself are elements: elements.entity makes one and elements.link parents it under another.

Inputs

  • geometry (Geometry). The mesh the entity draws. Its own material, the one geometry.set_material or instances.realize put there, is the one it draws with when material is left out; with neither, it draws with the default material.
  • name (String, default "model"). The root entity's name, and the handle the name-resolving nodes (prefab.entity, prefab.parent, prefab.link, prefab.place) reach it by afterwards. An empty string takes "model".
  • material (Points | Material | AssetRef<material>, optional). The material the entity draws with, ahead of whatever the geometry itself carries: what a material node answers (material.pbrMat, material.shader, io.import of a material), or a reference to a material asset, written asset.resolve("<identity>", "material").

Outputs

  • prefab (Prefab). One record: the root, its ecs holding a Mesh row (mesh, the geometry) and a Material row (id, the material). Spawning (the output node, bundle.spawn) makes each into the native component it names, and exporting writes the geometry and the material as assets the saved rows name by guid.
local crate = g.prefab.from_geometry({ geometry = g.mesh.box({}), name = "crate" })