Skip to content

Commit 6f19416

Browse files
committed
camera scrolling
1 parent 2c37dc3 commit 6f19416

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

v3/src/camera/Camera-2.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ var Camera = function (x, y, width, height)
99
this.state = null;
1010
this.statePositionX = 0.0;
1111
this.statePositionY = 0.0;
12+
this.scrollX = 0.0;
13+
this.scrollY = 0.0;
1214
};
1315

1416
Camera.prototype.setState = function (state)
@@ -28,7 +30,7 @@ Camera.prototype.preRender = function (interpolation, renderer)
2830
stateTransform.positionX = this.x;
2931
stateTransform.positionY = this.y;
3032

31-
Transform.updateRoot(stateTransform);
33+
Transform.updateRoot(stateTransform, -this.scrollX, -this.scrollY);
3234
};
3335

3436
Camera.prototype.postRender = function ()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Transform.prototype.remove = function (transform)
7272
}
7373
};
7474

75-
Transform.updateRoot = function (root)
75+
Transform.updateRoot = function (root, globalOffsetX, globalOffsetY)
7676
{
7777
var currentChild = null;
7878
var stackLength = 0;
@@ -117,8 +117,8 @@ Transform.updateRoot = function (root)
117117
var p4 = tempLocal[4];
118118
var p5 = tempLocal[5];
119119

120-
transX = child.positionX;
121-
transY = child.positionY;
120+
transX = child.positionX + globalOffsetX;
121+
transY = child.positionY + globalOffsetY;
122122
scaleX = child.scaleX;
123123
scaleY = child.scaleY;
124124
rotation = child.rotation;

v3/src/renderer/webgl/WebGLRenderer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ WebGLRenderer.prototype = {
273273

274274
var list = state.sys.children.list;
275275
var length = list.length;
276-
var matrixBuffer = Transform.float32Buffer;
277276
for (var index = 0; index < length; ++index)
278277
{
279278
var child = list[index];
@@ -299,7 +298,7 @@ WebGLRenderer.prototype = {
299298
this.blendMode = newBlendMode;
300299
}
301300
// drawing child
302-
child.renderWebGL(this, child, interpolationPercentage, matrixBuffer);
301+
child.renderWebGL(this, child, interpolationPercentage);
303302
batch = this.batch;
304303
if (batch && batch.isFull())
305304
{

0 commit comments

Comments
 (0)