Skip to content

Resource

Cached resource loading. The same path returns the same instance (no duplicate loads). All methods are static.

Returns: Map (or root type from TOML) — Cached config. Same as Config.load but cached by path; same path returns the same object.

Parameters:

  • path (String) — Path to the config file (e.g. TOML) relative to the mounted project.

Returns: BlendResult or null — Loaded blend data (classes, configs, node metadata). Cached per path. null if the file could not be loaded.

Parameters:

  • path (String) — Path to the .blend file relative to the mounted project (e.g. "Models/Cube.blend").

The result does not include a .nodes map; use instantiate to create scene instances and access nodes.

var blend = Resource.loadBlend("Models/Radio.blend")
if (blend != null) {
var root = blend.instantiate("Radio", _scene)
if (root != null && root.nodes.containsKey("body")) {
var bodyNode = root.nodes["body"]
}
}

Returns: Source or null — Cached audio source. Same path returns the same Source. null on load failure.

Parameters:

  • path (String) — Path to the audio file (e.g. "sounds/click.wav").
var sound = Resource.loadSound("sounds/click.wav")
if (sound != null) Audio.play(sound)

Result of Resource.loadBlend. Exposes .classes and .configs (no .nodes on the blend resource itself). Use instantiate(...) to create scene instances and register the blend’s actions.

Method / propertyReturnsParametersDescription
nodeCountNumNumber of nodes in the blend
nodeName(index)Stringindex (Num)Name of node at index
nodeId(index)(node ID)index (Num)ID of node at index
nodeCustomStringKeys(index)(list-like)index (Num)Custom string keys on node
nodeCustomIntKeys(index)(list-like)index (Num)Custom int keys on node
nodeCustomPropertyString(index, key)Stringindex, keyCustom string property
nodeCustomPropertyInt(index, key)Numindex, keyCustom int property

instantiate(className, scene) / instantiate(className, scene, prefix)

Section titled “instantiate(className, scene) / instantiate(className, scene, prefix)”

Returns: Node or null — Root node of the instantiated hierarchy (with .nodes map for children). null if the class was not found or instantiation failed.

Parameters:

  • className (String) — Class name as set in the Blender addon (e.g. "Radio", "Cube").
  • scene (Scene) — Scene to add the instance to.
  • prefix (String, optional) — Optional name prefix for instantiated nodes.

Creates an instance of the given class in the scene and registers the blend’s actions. The returned root’s .nodes map (nodeId → Node) lets you look up children.

var cubeRoot = _blend.instantiate("Cube", _scene)
if (cubeRoot != null && cubeRoot.nodes.containsKey("model")) {
var modelNode = cubeRoot.nodes["model"]
}