Use newly exposed props.Node.addChild method
This commit is contained in:
parent
33a5d73cc4
commit
a15d582937
3 changed files with 6 additions and 25 deletions
|
@ -11,7 +11,7 @@ var PropertyElement = {
|
|||
new: func(node, id)
|
||||
{
|
||||
if( typeof(node) == 'vector' )
|
||||
var node = _createNodeWithIndex(node[0], node[1]);
|
||||
var node = aircraft.makeNode(node[0]).addChild(node[1], 0, 0);
|
||||
else
|
||||
var node = aircraft.makeNode(node);
|
||||
|
||||
|
|
|
@ -1,23 +1,3 @@
|
|||
# Helper function to create a node with the first available index for the given
|
||||
# path relative to the given node
|
||||
#
|
||||
var _createNodeWithIndex = func(node, path, min_index = 0)
|
||||
{
|
||||
var node = aircraft.makeNode(node);
|
||||
|
||||
# TODO do we need an upper limit? (50000 seems already seems unreachable)
|
||||
for(var i = min_index; i < 50000; i += 1)
|
||||
{
|
||||
var p = path ~ "[" ~ i ~ "]";
|
||||
if( node.getNode(p) == nil )
|
||||
return node.getNode(p, 1);
|
||||
}
|
||||
|
||||
debug.warn("Unable to get child (already 50000 exist)");
|
||||
|
||||
return nil;
|
||||
};
|
||||
|
||||
# Internal helper
|
||||
var _createColorNodes = func(parent, name)
|
||||
{
|
||||
|
@ -237,8 +217,8 @@ var Element = {
|
|||
# @param vals Default values (Vector of 6 elements)
|
||||
createTransform: func(vals = nil)
|
||||
{
|
||||
var node = _createNodeWithIndex(me._node, "tf", 1); # tf[0] is reserved for
|
||||
# setRotation
|
||||
var node = me._node.addChild("tf", 1); # tf[0] is reserved for
|
||||
# setRotation
|
||||
return Transform.new(node, vals);
|
||||
},
|
||||
# Shortcut for setting translation
|
||||
|
@ -767,7 +747,7 @@ var Canvas = {
|
|||
# given every texture of the model will be replaced.
|
||||
addPlacement: func(vals)
|
||||
{
|
||||
var placement = _createNodeWithIndex(me.texture, "placement");
|
||||
var placement = me.texture.addChild("placement", 0, 0);
|
||||
placement.setValues(vals);
|
||||
return placement;
|
||||
},
|
||||
|
@ -801,7 +781,7 @@ var new = func(vals)
|
|||
{
|
||||
var m = { parents: [Canvas] };
|
||||
|
||||
m.texture = _createNodeWithIndex(Canvas.property_root, "texture");
|
||||
m.texture = Canvas.property_root.addChild("texture", 0, 0);
|
||||
m.color = _createColorNodes(m.texture, "color-background");
|
||||
m.texture.setValues(vals);
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ var Node = {
|
|||
getParent : func wrap(_getParent(me._g, arg)),
|
||||
getChild : func wrap(_getChild(me._g, arg)),
|
||||
getChildren : func wrap(_getChildren(me._g, arg)),
|
||||
addChild : func wrap(_addChild(me._g, arg)),
|
||||
removeChild : func wrap(_removeChild(me._g, arg)),
|
||||
removeChildren : func wrap(_removeChildren(me._g, arg)),
|
||||
getAliasTarget : func wrap(_getAliasTarget(me._g, arg)),
|
||||
|
|
Loading…
Reference in a new issue