This commit is contained in:
2026-05-06 17:52:45 -07:00
parent 9fc3f35125
commit 1463c23334
402 changed files with 3758 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,9 @@
Shows how to control material nodes at run-time.
Press 1, 2, 3 to change parameters.
- Enable `Parameter` property in `Logic Node Editor - Properties - Leenkx Material Node`
- RGB, Value and Image Texture nodes are supported
- See `MyTrait` script to set material parameters using Haxe
- See `NodeTree` to set material parameters using logic nodes
https://github.com/leenkx3d/leenkx/wiki/materials#material-parameters

View File

@ -0,0 +1,53 @@
package lnx;
import iron.math.Vec4;
import iron.object.Object;
import iron.object.Uniforms;
import iron.data.Data;
import iron.data.MaterialData;
import iron.system.Time;
class MyTrait extends iron.Trait {
var tex1:kha.Image = null;
var tex2:kha.Image = null;
public function new() {
super();
notifyOnInit(() -> {
// Register link callbacks
Uniforms.externalVec3Links.push(vec3Link);
Uniforms.externalFloatLinks.push(floatLink);
Uniforms.externalTextureLinks.push(textureLink);
});
Data.getImage("tex1.png", img -> tex1 = img );
Data.getImage("tex2.png", img -> tex2 = img );
}
function vec3Link(object:Object, mat:MaterialData, link:String):Vec4 {
// object - currently bound object
// mat - currently bound material
// link - material node name
if (link == "RGB") {
var t = Time.time();
return new Vec4(Math.sin(t) * 0.5 + 0.5, Math.cos(t) * 0.5 + 0.5, Math.sin(t + 0.5) * 0.5 + 0.5);
}
return null;
}
function floatLink(object:Object, mat:MaterialData, link:String):Null<kha.FastFloat> {
if (link == "Value") {
var t = Time.time();
return Math.floor(t);
}
return null;
}
function textureLink(object:Object, mat:MaterialData, link:String):kha.Image {
if (link == "Image Texture") {
var t = Time.time();
return Math.sin(t) > 0 ? tex1 : tex2;
}
return null;
}
}

Binary file not shown.