|
128 | 128 |
|
129 | 129 | } |
130 | 130 |
|
131 | | - clientToSurface(x, y) { |
| 131 | + clientToSurface(a, b, c) { |
132 | 132 | this.updateOffset(); |
133 | 133 | 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); |
136 | 147 | } |
137 | 148 |
|
138 | | - surfaceToClient(v) { |
| 149 | + surfaceToClient(a, b, c) { |
139 | 150 | this.updateOffset(); |
140 | 151 | 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); |
143 | 165 | } |
144 | 166 |
|
145 | 167 | zoomBy(byF, clientX, clientY) { |
|
0 commit comments