@maptalks/transform-control 0.99.0 → 0.101.0
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.
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/transform-control v0.
|
|
2
|
+
* @maptalks/transform-control v0.101.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2024 maptalks.org
|
|
5
5
|
*/
|
|
6
|
-
import { quat as A, mat4 as e, reshader as t, vec3 as s,
|
|
6
|
+
import { quat as A, mat4 as e, reshader as t, vec3 as s, gltf as i, vec2 as n } from "@maptalks/gl";
|
|
7
7
|
|
|
8
8
|
import * as I from "maptalks";
|
|
9
9
|
|
|
10
|
-
import { Point as o, Coordinate as g, Eventable as r, Handlerable as
|
|
10
|
+
import { Point as o, Coordinate as g, Eventable as r, Handlerable as a, Class as C, INTERNAL_LAYER_PREFIX as h } from "maptalks";
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import { GLTFLayer as w, GLTFMarker as c } from "@maptalks/gltf-layer";
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const Q = {
|
|
15
15
|
yuanhuan: {
|
|
16
16
|
accessors: [ {
|
|
17
17
|
name: "������_1_0_positions",
|
|
@@ -1156,33 +1156,33 @@ const w = {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
};
|
|
1158
1158
|
|
|
1159
|
-
function
|
|
1160
|
-
const
|
|
1161
|
-
return new
|
|
1159
|
+
function f(s, n, I, o, g, r) {
|
|
1160
|
+
const a = [], C = A.fromEuler([], I[0], I[1], I[2]), h = e.fromRotationTranslationScale([], C, n, o), w = function(A) {
|
|
1161
|
+
return new i.GLTFLoader("", JSON.parse(JSON.stringify(Q[A]))).load().then((A => A));
|
|
1162
1162
|
}(s);
|
|
1163
|
-
return
|
|
1163
|
+
return w.then((A => {
|
|
1164
1164
|
t.GLTFHelper.exportGLTFPack(A).getMeshesInfo().forEach(((A, s) => {
|
|
1165
|
-
const
|
|
1166
|
-
color:
|
|
1167
|
-
}),
|
|
1168
|
-
|
|
1169
|
-
const w =
|
|
1170
|
-
w.HAS_PICKING_ID = 2,
|
|
1171
|
-
e.multiply(
|
|
1172
|
-
|
|
1173
|
-
})),
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
})),
|
|
1165
|
+
const i = new t.Material({
|
|
1166
|
+
color: g || A.materialInfo.baseColorFactor
|
|
1167
|
+
}), C = new t.Mesh(A.geometry, i);
|
|
1168
|
+
C.setUniform("uPickingId", r + s);
|
|
1169
|
+
const w = C.getDefines();
|
|
1170
|
+
w.HAS_PICKING_ID = 2, C.setDefines(w), C.translate = n, C.rotation = I, C.scaling = o,
|
|
1171
|
+
e.multiply(C.localTransform, h, A.nodeMatrix), C.originTransform = e.copy([], C.localTransform),
|
|
1172
|
+
C.originColor = g || A.materialInfo.baseColorFactor, a.push(C);
|
|
1173
|
+
})), r > 100 && (a[0].properties.relatedMeshes = a.slice(1, 2), a[1].properties.relatedMeshes = a.slice(0, 1),
|
|
1174
|
+
a[2].properties.relatedMeshes = a.slice(3, 4), a[3].properties.relatedMeshes = a.slice(2, 3),
|
|
1175
|
+
a[4].properties.relatedMeshes = a.slice(5, 6), a[5].properties.relatedMeshes = a.slice(4, 5),
|
|
1176
|
+
a[6].properties.relatedMeshes = a.slice(0, 6));
|
|
1177
|
+
})), a;
|
|
1178
1178
|
}
|
|
1179
1179
|
|
|
1180
|
-
function
|
|
1180
|
+
function l(A, e) {
|
|
1181
1181
|
return Math.abs(A) * Math.sign(e);
|
|
1182
1182
|
}
|
|
1183
1183
|
|
|
1184
|
-
function
|
|
1185
|
-
const t = A.getCoordinates(), i = e.coordinateToPointAtRes(t, e.getGLRes()), n = [ i.x, i.y, 0 ], o =
|
|
1184
|
+
function P(A, e) {
|
|
1185
|
+
const t = A.getCoordinates(), i = e.coordinateToPointAtRes(t, e.getGLRes()), n = [ i.x, i.y, 0 ], o = D(e, A.getTranslation());
|
|
1186
1186
|
s.add(n, n, o);
|
|
1187
1187
|
const g = function(A, e, t, s) {
|
|
1188
1188
|
return A._pointAtResToContainerPoint(e, t, s);
|
|
@@ -1197,13 +1197,13 @@ function f(A, e) {
|
|
|
1197
1197
|
return Math.sqrt(Math.pow(r.x - n[0], 2) + Math.pow(r.y - n[1], 2)) / 5.272881136101205;
|
|
1198
1198
|
}
|
|
1199
1199
|
|
|
1200
|
-
function
|
|
1200
|
+
function D(A, e) {
|
|
1201
1201
|
if (!A) return e;
|
|
1202
1202
|
const t = A.distanceToPointAtRes(e[0], e[1], A.getGLRes()), i = A.altitudeToPoint(e[2], A.getGLRes());
|
|
1203
|
-
return s.set([],
|
|
1203
|
+
return s.set([], l(t.x, e[0]), l(t.y, e[1]), l(i, e[2]));
|
|
1204
1204
|
}
|
|
1205
1205
|
|
|
1206
|
-
class
|
|
1206
|
+
class u {
|
|
1207
1207
|
constructor(A) {
|
|
1208
1208
|
this.A = A, this._meshes = this.t();
|
|
1209
1209
|
}
|
|
@@ -1211,7 +1211,7 @@ class P {
|
|
|
1211
1211
|
this.A = A;
|
|
1212
1212
|
}
|
|
1213
1213
|
t() {
|
|
1214
|
-
const A = [], e = 340 / 177, t =
|
|
1214
|
+
const A = [], e = 340 / 177, t = f("jiantou", [ 1.2 * e, 0, 0 ], [ 0, 0, 90 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 7), s = f("jiantou", [ 0, 1.2 * e, 0 ], [ 0, 0, 180 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 8), i = f("jiantou", [ -1.2 * e, 0, 0 ], [ 0, 0, 270 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 9), n = f("jiantou", [ 0, -1.2 * e, 0 ], [ 0, 0, 0 ], [ e, e, e ], [ 89 / 255, 206 / 255, 147 / 255, 0 ], 10);
|
|
1215
1215
|
return A.push(t, s, i, n), A;
|
|
1216
1216
|
}
|
|
1217
1217
|
getMeshes() {
|
|
@@ -1219,7 +1219,7 @@ class P {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
}
|
|
1221
1221
|
|
|
1222
|
-
class
|
|
1222
|
+
class m {
|
|
1223
1223
|
constructor(A) {
|
|
1224
1224
|
this.A = A, this._meshes = this.t();
|
|
1225
1225
|
}
|
|
@@ -1227,7 +1227,7 @@ class D {
|
|
|
1227
1227
|
this.A = A;
|
|
1228
1228
|
}
|
|
1229
1229
|
t() {
|
|
1230
|
-
const A = [], e = 340 / 177, t =
|
|
1230
|
+
const A = [], e = 340 / 177, t = f("xuanzhuan", [ 0, 0, 0 ], [ 180, 0, 0 ], [ .5 * e, .5 * e, .5 * e ], [ 50 / 255, 130 / 255, 184 / 255, .8 ], 11);
|
|
1231
1231
|
return A.push(t), A;
|
|
1232
1232
|
}
|
|
1233
1233
|
getMeshes() {
|
|
@@ -1235,7 +1235,7 @@ class D {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
1237
|
|
|
1238
|
-
class
|
|
1238
|
+
class b {
|
|
1239
1239
|
constructor(A) {
|
|
1240
1240
|
this.A = A, this._meshes = this.t();
|
|
1241
1241
|
}
|
|
@@ -1243,7 +1243,7 @@ class u {
|
|
|
1243
1243
|
this.A = A;
|
|
1244
1244
|
}
|
|
1245
1245
|
t() {
|
|
1246
|
-
const A = [], e = 340 / 177, t =
|
|
1246
|
+
const A = [], e = 340 / 177, t = f("yuanhuan", [ 0, 0, 0 ], [ 0, 0, 0 ], [ .5 * e, .5 * e, .5 * e ], [ 149 / 255, 179 / 255, 199 / 255, .5 ], 12);
|
|
1247
1247
|
return A.push(t), A;
|
|
1248
1248
|
}
|
|
1249
1249
|
getMeshes() {
|
|
@@ -1251,7 +1251,7 @@ class u {
|
|
|
1251
1251
|
}
|
|
1252
1252
|
}
|
|
1253
1253
|
|
|
1254
|
-
class
|
|
1254
|
+
class B {
|
|
1255
1255
|
constructor(A) {
|
|
1256
1256
|
this.A = A, this._meshes = this.t();
|
|
1257
1257
|
}
|
|
@@ -1259,7 +1259,7 @@ class m {
|
|
|
1259
1259
|
this.A = A;
|
|
1260
1260
|
}
|
|
1261
1261
|
t() {
|
|
1262
|
-
const A = [], e =
|
|
1262
|
+
const A = [], e = f("plane", [ 0, 0, 0 ], [ 0, 0, 0 ], [ 10, 10, 10 ], [ 1, 0, 0, .5 ], 16);
|
|
1263
1263
|
return A.push(e), A;
|
|
1264
1264
|
}
|
|
1265
1265
|
getMeshes() {
|
|
@@ -1267,7 +1267,7 @@ class m {
|
|
|
1267
1267
|
}
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
1270
|
-
class
|
|
1270
|
+
class y {
|
|
1271
1271
|
constructor(A) {
|
|
1272
1272
|
this.A = A, this._meshes = this.t();
|
|
1273
1273
|
}
|
|
@@ -1275,7 +1275,7 @@ class b {
|
|
|
1275
1275
|
this.A = A;
|
|
1276
1276
|
}
|
|
1277
1277
|
t() {
|
|
1278
|
-
const A = [], e =
|
|
1278
|
+
const A = [], e = f("xyzScale", [ 0, 0, 0 ], [ 0, 0, 0 ], [ 2, 2, 2 ], null, 113);
|
|
1279
1279
|
return A.push(e), A;
|
|
1280
1280
|
}
|
|
1281
1281
|
getMeshes() {
|
|
@@ -1283,48 +1283,48 @@ class b {
|
|
|
1283
1283
|
}
|
|
1284
1284
|
}
|
|
1285
1285
|
|
|
1286
|
-
const
|
|
1286
|
+
const p = [], v = [], L = [], d = [], M = [], E = [ 177 / 170, 177 / 170, 177 / 170 ], O = [], F = [ 1, 2, 3, 4, 12 ];
|
|
1287
1287
|
|
|
1288
|
-
class
|
|
1288
|
+
class x {
|
|
1289
1289
|
constructor() {
|
|
1290
|
-
this.translate = new
|
|
1291
|
-
this.xyzScaleHelper = new
|
|
1290
|
+
this.translate = new u, this.rotation = new m, this.scaling = new b, this.planeHelper = new B,
|
|
1291
|
+
this.xyzScaleHelper = new y, this._meshes = this.t(), this.i = !0;
|
|
1292
1292
|
}
|
|
1293
1293
|
t() {
|
|
1294
1294
|
const A = {};
|
|
1295
1295
|
A.translate = this.translate.getMeshes(), A.rotation = this.rotation.getMeshes(),
|
|
1296
1296
|
A.scaling = this.scaling.getMeshes(), A.planeHelper = this.planeHelper.getMeshes(),
|
|
1297
1297
|
A.xyzScale = this.xyzScaleHelper.getMeshes();
|
|
1298
|
-
const e = 340 / 177, t =
|
|
1298
|
+
const e = 340 / 177, t = f("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 = f("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 = f("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 = f("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 = f("yuanpan", [ 0, 0, 0 ], [ 90, 0, 0 ], [ .5 * e, .5 * e, .5 * e ], [ 89 / 255, 206 / 255, 147 / 255, .5 ], 5), o = f("zzhou", [ 0, 0, 6.5 ], [ 90, 0, 0 ], [ 1, 1, 1 ], [ 14 / 255, 127 / 255, 191 / 255, 1 ], 6);
|
|
1299
1299
|
return A.translate.push(t, s, i, n, I, o), A;
|
|
1300
1300
|
}
|
|
1301
1301
|
updateMatrix(t, i, n, I, o) {
|
|
1302
|
-
const g = i.getCoordinates(), r = t.coordinateToPointAtRes(g, t.getGLRes()),
|
|
1303
|
-
s.set(
|
|
1304
|
-
const
|
|
1305
|
-
s.add(
|
|
1302
|
+
const g = i.getCoordinates(), r = t.coordinateToPointAtRes(g, t.getGLRes()), a = i.I();
|
|
1303
|
+
s.set(v, r.x, r.y, a);
|
|
1304
|
+
const C = s.copy(p, o), h = D(t, i.getTranslation());
|
|
1305
|
+
s.add(v, v, h), s.add(v, v, C);
|
|
1306
1306
|
for (const o in this._meshes) for (let g = 0; g < this._meshes[o].length; g++) {
|
|
1307
1307
|
const r = this._meshes[o][g];
|
|
1308
1308
|
for (let g = 0; g < r.length; g++) {
|
|
1309
|
-
const
|
|
1310
|
-
let w = s.copy(
|
|
1311
|
-
const c =
|
|
1312
|
-
if (11 ===
|
|
1313
|
-
|
|
1314
|
-
|
|
1309
|
+
const a = r[g], C = a.getUniform("uPickingId"), h = s.copy(p, a.translate);
|
|
1310
|
+
let w = s.copy(O, a.rotation);
|
|
1311
|
+
const c = a.scaling;
|
|
1312
|
+
if (11 === C && (this.i ? (w[2] += n, a.rotation[2] += n) : this.i || (w[2] += n,
|
|
1313
|
+
a.rotation[2] += n, w[0] = 360, w[2] -= 90)), C > 100 && 1 === i.getTargets().length && (w = i.getTargets()[0].getRotation()),
|
|
1314
|
+
F.indexOf(C) > -1) if (12 !== C) c[0] += I, c[1] += I, c[2] += I; else {
|
|
1315
1315
|
const A = this._meshes.translate[4][0];
|
|
1316
1316
|
c[0] = 1.2 * A.scaling[0], c[1] = 1.2 * A.scaling[0], c[2] = 1.2 * A.scaling[0];
|
|
1317
1317
|
}
|
|
1318
|
-
let Q =
|
|
1319
|
-
if (Q = s.set(
|
|
1320
|
-
const A = s.multiply(
|
|
1318
|
+
let Q = P(i, t);
|
|
1319
|
+
if (Q = s.set(L, Q, Q, Q), s.multiply(h, h, Q), s.multiply(Q, Q, c), 1 === C || 2 === C || 3 === C || 4 === C) {
|
|
1320
|
+
const A = s.multiply(M, c, E);
|
|
1321
1321
|
s.multiply(h, h, A);
|
|
1322
1322
|
}
|
|
1323
|
-
const
|
|
1324
|
-
if (s.add(h, h,
|
|
1325
|
-
const A = e.fromRotationTranslationScale([],
|
|
1326
|
-
e.multiply(
|
|
1327
|
-
} else e.fromRotationTranslationScale(
|
|
1323
|
+
const f = A.fromEuler(d, w[0], w[1], w[2]);
|
|
1324
|
+
if (s.add(h, h, v), "xyzScale" === o) {
|
|
1325
|
+
const A = e.fromRotationTranslationScale([], f, h, Q);
|
|
1326
|
+
e.multiply(a.localTransform, A, a.originTransform);
|
|
1327
|
+
} else e.fromRotationTranslationScale(a.localTransform, f, h, Q);
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
1330
1330
|
}
|
|
@@ -1347,9 +1347,9 @@ class O {
|
|
|
1347
1347
|
}
|
|
1348
1348
|
}
|
|
1349
1349
|
|
|
1350
|
-
const
|
|
1350
|
+
const U = [], V = [], S = [], k = new o(0, 0), T = [], H = [], J = [], N = [ 0, 0, 0 ];
|
|
1351
1351
|
|
|
1352
|
-
class
|
|
1352
|
+
class R {
|
|
1353
1353
|
constructor() {
|
|
1354
1354
|
this.C = [], this.h = [ 0, 0, 0 ], this.l = [ 1, 1, 1 ], this.P = [ 0, 0, 0 ];
|
|
1355
1355
|
}
|
|
@@ -1370,20 +1370,20 @@ class J {
|
|
|
1370
1370
|
}
|
|
1371
1371
|
p(A, e, t, i, n, I, o) {
|
|
1372
1372
|
for (let o = 0; o < this.C.length; o++) {
|
|
1373
|
-
const g = this.C[o], r = g.getRotation(),
|
|
1373
|
+
const g = this.C[o], r = g.getRotation(), a = g.getScale(), C = this.v(I, g, i, t, e);
|
|
1374
1374
|
let h = null;
|
|
1375
1375
|
h = i >= 0 ? i : i * (this.options && this.options.scaleStrength || 1);
|
|
1376
|
-
const w = s.add(
|
|
1376
|
+
const w = s.add(J, s.set(U, h * a[0], h * a[1], h * a[2]), a), c = Math.min(...w);
|
|
1377
1377
|
if (Math.abs(c) < n) {
|
|
1378
1378
|
const A = Math.abs(c);
|
|
1379
1379
|
w[0] = w[0] * (n / A), w[1] = w[1] * (n / A), w[2] = w[2] * (n / A);
|
|
1380
1380
|
}
|
|
1381
1381
|
const Q = s.add(r, t, r);
|
|
1382
|
-
g.setCoordinates(
|
|
1382
|
+
g.setCoordinates(C), this.L(A, w, a);
|
|
1383
1383
|
const f = g.getTranslation();
|
|
1384
1384
|
g.setTRS(f, Q, w);
|
|
1385
1385
|
}
|
|
1386
|
-
s.set(
|
|
1386
|
+
s.set(J, i, i, i), s.add(this.P, t, this.P), s.add(this.l, J, this.l), s.add(this.h, e, this.h),
|
|
1387
1387
|
A.indexOf("translate") > -1 ? o.fire("positionchange", {
|
|
1388
1388
|
action: A,
|
|
1389
1389
|
type: "positionchange",
|
|
@@ -1409,16 +1409,16 @@ class J {
|
|
|
1409
1409
|
});
|
|
1410
1410
|
}
|
|
1411
1411
|
v(t, i, n, I, o) {
|
|
1412
|
-
const g = i.getCenter(), r = i.getTransformOrigin(),
|
|
1413
|
-
|
|
1414
|
-
const h = t.coordinateToPointAtRes(r,
|
|
1415
|
-
h.z = t.altitudeToPoint(r.z,
|
|
1416
|
-
const w = s.sub(
|
|
1417
|
-
s.set(
|
|
1418
|
-
const Q = e.fromRotationTranslationScale(
|
|
1419
|
-
s.transformMat4(w, w, Q), s.add(w, w,
|
|
1420
|
-
const f = t.pointAtResToCoordinate(
|
|
1421
|
-
return f.z = w[2] / t.altitudeToPoint(1,
|
|
1412
|
+
const g = i.getCenter(), r = i.getTransformOrigin(), a = t.getGLRes(), C = t.coordinateToPointAtRes(g, a, k);
|
|
1413
|
+
C.z = t.altitudeToPoint(g.z, a), s.set(T, C.x, C.y, C.z || 0);
|
|
1414
|
+
const h = t.coordinateToPointAtRes(r, a, k);
|
|
1415
|
+
h.z = t.altitudeToPoint(r.z, a), s.set(H, h.x, h.y, h.z || 0);
|
|
1416
|
+
const w = s.sub(U, T, H), c = A.fromEuler(V, 0, 0, I[2]);
|
|
1417
|
+
s.set(J, n + 1, n + 1, n + 1);
|
|
1418
|
+
const Q = e.fromRotationTranslationScale(S, c, o, J);
|
|
1419
|
+
s.transformMat4(w, w, Q), s.add(w, w, H), k.set(w[0], w[1]);
|
|
1420
|
+
const f = t.pointAtResToCoordinate(k, a);
|
|
1421
|
+
return f.z = w[2] / t.altitudeToPoint(1, a), f;
|
|
1422
1422
|
}
|
|
1423
1423
|
L(A, e, t) {
|
|
1424
1424
|
return "x-scale" === A && (e[1] = t[1], e[2] = t[2]), "y-scale" === A && (e[0] = t[0],
|
|
@@ -1436,7 +1436,7 @@ class J {
|
|
|
1436
1436
|
return this.l;
|
|
1437
1437
|
}
|
|
1438
1438
|
getTranslation() {
|
|
1439
|
-
return 1 === this.C.length && this.C[0].getTranslation() ||
|
|
1439
|
+
return 1 === this.C.length && this.C[0].getTranslation() || N;
|
|
1440
1440
|
}
|
|
1441
1441
|
getRotation() {
|
|
1442
1442
|
return this.P;
|
|
@@ -1478,13 +1478,16 @@ class J {
|
|
|
1478
1478
|
}
|
|
1479
1479
|
}
|
|
1480
1480
|
|
|
1481
|
-
const
|
|
1481
|
+
const _ = [ 5, 6, 7, 8, 9, 10 ], K = [ 5, 7, 8, 9, 10 ], z = [ 2, 4, 11 ], G = [ 1, 3, 12 ], j = [ 12, 16 ], Z = [ 1, 2, 3, 4 ], Y = [ 1, 2, 3, 4, 12 ], W = [], q = [], X = [], $ = [], AA = [], eA = [], tA = [];
|
|
1482
1482
|
|
|
1483
|
-
class
|
|
1483
|
+
class sA extends(r(a(C))){
|
|
1484
1484
|
constructor(A = {}) {
|
|
1485
1485
|
super(A), this.options = A, this.mouseAction = "moving", this.U = this.options.mode || "translate",
|
|
1486
|
-
this.V = !0, this.TransformHelper = new
|
|
1487
|
-
this.addToMapCount = 0;
|
|
1486
|
+
this.V = !0, this.TransformHelper = new x, this.S = new R, this.helperScene = new t.Scene([]),
|
|
1487
|
+
this.addToMapCount = 0, this.k();
|
|
1488
|
+
}
|
|
1489
|
+
setCoordinates(A) {
|
|
1490
|
+
this.T.setCoordinates(A), this.transform(this.T);
|
|
1488
1491
|
}
|
|
1489
1492
|
enable() {
|
|
1490
1493
|
return this.V = !0, this.layerRenderer && this.layerRenderer.setToRedraw(), this;
|
|
@@ -1494,7 +1497,7 @@ class eA extends(r(C(a))){
|
|
|
1494
1497
|
this;
|
|
1495
1498
|
}
|
|
1496
1499
|
setMode(A) {
|
|
1497
|
-
this.U = A, this.
|
|
1500
|
+
this.U = A, this.H(), this.layerRenderer && this.layerRenderer.setToRedraw(), this.fire("modechange", {
|
|
1498
1501
|
mode: A,
|
|
1499
1502
|
type: "modechange"
|
|
1500
1503
|
});
|
|
@@ -1505,222 +1508,234 @@ class eA extends(r(C(a))){
|
|
|
1505
1508
|
isEnable() {
|
|
1506
1509
|
return this.V;
|
|
1507
1510
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1511
|
+
J(A) {
|
|
1512
|
+
_.indexOf(A) > -1 ? this.U = "translate" : z.indexOf(A) > -1 ? this.U = "rotation" : G.indexOf(A) > -1 ? this.U = "scaling" : "xyzScale" !== this.U && (this.U = "translate");
|
|
1510
1513
|
}
|
|
1511
|
-
|
|
1514
|
+
N() {
|
|
1512
1515
|
return this.U;
|
|
1513
1516
|
}
|
|
1514
1517
|
addTo(A) {
|
|
1515
|
-
this.map
|
|
1516
|
-
this.addToMapCount++, this.map = A, this.container = A.getContainer(),
|
|
1517
|
-
A.on("dom:
|
|
1518
|
-
this.
|
|
1518
|
+
if (this.map) return this.R(), void console.warn("transform control has been added to a map, it suggest remove from the map before");
|
|
1519
|
+
this.addToMapCount++, this.map = A, this._.addTo(this.map), this.container = A.getContainer(),
|
|
1520
|
+
A.on("dom:mousemove", this.K, this), A.on("dom:mousedown", this.G, this), A.on("dom:mouseup", this.j, this),
|
|
1521
|
+
A.on("zooming moving dragrotating", this.Z, this), this.Y();
|
|
1519
1522
|
}
|
|
1520
|
-
|
|
1521
|
-
this.
|
|
1522
|
-
|
|
1523
|
-
|
|
1523
|
+
k() {
|
|
1524
|
+
this._ = new w(`${h}_transformcontrol`), this.T = new c([ 0, 0 ], {
|
|
1525
|
+
symbol: {
|
|
1526
|
+
url: "cube",
|
|
1527
|
+
modelHeight: 1,
|
|
1528
|
+
uniforms: {
|
|
1529
|
+
polygonOpacity: .01
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}).addTo(this._);
|
|
1524
1533
|
}
|
|
1525
|
-
|
|
1526
|
-
this.container && this.
|
|
1527
|
-
this.
|
|
1534
|
+
remove() {
|
|
1535
|
+
this.map && this.container && this.layerRenderer && (this.R(), this.TransformHelper.dispose(),
|
|
1536
|
+
this.layerRenderer.setToRedraw(), this._.remove(), delete this.T, delete this._,
|
|
1537
|
+
delete this.map, delete this.layer, delete this.layerRenderer, delete this.container,
|
|
1538
|
+
delete this.S);
|
|
1539
|
+
}
|
|
1540
|
+
R() {
|
|
1541
|
+
this.container && this.map && (this.map.off("dom:mousemove", this.K, this), this.map.off("dom:mousedown", this.G, this),
|
|
1542
|
+
this.map.off("dom:mouseup", this.j, this), this.map.off("zooming moving dragrotating", this.Z, this),
|
|
1528
1543
|
this.layer && this.layer.off("renderend", this.render, this));
|
|
1529
1544
|
}
|
|
1530
|
-
|
|
1531
|
-
if (this.
|
|
1545
|
+
K(A) {
|
|
1546
|
+
if (this.W()) {
|
|
1532
1547
|
if (this.currentMousePosition = {
|
|
1533
1548
|
x: A.containerPoint.x,
|
|
1534
1549
|
y: A.containerPoint.y
|
|
1535
1550
|
}, "moving" === this.mouseAction) {
|
|
1536
|
-
const A = this.
|
|
1537
|
-
this.currentPickingObject = this.
|
|
1538
|
-
6 === this.currentPickingObject.pickingId ? this
|
|
1539
|
-
this.
|
|
1551
|
+
const A = this.q();
|
|
1552
|
+
this.currentPickingObject = this.X(this.currentMousePosition, A, "meshes"), this.currentPickingObject && null != this.currentPickingObject.pickingId ? (this.J(this.currentPickingObject.pickingId),
|
|
1553
|
+
6 === this.currentPickingObject.pickingId ? this.$(!0) : this.$(!1)) : (this.$(!1),
|
|
1554
|
+
this.J()), this.AA();
|
|
1540
1555
|
}
|
|
1541
|
-
this.
|
|
1556
|
+
this.eA(this.currentMousePosition);
|
|
1542
1557
|
}
|
|
1543
1558
|
}
|
|
1544
|
-
|
|
1545
|
-
if (!this.
|
|
1546
|
-
const e = this.
|
|
1559
|
+
G(A) {
|
|
1560
|
+
if (!this.W() || 0 !== A.domEvent.button) return;
|
|
1561
|
+
const e = this.q();
|
|
1547
1562
|
this.currentMousePosition = {
|
|
1548
1563
|
x: A.containerPoint.x,
|
|
1549
1564
|
y: A.containerPoint.y
|
|
1550
|
-
}, this
|
|
1551
|
-
this.firstDownPoint = this.
|
|
1552
|
-
this.
|
|
1565
|
+
}, this.tA = !0, this.currentPickingObject = this.X(this.currentMousePosition, e, "meshes"),
|
|
1566
|
+
this.firstDownPoint = this.X(this.currentMousePosition, e, "meshes"), this.currentPickingObject && null != this.currentPickingObject.meshId ? (this.mouseAction = "transform",
|
|
1567
|
+
this.sA(this.currentPickingObject.pickingId), this.map.config("zoomable", !1), this.map.config("draggable", !1),
|
|
1553
1568
|
this.layerRenderer && this.layerRenderer.setToRedraw()) : (this.mouseAction = "pan",
|
|
1554
|
-
this.map.config("zoomable", !0), this.map.config("draggable", !0), this.
|
|
1569
|
+
this.map.config("zoomable", !0), this.map.config("draggable", !0), this.H()), this.lastMousePosition = this.currentMousePosition,
|
|
1555
1570
|
this.lastPickingObject = this.currentPickingObject, this.lastPickingMesh = e[this.currentPickingObject.meshId];
|
|
1556
1571
|
}
|
|
1557
|
-
|
|
1558
|
-
"transform" === this.mouseAction && (this.firstDownPoint = null, this.
|
|
1572
|
+
j() {
|
|
1573
|
+
"transform" === this.mouseAction && (this.firstDownPoint = null, this.H(), this.tA = !0,
|
|
1559
1574
|
this.fire("transformend", {
|
|
1560
|
-
action: this.
|
|
1575
|
+
action: this.iA,
|
|
1561
1576
|
type: "transformend"
|
|
1562
1577
|
})), this.mouseAction = "moving", "xyzScale" !== this.U && (this.U = "translate"),
|
|
1563
1578
|
this.map.config("zoomable", !0), this.map.config("draggable", !0), this.layerRenderer && this.layerRenderer.setToRedraw();
|
|
1564
1579
|
}
|
|
1565
|
-
|
|
1580
|
+
Z() {
|
|
1566
1581
|
const A = this.TransformHelper.planeHelper.getMeshes()[0][0], e = this.map.getBearing();
|
|
1567
|
-
A.rotation[2] = -e, this.
|
|
1582
|
+
A.rotation[2] = -e, this.nA();
|
|
1568
1583
|
}
|
|
1569
|
-
|
|
1570
|
-
this.
|
|
1571
|
-
this
|
|
1584
|
+
nA() {
|
|
1585
|
+
this.W() && (this.TransformHelper.updateMatrix(this.map, this.S, 0, 0, [ 0, 0, 0 ]),
|
|
1586
|
+
this.tA = !0);
|
|
1572
1587
|
}
|
|
1573
1588
|
picked(A) {
|
|
1574
1589
|
if (!this.layerRenderer) return !1;
|
|
1575
|
-
const e = this.
|
|
1590
|
+
const e = this.q(), t = this.map;
|
|
1576
1591
|
let s = A;
|
|
1577
1592
|
A instanceof o || (s = t.coordinateToContainerPoint(new g(A)));
|
|
1578
|
-
const i = this.
|
|
1593
|
+
const i = this.X(s, e, "picked");
|
|
1579
1594
|
return !(!i || null === i.meshId);
|
|
1580
1595
|
}
|
|
1581
|
-
|
|
1596
|
+
H() {
|
|
1582
1597
|
const A = this.TransformHelper.getMeshes("scaling").scaling[0][0], e = 340 / 177;
|
|
1583
|
-
A.scaling = [ .6 * e, .6 * e, .6 * e ], this.layerRenderer && (this.
|
|
1598
|
+
A.scaling = [ .6 * e, .6 * e, .6 * e ], this.layerRenderer && (this.IA(A), this.oA());
|
|
1584
1599
|
}
|
|
1585
|
-
|
|
1600
|
+
oA() {
|
|
1586
1601
|
this.TransformHelper._meshes.translate.forEach((A => {
|
|
1587
1602
|
for (let e = 0; e < A.length; e++) {
|
|
1588
1603
|
const t = A[e];
|
|
1589
|
-
|
|
1604
|
+
Z.indexOf(t.getUniform("uPickingId")) > -1 && t.material.set("color", t.originColor);
|
|
1590
1605
|
}
|
|
1591
1606
|
}));
|
|
1592
1607
|
}
|
|
1593
|
-
|
|
1594
|
-
const i = this.S.getCoordinates(), n = this.map.coordinateToPointAtRes(i, this.map.getGLRes()), I = [ n.x, n.y, 0 ], o =
|
|
1608
|
+
IA(t) {
|
|
1609
|
+
const i = this.S.getCoordinates(), n = this.map.coordinateToPointAtRes(i, this.map.getGLRes()), I = [ n.x, n.y, 0 ], o = D(this.map, this.S.getTranslation());
|
|
1595
1610
|
s.add(I, I, o);
|
|
1596
1611
|
const g = s.copy([], t.translate), r = t.scaling;
|
|
1597
|
-
let
|
|
1598
|
-
|
|
1599
|
-
e.fromRotationTranslationScale(t.localTransform, [ 0, 0, 0, 1 ], g,
|
|
1600
|
-
this.
|
|
1612
|
+
let a = P(this.S, this.map);
|
|
1613
|
+
a = s.set([], a, a, a), s.multiply(g, g, a), s.multiply(a, a, r), s.add(g, g, I),
|
|
1614
|
+
e.fromRotationTranslationScale(t.localTransform, [ 0, 0, 0, 1 ], g, a);
|
|
1615
|
+
this.q().forEach((t => {
|
|
1601
1616
|
const i = t.getUniform("uPickingId");
|
|
1602
1617
|
if (1 === i || 3 === i || 2 === i || 4 === i) {
|
|
1603
1618
|
const i = s.copy([], t.translate), n = 170 / 177;
|
|
1604
1619
|
t.scaling = [ n, n, n ];
|
|
1605
1620
|
const o = t.scaling, g = t.rotation;
|
|
1606
|
-
let r =
|
|
1621
|
+
let r = P(this.S, this.map);
|
|
1607
1622
|
r = s.set([], r, r, r), s.multiply(i, i, r), s.multiply(r, r, o), s.add(i, i, I);
|
|
1608
|
-
const
|
|
1609
|
-
e.fromRotationTranslationScale(t.localTransform,
|
|
1623
|
+
const a = A.fromEuler([], g[0], g[1], g[2]);
|
|
1624
|
+
e.fromRotationTranslationScale(t.localTransform, a, i, r);
|
|
1610
1625
|
}
|
|
1611
1626
|
}));
|
|
1612
1627
|
}
|
|
1613
|
-
|
|
1628
|
+
gA(A) {
|
|
1614
1629
|
const e = this.map.containerPointToCoordinate(A), t = this.map.coordinateToPointAtRes(e, this.map.getGLRes());
|
|
1615
1630
|
return {
|
|
1616
1631
|
point: [ t.x, t.y ]
|
|
1617
1632
|
};
|
|
1618
1633
|
}
|
|
1619
|
-
|
|
1634
|
+
eA(A) {
|
|
1620
1635
|
if ("transform" === this.mouseAction) {
|
|
1621
|
-
const A = this.
|
|
1622
|
-
let s = null,
|
|
1623
|
-
if (e[2] + t < .01 && "z-translate" !== this.
|
|
1624
|
-
|
|
1636
|
+
const A = this.N(), e = D(this.map, this.S.getTranslation()), t = this.S.I();
|
|
1637
|
+
let s = null, i = null;
|
|
1638
|
+
if (e[2] + t < .01 && "z-translate" !== this.iA) s = this.gA(this.currentMousePosition),
|
|
1639
|
+
i = this.gA(this.lastMousePosition); else {
|
|
1625
1640
|
const A = this.TransformHelper.planeHelper.getMeshes()[0];
|
|
1626
|
-
if (s = this.
|
|
1627
|
-
!s || null === s.meshId || !
|
|
1641
|
+
if (s = this.X(this.currentMousePosition, A, "plane"), i = this.X(this.lastMousePosition, A, "plane"),
|
|
1642
|
+
!s || null === s.meshId || !i || null === i.meshId) return;
|
|
1628
1643
|
}
|
|
1629
1644
|
const I = [ 0, 0, 0 ], g = [ 0, 0, 0 ];
|
|
1630
|
-
let r = 0,
|
|
1645
|
+
let r = 0, a = 0, C = 0;
|
|
1631
1646
|
if ("translate" === A) {
|
|
1632
|
-
if ("xy-translate" === this.
|
|
1633
|
-
const A = s.point[0] -
|
|
1647
|
+
if ("xy-translate" === this.iA) {
|
|
1648
|
+
const A = s.point[0] - i.point[0], e = s.point[1] - i.point[1];
|
|
1634
1649
|
I[0] = A, I[1] = e;
|
|
1635
|
-
} else if ("x-translate" === this.
|
|
1636
|
-
const A = s.point[0] -
|
|
1650
|
+
} else if ("x-translate" === this.iA) {
|
|
1651
|
+
const A = s.point[0] - i.point[0];
|
|
1637
1652
|
I[0] = A;
|
|
1638
|
-
} else if ("y-translate" === this.
|
|
1639
|
-
const A = s.point[1] -
|
|
1653
|
+
} else if ("y-translate" === this.iA) {
|
|
1654
|
+
const A = s.point[1] - i.point[1];
|
|
1640
1655
|
I[1] = A;
|
|
1641
|
-
} else if ("z-translate" === this.
|
|
1656
|
+
} else if ("z-translate" === this.iA) {
|
|
1642
1657
|
let A = 0;
|
|
1643
|
-
if (this.
|
|
1644
|
-
const e = this.map.getGLRes(), t = this.map._pointAtResToContainerPoint(new o(
|
|
1658
|
+
if (this.rA()) {
|
|
1659
|
+
const e = this.map.getGLRes(), t = this.map._pointAtResToContainerPoint(new o(i.point[0], i.point[1]), e), I = this.map._pointAtResToContainerPoint(new o(s.point[0], s.point[1]), e), g = n.length(n.set($, s.point[0] - i.point[0], s.point[1] - i.point[1]));
|
|
1645
1660
|
A = I.y < t.y ? g : -g;
|
|
1646
|
-
} else A = s.point[2] -
|
|
1661
|
+
} else A = s.point[2] - i.point[2];
|
|
1647
1662
|
I[2] = A;
|
|
1648
1663
|
}
|
|
1649
|
-
} else if ("rotation" === A)
|
|
1650
|
-
g[2] +=
|
|
1651
|
-
const A = this.
|
|
1652
|
-
r = this.
|
|
1664
|
+
} else if ("rotation" === A) a = this.aA(s.point, i.point), a >= 0 ? this.TransformHelper.o(!0) : this.TransformHelper.o(!1),
|
|
1665
|
+
g[2] += a; else if ("scaling" === A || "xyzScale" === A) {
|
|
1666
|
+
const A = this.CA(), e = n.length(n.set($, this.firstDownPoint.point[0] - A[0], this.firstDownPoint.point[1] - A[1])), t = n.length(n.set($, i.point[0] - A[0], i.point[1] - A[1]));
|
|
1667
|
+
r = this.hA(s.point, i.point, A, t), C = this.hA(s.point, i.point, A, e);
|
|
1653
1668
|
}
|
|
1654
|
-
this.TransformHelper.updateMatrix(this.map, this.S,
|
|
1669
|
+
this.TransformHelper.updateMatrix(this.map, this.S, a, C, I), this.S.p(this.iA, I, g, r, .01, this.map, this);
|
|
1655
1670
|
}
|
|
1656
1671
|
this.lastMousePosition = A, this.lastPickingObject = this.currentPickingObject;
|
|
1657
|
-
const e = this.
|
|
1672
|
+
const e = this.q();
|
|
1658
1673
|
this.lastPickingMesh = e[this.currentPickingObject.meshId];
|
|
1659
1674
|
}
|
|
1660
|
-
|
|
1661
|
-
const I = (
|
|
1662
|
-
return
|
|
1675
|
+
hA(A, e, t, s, i) {
|
|
1676
|
+
const I = (n.length(n.set($, A[0] - t[0], A[1] - t[1])) - n.length(n.set($, e[0] - t[0], e[1] - t[1]))) / s;
|
|
1677
|
+
return i ? (i[0] - .01) * I : I;
|
|
1663
1678
|
}
|
|
1664
|
-
|
|
1665
|
-
const A = this.map, e = this.S.getCoordinates(), t = A.coordinateToPointAtRes(e, A.getGLRes()), i = s.set(
|
|
1679
|
+
CA() {
|
|
1680
|
+
const A = this.map, e = this.S.getCoordinates(), t = A.coordinateToPointAtRes(e, A.getGLRes()), i = s.set(AA, t.x, t.y, 0), n = D(A, this.S.getTranslation());
|
|
1666
1681
|
return s.add(i, i, n), i;
|
|
1667
1682
|
}
|
|
1668
|
-
|
|
1669
|
-
const i = this.TransformHelper.planeHelper.getMeshes()[0][0], n = e.getTranslation(
|
|
1670
|
-
let o = A.fromEuler(
|
|
1683
|
+
$(t) {
|
|
1684
|
+
const i = this.TransformHelper.planeHelper.getMeshes()[0][0], n = e.getTranslation(X, i.localTransform), I = e.getScaling(q, i.localTransform);
|
|
1685
|
+
let o = A.fromEuler(W, 0, 0, 0);
|
|
1671
1686
|
const g = this.map.getBearing();
|
|
1672
|
-
t && !this.
|
|
1673
|
-
s.set(i.rotation, 90, 0, -g)) : (90 === i.rotation[0] && (this
|
|
1687
|
+
t && !this.rA() ? (o = A.fromEuler(W, 90, 0, -g), 0 === i.rotation[0] && (this.tA = !0),
|
|
1688
|
+
s.set(i.rotation, 90, 0, -g)) : (90 === i.rotation[0] && (this.tA = !0), s.set(i.rotation, 0, 0, -g)),
|
|
1674
1689
|
e.fromRotationTranslationScale(i.localTransform, o, n, I);
|
|
1675
1690
|
}
|
|
1676
|
-
|
|
1691
|
+
rA() {
|
|
1677
1692
|
if (this.map.getPitch()) return !1;
|
|
1678
1693
|
const A = this.map.cameraPosition, e = this.map.coordinateToPointAtRes(this.map.getCenter(), this.map.getGLRes());
|
|
1679
1694
|
s.set(e, e.x, e.y, 0);
|
|
1680
|
-
const t = this.S.getCoordinates(), i = this.map.coordinateToPointAtRes(t, this.map.getGLRes()), n =
|
|
1695
|
+
const t = this.S.getCoordinates(), i = this.map.coordinateToPointAtRes(t, this.map.getGLRes()), n = D(this.map, this.S.getTranslation()), I = s.set(X, i.x, i.y, 0), o = s.add(I, I, n), g = s.subtract([], A, o), r = s.subtract([], A, e);
|
|
1681
1696
|
return s.angle(g, r) < 1 / 180 * Math.PI;
|
|
1682
1697
|
}
|
|
1683
|
-
|
|
1684
|
-
const A = this.
|
|
1698
|
+
AA() {
|
|
1699
|
+
const A = this.q();
|
|
1685
1700
|
if (this.currentPickingObject && null != this.currentPickingObject.meshId) {
|
|
1686
|
-
this.
|
|
1701
|
+
this.wA(), this.lastPickingObject && null != this.lastPickingObject.meshId && this.lastPickingObject.meshId !== this.currentPickingObject.meshId && this.cA();
|
|
1687
1702
|
const e = A[this.currentPickingObject.meshId];
|
|
1688
|
-
if (e &&
|
|
1703
|
+
if (e && j.indexOf(this.currentPickingObject.pickingId) < 0) if (this.currentPickingObject.pickingId > 100) this.QA(e); else {
|
|
1689
1704
|
const A = [ e.originColor[0], e.originColor[1], e.originColor[2], .8 ];
|
|
1690
|
-
e.material.set("color", A), this.
|
|
1705
|
+
e.material.set("color", A), this.fA(e, .5);
|
|
1691
1706
|
}
|
|
1692
1707
|
this.layerRenderer.setToRedraw();
|
|
1693
1708
|
} else this.lastPickingObject && null != this.lastPickingObject.meshId && (this.map.resetCursor(),
|
|
1694
|
-
this.
|
|
1709
|
+
this.cA(), this.layerRenderer.setToRedraw());
|
|
1695
1710
|
}
|
|
1696
|
-
|
|
1711
|
+
QA(A) {
|
|
1697
1712
|
const e = [ 1, 179 / 255, 2 / 255, 1 ];
|
|
1698
1713
|
A.material.set("color", e), A.properties.relatedMeshes && A.properties.relatedMeshes.forEach((A => {
|
|
1699
1714
|
A.material.set("color", e);
|
|
1700
1715
|
}));
|
|
1701
1716
|
}
|
|
1702
|
-
|
|
1703
|
-
6 === this.currentPickingObject.pickingId ? this.map.setCursor("ns-resize") :
|
|
1717
|
+
wA() {
|
|
1718
|
+
6 === this.currentPickingObject.pickingId ? this.map.setCursor("ns-resize") : K.indexOf(this.currentPickingObject.pickingId) > -1 ? this.map.setCursor("move") : this.map.setCursor("pointer");
|
|
1704
1719
|
}
|
|
1705
|
-
|
|
1720
|
+
cA() {
|
|
1706
1721
|
const A = this.lastPickingMesh;
|
|
1707
1722
|
if (!A) return;
|
|
1708
|
-
const e = A.getUniform("uPickingId"), t = this.
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
})) :
|
|
1723
|
+
const e = A.getUniform("uPickingId"), t = this.q();
|
|
1724
|
+
K.indexOf(e) > -1 ? t.forEach((A => {
|
|
1725
|
+
K.indexOf(A.getUniform("uPickingId")) > -1 && A.material.set("color", A.originColor);
|
|
1726
|
+
})) : Y.indexOf(e) > -1 ? t.forEach((A => {
|
|
1712
1727
|
const e = A.getUniform("uPickingId");
|
|
1713
|
-
|
|
1728
|
+
Z.indexOf(e) > -1 && A.material.set("color", A.originColor);
|
|
1714
1729
|
})) : 11 === e && t.forEach((A => {
|
|
1715
|
-
|
|
1730
|
+
Z.indexOf(A.getUniform("uPickingId")) > -1 && A.material.set("color", A.originColor);
|
|
1716
1731
|
})), A.material.set("color", A.originColor), A.properties.relatedMeshes && A.properties.relatedMeshes.forEach((A => {
|
|
1717
1732
|
A.material.set("color", A.originColor);
|
|
1718
1733
|
}));
|
|
1719
1734
|
}
|
|
1720
|
-
|
|
1721
|
-
const t = A.getUniform("uPickingId"), s = this.
|
|
1722
|
-
|
|
1723
|
-
if (
|
|
1735
|
+
fA(A, e) {
|
|
1736
|
+
const t = A.getUniform("uPickingId"), s = this.q();
|
|
1737
|
+
K.indexOf(t) > -1 ? s.forEach((t => {
|
|
1738
|
+
if (K.indexOf(t.getUniform("uPickingId")) > -1 && t.getUniform("uPickingId") !== A.getUniform("uPickingId")) {
|
|
1724
1739
|
const A = [ t.originColor[0], t.originColor[1], t.originColor[2], e ];
|
|
1725
1740
|
t.material.set("color", A);
|
|
1726
1741
|
}
|
|
@@ -1741,21 +1756,21 @@ class eA extends(r(C(a))){
|
|
|
1741
1756
|
reset() {
|
|
1742
1757
|
this.map && this.S && (this.S.M(), this.TransformHelper.updateMatrix(this.map, this.S, 0, 0, [ 0, 0, 0 ]));
|
|
1743
1758
|
}
|
|
1744
|
-
|
|
1745
|
-
const t = this.
|
|
1746
|
-
return (Math.atan2(
|
|
1759
|
+
aA(A, e) {
|
|
1760
|
+
const t = this.CA(), s = n.set(eA, e[0] - t[0], e[1] - t[1]), i = n.set(tA, A[0] - t[0], A[1] - t[1]), I = Math.atan2(s[1], s[0]);
|
|
1761
|
+
return (Math.atan2(i[1], i[0]) - I) / Math.PI * 180;
|
|
1747
1762
|
}
|
|
1748
|
-
|
|
1749
|
-
return this.
|
|
1750
|
-
this.
|
|
1763
|
+
sA(A) {
|
|
1764
|
+
return this.iA = 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",
|
|
1765
|
+
this.iA;
|
|
1751
1766
|
}
|
|
1752
1767
|
transform(A) {
|
|
1753
1768
|
if (!A) return;
|
|
1754
1769
|
if (this.layerRenderer && this.layerRenderer.layer && (this.layerRenderer.layer.off("renderend", this.render),
|
|
1755
|
-
this.layerRenderer.layer.off("resizeCanvas", this.
|
|
1770
|
+
this.layerRenderer.layer.off("resizeCanvas", this.lA)), !this.map) return void console.error("should add to a target first");
|
|
1756
1771
|
if (this.S && (this.S.B(), this.S.D(A)), !this.S.getTargets().length) return;
|
|
1757
1772
|
const e = this.map;
|
|
1758
|
-
this.TransformHelper.updateMatrix(e, this.S, 0, 0, [ 0, 0, 0 ]), this.
|
|
1773
|
+
this.TransformHelper.updateMatrix(e, this.S, 0, 0, [ 0, 0, 0 ]), this.PA(), this.tA = !0;
|
|
1759
1774
|
}
|
|
1760
1775
|
getTransformTarget() {
|
|
1761
1776
|
return this.S;
|
|
@@ -1763,51 +1778,41 @@ class eA extends(r(C(a))){
|
|
|
1763
1778
|
u() {
|
|
1764
1779
|
delete this.S;
|
|
1765
1780
|
}
|
|
1766
|
-
|
|
1781
|
+
PA() {
|
|
1767
1782
|
const A = this.S.O();
|
|
1768
|
-
A && (A.off("renderend", this.render), A.off("resizeCanvas", this.
|
|
1769
|
-
const e = this.map.
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
if (!t) return;
|
|
1776
|
-
const s = t.getLayers(), i = s.indexOf(A);
|
|
1777
|
-
if (i < 0) return;
|
|
1778
|
-
s.splice(i, 1), s.push(A);
|
|
1779
|
-
const I = this.map, o = A.getRenderer();
|
|
1780
|
-
this.layerRenderer = o, this.regl = o.regl, this.renderer = o.renderer, this.fA = this.layerRenderer.getFBORayPicking(),
|
|
1781
|
-
this.lA = {
|
|
1782
|
-
projViewMatrix: I.projViewMatrix,
|
|
1783
|
-
projMatrix: I.projMatrix,
|
|
1784
|
-
viewMatrix: I.viewMatrix,
|
|
1783
|
+
A && (A.off("renderend", this.render), A.off("resizeCanvas", this.lA));
|
|
1784
|
+
const e = this.map, t = A.getRenderer();
|
|
1785
|
+
this.layerRenderer = t, this.regl = t.regl, this.renderer = t.renderer, this.DA = this.layerRenderer.getFBORayPicking(),
|
|
1786
|
+
this.uA = {
|
|
1787
|
+
projViewMatrix: e.projViewMatrix,
|
|
1788
|
+
projMatrix: e.projMatrix,
|
|
1789
|
+
viewMatrix: e.viewMatrix,
|
|
1785
1790
|
pointSize: 1
|
|
1786
|
-
}, A.on("renderend", this.render, this), A.on("resizeCanvas", this.
|
|
1791
|
+
}, A.on("renderend", this.render, this), A.on("resizeCanvas", this.lA, this), t.setToRedraw();
|
|
1787
1792
|
}
|
|
1788
|
-
|
|
1789
|
-
this.
|
|
1793
|
+
lA() {
|
|
1794
|
+
this.DA.clear(), this.tA = !0;
|
|
1790
1795
|
}
|
|
1791
|
-
|
|
1796
|
+
X(A, e, t) {
|
|
1792
1797
|
const s = this.map;
|
|
1793
|
-
if (!(s && this.
|
|
1794
|
-
const i = s.getDevicePixelRatio(), n = A.x * i, I = A.y * i, o = this.
|
|
1795
|
-
(this
|
|
1796
|
-
this
|
|
1797
|
-
return this.
|
|
1798
|
+
if (!(s && this.DA && this.layerRenderer && this.layerRenderer.canvas)) return null;
|
|
1799
|
+
const i = s.getDevicePixelRatio(), n = A.x * i, I = A.y * i, o = this.uA, g = this.layerRenderer.canvas.gl && this.layerRenderer.canvas.gl.wrap;
|
|
1800
|
+
(this.tA || g || !this.mA || this.mA !== t) && (this.DA.render(e, o, !0), this.mA = t,
|
|
1801
|
+
this.tA = !1);
|
|
1802
|
+
return this.DA.pick(n, I, 10, o, {
|
|
1798
1803
|
viewMatrix: this.map.viewMatrix,
|
|
1799
1804
|
projMatrix: this.map.projMatrix,
|
|
1800
1805
|
returnPoint: !0
|
|
1801
1806
|
});
|
|
1802
1807
|
}
|
|
1803
|
-
|
|
1808
|
+
Y() {
|
|
1804
1809
|
const A = this.map.getDevicePixelRatio(), s = {
|
|
1805
1810
|
x: 0,
|
|
1806
1811
|
y: 0,
|
|
1807
1812
|
width: () => this.map ? this.map.width * A : 1,
|
|
1808
1813
|
height: () => this.map ? this.map.height * A : 1
|
|
1809
1814
|
};
|
|
1810
|
-
this.
|
|
1815
|
+
this.bA = new t.MeshShader({
|
|
1811
1816
|
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",
|
|
1812
1817
|
frag: "precision mediump float;\n\nuniform vec4 color;\n\n\n\nvoid main() {\n\n gl_FragColor = color;\n\n}\n\n",
|
|
1813
1818
|
uniforms: [ "color", {
|
|
@@ -1838,16 +1843,16 @@ class eA extends(r(C(a))){
|
|
|
1838
1843
|
});
|
|
1839
1844
|
}
|
|
1840
1845
|
render() {
|
|
1841
|
-
if (!this.
|
|
1842
|
-
const A = this.
|
|
1846
|
+
if (!this.W()) return;
|
|
1847
|
+
const A = this.q();
|
|
1843
1848
|
this.helperScene.setMeshes(A);
|
|
1844
1849
|
const e = this.layerRenderer.getFrameContext();
|
|
1845
1850
|
if (e && e.renderTarget && this.layerRenderer.getFrameTimestamp() !== e.timestamp) return;
|
|
1846
|
-
this.
|
|
1851
|
+
this.nA(), this.bA.filter = e && e.sceneFilter;
|
|
1847
1852
|
const t = e && e.renderTarget && e.renderTarget.fbo;
|
|
1848
|
-
this.renderer.render(this.
|
|
1853
|
+
this.renderer.render(this.bA, this.uA, this.helperScene, t);
|
|
1849
1854
|
}
|
|
1850
|
-
|
|
1855
|
+
q() {
|
|
1851
1856
|
let A = [];
|
|
1852
1857
|
const e = this.TransformHelper.getMeshes(this.U);
|
|
1853
1858
|
for (const t in e) {
|
|
@@ -1859,17 +1864,17 @@ class eA extends(r(C(a))){
|
|
|
1859
1864
|
if (t) for (let e = 0; e < t.length; e++) A = A.concat(t[e]);
|
|
1860
1865
|
return A;
|
|
1861
1866
|
}
|
|
1862
|
-
|
|
1867
|
+
W() {
|
|
1863
1868
|
const A = this.layerRenderer, e = A && A.layer;
|
|
1864
1869
|
return A && this.S && e && e.isVisible() && this.S.F() && this.regl && this.V;
|
|
1865
1870
|
}
|
|
1866
1871
|
}
|
|
1867
1872
|
|
|
1868
|
-
|
|
1873
|
+
sA.mergeOptions({
|
|
1869
1874
|
scaleStrength: 2
|
|
1870
1875
|
});
|
|
1871
1876
|
|
|
1872
|
-
export {
|
|
1877
|
+
export { sA as TransformControl };
|
|
1873
1878
|
|
|
1874
|
-
"undefined" != typeof console && console.log("@maptalks/transform-control v0.
|
|
1879
|
+
"undefined" != typeof console && console.log("@maptalks/transform-control v0.101.0");
|
|
1875
1880
|
//# sourceMappingURL=transform-control.es.js.map
|