@xeokit/xeokit-sdk 2.6.30 → 2.6.32
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/README.md +17 -23
- package/dist/xeokit-sdk.cjs.js +353 -336
- package/dist/xeokit-sdk.es.js +353 -336
- package/dist/xeokit-sdk.es5.js +412 -408
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.js +110 -33
- package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +7 -2
- package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +1 -1
- package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +5 -1
- package/src/plugins/ZonesPlugin/ZonesPlugin.js +97 -148
- package/src/plugins/lib/html/Dot.js +2 -2
- package/src/viewer/scene/webgl/Renderer.js +132 -154
- package/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts +5 -3
- package/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts +2 -2
- package/types/plugins/OBJLoaderPlugin/OBJLoaderPlugin.d.ts +3 -3
package/package.json
CHANGED
|
@@ -426,50 +426,127 @@ export class DotBIMLoaderPlugin extends Plugin {
|
|
|
426
426
|
|
|
427
427
|
const dbMeshId = element.mesh_id;
|
|
428
428
|
|
|
429
|
-
parseDBMesh(dbMeshId);
|
|
430
|
-
|
|
431
|
-
const meshId = `${objectId}-mesh`;
|
|
432
429
|
const vector = element.vector;
|
|
433
430
|
const rotation = element.rotation;
|
|
434
431
|
const props = objectDefaults ? objectDefaults[elementType] || objectDefaults["DEFAULT"] : null;
|
|
435
|
-
|
|
436
432
|
let visible = true;
|
|
437
433
|
let pickable = true;
|
|
438
|
-
let color = element.color ? [element.color.r / 255, element.color.g / 255, element.color.b / 255] : [1, 1, 1];
|
|
439
|
-
let opacity = element.color ? element.color.a / 255 : 1.0;
|
|
440
434
|
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
435
|
+
if (element.face_colors === undefined) {
|
|
436
|
+
|
|
437
|
+
parseDBMesh(dbMeshId);
|
|
438
|
+
|
|
439
|
+
const meshId = `${objectId}-mesh`;
|
|
440
|
+
|
|
441
|
+
let color = element.color ? [element.color.r / 255.0, element.color.g / 255.0, element.color.b / 255.0] : [1, 1, 1];
|
|
442
|
+
let opacity = element.color ? element.color.a / 255.0 : 1.0;
|
|
443
|
+
|
|
444
|
+
if (props) {
|
|
445
|
+
if (props.visible === false) {
|
|
446
|
+
visible = false;
|
|
447
|
+
}
|
|
448
|
+
if (props.pickable === false) {
|
|
449
|
+
pickable = false;
|
|
450
|
+
}
|
|
451
|
+
if (props.colorize) {
|
|
452
|
+
color = props.colorize;
|
|
453
|
+
}
|
|
454
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
455
|
+
opacity = props.opacity;
|
|
456
|
+
}
|
|
447
457
|
}
|
|
448
|
-
|
|
449
|
-
|
|
458
|
+
|
|
459
|
+
sceneModel.createMesh({
|
|
460
|
+
id: meshId,
|
|
461
|
+
geometryId: dbMeshId,
|
|
462
|
+
color: color,
|
|
463
|
+
opacity: opacity,
|
|
464
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
465
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
sceneModel.createEntity({
|
|
469
|
+
id: objectId,
|
|
470
|
+
meshIds: [meshId],
|
|
471
|
+
visible: visible,
|
|
472
|
+
pickable: pickable,
|
|
473
|
+
isObject: true
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
let faceColors = element.face_colors;
|
|
478
|
+
let coloredTrianglesDictionary = {};
|
|
479
|
+
let currentTriangleIndicesCount = 0;
|
|
480
|
+
let dbMesh = fileData.meshes[element.mesh_id];
|
|
481
|
+
for (let i = 0, len = faceColors.length; i < len; i+=4) {
|
|
482
|
+
let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
|
|
483
|
+
if (coloredTrianglesDictionary[faceColor] === undefined) {
|
|
484
|
+
coloredTrianglesDictionary[faceColor] = [];
|
|
485
|
+
}
|
|
486
|
+
let indexForPoint0 = dbMesh.indices[currentTriangleIndicesCount];
|
|
487
|
+
let x0 = dbMesh.coordinates[indexForPoint0*3];
|
|
488
|
+
let y0 = dbMesh.coordinates[indexForPoint0*3+1];
|
|
489
|
+
let z0 = dbMesh.coordinates[indexForPoint0*3+2];
|
|
490
|
+
let indexForPoint1 = dbMesh.indices[currentTriangleIndicesCount+1];
|
|
491
|
+
let x1 = dbMesh.coordinates[indexForPoint1*3];
|
|
492
|
+
let y1 = dbMesh.coordinates[indexForPoint1*3+1];
|
|
493
|
+
let z1 = dbMesh.coordinates[indexForPoint1*3+2];
|
|
494
|
+
let indexForPoint2 = dbMesh.indices[currentTriangleIndicesCount+2];
|
|
495
|
+
let x2 = dbMesh.coordinates[indexForPoint2*3];
|
|
496
|
+
let y2 = dbMesh.coordinates[indexForPoint2*3+1];
|
|
497
|
+
let z2 = dbMesh.coordinates[indexForPoint2*3+2];
|
|
498
|
+
coloredTrianglesDictionary[faceColor].push(x0, y0, z0, x1, y1, z1, x2, y2, z2);
|
|
499
|
+
|
|
500
|
+
currentTriangleIndicesCount += 3;
|
|
450
501
|
}
|
|
451
|
-
|
|
452
|
-
|
|
502
|
+
let meshIds = [];
|
|
503
|
+
for (const [faceColor, trianglesCoordinates] of Object.entries(coloredTrianglesDictionary)) {
|
|
504
|
+
sceneModel.createGeometry({
|
|
505
|
+
id: `${dbMeshId}-${faceColor}`,
|
|
506
|
+
primitive: "triangles",
|
|
507
|
+
positions: trianglesCoordinates,
|
|
508
|
+
indices: [...Array(trianglesCoordinates.length).keys()]
|
|
509
|
+
});
|
|
510
|
+
const meshId = `${objectId}-mesh-${faceColor}`;
|
|
511
|
+
const faceColorArray = faceColor.split(',').map(Number);
|
|
512
|
+
|
|
513
|
+
let color = [faceColorArray[0] / 255.0, faceColorArray[1] / 255.0, faceColorArray[2] / 255.0];
|
|
514
|
+
let opacity = faceColorArray[3] / 255.0;
|
|
515
|
+
|
|
516
|
+
if (props) {
|
|
517
|
+
if (props.visible === false) {
|
|
518
|
+
visible = false;
|
|
519
|
+
}
|
|
520
|
+
if (props.pickable === false) {
|
|
521
|
+
pickable = false;
|
|
522
|
+
}
|
|
523
|
+
if (props.colorize) {
|
|
524
|
+
color = props.colorize;
|
|
525
|
+
}
|
|
526
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
527
|
+
opacity = props.opacity;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
sceneModel.createMesh({
|
|
532
|
+
id: meshId,
|
|
533
|
+
geometryId: `${dbMeshId}-${faceColor}`,
|
|
534
|
+
color: color,
|
|
535
|
+
opacity: opacity,
|
|
536
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
537
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
538
|
+
});
|
|
539
|
+
meshIds.push(meshId);
|
|
453
540
|
}
|
|
541
|
+
sceneModel.createEntity({
|
|
542
|
+
id: objectId,
|
|
543
|
+
meshIds: meshIds,
|
|
544
|
+
visible: visible,
|
|
545
|
+
pickable: pickable,
|
|
546
|
+
isObject: true
|
|
547
|
+
});
|
|
454
548
|
}
|
|
455
549
|
|
|
456
|
-
sceneModel.createMesh({
|
|
457
|
-
id: meshId,
|
|
458
|
-
geometryId: dbMeshId,
|
|
459
|
-
color,
|
|
460
|
-
opacity,
|
|
461
|
-
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
462
|
-
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
sceneModel.createEntity({
|
|
466
|
-
id: objectId,
|
|
467
|
-
meshIds: [meshId],
|
|
468
|
-
visible,
|
|
469
|
-
pickable,
|
|
470
|
-
isObject: true
|
|
471
|
-
});
|
|
472
|
-
|
|
473
550
|
for (let infoKey in info) {
|
|
474
551
|
let properties;
|
|
475
552
|
if (infoKey.startsWith("IFC_Pset_")) {
|
|
@@ -5,6 +5,7 @@ import {sRGBEncoding} from "../../viewer/scene/constants/constants.js";
|
|
|
5
5
|
import {worldToRTCPositions} from "../../viewer/scene/math/rtcCoords.js";
|
|
6
6
|
import {parse} from '@loaders.gl/core';
|
|
7
7
|
import {GLTFLoader} from '@loaders.gl/gltf/dist/esm/gltf-loader.js';
|
|
8
|
+
|
|
8
9
|
import {
|
|
9
10
|
ClampToEdgeWrapping,
|
|
10
11
|
LinearFilter,
|
|
@@ -503,7 +504,7 @@ const parseNodesWithNames = (function () {
|
|
|
503
504
|
|
|
504
505
|
const objectIdStack = [];
|
|
505
506
|
const meshIdsStack = [];
|
|
506
|
-
let meshIds =
|
|
507
|
+
let meshIds = [];
|
|
507
508
|
|
|
508
509
|
return function (ctx, node, depth, matrix) {
|
|
509
510
|
matrix = parseNodeMatrix(node, matrix);
|
|
@@ -681,7 +682,11 @@ function parseNodeMesh(node, ctx, matrix, meshIds) {
|
|
|
681
682
|
if (primitive.indices) {
|
|
682
683
|
meshCfg.indices = primitive.indices.value;
|
|
683
684
|
}
|
|
684
|
-
|
|
685
|
+
if (matrix) {
|
|
686
|
+
math.transformPositions3(matrix, meshCfg.localPositions, meshCfg.positions);
|
|
687
|
+
} else { // eqiv to math.transformPositions3(math.identityMat4(), meshCfg.localPositions, meshCfg.positions);
|
|
688
|
+
meshCfg.positions.set(meshCfg.localPositions);
|
|
689
|
+
}
|
|
685
690
|
const origin = math.vec3();
|
|
686
691
|
const rtcNeeded = worldToRTCPositions(meshCfg.positions, meshCfg.positions, origin); // Small cellsize guarantees better accuracy
|
|
687
692
|
if (rtcNeeded) {
|
|
@@ -990,7 +990,7 @@ export class TreeViewPlugin extends Plugin {
|
|
|
990
990
|
this._nodeNodes[buildingNode.nodeId] = buildingNode;
|
|
991
991
|
} else if (metaObjectType === "IfcBuildingStorey") {
|
|
992
992
|
if (!buildingNode) {
|
|
993
|
-
this.error("Failed to build storeys hierarchy for model
|
|
993
|
+
this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");
|
|
994
994
|
return;
|
|
995
995
|
}
|
|
996
996
|
storeyNode = {
|
|
@@ -880,6 +880,9 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
880
880
|
* represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
|
|
881
881
|
* to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
|
|
882
882
|
* primitives. Only works while {@link DTX#enabled} is also ````true````.
|
|
883
|
+
* @param {Number} [params.renderOrder=0] Specifies the rendering order for the model. This is used to control the order in which
|
|
884
|
+
* SceneModels are drawn when they have transparent objects, to give control over the order in which those objects are blended within the transparent
|
|
885
|
+
* render pass.
|
|
883
886
|
* @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}.
|
|
884
887
|
*/
|
|
885
888
|
load(params = {}) {
|
|
@@ -929,7 +932,8 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
929
932
|
origin: params.origin,
|
|
930
933
|
disableVertexWelding: params.disableVertexWelding || false,
|
|
931
934
|
disableIndexRebucketing: params.disableIndexRebucketing || false,
|
|
932
|
-
dtxEnabled: params.dtxEnabled
|
|
935
|
+
dtxEnabled: params.dtxEnabled,
|
|
936
|
+
renderOrder: params.renderOrder
|
|
933
937
|
}));
|
|
934
938
|
|
|
935
939
|
const modelId = sceneModel.id; // In case ID was auto-generated
|
|
@@ -271,10 +271,9 @@ const basePolygon3D = function(scene, color, alpha) {
|
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
-
const
|
|
275
|
-
const marker1 = marker3D(scene,
|
|
276
|
-
const marker2 = marker3D(scene,
|
|
277
|
-
const basePolygon = basePolygon3D(scene, zoneColor, zoneAlpha);
|
|
274
|
+
const startAARectCreateUI = function(scene, markersColor, pointerLens, select3dPoint, withPoints, onPointsSelected) {
|
|
275
|
+
const marker1 = marker3D(scene, markersColor);
|
|
276
|
+
const marker2 = marker3D(scene, markersColor);
|
|
278
277
|
|
|
279
278
|
const updatePointerLens = (pointerLens
|
|
280
279
|
? function(canvasPos) {
|
|
@@ -302,29 +301,14 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
|
|
|
302
301
|
function() {
|
|
303
302
|
updatePointerLens(null);
|
|
304
303
|
marker2.update(null);
|
|
305
|
-
|
|
304
|
+
withPoints(null);
|
|
306
305
|
},
|
|
307
306
|
function(canvasPos, point2WorldPos) {
|
|
308
307
|
updatePointerLens(canvasPos);
|
|
309
308
|
marker2.update(point2WorldPos);
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const min = (idx) => Math.min(point1WorldPos[idx], point2WorldPos[idx]);
|
|
314
|
-
const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
|
|
315
|
-
|
|
316
|
-
const xmin = min(0);
|
|
317
|
-
const ymin = min(1);
|
|
318
|
-
const zmin = min(2);
|
|
319
|
-
const xmax = max(0);
|
|
320
|
-
const ymax = max(1);
|
|
321
|
-
const zmax = max(2);
|
|
322
|
-
|
|
323
|
-
basePolygon.updateBase([ [ xmin, ymin, zmax ], [ xmax, ymin, zmax ],
|
|
324
|
-
[ xmax, ymin, zmin ], [ xmin, ymin, zmin ] ]);
|
|
325
|
-
}
|
|
326
|
-
else
|
|
327
|
-
basePolygon.updateBase(null);
|
|
309
|
+
withPoints((math.distVec3(point1WorldPos, point2WorldPos) > 0.01)
|
|
310
|
+
&&
|
|
311
|
+
[ point1WorldPos, point2WorldPos ]);
|
|
328
312
|
},
|
|
329
313
|
function(point2CanvasPos, point2WorldPos) {
|
|
330
314
|
// `marker2.update' makes sure marker's position has been updated from its default [0,0,0]
|
|
@@ -334,35 +318,9 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
|
|
|
334
318
|
|
|
335
319
|
marker1.destroy();
|
|
336
320
|
marker2.destroy();
|
|
337
|
-
basePolygon.destroy();
|
|
338
321
|
updatePointerLens(null);
|
|
339
322
|
|
|
340
|
-
|
|
341
|
-
const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
|
|
342
|
-
|
|
343
|
-
const xmin = min(0);
|
|
344
|
-
const zmin = min(2);
|
|
345
|
-
const xmax = max(0);
|
|
346
|
-
const zmax = max(2);
|
|
347
|
-
|
|
348
|
-
const zone = zonesPlugin.createZone(
|
|
349
|
-
{
|
|
350
|
-
id: math.createUUID(),
|
|
351
|
-
geometry: {
|
|
352
|
-
planeCoordinates: [
|
|
353
|
-
[ xmin, zmax ],
|
|
354
|
-
[ xmax, zmax ],
|
|
355
|
-
[ xmax, zmin ],
|
|
356
|
-
[ xmin, zmin ]
|
|
357
|
-
],
|
|
358
|
-
altitude: zoneAltitude,
|
|
359
|
-
height: zoneHeight
|
|
360
|
-
},
|
|
361
|
-
alpha: zoneAlpha,
|
|
362
|
-
color: zoneColor
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
onZoneCreated(zone);
|
|
323
|
+
onPointsSelected([ point1WorldPos, point2WorldPos ]);
|
|
366
324
|
});
|
|
367
325
|
});
|
|
368
326
|
|
|
@@ -371,7 +329,6 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
|
|
|
371
329
|
deactivatePointSelection();
|
|
372
330
|
marker1.destroy();
|
|
373
331
|
marker2.destroy();
|
|
374
|
-
basePolygon.destroy();
|
|
375
332
|
updatePointerLens(null);
|
|
376
333
|
}
|
|
377
334
|
};
|
|
@@ -1052,6 +1009,34 @@ class Zone extends Component {
|
|
|
1052
1009
|
}
|
|
1053
1010
|
}
|
|
1054
1011
|
|
|
1012
|
+
const createAAZoneFromPoints = function(pos1, pos2, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, zonesPlugin) {
|
|
1013
|
+
|
|
1014
|
+
const min = (idx) => Math.min(pos1[idx], pos2[idx]);
|
|
1015
|
+
const max = (idx) => Math.max(pos1[idx], pos2[idx]);
|
|
1016
|
+
|
|
1017
|
+
const xmin = min(0);
|
|
1018
|
+
const zmin = min(2);
|
|
1019
|
+
const xmax = max(0);
|
|
1020
|
+
const zmax = max(2);
|
|
1021
|
+
|
|
1022
|
+
return zonesPlugin.createZone(
|
|
1023
|
+
{
|
|
1024
|
+
id: math.createUUID(),
|
|
1025
|
+
geometry: {
|
|
1026
|
+
planeCoordinates: [
|
|
1027
|
+
[ xmin, zmax ],
|
|
1028
|
+
[ xmax, zmax ],
|
|
1029
|
+
[ xmax, zmin ],
|
|
1030
|
+
[ xmin, zmin ]
|
|
1031
|
+
],
|
|
1032
|
+
altitude: zoneAltitude,
|
|
1033
|
+
height: zoneHeight
|
|
1034
|
+
},
|
|
1035
|
+
alpha: zoneAlpha,
|
|
1036
|
+
color: zoneColor
|
|
1037
|
+
});
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1055
1040
|
/**
|
|
1056
1041
|
* Creates {@link Zone}s in a {@link ZonesPlugin} from mouse input.
|
|
1057
1042
|
*
|
|
@@ -1082,7 +1067,7 @@ class Zone extends Component {
|
|
|
1082
1067
|
* const zonesControl = new ZonesMouseControl(Zones)
|
|
1083
1068
|
* ````
|
|
1084
1069
|
*/
|
|
1085
|
-
class
|
|
1070
|
+
class ZonesAAZoneControl extends Component {
|
|
1086
1071
|
|
|
1087
1072
|
/**
|
|
1088
1073
|
* Creates a ZonesMouseControl bound to the given ZonesPlugin.
|
|
@@ -1091,11 +1076,12 @@ class ZonesMouseControl extends Component {
|
|
|
1091
1076
|
* @param [cfg] Configuration
|
|
1092
1077
|
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
|
|
1093
1078
|
*/
|
|
1094
|
-
constructor(zonesPlugin, cfg
|
|
1079
|
+
constructor(zonesPlugin, cfg, createSelect3dPoint) {
|
|
1095
1080
|
super(zonesPlugin.viewer.scene);
|
|
1096
1081
|
|
|
1097
1082
|
this.zonesPlugin = zonesPlugin;
|
|
1098
1083
|
this.pointerLens = cfg.pointerLens;
|
|
1084
|
+
this.createSelect3dPoint = createSelect3dPoint;
|
|
1099
1085
|
this._deactivate = null;
|
|
1100
1086
|
}
|
|
1101
1087
|
|
|
@@ -1132,16 +1118,35 @@ class ZonesMouseControl extends Component {
|
|
|
1132
1118
|
const scene = viewer.scene;
|
|
1133
1119
|
const self = this;
|
|
1134
1120
|
|
|
1135
|
-
const select3dPoint =
|
|
1136
|
-
viewer,
|
|
1137
|
-
function(origin, direction) {
|
|
1138
|
-
return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
|
|
1139
|
-
});
|
|
1121
|
+
const select3dPoint = this.createSelect3dPoint(viewer, (origin, direction) => planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction));
|
|
1140
1122
|
|
|
1141
1123
|
(function rec() {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1124
|
+
const basePolygon = basePolygon3D(scene, zoneColor, zoneAlpha);
|
|
1125
|
+
const deactivate = startAARectCreateUI(
|
|
1126
|
+
scene, zoneColor, self.pointerLens, select3dPoint,
|
|
1127
|
+
points => {
|
|
1128
|
+
if (points) {
|
|
1129
|
+
const p0 = points[0];
|
|
1130
|
+
const p1 = points[1];
|
|
1131
|
+
const min = (idx) => Math.min(p0[idx], p1[idx]);
|
|
1132
|
+
const max = (idx) => Math.max(p0[idx], p1[idx]);
|
|
1133
|
+
|
|
1134
|
+
const xmin = min(0);
|
|
1135
|
+
const ymin = min(1);
|
|
1136
|
+
const zmin = min(2);
|
|
1137
|
+
const xmax = max(0);
|
|
1138
|
+
const ymax = max(1);
|
|
1139
|
+
const zmax = max(2);
|
|
1140
|
+
|
|
1141
|
+
basePolygon.updateBase([ [ xmin, ymin, zmax ], [ xmax, ymin, zmax ],
|
|
1142
|
+
[ xmax, ymin, zmin ], [ xmin, ymin, zmin ] ]);
|
|
1143
|
+
} else {
|
|
1144
|
+
basePolygon.updateBase(null);
|
|
1145
|
+
}
|
|
1146
|
+
},
|
|
1147
|
+
points => {
|
|
1148
|
+
basePolygon.destroy();
|
|
1149
|
+
const zone = createAAZoneFromPoints(points[0], points[1], zoneAltitude, zoneHeight, zoneColor, zoneAlpha, zonesPlugin);
|
|
1145
1150
|
let reactivate = true;
|
|
1146
1151
|
self._deactivate = () => { reactivate = false; };
|
|
1147
1152
|
self.fire("zoneEnd", zone);
|
|
@@ -1150,6 +1155,10 @@ class ZonesMouseControl extends Component {
|
|
|
1150
1155
|
rec();
|
|
1151
1156
|
}
|
|
1152
1157
|
}).deactivate;
|
|
1158
|
+
self._deactivate = () => {
|
|
1159
|
+
deactivate();
|
|
1160
|
+
basePolygon.destroy();
|
|
1161
|
+
};
|
|
1153
1162
|
})();
|
|
1154
1163
|
}
|
|
1155
1164
|
|
|
@@ -1172,10 +1181,36 @@ class ZonesMouseControl extends Component {
|
|
|
1172
1181
|
}
|
|
1173
1182
|
}
|
|
1174
1183
|
|
|
1184
|
+
export class ZonesMouseControl extends ZonesAAZoneControl {
|
|
1185
|
+
constructor(zonesPlugin, cfg = {}) {
|
|
1186
|
+
super(
|
|
1187
|
+
zonesPlugin,
|
|
1188
|
+
cfg,
|
|
1189
|
+
(viewer, ray2WorldPos) => mousePointSelector(viewer, ray2WorldPos));
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
import {PointerCircle} from "../../extras/PointerCircle/PointerCircle.js";
|
|
1194
|
+
export class ZonesTouchControl extends ZonesAAZoneControl {
|
|
1195
|
+
constructor(zonesPlugin, cfg = {}) {
|
|
1196
|
+
const pointerCircle = new PointerCircle(zonesPlugin.viewer);
|
|
1197
|
+
super(
|
|
1198
|
+
zonesPlugin,
|
|
1199
|
+
cfg,
|
|
1200
|
+
(viewer, ray2WorldPos) => touchPointSelector(viewer, pointerCircle, ray2WorldPos));
|
|
1201
|
+
this.pointerCircle = pointerCircle;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
destroy() {
|
|
1205
|
+
this.pointerCircle.destroy();
|
|
1206
|
+
super.destroy();
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1175
1210
|
/**
|
|
1176
1211
|
* ZonesPlugin documentation to be added, mostly compatible with DistanceMeasurementsPlugin.
|
|
1177
1212
|
*/
|
|
1178
|
-
class ZonesPlugin extends Plugin {
|
|
1213
|
+
export class ZonesPlugin extends Plugin {
|
|
1179
1214
|
|
|
1180
1215
|
/**
|
|
1181
1216
|
* @constructor
|
|
@@ -1286,88 +1321,6 @@ class ZonesPlugin extends Plugin {
|
|
|
1286
1321
|
}
|
|
1287
1322
|
}
|
|
1288
1323
|
|
|
1289
|
-
import {PointerCircle} from "../../extras/PointerCircle/PointerCircle.js";
|
|
1290
|
-
|
|
1291
|
-
export class ZonesTouchControl extends Component {
|
|
1292
|
-
|
|
1293
|
-
constructor(zonesPlugin, cfg = {}) {
|
|
1294
|
-
super(zonesPlugin.viewer.scene);
|
|
1295
|
-
|
|
1296
|
-
this.zonesPlugin = zonesPlugin;
|
|
1297
|
-
this.pointerLens = cfg.pointerLens;
|
|
1298
|
-
this.pointerCircle = new PointerCircle(zonesPlugin.viewer);
|
|
1299
|
-
this._deactivate = null;
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
get active() {
|
|
1303
|
-
return !! this._deactivate;
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
activate(zoneAltitude, zoneHeight, zoneColor, zoneAlpha) {
|
|
1307
|
-
|
|
1308
|
-
if (typeof(zoneAltitude) === "object" && (zoneAltitude !== null)) {
|
|
1309
|
-
const params = zoneAltitude;
|
|
1310
|
-
const param = (name, defaultValue) => {
|
|
1311
|
-
if (name in params) {
|
|
1312
|
-
return params[name];
|
|
1313
|
-
} else if (defaultValue !== undefined) {
|
|
1314
|
-
return defaultValue;
|
|
1315
|
-
} else {
|
|
1316
|
-
throw "config missing: " + name;
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
|
|
1320
|
-
zoneAltitude = param("altitude");
|
|
1321
|
-
zoneHeight = param("height");
|
|
1322
|
-
zoneColor = param("color", "#008000");
|
|
1323
|
-
zoneAlpha = param("alpha", 0.5);
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
if (this._deactivate) {
|
|
1327
|
-
return;
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
const zonesPlugin = this.zonesPlugin;
|
|
1331
|
-
const viewer = zonesPlugin.viewer;
|
|
1332
|
-
const scene = viewer.scene;
|
|
1333
|
-
const self = this;
|
|
1334
|
-
|
|
1335
|
-
const select3dPoint = touchPointSelector(
|
|
1336
|
-
viewer,
|
|
1337
|
-
this.pointerCircle,
|
|
1338
|
-
function(origin, direction) {
|
|
1339
|
-
return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
|
|
1340
|
-
});
|
|
1341
|
-
|
|
1342
|
-
(function rec() {
|
|
1343
|
-
self._deactivate = startAAZoneCreateUI(
|
|
1344
|
-
scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, self.pointerLens, zonesPlugin, select3dPoint,
|
|
1345
|
-
zone => {
|
|
1346
|
-
let reactivate = true;
|
|
1347
|
-
self._deactivate = () => { reactivate = false; };
|
|
1348
|
-
self.fire("zoneEnd", zone);
|
|
1349
|
-
if (reactivate)
|
|
1350
|
-
{
|
|
1351
|
-
rec();
|
|
1352
|
-
}
|
|
1353
|
-
}).deactivate;
|
|
1354
|
-
})();
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
deactivate() {
|
|
1358
|
-
if (this._deactivate)
|
|
1359
|
-
{
|
|
1360
|
-
this._deactivate();
|
|
1361
|
-
this._deactivate = null;
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
destroy() {
|
|
1366
|
-
this.deactivate();
|
|
1367
|
-
super.destroy();
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
1324
|
const startPolysurfaceZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, pointerLens, zonesPlugin, select3dPoint, onZoneCreated) {
|
|
1372
1325
|
const updatePointerLens = (pointerLens
|
|
1373
1326
|
? function(canvasPos) {
|
|
@@ -1933,7 +1886,3 @@ export class ZoneTranslateTouchControl extends ZoneTranslateControl {
|
|
|
1933
1886
|
super(zone, cfg, false, true);
|
|
1934
1887
|
}
|
|
1935
1888
|
}
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
export {ZonesMouseControl}
|
|
1939
|
-
export {ZonesPlugin}
|
|
@@ -15,7 +15,7 @@ class Dot {
|
|
|
15
15
|
this._dotClickable = document.createElement('div');
|
|
16
16
|
this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
|
|
17
17
|
|
|
18
|
-
this._visible =
|
|
18
|
+
this._visible = cfg.visible !== false;
|
|
19
19
|
this._culled = false;
|
|
20
20
|
|
|
21
21
|
var dot = this._dot;
|
|
@@ -27,7 +27,7 @@ class Dot {
|
|
|
27
27
|
dotStyle["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
|
|
28
28
|
dotStyle.width = 8 + "px";
|
|
29
29
|
dotStyle.height = 8 + "px";
|
|
30
|
-
dotStyle.visibility =
|
|
30
|
+
dotStyle.visibility = this._visible ? "visible" : "hidden";
|
|
31
31
|
dotStyle.top = 0 + "px";
|
|
32
32
|
dotStyle.left = 0 + "px";
|
|
33
33
|
dotStyle["box-shadow"] = "0 2px 5px 0 #182A3D;";
|