The object has a diffuse material with empty texture. It works without exception, when I manually duplicate the object in blender. But when I spawn these object from a Trait attached to the scene, it comes to an exception.
Does the ui_script3d example work for you? The example is’nt working for me, because I can’t press the button. So also the gate doesn’t open or close.
But I tried to reproduce your error and also got a exception.
I added the following haxe trait to the scene of the ui_script3d example:
package arm;
class MyTrait extends iron.Trait {
public function new() {
super();
notifyOnInit(function() {
iron.Scene.active.spawnObject("Plane", null, function(o) {});
});
}
}
and got the following exception:
Uncaught exception:
var mat = (js_Boot.__cast(this.object , iron_object_MeshObject)).materials[0];
^
TypeError: Unable to get property ‘materials’ of undefined or null reference
at sceneInit (krom.js:406:3)
at iron_Scene.prototype.notifyOnInit (krom.js:6933:4)
at Anonymous function (krom.js:389:3)
at iron_data_Data.getFont (krom.js:7842:3)
at arm_UITrait (krom.js:387:2)
at Type.createInstance (krom.js:189:2)
at iron_Scene.createTraitClassInstance (krom.js:6297:2)
at iron_Scene.createTraits (krom.js:6224:4)
at iron_Scene.prototype.returnObjectLoaded (krom.js:6900:4)
at iron_Scene.prototype.returnObject (krom.js:6864:4)
The exception was in UITrait.hx at line 34 as you told, because object is null.
When duplicating the object manually in blender, the object is not null in line 34.
So I think there is a bug in the spawnObject function.