@maptalks/transform-control 0.90.0 → 0.91.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/transform-control.es.js +256 -221
- package/dist/transform-control.js +4 -4
- package/package.json +4 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/transform-control v0.
|
|
2
|
+
* @maptalks/transform-control v0.91.2
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2023 maptalks.org
|
|
5
5
|
*/
|
|
6
|
-
import { quat as A, mat4 as e, reshader as t, vec3 as s, vec2 as i, GroupGLLayer as
|
|
6
|
+
import { quat as A, mat4 as e, reshader as t, vec3 as s, vec2 as i, GroupGLLayer as n } from "@maptalks/gl";
|
|
7
7
|
|
|
8
|
-
import * as
|
|
8
|
+
import * as I from "maptalks";
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { Point as o, Coordinate as g, Eventable as r, Handlerable as C, Class as a } from "maptalks";
|
|
11
11
|
|
|
12
12
|
import * as h from "@maptalks/gltf-loader";
|
|
13
13
|
|
|
@@ -1156,8 +1156,8 @@ const w = {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
}, c = [];
|
|
1158
1158
|
|
|
1159
|
-
function Q(s, i,
|
|
1160
|
-
const r = [], C = A.fromEuler([],
|
|
1159
|
+
function Q(s, i, n, I, o, g) {
|
|
1160
|
+
const r = [], C = A.fromEuler([], n[0], n[1], n[2]), a = e.fromRotationTranslationScale([], C, i, I);
|
|
1161
1161
|
return function(A) {
|
|
1162
1162
|
return new h.GLTFLoader("", w[A]).load().then(A => A);
|
|
1163
1163
|
}(s).then(A => {
|
|
@@ -1167,10 +1167,13 @@ function Q(s, i, I, n, o, g) {
|
|
|
1167
1167
|
}), h = new t.Mesh(A.geometry, C);
|
|
1168
1168
|
h.setUniform("uPickingId", g + s);
|
|
1169
1169
|
const w = h.getDefines();
|
|
1170
|
-
w.HAS_PICKING_ID = 2, h.setDefines(w), h.translate = i, h.rotation =
|
|
1170
|
+
w.HAS_PICKING_ID = 2, h.setDefines(w), h.translate = i, h.rotation = n, h.scaling = I,
|
|
1171
1171
|
e.multiply(h.localTransform, a, A.nodeMatrix), h.originTransform = e.copy([], h.localTransform),
|
|
1172
1172
|
h.originColor = o || A.materialInfo.baseColorFactor, r.push(h);
|
|
1173
|
-
})
|
|
1173
|
+
}), g > 100 && (r[0].properties.relatedMeshes = r.slice(1, 2), r[1].properties.relatedMeshes = r.slice(0, 1),
|
|
1174
|
+
r[2].properties.relatedMeshes = r.slice(3, 4), r[3].properties.relatedMeshes = r.slice(2, 3),
|
|
1175
|
+
r[4].properties.relatedMeshes = r.slice(5, 6), r[5].properties.relatedMeshes = r.slice(4, 5),
|
|
1176
|
+
r[6].properties.relatedMeshes = r.slice(0, 6));
|
|
1174
1177
|
}), r;
|
|
1175
1178
|
}
|
|
1176
1179
|
|
|
@@ -1178,21 +1181,21 @@ function f(A, e) {
|
|
|
1178
1181
|
return Math.abs(A) * Math.sign(e);
|
|
1179
1182
|
}
|
|
1180
1183
|
|
|
1181
|
-
function
|
|
1182
|
-
const i = A.getCoordinates(),
|
|
1184
|
+
function l(A, t) {
|
|
1185
|
+
const i = A.getCoordinates(), n = t.coordinateToPointAtRes(i, t.getGLRes()), o = [ n.x, n.y, 0 ], g = P(t, A.getTranslation());
|
|
1183
1186
|
s.add(o, o, g);
|
|
1184
1187
|
const r = function(A, e, t, s) {
|
|
1185
1188
|
return A._pointAtResToContainerPoint(e, t, s);
|
|
1186
|
-
}(t, new
|
|
1187
|
-
r.x +=
|
|
1188
|
-
const C = function(A, t, i,
|
|
1189
|
-
if (
|
|
1189
|
+
}(t, new I.Point(o[0], o[1]), t.getGLRes());
|
|
1190
|
+
r.x += 85;
|
|
1191
|
+
const C = function(A, t, i, n) {
|
|
1192
|
+
if (n) {
|
|
1190
1193
|
const o = i / A._getResolution(), g = A.width / 2, r = A.height / 2;
|
|
1191
|
-
c[0] = (t.x - g) / g, c[1] = t.y / r - 1, c[3] =
|
|
1194
|
+
c[0] = (t.x - g) / g, c[1] = t.y / r - 1, c[3] = n * o;
|
|
1192
1195
|
const C = e.invert([], A.projViewMatrix);
|
|
1193
1196
|
s.transformMat4(c, c, C);
|
|
1194
1197
|
const a = A.getGLScale();
|
|
1195
|
-
return s.set(c, c[0] / a, c[1] / a, c[2] / a), s.scale(c, c, 1 / o), new
|
|
1198
|
+
return s.set(c, c[0] / a, c[1] / a, c[2] / a), s.scale(c, c, 1 / o), new I.Point(c[0], c[1]);
|
|
1196
1199
|
}
|
|
1197
1200
|
{
|
|
1198
1201
|
const e = A.containerPointToCoordinate(t);
|
|
@@ -1202,7 +1205,7 @@ function P(A, t) {
|
|
|
1202
1205
|
return Math.sqrt(Math.pow(C.x - o[0], 2) + Math.pow(C.y - o[1], 2)) / 5.272881136101205;
|
|
1203
1206
|
}
|
|
1204
1207
|
|
|
1205
|
-
function
|
|
1208
|
+
function P(A, e) {
|
|
1206
1209
|
if (!A) return e;
|
|
1207
1210
|
const t = A.distanceToPointAtRes(e[0], e[1], A.getGLRes()), i = A.altitudeToPoint(e[2], A.getGLRes());
|
|
1208
1211
|
return s.set([], f(t.x, e[0]), f(t.y, e[1]), f(i, e[2]));
|
|
@@ -1216,8 +1219,8 @@ class D {
|
|
|
1216
1219
|
this.A = A;
|
|
1217
1220
|
}
|
|
1218
1221
|
t() {
|
|
1219
|
-
const A = [], e = 340 / 177, t = Q("jiantou", [ 1.2 * e, 0, 0 ], [ 0, 0, 90 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 7), s = Q("jiantou", [ 0, 1.2 * e, 0 ], [ 0, 0, 180 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 8), i = Q("jiantou", [ -1.2 * e, 0, 0 ], [ 0, 0, 270 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 9),
|
|
1220
|
-
return A.push(t, s, i,
|
|
1222
|
+
const A = [], e = 340 / 177, t = Q("jiantou", [ 1.2 * e, 0, 0 ], [ 0, 0, 90 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 7), s = Q("jiantou", [ 0, 1.2 * e, 0 ], [ 0, 0, 180 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 8), i = Q("jiantou", [ -1.2 * e, 0, 0 ], [ 0, 0, 270 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 9), n = Q("jiantou", [ 0, -1.2 * e, 0 ], [ 0, 0, 0 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 10);
|
|
1223
|
+
return A.push(t, s, i, n), A;
|
|
1221
1224
|
}
|
|
1222
1225
|
getMeshes() {
|
|
1223
1226
|
return this._meshes;
|
|
@@ -1288,7 +1291,7 @@ class B {
|
|
|
1288
1291
|
}
|
|
1289
1292
|
}
|
|
1290
1293
|
|
|
1291
|
-
const y = [], p = [], v = [], L = [], M = [],
|
|
1294
|
+
const y = [], p = [], v = [], L = [], M = [], d = [ 177 / 170, 177 / 170, 177 / 170 ], E = [ 1, 2, 3, 4, 12 ];
|
|
1292
1295
|
|
|
1293
1296
|
class O {
|
|
1294
1297
|
constructor() {
|
|
@@ -1300,27 +1303,27 @@ class O {
|
|
|
1300
1303
|
A.translate = this.translate.getMeshes(), A.rotation = this.rotation.getMeshes(),
|
|
1301
1304
|
A.scaling = this.scaling.getMeshes(), A.planeHelper = this.planeHelper.getMeshes(),
|
|
1302
1305
|
A.xyzScale = this.xyzScaleHelper.getMeshes();
|
|
1303
|
-
const e = 340 / 177, t = Q("yuanhuan41", [ -2.745 * e, 2.745 * e, 0 ], [ 90, 0, 0 ], [ .5 * e, .5 * e, .5 * e ], [ 149 / 255, 179 / 255, 199 / 255, .6 ], 1), s = Q("yuanhuan41", [ 2.745 * e, 2.745 * e, 0 ], [ -90, 0, 180 ], [ .5 * e, .5 * e, .5 * e ], [ 50 / 255, 130 / 255, 184 / 255, .5 ], 2), i = Q("yuanhuan41", [ 2.745 * e, -2.745 * e, 0 ], [ 90, 0, 180 ], [ .5 * e, .5 * e, .5 * e ], [ 149 / 255, 179 / 255, 199 / 255, .6 ], 3),
|
|
1304
|
-
return A.translate.push(t, s, i,
|
|
1306
|
+
const e = 340 / 177, t = Q("yuanhuan41", [ -2.745 * e, 2.745 * e, 0 ], [ 90, 0, 0 ], [ .5 * e, .5 * e, .5 * e ], [ 149 / 255, 179 / 255, 199 / 255, .6 ], 1), s = Q("yuanhuan41", [ 2.745 * e, 2.745 * e, 0 ], [ -90, 0, 180 ], [ .5 * e, .5 * e, .5 * e ], [ 50 / 255, 130 / 255, 184 / 255, .5 ], 2), i = Q("yuanhuan41", [ 2.745 * e, -2.745 * e, 0 ], [ 90, 0, 180 ], [ .5 * e, .5 * e, .5 * e ], [ 149 / 255, 179 / 255, 199 / 255, .6 ], 3), n = Q("yuanhuan41", [ -2.745 * e, -2.745 * e, 0 ], [ -90, 0, 0 ], [ .5 * e, .5 * e, .5 * e ], [ 50 / 255, 130 / 255, 184 / 255, .5 ], 4), I = Q("yuanpan", [ 0, 0, 0 ], [ 90, 0, 0 ], [ .5 * e, .5 * e, .5 * e ], [ 89 / 255, 206 / 255, 147 / 255, .5 ], 5), o = Q("zzhou", [ 0, 0, 6.5 ], [ 90, 0, 0 ], [ 1, 1, 1 ], [ 14 / 255, 127 / 255, 191 / 255, 1 ], 6);
|
|
1307
|
+
return A.translate.push(t, s, i, n, I, o), A;
|
|
1305
1308
|
}
|
|
1306
|
-
updateMatrix(t, i,
|
|
1309
|
+
updateMatrix(t, i, n, I, o) {
|
|
1307
1310
|
const g = i.getCoordinates(), r = t.coordinateToPointAtRes(g, t.getGLRes()), C = i.i();
|
|
1308
1311
|
s.set(p, r.x, r.y, C);
|
|
1309
|
-
const a = s.copy(y, o), h =
|
|
1312
|
+
const a = s.copy(y, o), h = P(t, i.getTranslation());
|
|
1310
1313
|
s.add(p, p, h), s.add(p, p, a);
|
|
1311
1314
|
for (const o in this._meshes) for (let g = 0; g < this._meshes[o].length; g++) {
|
|
1312
1315
|
const r = this._meshes[o][g];
|
|
1313
1316
|
for (let g = 0; g < r.length; g++) {
|
|
1314
1317
|
const C = r[g], a = C.getUniform("uPickingId"), h = s.copy(y, C.translate), w = [ C.rotation[0], C.rotation[1], C.rotation[2] ], c = C.scaling;
|
|
1315
|
-
if (11 === a && (this.s ? (w[2] +=
|
|
1316
|
-
C.rotation[2] +=
|
|
1317
|
-
c[1] +=
|
|
1318
|
+
if (11 === a && (this.s ? (w[2] += n, C.rotation[2] += n) : this.s || (w[2] += n,
|
|
1319
|
+
C.rotation[2] += n, w[0] = 360, w[2] -= 90)), E.indexOf(a) > -1) if (12 !== a) c[0] += I,
|
|
1320
|
+
c[1] += I, c[2] += I; else {
|
|
1318
1321
|
const A = this._meshes.translate[4][0];
|
|
1319
1322
|
c[0] = 1.2 * A.scaling[0], c[1] = 1.2 * A.scaling[0], c[2] = 1.2 * A.scaling[0];
|
|
1320
1323
|
}
|
|
1321
|
-
let Q =
|
|
1324
|
+
let Q = l(i, t);
|
|
1322
1325
|
if (Q = s.set(v, Q, Q, Q), s.multiply(h, h, Q), s.multiply(Q, Q, c), 1 === a || 2 === a || 3 === a || 4 === a) {
|
|
1323
|
-
const A = s.multiply(M, c,
|
|
1326
|
+
const A = s.multiply(M, c, d);
|
|
1324
1327
|
s.multiply(h, h, A);
|
|
1325
1328
|
}
|
|
1326
1329
|
const f = A.fromEuler(L, w[0], w[1], w[2]);
|
|
@@ -1350,16 +1353,16 @@ class O {
|
|
|
1350
1353
|
}
|
|
1351
1354
|
}
|
|
1352
1355
|
|
|
1353
|
-
const F = [];
|
|
1356
|
+
const F = [], x = [], U = [], V = new o(0, 0), S = [], k = [], T = [];
|
|
1354
1357
|
|
|
1355
|
-
class
|
|
1358
|
+
class H {
|
|
1356
1359
|
constructor() {
|
|
1357
1360
|
this.o = [], this.g = [ 0, 0, 0 ], this.C = [ 1, 1, 1 ], this.h = [ 0, 0, 0 ];
|
|
1358
1361
|
}
|
|
1359
|
-
|
|
1362
|
+
l(A) {
|
|
1360
1363
|
Array.isArray(A) ? A.forEach(A => {
|
|
1361
|
-
this.
|
|
1362
|
-
}) : (A.on("remove", this.
|
|
1364
|
+
this.l(A);
|
|
1365
|
+
}) : (A.on("remove", this.P, this), A.D = {
|
|
1363
1366
|
coordinate: A.getCoordinates(),
|
|
1364
1367
|
translation: A.getTranslation(),
|
|
1365
1368
|
rotation: A.getRotation(),
|
|
@@ -1368,41 +1371,62 @@ class x {
|
|
|
1368
1371
|
}
|
|
1369
1372
|
u() {
|
|
1370
1373
|
this.o.forEach(A => {
|
|
1371
|
-
A.off("remove", this.
|
|
1374
|
+
A.off("remove", this.P, this);
|
|
1372
1375
|
}), this.o = [];
|
|
1373
1376
|
}
|
|
1374
|
-
m(A, e, t, i,
|
|
1375
|
-
for (let
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
D[0] = D[0] * (I / A), D[1] = D[1] * (I / A), D[2] = D[2] * (I / A);
|
|
1384
|
-
}
|
|
1385
|
-
const u = s.add(w, t, w);
|
|
1386
|
-
if (A.indexOf("translate") > -1) g.fire("positionchange", {
|
|
1387
|
-
action: A,
|
|
1388
|
-
type: "positionchange",
|
|
1389
|
-
target: this,
|
|
1390
|
-
coordinate: P
|
|
1391
|
-
}), C.setCoordinates(P); else {
|
|
1392
|
-
this.B(A, D, c);
|
|
1393
|
-
const e = C.getTranslation();
|
|
1394
|
-
C.setTRS(e, u, D), g.fire("transforming", {
|
|
1395
|
-
action: this.p,
|
|
1396
|
-
type: "transforming",
|
|
1397
|
-
target: this,
|
|
1398
|
-
translate: e,
|
|
1399
|
-
rotation: u,
|
|
1400
|
-
scale: D
|
|
1401
|
-
});
|
|
1377
|
+
m(A, e, t, i, n, I, o) {
|
|
1378
|
+
for (let o = 0; o < this.o.length; o++) {
|
|
1379
|
+
const g = this.o[o], r = g.getRotation(), C = g.getScale(), a = this.B(I, g, i, t, e);
|
|
1380
|
+
let h = null;
|
|
1381
|
+
h = i >= 0 ? i : i * (this.options && this.options.scaleStrength || 1);
|
|
1382
|
+
const w = s.add(T, s.set(F, h, h * (C[1] / C[0]), h * (C[2] / C[0])), C);
|
|
1383
|
+
if (Math.min(...w) < n) {
|
|
1384
|
+
const A = Math.min(...w);
|
|
1385
|
+
w[0] = w[0] * (n / A), w[1] = w[1] * (n / A), w[2] = w[2] * (n / A);
|
|
1402
1386
|
}
|
|
1387
|
+
const c = s.add(r, t, r);
|
|
1388
|
+
g.setCoordinates(a), this.p(A, w, C);
|
|
1389
|
+
const Q = g.getTranslation();
|
|
1390
|
+
g.setTRS(Q, c, w);
|
|
1403
1391
|
}
|
|
1392
|
+
s.set(T, i, i, i), s.add(this.h, t, this.h), s.add(this.C, T, this.C), s.add(this.g, e, this.g),
|
|
1393
|
+
A.indexOf("translate") > -1 ? o.fire("positionchange", {
|
|
1394
|
+
action: A,
|
|
1395
|
+
type: "positionchange",
|
|
1396
|
+
target: this.o,
|
|
1397
|
+
center: this.getCoordinates(),
|
|
1398
|
+
scale: this.C,
|
|
1399
|
+
rotation: this.h,
|
|
1400
|
+
translation: this.g,
|
|
1401
|
+
deltaTranslate: e,
|
|
1402
|
+
deltaRotation: t,
|
|
1403
|
+
deltaScale: i
|
|
1404
|
+
}) : o.fire("transforming", {
|
|
1405
|
+
action: A,
|
|
1406
|
+
type: "transforming",
|
|
1407
|
+
target: this.o,
|
|
1408
|
+
center: this.o[0].getTransformOrigin(),
|
|
1409
|
+
scale: this.C,
|
|
1410
|
+
rotation: this.h,
|
|
1411
|
+
translation: this.g,
|
|
1412
|
+
deltaTranslate: e,
|
|
1413
|
+
deltaRotation: t,
|
|
1414
|
+
deltaScale: i
|
|
1415
|
+
});
|
|
1404
1416
|
}
|
|
1405
|
-
B(
|
|
1417
|
+
B(t, i, n, I, o) {
|
|
1418
|
+
const g = i.getCenter(), r = i.getTransformOrigin(), C = t.getGLRes(), a = t.coordinateToPointAtRes(g, C, V);
|
|
1419
|
+
a.z = t.altitudeToPoint(g.z, C), s.set(S, a.x, a.y, a.z || 0);
|
|
1420
|
+
const h = t.coordinateToPointAtRes(r, C, V);
|
|
1421
|
+
h.z = t.altitudeToPoint(r.z, C), s.set(k, h.x, h.y, h.z || 0);
|
|
1422
|
+
const w = s.sub(F, S, k), c = A.fromEuler(x, 0, 0, I[2]);
|
|
1423
|
+
s.set(T, n + 1, n + 1, n + 1);
|
|
1424
|
+
const Q = e.fromRotationTranslationScale(U, c, o, T);
|
|
1425
|
+
s.transformMat4(w, w, Q), s.add(w, w, k), V.set(w[0], w[1]);
|
|
1426
|
+
const f = t.pointAtResToCoordinate(V, C);
|
|
1427
|
+
return f.z = w[2] / t.altitudeToPoint(1, C), f;
|
|
1428
|
+
}
|
|
1429
|
+
p(A, e, t) {
|
|
1406
1430
|
return "x-scale" === A && (e[1] = t[1], e[2] = t[2]), "y-scale" === A && (e[0] = t[0],
|
|
1407
1431
|
e[2] = t[2]), "z-scale" === A && (e[0] = t[0], e[1] = t[1]), e;
|
|
1408
1432
|
}
|
|
@@ -1434,9 +1458,12 @@ class x {
|
|
|
1434
1458
|
const s = this.o[i].getCenter();
|
|
1435
1459
|
A += s.x, e += s.y, t += s.z || 0;
|
|
1436
1460
|
}
|
|
1437
|
-
|
|
1461
|
+
A /= s, e /= s, t /= s;
|
|
1462
|
+
const i = new g(A, e, t);
|
|
1463
|
+
for (let A = 0; A < s; A++) this.o[A].setTransformOrigin(i);
|
|
1464
|
+
return i;
|
|
1438
1465
|
}
|
|
1439
|
-
|
|
1466
|
+
P(A) {
|
|
1440
1467
|
const e = A.target, t = this.o.indexOf(e);
|
|
1441
1468
|
t > -1 && (delete e.D, this.o.splice(t, 1));
|
|
1442
1469
|
}
|
|
@@ -1457,12 +1484,12 @@ class x {
|
|
|
1457
1484
|
}
|
|
1458
1485
|
}
|
|
1459
1486
|
|
|
1460
|
-
const
|
|
1487
|
+
const J = [ 5, 6, 7, 8, 9, 10 ], N = [ 5, 7, 8, 9, 10 ], R = [ 2, 4, 11 ], _ = [ 1, 3, 12 ], K = [ 12, 16 ], z = [ 1, 2, 3, 4 ], G = [ 1, 2, 3, 4, 12 ], j = [], Z = [], Y = [], W = [], q = [], X = [], $ = [];
|
|
1461
1488
|
|
|
1462
|
-
class
|
|
1489
|
+
class AA extends(r(C(a))){
|
|
1463
1490
|
constructor(A = {}) {
|
|
1464
1491
|
super(A), this.options = A, this.mouseAction = "moving", this.O = this.options.mode || "translate",
|
|
1465
|
-
this.F = !0, this.TransformHelper = new O, this.U = new
|
|
1492
|
+
this.F = !0, this.TransformHelper = new O, this.U = new H, this.helperScene = new t.Scene([]),
|
|
1466
1493
|
this.addToMapCount = 0;
|
|
1467
1494
|
}
|
|
1468
1495
|
enable() {
|
|
@@ -1473,7 +1500,7 @@ class Z extends(g(r(C))){
|
|
|
1473
1500
|
this;
|
|
1474
1501
|
}
|
|
1475
1502
|
setMode(A) {
|
|
1476
|
-
this.O = A, this.layerRenderer && this.layerRenderer.setToRedraw();
|
|
1503
|
+
this.O = A, this.V(), this.layerRenderer && this.layerRenderer.setToRedraw();
|
|
1477
1504
|
}
|
|
1478
1505
|
getMode() {
|
|
1479
1506
|
return this.O;
|
|
@@ -1481,215 +1508,223 @@ class Z extends(g(r(C))){
|
|
|
1481
1508
|
isEnable() {
|
|
1482
1509
|
return this.F;
|
|
1483
1510
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1511
|
+
S(A) {
|
|
1512
|
+
J.indexOf(A) > -1 ? this.O = "translate" : R.indexOf(A) > -1 ? this.O = "rotation" : _.indexOf(A) > -1 ? this.O = "scaling" : "xyzScale" !== this.O && (this.O = "translate");
|
|
1486
1513
|
}
|
|
1487
|
-
|
|
1514
|
+
k() {
|
|
1488
1515
|
return this.O;
|
|
1489
1516
|
}
|
|
1490
1517
|
addTo(A) {
|
|
1491
|
-
this.map && (this.
|
|
1492
|
-
this.addToMapCount++, this.map = A, this.container = A.getContainer(), A.on("dom:mousemove", this.
|
|
1493
|
-
A.on("dom:mousedown", this.
|
|
1494
|
-
this.
|
|
1518
|
+
this.map && (this.T(), console.warn("transform control has been added to a map, it suggest remove from the map before")),
|
|
1519
|
+
this.addToMapCount++, this.map = A, this.container = A.getContainer(), A.on("dom:mousemove", this.H, this),
|
|
1520
|
+
A.on("dom:mousedown", this.J, this), A.on("dom:mouseup", this.N, this), A.on("zooming moving dragrotating", this.R, this),
|
|
1521
|
+
this._();
|
|
1495
1522
|
}
|
|
1496
1523
|
remove() {
|
|
1497
|
-
this.map && this.container && this.layerRenderer && (this.
|
|
1524
|
+
this.map && this.container && this.layerRenderer && (this.T(), this.TransformHelper.dispose(),
|
|
1498
1525
|
this.layerRenderer.setToRedraw(), delete this.map, delete this.layer, delete this.layerRenderer,
|
|
1499
1526
|
delete this.container, delete this.U);
|
|
1500
1527
|
}
|
|
1501
|
-
|
|
1502
|
-
this.container && this.map && (this.map.off("dom:mousemove", this.
|
|
1503
|
-
this.map.off("dom:mouseup", this.
|
|
1528
|
+
T() {
|
|
1529
|
+
this.container && this.map && (this.map.off("dom:mousemove", this.H, this), this.map.off("dom:mousedown", this.J, this),
|
|
1530
|
+
this.map.off("dom:mouseup", this.N, this), this.map.off("zooming moving dragrotating", this.R, this),
|
|
1504
1531
|
this.layer && this.layer.off("renderend", this.render, this));
|
|
1505
1532
|
}
|
|
1506
|
-
|
|
1507
|
-
if (this.
|
|
1533
|
+
H(A) {
|
|
1534
|
+
if (this.K()) {
|
|
1508
1535
|
if (this.currentMousePosition = {
|
|
1509
1536
|
x: A.containerPoint.x,
|
|
1510
1537
|
y: A.containerPoint.y
|
|
1511
1538
|
}, "moving" === this.mouseAction) {
|
|
1512
|
-
const A = this.
|
|
1513
|
-
this.currentPickingObject = this.
|
|
1514
|
-
6 === this.currentPickingObject.pickingId ? this.
|
|
1515
|
-
this.
|
|
1539
|
+
const A = this.G();
|
|
1540
|
+
this.currentPickingObject = this.j(this.currentMousePosition, A, "meshes"), this.currentPickingObject && null != this.currentPickingObject.pickingId ? (this.S(this.currentPickingObject.pickingId),
|
|
1541
|
+
6 === this.currentPickingObject.pickingId ? this.Z(!0) : this.Z(!1)) : (this.Z(!1),
|
|
1542
|
+
this.S()), this.Y();
|
|
1516
1543
|
}
|
|
1517
|
-
this.
|
|
1544
|
+
this.W(this.currentMousePosition);
|
|
1518
1545
|
}
|
|
1519
1546
|
}
|
|
1520
|
-
|
|
1521
|
-
if (!this.
|
|
1522
|
-
const e = this.
|
|
1547
|
+
J(A) {
|
|
1548
|
+
if (!this.K() || 0 !== A.domEvent.button) return;
|
|
1549
|
+
const e = this.G();
|
|
1523
1550
|
this.currentMousePosition = {
|
|
1524
1551
|
x: A.containerPoint.x,
|
|
1525
1552
|
y: A.containerPoint.y
|
|
1526
|
-
}, this.
|
|
1527
|
-
this.firstDownPoint = this.
|
|
1528
|
-
this.
|
|
1553
|
+
}, this.q = !0, this.currentPickingObject = this.j(this.currentMousePosition, e, "meshes"),
|
|
1554
|
+
this.firstDownPoint = this.j(this.currentMousePosition, e, "meshes"), this.currentPickingObject && null != this.currentPickingObject.meshId ? (this.mouseAction = "transform",
|
|
1555
|
+
this.X(this.currentPickingObject.pickingId), this.map.config("zoomable", !1), this.map.config("draggable", !1),
|
|
1529
1556
|
this.layerRenderer && this.layerRenderer.setToRedraw()) : (this.mouseAction = "pan",
|
|
1530
|
-
this.map.config("zoomable", !0), this.map.config("draggable", !0), this.
|
|
1557
|
+
this.map.config("zoomable", !0), this.map.config("draggable", !0), this.V()), this.lastMousePosition = this.currentMousePosition,
|
|
1531
1558
|
this.lastPickingObject = this.currentPickingObject, this.lastPickingMesh = e[this.currentPickingObject.meshId];
|
|
1532
1559
|
}
|
|
1533
|
-
|
|
1534
|
-
"transform" === this.mouseAction && (this.firstDownPoint = null, this.
|
|
1560
|
+
N() {
|
|
1561
|
+
"transform" === this.mouseAction && (this.firstDownPoint = null, this.V(), this.q = !0,
|
|
1535
1562
|
this.fire("transformend", {
|
|
1536
|
-
action: this
|
|
1563
|
+
action: this.$,
|
|
1537
1564
|
type: "transformend"
|
|
1538
1565
|
})), this.mouseAction = "moving", "xyzScale" !== this.O && (this.O = "translate"),
|
|
1539
1566
|
this.map.config("zoomable", !0), this.map.config("draggable", !0), this.layerRenderer && this.layerRenderer.setToRedraw();
|
|
1540
1567
|
}
|
|
1541
|
-
|
|
1568
|
+
R() {
|
|
1542
1569
|
const A = this.TransformHelper.planeHelper.getMeshes()[0][0], e = this.map.getBearing();
|
|
1543
|
-
A.rotation[2] = -e, this
|
|
1570
|
+
A.rotation[2] = -e, this.AA();
|
|
1544
1571
|
}
|
|
1545
|
-
|
|
1546
|
-
this.
|
|
1547
|
-
this.
|
|
1572
|
+
AA() {
|
|
1573
|
+
this.K() && (this.TransformHelper.updateMatrix(this.map, this.U, 0, 0, [ 0, 0, 0 ]),
|
|
1574
|
+
this.q = !0);
|
|
1548
1575
|
}
|
|
1549
1576
|
picked(A) {
|
|
1550
1577
|
if (!this.layerRenderer) return !1;
|
|
1551
|
-
const e = this.
|
|
1578
|
+
const e = this.G(), t = this.map;
|
|
1552
1579
|
let s = A;
|
|
1553
|
-
A instanceof
|
|
1554
|
-
const i = this.
|
|
1580
|
+
A instanceof o || (s = t.coordinateToContainerPoint(new g(A)));
|
|
1581
|
+
const i = this.j(s, e, "picked");
|
|
1555
1582
|
return !(!i || null === i.meshId);
|
|
1556
1583
|
}
|
|
1557
|
-
|
|
1584
|
+
V() {
|
|
1558
1585
|
const A = this.TransformHelper.getMeshes("scaling").scaling[0][0];
|
|
1559
|
-
A.scaling = [ 340 / 177 * .6, 340 / 177 * .6, 340 / 177 * .6 ], this.layerRenderer && (this.
|
|
1560
|
-
this.
|
|
1586
|
+
A.scaling = [ 340 / 177 * .6, 340 / 177 * .6, 340 / 177 * .6 ], this.layerRenderer && (this.eA(A),
|
|
1587
|
+
this.tA());
|
|
1561
1588
|
}
|
|
1562
|
-
|
|
1589
|
+
tA() {
|
|
1563
1590
|
this.TransformHelper._meshes.translate.forEach(A => {
|
|
1564
1591
|
for (let e = 0; e < A.length; e++) {
|
|
1565
1592
|
const t = A[e];
|
|
1566
|
-
|
|
1593
|
+
z.indexOf(t.getUniform("uPickingId")) > -1 && t.material.set("color", t.originColor);
|
|
1567
1594
|
}
|
|
1568
1595
|
});
|
|
1569
1596
|
}
|
|
1570
|
-
|
|
1571
|
-
const i = this.U.getCoordinates(),
|
|
1572
|
-
s.add(
|
|
1597
|
+
eA(t) {
|
|
1598
|
+
const i = this.U.getCoordinates(), n = this.map.coordinateToPointAtRes(i, this.map.getGLRes()), I = [ n.x, n.y, 0 ], o = P(this.map, this.U.getTranslation());
|
|
1599
|
+
s.add(I, I, o);
|
|
1573
1600
|
const g = s.copy([], t.translate), r = t.scaling;
|
|
1574
|
-
let C =
|
|
1575
|
-
C = s.set([], C, C, C), s.multiply(g, g, C), s.multiply(C, C, r), s.add(g, g,
|
|
1601
|
+
let C = l(this.U, this.map);
|
|
1602
|
+
C = s.set([], C, C, C), s.multiply(g, g, C), s.multiply(C, C, r), s.add(g, g, I),
|
|
1576
1603
|
e.fromRotationTranslationScale(t.localTransform, [ 0, 0, 0, 1 ], g, C);
|
|
1577
|
-
this.
|
|
1604
|
+
this.G().forEach(t => {
|
|
1578
1605
|
const i = t.getUniform("uPickingId");
|
|
1579
1606
|
if (1 === i || 3 === i || 2 === i || 4 === i) {
|
|
1580
|
-
const i = s.copy([], t.translate),
|
|
1581
|
-
t.scaling = [
|
|
1607
|
+
const i = s.copy([], t.translate), n = 170 / 177;
|
|
1608
|
+
t.scaling = [ n, n, n ];
|
|
1582
1609
|
const o = t.scaling, g = t.rotation;
|
|
1583
|
-
let r =
|
|
1584
|
-
r = s.set([], r, r, r), s.multiply(i, i, r), s.multiply(r, r, o), s.add(i, i,
|
|
1610
|
+
let r = l(this.U, this.map);
|
|
1611
|
+
r = s.set([], r, r, r), s.multiply(i, i, r), s.multiply(r, r, o), s.add(i, i, I);
|
|
1585
1612
|
const C = A.fromEuler([], g[0], g[1], g[2]);
|
|
1586
1613
|
e.fromRotationTranslationScale(t.localTransform, C, i, r);
|
|
1587
1614
|
}
|
|
1588
1615
|
});
|
|
1589
1616
|
}
|
|
1590
|
-
|
|
1617
|
+
sA(A) {
|
|
1591
1618
|
const e = this.map.containerPointToCoordinate(A), t = this.map.coordinateToPointAtRes(e, this.map.getGLRes());
|
|
1592
1619
|
return {
|
|
1593
1620
|
point: [ t.x, t.y ]
|
|
1594
1621
|
};
|
|
1595
1622
|
}
|
|
1596
|
-
|
|
1623
|
+
W(A) {
|
|
1597
1624
|
if ("transform" === this.mouseAction) {
|
|
1598
|
-
const A = this.
|
|
1599
|
-
let s = null,
|
|
1600
|
-
if (e[2] + t < .01 && "z-translate" !== this
|
|
1601
|
-
|
|
1625
|
+
const A = this.k(), e = P(this.map, this.U.getTranslation()), t = this.U.i();
|
|
1626
|
+
let s = null, n = null;
|
|
1627
|
+
if (e[2] + t < .01 && "z-translate" !== this.$) s = this.sA(this.currentMousePosition),
|
|
1628
|
+
n = this.sA(this.lastMousePosition); else {
|
|
1602
1629
|
const A = this.TransformHelper.planeHelper.getMeshes()[0];
|
|
1603
|
-
if (s = this.
|
|
1604
|
-
!s || null === s.meshId || !
|
|
1630
|
+
if (s = this.j(this.currentMousePosition, A, "plane"), n = this.j(this.lastMousePosition, A, "plane"),
|
|
1631
|
+
!s || null === s.meshId || !n || null === n.meshId) return;
|
|
1605
1632
|
}
|
|
1606
|
-
const
|
|
1607
|
-
let
|
|
1633
|
+
const I = [ 0, 0, 0 ], g = [ 0, 0, 0 ];
|
|
1634
|
+
let r = 0, C = 0, a = 0;
|
|
1608
1635
|
if ("translate" === A) {
|
|
1609
|
-
if ("xy-translate" === this
|
|
1610
|
-
const A = s.point[0] -
|
|
1611
|
-
|
|
1612
|
-
} else if ("x-translate" === this
|
|
1613
|
-
const A = s.point[0] -
|
|
1614
|
-
|
|
1615
|
-
} else if ("y-translate" === this
|
|
1616
|
-
const A = s.point[1] -
|
|
1617
|
-
|
|
1618
|
-
} else if ("z-translate" === this
|
|
1636
|
+
if ("xy-translate" === this.$) {
|
|
1637
|
+
const A = s.point[0] - n.point[0], e = s.point[1] - n.point[1];
|
|
1638
|
+
I[0] = A, I[1] = e;
|
|
1639
|
+
} else if ("x-translate" === this.$) {
|
|
1640
|
+
const A = s.point[0] - n.point[0];
|
|
1641
|
+
I[0] = A;
|
|
1642
|
+
} else if ("y-translate" === this.$) {
|
|
1643
|
+
const A = s.point[1] - n.point[1];
|
|
1644
|
+
I[1] = A;
|
|
1645
|
+
} else if ("z-translate" === this.$) {
|
|
1619
1646
|
let A = 0;
|
|
1620
|
-
if (this.
|
|
1621
|
-
const e = this.map.getGLRes(), t = this.map._pointAtResToContainerPoint(new
|
|
1622
|
-
A =
|
|
1623
|
-
} else A = s.point[2] -
|
|
1624
|
-
|
|
1647
|
+
if (this.iA()) {
|
|
1648
|
+
const e = this.map.getGLRes(), t = this.map._pointAtResToContainerPoint(new o(n.point[0], n.point[1]), e), I = this.map._pointAtResToContainerPoint(new o(s.point[0], s.point[1]), e), g = i.length(i.set(W, s.point[0] - n.point[0], s.point[1] - n.point[1]));
|
|
1649
|
+
A = I.y < t.y ? g : -g;
|
|
1650
|
+
} else A = s.point[2] - n.point[2];
|
|
1651
|
+
I[2] = A;
|
|
1625
1652
|
}
|
|
1626
|
-
} else if ("rotation" === A)
|
|
1627
|
-
|
|
1628
|
-
const A = this.IA(), e = i.length(i.set(
|
|
1629
|
-
|
|
1653
|
+
} else if ("rotation" === A) C = this.nA(s.point, n.point), C >= 0 ? this.TransformHelper.I(!0) : this.TransformHelper.I(!1),
|
|
1654
|
+
g[2] += C; else if ("scaling" === A || "xyzScale" === A) {
|
|
1655
|
+
const A = this.IA(), e = i.length(i.set(W, this.firstDownPoint.point[0] - A[0], this.firstDownPoint.point[1] - A[1])), t = i.length(i.set(W, n.point[0] - A[0], n.point[1] - A[1]));
|
|
1656
|
+
r = this.oA(s.point, n.point, A, t), a = this.oA(s.point, n.point, A, e);
|
|
1630
1657
|
}
|
|
1631
|
-
this.TransformHelper.updateMatrix(this.map, this.U,
|
|
1658
|
+
this.TransformHelper.updateMatrix(this.map, this.U, C, a, I), this.U.m(this.$, I, g, r, .01, this.map, this);
|
|
1632
1659
|
}
|
|
1633
1660
|
this.lastMousePosition = A, this.lastPickingObject = this.currentPickingObject;
|
|
1634
|
-
const e = this.
|
|
1661
|
+
const e = this.G();
|
|
1635
1662
|
this.lastPickingMesh = e[this.currentPickingObject.meshId];
|
|
1636
1663
|
}
|
|
1637
|
-
|
|
1638
|
-
const
|
|
1639
|
-
return
|
|
1664
|
+
oA(A, e, t, s, n) {
|
|
1665
|
+
const I = (i.length(i.set(W, A[0] - t[0], A[1] - t[1])) - i.length(i.set(W, e[0] - t[0], e[1] - t[1]))) / s;
|
|
1666
|
+
return n ? (n[0] - .01) * I : I;
|
|
1640
1667
|
}
|
|
1641
1668
|
IA() {
|
|
1642
|
-
const A = this.map, e = this.U.getCoordinates(), t = A.coordinateToPointAtRes(e, A.getGLRes()), i = s.set(
|
|
1643
|
-
return s.add(i, i,
|
|
1669
|
+
const A = this.map, e = this.U.getCoordinates(), t = A.coordinateToPointAtRes(e, A.getGLRes()), i = s.set(q, t.x, t.y, 0), n = P(A, this.U.getTranslation());
|
|
1670
|
+
return s.add(i, i, n), i;
|
|
1644
1671
|
}
|
|
1645
|
-
|
|
1646
|
-
const i = this.TransformHelper.planeHelper.getMeshes()[0][0],
|
|
1647
|
-
let o = A.fromEuler(
|
|
1672
|
+
Z(t) {
|
|
1673
|
+
const i = this.TransformHelper.planeHelper.getMeshes()[0][0], n = e.getTranslation(Y, i.localTransform), I = e.getScaling(Z, i.localTransform);
|
|
1674
|
+
let o = A.fromEuler(j, 0, 0, 0);
|
|
1648
1675
|
const g = this.map.getBearing();
|
|
1649
|
-
t && !this.
|
|
1650
|
-
s.set(i.rotation, 90, 0, -g)) : (90 === i.rotation[0] && (this.
|
|
1651
|
-
e.fromRotationTranslationScale(i.localTransform, o,
|
|
1676
|
+
t && !this.iA() ? (o = A.fromEuler(j, 90, 0, -g), 0 === i.rotation[0] && (this.q = !0),
|
|
1677
|
+
s.set(i.rotation, 90, 0, -g)) : (90 === i.rotation[0] && (this.q = !0), s.set(i.rotation, 0, 0, -g)),
|
|
1678
|
+
e.fromRotationTranslationScale(i.localTransform, o, n, I);
|
|
1652
1679
|
}
|
|
1653
|
-
|
|
1680
|
+
iA() {
|
|
1654
1681
|
if (this.map.getPitch()) return !1;
|
|
1655
1682
|
const A = this.map.cameraPosition, e = this.map.coordinateToPointAtRes(this.map.getCenter(), this.map.getGLRes());
|
|
1656
1683
|
s.set(e, e.x, e.y, 0);
|
|
1657
|
-
const t = this.U.getCoordinates(), i = this.map.coordinateToPointAtRes(t, this.map.getGLRes()),
|
|
1684
|
+
const t = this.U.getCoordinates(), i = this.map.coordinateToPointAtRes(t, this.map.getGLRes()), n = P(this.map, this.U.getTranslation()), I = s.set(Y, i.x, i.y, 0), o = s.add(I, I, n), g = s.subtract([], A, o), r = s.subtract([], A, e);
|
|
1658
1685
|
return s.angle(g, r) < 1 / 180 * Math.PI;
|
|
1659
1686
|
}
|
|
1660
|
-
|
|
1661
|
-
const A = this.
|
|
1687
|
+
Y() {
|
|
1688
|
+
const A = this.G();
|
|
1662
1689
|
if (this.currentPickingObject && null != this.currentPickingObject.meshId) {
|
|
1663
|
-
this.
|
|
1690
|
+
this.gA(), this.lastPickingObject && null != this.lastPickingObject.meshId && this.lastPickingObject.meshId !== this.currentPickingObject.meshId && this.rA();
|
|
1664
1691
|
const e = A[this.currentPickingObject.meshId];
|
|
1665
|
-
if (e &&
|
|
1692
|
+
if (e && K.indexOf(this.currentPickingObject.pickingId) < 0) if (this.currentPickingObject.pickingId > 100) this.CA(e); else {
|
|
1666
1693
|
const A = [ e.originColor[0], e.originColor[1], e.originColor[2], .8 ];
|
|
1667
|
-
e.material.set("color", A), this.
|
|
1694
|
+
e.material.set("color", A), this.aA(e, .5);
|
|
1668
1695
|
}
|
|
1669
1696
|
this.layerRenderer.setToRedraw();
|
|
1670
1697
|
} else this.lastPickingObject && null != this.lastPickingObject.meshId && (this.map.resetCursor(),
|
|
1671
|
-
this.
|
|
1698
|
+
this.rA(), this.layerRenderer.setToRedraw());
|
|
1672
1699
|
}
|
|
1673
|
-
|
|
1674
|
-
|
|
1700
|
+
CA(A) {
|
|
1701
|
+
const e = [ 1, 179 / 255, 2 / 255, 1 ];
|
|
1702
|
+
A.material.set("color", e), A.properties.relatedMeshes && A.properties.relatedMeshes.forEach(A => {
|
|
1703
|
+
A.material.set("color", e);
|
|
1704
|
+
});
|
|
1675
1705
|
}
|
|
1676
1706
|
gA() {
|
|
1707
|
+
6 === this.currentPickingObject.pickingId ? this.map.setCursor("ns-resize") : N.indexOf(this.currentPickingObject.pickingId) > -1 ? this.map.setCursor("move") : this.map.setCursor("pointer");
|
|
1708
|
+
}
|
|
1709
|
+
rA() {
|
|
1677
1710
|
const A = this.lastPickingMesh;
|
|
1678
1711
|
if (!A) return;
|
|
1679
|
-
const e = A.getUniform("uPickingId"), t = this.
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
}) :
|
|
1712
|
+
const e = A.getUniform("uPickingId"), t = this.G();
|
|
1713
|
+
N.indexOf(e) > -1 ? t.forEach(A => {
|
|
1714
|
+
N.indexOf(A.getUniform("uPickingId")) > -1 && A.material.set("color", A.originColor);
|
|
1715
|
+
}) : G.indexOf(e) > -1 ? t.forEach(A => {
|
|
1683
1716
|
const e = A.getUniform("uPickingId");
|
|
1684
|
-
|
|
1717
|
+
z.indexOf(e) > -1 && A.material.set("color", A.originColor);
|
|
1685
1718
|
}) : 11 === e && t.forEach(A => {
|
|
1686
|
-
|
|
1687
|
-
}), A.material.set("color", A.originColor)
|
|
1719
|
+
z.indexOf(A.getUniform("uPickingId")) > -1 && A.material.set("color", A.originColor);
|
|
1720
|
+
}), A.material.set("color", A.originColor), A.properties.relatedMeshes && A.properties.relatedMeshes.forEach(A => {
|
|
1721
|
+
A.material.set("color", A.originColor);
|
|
1722
|
+
});
|
|
1688
1723
|
}
|
|
1689
|
-
|
|
1690
|
-
const t = A.getUniform("uPickingId"), s = this.
|
|
1691
|
-
|
|
1692
|
-
if (
|
|
1724
|
+
aA(A, e) {
|
|
1725
|
+
const t = A.getUniform("uPickingId"), s = this.G();
|
|
1726
|
+
N.indexOf(t) > -1 ? s.forEach(t => {
|
|
1727
|
+
if (N.indexOf(t.getUniform("uPickingId")) > -1 && t.getUniform("uPickingId") !== A.getUniform("uPickingId")) {
|
|
1693
1728
|
const A = [ t.originColor[0], t.originColor[1], t.originColor[2], e ];
|
|
1694
1729
|
t.material.set("color", A);
|
|
1695
1730
|
}
|
|
@@ -1710,34 +1745,34 @@ class Z extends(g(r(C))){
|
|
|
1710
1745
|
reset() {
|
|
1711
1746
|
this.map && this.U && (this.U.v(), this.TransformHelper.updateMatrix(this.map, this.U, 0, 0, [ 0, 0, 0 ]));
|
|
1712
1747
|
}
|
|
1713
|
-
|
|
1714
|
-
const t = this.IA(), s = i.set(
|
|
1715
|
-
return (Math.atan2(
|
|
1748
|
+
nA(A, e) {
|
|
1749
|
+
const t = this.IA(), s = i.set(X, e[0] - t[0], e[1] - t[1]), n = i.set($, A[0] - t[0], A[1] - t[1]), I = Math.atan2(s[1], s[0]);
|
|
1750
|
+
return (Math.atan2(n[1], n[0]) - I) / Math.PI * 180;
|
|
1716
1751
|
}
|
|
1717
|
-
|
|
1718
|
-
return this
|
|
1719
|
-
this
|
|
1752
|
+
X(A) {
|
|
1753
|
+
return this.$ = 113 === A || 114 === A ? "x-scale" : 115 === A || 116 === A ? "z-scale" : 117 === A || 118 === A ? "y-scale" : 119 === A ? "xyz-scale" : 5 === A ? "xy-translate" : 6 === A ? "z-translate" : 7 === A || 9 === A ? "x-translate" : 8 === A || 10 === A ? "y-translate" : 11 === A ? "z-rotate" : "scale",
|
|
1754
|
+
this.$;
|
|
1720
1755
|
}
|
|
1721
1756
|
transform(A) {
|
|
1722
1757
|
if (!A) return;
|
|
1723
1758
|
if (this.layerRenderer && this.layerRenderer.layer && (this.layerRenderer.layer.off("renderend", this.render),
|
|
1724
|
-
this.layerRenderer.layer.off("resizeCanvas", this.
|
|
1725
|
-
if (this.U && (this.U.u(), this.U.
|
|
1759
|
+
this.layerRenderer.layer.off("resizeCanvas", this.hA)), !this.map) return void console.error("should add to a target first");
|
|
1760
|
+
if (this.U && (this.U.u(), this.U.l(A)), !this.U.getTargets().length) return;
|
|
1726
1761
|
const e = this.map;
|
|
1727
|
-
this.TransformHelper.updateMatrix(e, this.U, 0, 0, [ 0, 0, 0 ]), this.
|
|
1762
|
+
this.TransformHelper.updateMatrix(e, this.U, 0, 0, [ 0, 0, 0 ]), this.wA(), this.q = !0;
|
|
1728
1763
|
}
|
|
1729
1764
|
getTransformTarget() {
|
|
1730
1765
|
return this.U;
|
|
1731
1766
|
}
|
|
1732
|
-
|
|
1767
|
+
P() {
|
|
1733
1768
|
delete this.U;
|
|
1734
1769
|
}
|
|
1735
|
-
|
|
1770
|
+
wA() {
|
|
1736
1771
|
const A = this.U.L();
|
|
1737
|
-
A && (A.off("renderend", this.render), A.off("resizeCanvas", this.
|
|
1772
|
+
A && (A.off("renderend", this.render), A.off("resizeCanvas", this.hA));
|
|
1738
1773
|
const e = this.map.getLayers();
|
|
1739
1774
|
let t = null;
|
|
1740
|
-
for (let A = 0; A < e.length; A++) if (e[A] instanceof
|
|
1775
|
+
for (let A = 0; A < e.length; A++) if (e[A] instanceof n) {
|
|
1741
1776
|
t = e[A];
|
|
1742
1777
|
break;
|
|
1743
1778
|
}
|
|
@@ -1745,38 +1780,38 @@ class Z extends(g(r(C))){
|
|
|
1745
1780
|
const s = t.getLayers(), i = s.indexOf(A);
|
|
1746
1781
|
if (i < 0) return;
|
|
1747
1782
|
s.splice(i, 1), s.push(A);
|
|
1748
|
-
const
|
|
1749
|
-
this.layerRenderer = o, this.regl = o.regl, this.renderer = o.renderer, this.
|
|
1750
|
-
this.
|
|
1751
|
-
projViewMatrix:
|
|
1752
|
-
}, A.on("renderend", this.render, this), A.on("resizeCanvas", this.
|
|
1783
|
+
const I = this.map, o = A.getRenderer();
|
|
1784
|
+
this.layerRenderer = o, this.regl = o.regl, this.renderer = o.renderer, this.cA = this.layerRenderer.getFBORayPicking(),
|
|
1785
|
+
this.QA = {
|
|
1786
|
+
projViewMatrix: I.projViewMatrix
|
|
1787
|
+
}, A.on("renderend", this.render, this), A.on("resizeCanvas", this.hA, this), o.setToRedraw();
|
|
1753
1788
|
}
|
|
1754
|
-
|
|
1755
|
-
this.
|
|
1789
|
+
hA() {
|
|
1790
|
+
this.cA.clear(), this.q = !0;
|
|
1756
1791
|
}
|
|
1757
|
-
|
|
1792
|
+
j(A, e, t) {
|
|
1758
1793
|
const s = this.map;
|
|
1759
|
-
if (!(s && this.
|
|
1760
|
-
const i = s.getDevicePixelRatio(),
|
|
1794
|
+
if (!(s && this.cA && this.layerRenderer && this.layerRenderer.canvas)) return null;
|
|
1795
|
+
const i = s.getDevicePixelRatio(), n = A.x * i, I = A.y * i, o = {
|
|
1761
1796
|
projViewMatrix: this.map.projViewMatrix,
|
|
1762
1797
|
pointSize: 1
|
|
1763
1798
|
}, g = this.layerRenderer.canvas.gl && this.layerRenderer.canvas.gl.wrap;
|
|
1764
|
-
(this.
|
|
1765
|
-
this.
|
|
1766
|
-
return this.
|
|
1799
|
+
(this.q || g || !this.fA || this.fA !== t) && (this.cA.render(e, o, !0), this.fA = t,
|
|
1800
|
+
this.q = !1);
|
|
1801
|
+
return this.cA.pick(n, I, 10, o, {
|
|
1767
1802
|
viewMatrix: this.map.viewMatrix,
|
|
1768
1803
|
projMatrix: this.map.projMatrix,
|
|
1769
1804
|
returnPoint: !0
|
|
1770
1805
|
});
|
|
1771
1806
|
}
|
|
1772
|
-
|
|
1807
|
+
_() {
|
|
1773
1808
|
const A = this.map.getDevicePixelRatio(), s = {
|
|
1774
1809
|
x: 0,
|
|
1775
1810
|
y: 0,
|
|
1776
1811
|
width: () => this.map ? this.map.width * A : 1,
|
|
1777
1812
|
height: () => this.map ? this.map.height * A : 1
|
|
1778
1813
|
};
|
|
1779
|
-
this.
|
|
1814
|
+
this.lA = new t.MeshShader({
|
|
1780
1815
|
vert: "attribute vec3 aPosition;\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main()\n\n{\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n\n\n}\n\n",
|
|
1781
1816
|
frag: "precision mediump float;\n\nuniform vec4 color;\n\n\n\nvoid main() {\n\n gl_FragColor = color;\n\n}\n\n",
|
|
1782
1817
|
uniforms: [ "color", {
|
|
@@ -1807,16 +1842,16 @@ class Z extends(g(r(C))){
|
|
|
1807
1842
|
});
|
|
1808
1843
|
}
|
|
1809
1844
|
render() {
|
|
1810
|
-
if (!this.
|
|
1811
|
-
const A = this.
|
|
1845
|
+
if (!this.K()) return;
|
|
1846
|
+
const A = this.G();
|
|
1812
1847
|
this.helperScene.setMeshes(A);
|
|
1813
1848
|
const e = this.layerRenderer.getFrameContext();
|
|
1814
1849
|
if (e && e.renderTarget && this.layerRenderer.getFrameTimestamp() !== e.timestamp) return;
|
|
1815
|
-
this
|
|
1850
|
+
this.AA(), this.lA.filter = e && e.sceneFilter;
|
|
1816
1851
|
const t = e && e.renderTarget && e.renderTarget.fbo;
|
|
1817
|
-
this.renderer.render(this.
|
|
1852
|
+
this.renderer.render(this.lA, this.QA, this.helperScene, t);
|
|
1818
1853
|
}
|
|
1819
|
-
|
|
1854
|
+
G() {
|
|
1820
1855
|
let A = [];
|
|
1821
1856
|
const e = this.TransformHelper.getMeshes(this.O);
|
|
1822
1857
|
for (const t in e) {
|
|
@@ -1828,16 +1863,16 @@ class Z extends(g(r(C))){
|
|
|
1828
1863
|
if (t) for (let e = 0; e < t.length; e++) A = A.concat(t[e]);
|
|
1829
1864
|
return A;
|
|
1830
1865
|
}
|
|
1831
|
-
|
|
1866
|
+
K() {
|
|
1832
1867
|
const A = this.layerRenderer, e = A && A.layer;
|
|
1833
1868
|
return A && this.U && e && e.isVisible() && this.U.M() && this.regl && this.F;
|
|
1834
1869
|
}
|
|
1835
1870
|
}
|
|
1836
1871
|
|
|
1837
|
-
|
|
1872
|
+
AA.mergeOptions({
|
|
1838
1873
|
scaleStrength: 2
|
|
1839
1874
|
});
|
|
1840
1875
|
|
|
1841
|
-
export {
|
|
1876
|
+
export { AA as TransformControl };
|
|
1842
1877
|
|
|
1843
|
-
"undefined" != typeof console && console.log("@maptalks/transform-control v0.
|
|
1878
|
+
"undefined" != typeof console && console.log("@maptalks/transform-control v0.91.2");
|