@xeokit/xeokit-sdk 2.6.31 → 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 +226 -295
- package/dist/xeokit-sdk.es.js +226 -295
- package/dist/xeokit-sdk.es5.js +408 -405
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +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 +126 -151
package/package.json
CHANGED
|
@@ -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;";
|