|
@@ -119,4 +119,27 @@ class ModelCache {
|
|
|
return a;
|
|
|
}
|
|
|
|
|
|
+ #if hide
|
|
|
+
|
|
|
+ public function loadPrefab( res : hxd.res.Prefab, ?parent : h3d.scene.Object ) {
|
|
|
+ var p = res.load();
|
|
|
+ var ctx = new hrt.prefab.Context();
|
|
|
+ ctx.init(res);
|
|
|
+ @:privateAccess ctx.shared.cache = this;
|
|
|
+ var prevChild = 0;
|
|
|
+ if( parent != null ) {
|
|
|
+ ctx.local3d = ctx.shared.root3d = parent;
|
|
|
+ prevChild = parent.numChildren;
|
|
|
+ }
|
|
|
+ var ctx2 = p.make(ctx);
|
|
|
+ if( parent != null ) {
|
|
|
+ // only return object if a single child was added
|
|
|
+ // if not - multiple children were added and cannot be returned as a single object
|
|
|
+ return parent.numChildren == prevChild + 1 ? parent.getChildAt(prevChild) : null;
|
|
|
+ }
|
|
|
+ return ctx.local3d.numChildren == 1 ? ctx.local3d.getChildAt(0) : ctx.local3d;
|
|
|
+ }
|
|
|
+
|
|
|
+ #end
|
|
|
+
|
|
|
}
|