Skip to content

Commit c16c19b

Browse files
committed
Slight optimization on camera.applyView
1 parent 76526d5 commit c16c19b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/classes/sigma.classes.camera.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,22 @@
100100
cos = Math.cos(this.angle),
101101
sin = Math.sin(this.angle),
102102
nodeRatio = Math.pow(this.ratio, this.settings('nodesPowRatio')),
103-
edgeRatio = Math.pow(this.ratio, this.settings('edgesPowRatio'));
103+
edgeRatio = Math.pow(this.ratio, this.settings('edgesPowRatio')),
104+
xDivider = this.ratio + (options.width || 0) / 2,
105+
yDivider = this.ratio + (options.height || 0) / 2;
104106

105107
for (i = 0, l = nodes.length; i < l; i++) {
106108
node = nodes[i];
107109
node[write + 'x'] =
108110
(
109111
((node[read + 'x'] || 0) - this.x) * cos +
110112
((node[read + 'y'] || 0) - this.y) * sin
111-
) / this.ratio + (options.width || 0) / 2;
113+
) / xDivider;
112114
node[write + 'y'] =
113115
(
114116
((node[read + 'y'] || 0) - this.y) * cos -
115117
((node[read + 'x'] || 0) - this.x) * sin
116-
) / this.ratio + (options.height || 0) / 2;
118+
) / yDivider;
117119
node[write + 'size'] =
118120
(node[read + 'size'] || 0) /
119121
nodeRatio;

0 commit comments

Comments
 (0)