Model Scripting API

Module:

engine.resources.model_resource

Handle Type:

ModelId

Functions

generate_model(generator_path: string; properties: auto(T); on_ready: lambda<(id:PrefabId):void> = lambda<(id:PrefabId):void>()): PrefabId

Generates a model with the [model_generator] function of the file generator_path on a worker thread and returns the id of its prefab. Game code can instantiate the prefab at once: the instance is an empty node that the model fills when it is ready. on_ready gets the prefab, or PrefabId() if the generation failed; the error is in the log.

Usage example:

let tower = instantiate_prefab(generate_model("%file/tower.das", (floors = 3)), NodeData(position = float3(0, 0, 10)))
generate_model("%file/tower.das", (floors = 5), @(prefab : PrefabId) {
    instantiate_prefab(prefab, NodeData(position = float3(0, 0, 20)))
})
Arguments:
  • generator_path : string

  • properties : auto(T)

  • on_ready : lambda<(id: PrefabId):void>

generate_model(generator_path: string; on_ready: lambda<(id:PrefabId):void> = lambda<(id:PrefabId):void>()): PrefabId

Generates a model with a [model_generator] function whose arguments take their default values, see the overload with properties.

Arguments:
  • generator_path : string

  • on_ready : lambda<(id: PrefabId):void>

request_model(path: string): ModelId

Request model resource located in the ‘path’. multiple request calls with same path and other properties will return same ModelId

Arguments:
  • path : string