Files
LNXSDK/leenkx/Sources/leenkx/logicnode/GetMaterialsNode.hx
2025-01-22 16:18:30 +01:00

35 lines
711 B
Haxe

package leenkx.logicnode;
import iron.object.MeshObject;
import iron.object.DecalObject;
class GetMaterialsNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function get(from: Int): Dynamic {
var object = inputs[0].get();
assert(Error, object != null, "The object input must not be null");
#if rp_decals
if (Std.isOfType(object, DecalObject)) {
var decal = cast(object, DecalObject);
return from == 0 ? [decal.material] : 1;
}
#end
if (Std.isOfType(object, MeshObject)) {
var mesh = cast(object, MeshObject);
if (mesh == null) return null;
return from == 0 ? mesh.materials : mesh.materials.length;
}
return null;
}
}