Skip to content

Commit 77170ef

Browse files
committed
Passed Fixes Along to ES5 Version of ZUI
1 parent d7a6e67 commit 77170ef

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

extras/js/zui.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,40 @@
128128

129129
}
130130

131-
clientToSurface(x, y) {
131+
clientToSurface(a, b, c) {
132132
this.updateOffset();
133133
const m = this.surfaceMatrix.inverse();
134-
const n = this.viewportOffset.matrix.inverse().multiply(x, y, 1);
135-
return m.multiply.apply(m, [n.x, n.y, n.z]);
134+
let x, y, z;
135+
if (arguments.length === 1) {
136+
const v = a;
137+
x = typeof v.x === 'number' ? v.x : 0;
138+
y = typeof v.y === 'number' ? v.y : 0;
139+
z = typeof v.z === 'number' ? v.z : 1;
140+
} else {
141+
x = typeof a === 'number' ? a : 0;
142+
y = typeof b === 'number' ? b : 0;
143+
z = typeof c === 'number' ? c : 1;
144+
}
145+
const n = this.viewportOffset.matrix.inverse().multiply(x, y, z);
146+
return m.multiply(n.x, n.y, n.z);
136147
}
137148

138-
surfaceToClient(v) {
149+
surfaceToClient(a, b, c) {
139150
this.updateOffset();
140151
const vo = this.viewportOffset.matrix.clone();
141-
const sm = this.surfaceMatrix.multiply.apply(this.surfaceMatrix, [v.x, v.y, v.z]);
142-
return vo.multiply.apply(vo, [sm.x, sm.y, sm.z]);
152+
let x, y, z;
153+
if (arguments.length === 1) {
154+
const v = a;
155+
x = typeof v.x === 'number' ? v.x : 0;
156+
y = typeof v.y === 'number' ? v.y : 0;
157+
z = typeof v.z === 'number' ? v.z : 1;
158+
} else {
159+
x = typeof a === 'number' ? a : 0;
160+
y = typeof b === 'number' ? b : 0;
161+
z = typeof c === 'number' ? c : 1;
162+
}
163+
const sm = this.surfaceMatrix.multiply(x, y, z);
164+
return vo.multiply(sm.x, sm.y, sm.z);
143165
}
144166

145167
zoomBy(byF, clientX, clientY) {

extras/jsm/zui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Two from 'two.js';
21
import { Matrix } from '../../src/matrix.js';
32

43
class Surface {
@@ -159,6 +158,7 @@ export class ZUI {
159158
const m = this.surfaceMatrix.inverse();
160159
let x, y, z;
161160
if (arguments.length === 1) {
161+
const v = a;
162162
x = typeof v.x === 'number' ? v.x : 0;
163163
y = typeof v.y === 'number' ? v.y : 0;
164164
z = typeof v.z === 'number' ? v.z : 1;

0 commit comments

Comments
 (0)