Skip to content

Commit b335782

Browse files
committed
Fix for generating transform list
1 parent 9371753 commit b335782

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

v3/src/components/experimental-Transform-2.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function Transform(gameObject, root)
5858
// Only for user
5959
this.children = [];
6060
this.hasChildren = false;
61+
this.parent = this;
6162
// Only valid if you are the root.
6263
// This probably needs to be on State and not here.
6364
this.flatChildrenArray = [];
@@ -82,7 +83,7 @@ Transform.prototype.flattenTree = function (children, flatRenderArray, flatChild
8283
flatChildrenArray[childCount++] = child;
8384
if (children[index].children.length > 0)
8485
{
85-
var counts = this.flattenTree(children[index].children, flatChildrenArray, childCount);
86+
var counts = this.flattenTree(children[index].children, flatRenderArray, flatChildrenArray, childCount, renderCount);
8687
childCount = counts[0];
8788
renderCount = counts[1];
8889
flatChildrenArray[childCount++] = children[index]; // add ending tag
@@ -95,6 +96,8 @@ Transform.prototype.add = function (transform)
9596
this.root.dirty = true;
9697
this.hasChildren = true;
9798
transform.root = this.root;
99+
transform.parent.remove(transform);
100+
transform.parent = this;
98101
this.children.push(transform);
99102
};
100103
Transform.prototype.remove = function (transform)
@@ -106,6 +109,7 @@ Transform.prototype.remove = function (transform)
106109
children.splice(index, 1);
107110
this.hasChildren = (children.length > 0);
108111
this.root.dirty = true;
112+
transform.parent = transform;
109113
}
110114
};
111115

@@ -157,11 +161,14 @@ Transform.prototype.update = function (parentTransformMatrix)
157161
{
158162
var parent = parentTransformMatrix.matrix;
159163
var world = this.worldMatrix.matrix;
160-
var localm = this.localMatrix.loadIdentity();
161164
var rotation = this.rotation;
165+
166+
var localm = this.localMatrix.loadIdentity();
162167
localm.translate(this.positionX, this.positionY);
163-
if (rotation !== 0) localm.rotate(this.rotation);
164-
var local = localm.scale(this.scaleX, this.scaleY).matrix;
168+
//localm.rotate(rotation);
169+
localm.scale(this.scaleX, this.scaleY);
170+
171+
var local = localm.matrix;
165172

166173
world[0] = parent[0] * local[0] + parent[1] * local[2];
167174
world[1] = parent[0] * local[1] + parent[1] * local[3];

0 commit comments

Comments
 (0)