@xeokit/xeokit-sdk 2.6.30 → 2.6.31
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/xeokit-sdk.cjs.js +127 -41
- package/dist/xeokit-sdk.es.js +127 -41
- package/dist/xeokit-sdk.es5.js +15 -14
- 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 +2 -2
- 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/viewer/scene/webgl/Renderer.js +6 -3
- 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/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -20504,6 +20504,8 @@ const Renderer$1 = function (scene, options) {
|
|
|
20504
20504
|
// result 1) regular hi-precision world position
|
|
20505
20505
|
|
|
20506
20506
|
let worldPos = null;
|
|
20507
|
+
let worldNormal = null;
|
|
20508
|
+
let pickable = null;
|
|
20507
20509
|
|
|
20508
20510
|
const middleX = snapRadiusInPixels;
|
|
20509
20511
|
const middleY = snapRadiusInPixels;
|
|
@@ -20521,7 +20523,7 @@ const Renderer$1 = function (scene, options) {
|
|
|
20521
20523
|
pickResultMiddleXY[1] * scale[1] + origin[1],
|
|
20522
20524
|
pickResultMiddleXY[2] * scale[2] + origin[2],
|
|
20523
20525
|
];
|
|
20524
|
-
math.normalizeVec3([
|
|
20526
|
+
worldNormal = math.normalizeVec3([
|
|
20525
20527
|
pickNormalResultMiddleXY[0] / math.MAX_INT,
|
|
20526
20528
|
pickNormalResultMiddleXY[1] / math.MAX_INT,
|
|
20527
20529
|
pickNormalResultMiddleXY[2] / math.MAX_INT,
|
|
@@ -20533,7 +20535,7 @@ const Renderer$1 = function (scene, options) {
|
|
|
20533
20535
|
+ (pickPickableResultMiddleXY[2] << 16)
|
|
20534
20536
|
+ (pickPickableResultMiddleXY[3] << 24);
|
|
20535
20537
|
|
|
20536
|
-
pickIDs.items[pickID];
|
|
20538
|
+
pickable = pickIDs.items[pickID];
|
|
20537
20539
|
}
|
|
20538
20540
|
|
|
20539
20541
|
// result 2) hi-precision snapped (to vertex/edge) world position
|
|
@@ -20630,13 +20632,16 @@ const Renderer$1 = function (scene, options) {
|
|
|
20630
20632
|
}
|
|
20631
20633
|
|
|
20632
20634
|
const snappedEntity = (snappedPickable && snappedPickable.delegatePickedEntity) ? snappedPickable.delegatePickedEntity() : snappedPickable;
|
|
20635
|
+
if (!snappedEntity && pickable) {
|
|
20636
|
+
pickable = pickable.delegatePickedEntity ? pickable.delegatePickedEntity() : pickable;
|
|
20637
|
+
}
|
|
20633
20638
|
|
|
20634
20639
|
pickResult.reset();
|
|
20635
20640
|
pickResult.snappedToEdge = (snapType === "edge");
|
|
20636
20641
|
pickResult.snappedToVertex = (snapType === "vertex");
|
|
20637
|
-
pickResult.worldPos = snappedWorldPos;
|
|
20638
|
-
pickResult.worldNormal = snappedWorldNormal;
|
|
20639
|
-
pickResult.entity = snappedEntity;
|
|
20642
|
+
pickResult.worldPos = snappedWorldPos || worldPos;
|
|
20643
|
+
pickResult.worldNormal = snappedWorldNormal || worldNormal;
|
|
20644
|
+
pickResult.entity = snappedEntity || pickable;
|
|
20640
20645
|
pickResult.canvasPos = canvasPos || scene.camera.projectWorldPos(worldPos || snappedWorldPos);
|
|
20641
20646
|
pickResult.snappedCanvasPos = snappedCanvasPos || canvasPos;
|
|
20642
20647
|
|
|
@@ -118170,7 +118175,7 @@ const parseNodesWithNames = (function () {
|
|
|
118170
118175
|
|
|
118171
118176
|
const objectIdStack = [];
|
|
118172
118177
|
const meshIdsStack = [];
|
|
118173
|
-
let meshIds =
|
|
118178
|
+
let meshIds = [];
|
|
118174
118179
|
|
|
118175
118180
|
return function (ctx, node, depth, matrix) {
|
|
118176
118181
|
matrix = parseNodeMatrix(node, matrix);
|
|
@@ -118346,7 +118351,11 @@ function parseNodeMesh(node, ctx, matrix, meshIds) {
|
|
|
118346
118351
|
if (primitive.indices) {
|
|
118347
118352
|
meshCfg.indices = primitive.indices.value;
|
|
118348
118353
|
}
|
|
118349
|
-
|
|
118354
|
+
if (matrix) {
|
|
118355
|
+
math.transformPositions3(matrix, meshCfg.localPositions, meshCfg.positions);
|
|
118356
|
+
} else { // eqiv to math.transformPositions3(math.identityMat4(), meshCfg.localPositions, meshCfg.positions);
|
|
118357
|
+
meshCfg.positions.set(meshCfg.localPositions);
|
|
118358
|
+
}
|
|
118350
118359
|
const origin = math.vec3();
|
|
118351
118360
|
const rtcNeeded = worldToRTCPositions(meshCfg.positions, meshCfg.positions, origin); // Small cellsize guarantees better accuracy
|
|
118352
118361
|
if (rtcNeeded) {
|
|
@@ -127071,7 +127080,7 @@ class TreeViewPlugin extends Plugin {
|
|
|
127071
127080
|
this._nodeNodes[buildingNode.nodeId] = buildingNode;
|
|
127072
127081
|
} else if (metaObjectType === "IfcBuildingStorey") {
|
|
127073
127082
|
if (!buildingNode) {
|
|
127074
|
-
this.error("Failed to build storeys hierarchy for model
|
|
127083
|
+
this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");
|
|
127075
127084
|
return;
|
|
127076
127085
|
}
|
|
127077
127086
|
storeyNode = {
|
|
@@ -139258,49 +139267,126 @@ class DotBIMLoaderPlugin extends Plugin {
|
|
|
139258
139267
|
|
|
139259
139268
|
const dbMeshId = element.mesh_id;
|
|
139260
139269
|
|
|
139261
|
-
parseDBMesh(dbMeshId);
|
|
139262
|
-
|
|
139263
|
-
const meshId = `${objectId}-mesh`;
|
|
139264
139270
|
const vector = element.vector;
|
|
139265
139271
|
const rotation = element.rotation;
|
|
139266
139272
|
const props = objectDefaults ? objectDefaults[elementType] || objectDefaults["DEFAULT"] : null;
|
|
139267
|
-
|
|
139268
139273
|
let visible = true;
|
|
139269
139274
|
let pickable = true;
|
|
139270
|
-
let color = element.color ? [element.color.r / 255, element.color.g / 255, element.color.b / 255] : [1, 1, 1];
|
|
139271
|
-
let opacity = element.color ? element.color.a / 255 : 1.0;
|
|
139272
139275
|
|
|
139273
|
-
if (
|
|
139274
|
-
|
|
139275
|
-
|
|
139276
|
-
|
|
139277
|
-
|
|
139278
|
-
|
|
139279
|
-
|
|
139280
|
-
|
|
139281
|
-
|
|
139282
|
-
|
|
139283
|
-
|
|
139284
|
-
|
|
139276
|
+
if (element.face_colors === undefined) {
|
|
139277
|
+
|
|
139278
|
+
parseDBMesh(dbMeshId);
|
|
139279
|
+
|
|
139280
|
+
const meshId = `${objectId}-mesh`;
|
|
139281
|
+
|
|
139282
|
+
let color = element.color ? [element.color.r / 255.0, element.color.g / 255.0, element.color.b / 255.0] : [1, 1, 1];
|
|
139283
|
+
let opacity = element.color ? element.color.a / 255.0 : 1.0;
|
|
139284
|
+
|
|
139285
|
+
if (props) {
|
|
139286
|
+
if (props.visible === false) {
|
|
139287
|
+
visible = false;
|
|
139288
|
+
}
|
|
139289
|
+
if (props.pickable === false) {
|
|
139290
|
+
pickable = false;
|
|
139291
|
+
}
|
|
139292
|
+
if (props.colorize) {
|
|
139293
|
+
color = props.colorize;
|
|
139294
|
+
}
|
|
139295
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
139296
|
+
opacity = props.opacity;
|
|
139297
|
+
}
|
|
139285
139298
|
}
|
|
139299
|
+
|
|
139300
|
+
sceneModel.createMesh({
|
|
139301
|
+
id: meshId,
|
|
139302
|
+
geometryId: dbMeshId,
|
|
139303
|
+
color: color,
|
|
139304
|
+
opacity: opacity,
|
|
139305
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
139306
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
139307
|
+
});
|
|
139308
|
+
|
|
139309
|
+
sceneModel.createEntity({
|
|
139310
|
+
id: objectId,
|
|
139311
|
+
meshIds: [meshId],
|
|
139312
|
+
visible: visible,
|
|
139313
|
+
pickable: pickable,
|
|
139314
|
+
isObject: true
|
|
139315
|
+
});
|
|
139286
139316
|
}
|
|
139317
|
+
else {
|
|
139318
|
+
let faceColors = element.face_colors;
|
|
139319
|
+
let coloredTrianglesDictionary = {};
|
|
139320
|
+
let currentTriangleIndicesCount = 0;
|
|
139321
|
+
let dbMesh = fileData.meshes[element.mesh_id];
|
|
139322
|
+
for (let i = 0, len = faceColors.length; i < len; i+=4) {
|
|
139323
|
+
let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
|
|
139324
|
+
if (coloredTrianglesDictionary[faceColor] === undefined) {
|
|
139325
|
+
coloredTrianglesDictionary[faceColor] = [];
|
|
139326
|
+
}
|
|
139327
|
+
let indexForPoint0 = dbMesh.indices[currentTriangleIndicesCount];
|
|
139328
|
+
let x0 = dbMesh.coordinates[indexForPoint0*3];
|
|
139329
|
+
let y0 = dbMesh.coordinates[indexForPoint0*3+1];
|
|
139330
|
+
let z0 = dbMesh.coordinates[indexForPoint0*3+2];
|
|
139331
|
+
let indexForPoint1 = dbMesh.indices[currentTriangleIndicesCount+1];
|
|
139332
|
+
let x1 = dbMesh.coordinates[indexForPoint1*3];
|
|
139333
|
+
let y1 = dbMesh.coordinates[indexForPoint1*3+1];
|
|
139334
|
+
let z1 = dbMesh.coordinates[indexForPoint1*3+2];
|
|
139335
|
+
let indexForPoint2 = dbMesh.indices[currentTriangleIndicesCount+2];
|
|
139336
|
+
let x2 = dbMesh.coordinates[indexForPoint2*3];
|
|
139337
|
+
let y2 = dbMesh.coordinates[indexForPoint2*3+1];
|
|
139338
|
+
let z2 = dbMesh.coordinates[indexForPoint2*3+2];
|
|
139339
|
+
coloredTrianglesDictionary[faceColor].push(x0, y0, z0, x1, y1, z1, x2, y2, z2);
|
|
139340
|
+
|
|
139341
|
+
currentTriangleIndicesCount += 3;
|
|
139342
|
+
}
|
|
139343
|
+
let meshIds = [];
|
|
139344
|
+
for (const [faceColor, trianglesCoordinates] of Object.entries(coloredTrianglesDictionary)) {
|
|
139345
|
+
sceneModel.createGeometry({
|
|
139346
|
+
id: `${dbMeshId}-${faceColor}`,
|
|
139347
|
+
primitive: "triangles",
|
|
139348
|
+
positions: trianglesCoordinates,
|
|
139349
|
+
indices: [...Array(trianglesCoordinates.length).keys()]
|
|
139350
|
+
});
|
|
139351
|
+
const meshId = `${objectId}-mesh-${faceColor}`;
|
|
139352
|
+
const faceColorArray = faceColor.split(',').map(Number);
|
|
139287
139353
|
|
|
139288
|
-
|
|
139289
|
-
|
|
139290
|
-
geometryId: dbMeshId,
|
|
139291
|
-
color,
|
|
139292
|
-
opacity,
|
|
139293
|
-
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
139294
|
-
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
139295
|
-
});
|
|
139354
|
+
let color = [faceColorArray[0] / 255.0, faceColorArray[1] / 255.0, faceColorArray[2] / 255.0];
|
|
139355
|
+
let opacity = faceColorArray[3] / 255.0;
|
|
139296
139356
|
|
|
139297
|
-
|
|
139298
|
-
|
|
139299
|
-
|
|
139300
|
-
|
|
139301
|
-
|
|
139302
|
-
|
|
139303
|
-
|
|
139357
|
+
if (props) {
|
|
139358
|
+
if (props.visible === false) {
|
|
139359
|
+
visible = false;
|
|
139360
|
+
}
|
|
139361
|
+
if (props.pickable === false) {
|
|
139362
|
+
pickable = false;
|
|
139363
|
+
}
|
|
139364
|
+
if (props.colorize) {
|
|
139365
|
+
color = props.colorize;
|
|
139366
|
+
}
|
|
139367
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
139368
|
+
opacity = props.opacity;
|
|
139369
|
+
}
|
|
139370
|
+
}
|
|
139371
|
+
|
|
139372
|
+
sceneModel.createMesh({
|
|
139373
|
+
id: meshId,
|
|
139374
|
+
geometryId: `${dbMeshId}-${faceColor}`,
|
|
139375
|
+
color: color,
|
|
139376
|
+
opacity: opacity,
|
|
139377
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
139378
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
139379
|
+
});
|
|
139380
|
+
meshIds.push(meshId);
|
|
139381
|
+
}
|
|
139382
|
+
sceneModel.createEntity({
|
|
139383
|
+
id: objectId,
|
|
139384
|
+
meshIds: meshIds,
|
|
139385
|
+
visible: visible,
|
|
139386
|
+
pickable: pickable,
|
|
139387
|
+
isObject: true
|
|
139388
|
+
});
|
|
139389
|
+
}
|
|
139304
139390
|
|
|
139305
139391
|
for (let infoKey in info) {
|
|
139306
139392
|
let properties;
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -20500,6 +20500,8 @@ const Renderer$1 = function (scene, options) {
|
|
|
20500
20500
|
// result 1) regular hi-precision world position
|
|
20501
20501
|
|
|
20502
20502
|
let worldPos = null;
|
|
20503
|
+
let worldNormal = null;
|
|
20504
|
+
let pickable = null;
|
|
20503
20505
|
|
|
20504
20506
|
const middleX = snapRadiusInPixels;
|
|
20505
20507
|
const middleY = snapRadiusInPixels;
|
|
@@ -20517,7 +20519,7 @@ const Renderer$1 = function (scene, options) {
|
|
|
20517
20519
|
pickResultMiddleXY[1] * scale[1] + origin[1],
|
|
20518
20520
|
pickResultMiddleXY[2] * scale[2] + origin[2],
|
|
20519
20521
|
];
|
|
20520
|
-
math.normalizeVec3([
|
|
20522
|
+
worldNormal = math.normalizeVec3([
|
|
20521
20523
|
pickNormalResultMiddleXY[0] / math.MAX_INT,
|
|
20522
20524
|
pickNormalResultMiddleXY[1] / math.MAX_INT,
|
|
20523
20525
|
pickNormalResultMiddleXY[2] / math.MAX_INT,
|
|
@@ -20529,7 +20531,7 @@ const Renderer$1 = function (scene, options) {
|
|
|
20529
20531
|
+ (pickPickableResultMiddleXY[2] << 16)
|
|
20530
20532
|
+ (pickPickableResultMiddleXY[3] << 24);
|
|
20531
20533
|
|
|
20532
|
-
pickIDs.items[pickID];
|
|
20534
|
+
pickable = pickIDs.items[pickID];
|
|
20533
20535
|
}
|
|
20534
20536
|
|
|
20535
20537
|
// result 2) hi-precision snapped (to vertex/edge) world position
|
|
@@ -20626,13 +20628,16 @@ const Renderer$1 = function (scene, options) {
|
|
|
20626
20628
|
}
|
|
20627
20629
|
|
|
20628
20630
|
const snappedEntity = (snappedPickable && snappedPickable.delegatePickedEntity) ? snappedPickable.delegatePickedEntity() : snappedPickable;
|
|
20631
|
+
if (!snappedEntity && pickable) {
|
|
20632
|
+
pickable = pickable.delegatePickedEntity ? pickable.delegatePickedEntity() : pickable;
|
|
20633
|
+
}
|
|
20629
20634
|
|
|
20630
20635
|
pickResult.reset();
|
|
20631
20636
|
pickResult.snappedToEdge = (snapType === "edge");
|
|
20632
20637
|
pickResult.snappedToVertex = (snapType === "vertex");
|
|
20633
|
-
pickResult.worldPos = snappedWorldPos;
|
|
20634
|
-
pickResult.worldNormal = snappedWorldNormal;
|
|
20635
|
-
pickResult.entity = snappedEntity;
|
|
20638
|
+
pickResult.worldPos = snappedWorldPos || worldPos;
|
|
20639
|
+
pickResult.worldNormal = snappedWorldNormal || worldNormal;
|
|
20640
|
+
pickResult.entity = snappedEntity || pickable;
|
|
20636
20641
|
pickResult.canvasPos = canvasPos || scene.camera.projectWorldPos(worldPos || snappedWorldPos);
|
|
20637
20642
|
pickResult.snappedCanvasPos = snappedCanvasPos || canvasPos;
|
|
20638
20643
|
|
|
@@ -118166,7 +118171,7 @@ const parseNodesWithNames = (function () {
|
|
|
118166
118171
|
|
|
118167
118172
|
const objectIdStack = [];
|
|
118168
118173
|
const meshIdsStack = [];
|
|
118169
|
-
let meshIds =
|
|
118174
|
+
let meshIds = [];
|
|
118170
118175
|
|
|
118171
118176
|
return function (ctx, node, depth, matrix) {
|
|
118172
118177
|
matrix = parseNodeMatrix(node, matrix);
|
|
@@ -118342,7 +118347,11 @@ function parseNodeMesh(node, ctx, matrix, meshIds) {
|
|
|
118342
118347
|
if (primitive.indices) {
|
|
118343
118348
|
meshCfg.indices = primitive.indices.value;
|
|
118344
118349
|
}
|
|
118345
|
-
|
|
118350
|
+
if (matrix) {
|
|
118351
|
+
math.transformPositions3(matrix, meshCfg.localPositions, meshCfg.positions);
|
|
118352
|
+
} else { // eqiv to math.transformPositions3(math.identityMat4(), meshCfg.localPositions, meshCfg.positions);
|
|
118353
|
+
meshCfg.positions.set(meshCfg.localPositions);
|
|
118354
|
+
}
|
|
118346
118355
|
const origin = math.vec3();
|
|
118347
118356
|
const rtcNeeded = worldToRTCPositions(meshCfg.positions, meshCfg.positions, origin); // Small cellsize guarantees better accuracy
|
|
118348
118357
|
if (rtcNeeded) {
|
|
@@ -127067,7 +127076,7 @@ class TreeViewPlugin extends Plugin {
|
|
|
127067
127076
|
this._nodeNodes[buildingNode.nodeId] = buildingNode;
|
|
127068
127077
|
} else if (metaObjectType === "IfcBuildingStorey") {
|
|
127069
127078
|
if (!buildingNode) {
|
|
127070
|
-
this.error("Failed to build storeys hierarchy for model
|
|
127079
|
+
this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");
|
|
127071
127080
|
return;
|
|
127072
127081
|
}
|
|
127073
127082
|
storeyNode = {
|
|
@@ -139254,49 +139263,126 @@ class DotBIMLoaderPlugin extends Plugin {
|
|
|
139254
139263
|
|
|
139255
139264
|
const dbMeshId = element.mesh_id;
|
|
139256
139265
|
|
|
139257
|
-
parseDBMesh(dbMeshId);
|
|
139258
|
-
|
|
139259
|
-
const meshId = `${objectId}-mesh`;
|
|
139260
139266
|
const vector = element.vector;
|
|
139261
139267
|
const rotation = element.rotation;
|
|
139262
139268
|
const props = objectDefaults ? objectDefaults[elementType] || objectDefaults["DEFAULT"] : null;
|
|
139263
|
-
|
|
139264
139269
|
let visible = true;
|
|
139265
139270
|
let pickable = true;
|
|
139266
|
-
let color = element.color ? [element.color.r / 255, element.color.g / 255, element.color.b / 255] : [1, 1, 1];
|
|
139267
|
-
let opacity = element.color ? element.color.a / 255 : 1.0;
|
|
139268
139271
|
|
|
139269
|
-
if (
|
|
139270
|
-
|
|
139271
|
-
|
|
139272
|
-
|
|
139273
|
-
|
|
139274
|
-
|
|
139275
|
-
|
|
139276
|
-
|
|
139277
|
-
|
|
139278
|
-
|
|
139279
|
-
|
|
139280
|
-
|
|
139272
|
+
if (element.face_colors === undefined) {
|
|
139273
|
+
|
|
139274
|
+
parseDBMesh(dbMeshId);
|
|
139275
|
+
|
|
139276
|
+
const meshId = `${objectId}-mesh`;
|
|
139277
|
+
|
|
139278
|
+
let color = element.color ? [element.color.r / 255.0, element.color.g / 255.0, element.color.b / 255.0] : [1, 1, 1];
|
|
139279
|
+
let opacity = element.color ? element.color.a / 255.0 : 1.0;
|
|
139280
|
+
|
|
139281
|
+
if (props) {
|
|
139282
|
+
if (props.visible === false) {
|
|
139283
|
+
visible = false;
|
|
139284
|
+
}
|
|
139285
|
+
if (props.pickable === false) {
|
|
139286
|
+
pickable = false;
|
|
139287
|
+
}
|
|
139288
|
+
if (props.colorize) {
|
|
139289
|
+
color = props.colorize;
|
|
139290
|
+
}
|
|
139291
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
139292
|
+
opacity = props.opacity;
|
|
139293
|
+
}
|
|
139281
139294
|
}
|
|
139295
|
+
|
|
139296
|
+
sceneModel.createMesh({
|
|
139297
|
+
id: meshId,
|
|
139298
|
+
geometryId: dbMeshId,
|
|
139299
|
+
color: color,
|
|
139300
|
+
opacity: opacity,
|
|
139301
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
139302
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
139303
|
+
});
|
|
139304
|
+
|
|
139305
|
+
sceneModel.createEntity({
|
|
139306
|
+
id: objectId,
|
|
139307
|
+
meshIds: [meshId],
|
|
139308
|
+
visible: visible,
|
|
139309
|
+
pickable: pickable,
|
|
139310
|
+
isObject: true
|
|
139311
|
+
});
|
|
139282
139312
|
}
|
|
139313
|
+
else {
|
|
139314
|
+
let faceColors = element.face_colors;
|
|
139315
|
+
let coloredTrianglesDictionary = {};
|
|
139316
|
+
let currentTriangleIndicesCount = 0;
|
|
139317
|
+
let dbMesh = fileData.meshes[element.mesh_id];
|
|
139318
|
+
for (let i = 0, len = faceColors.length; i < len; i+=4) {
|
|
139319
|
+
let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
|
|
139320
|
+
if (coloredTrianglesDictionary[faceColor] === undefined) {
|
|
139321
|
+
coloredTrianglesDictionary[faceColor] = [];
|
|
139322
|
+
}
|
|
139323
|
+
let indexForPoint0 = dbMesh.indices[currentTriangleIndicesCount];
|
|
139324
|
+
let x0 = dbMesh.coordinates[indexForPoint0*3];
|
|
139325
|
+
let y0 = dbMesh.coordinates[indexForPoint0*3+1];
|
|
139326
|
+
let z0 = dbMesh.coordinates[indexForPoint0*3+2];
|
|
139327
|
+
let indexForPoint1 = dbMesh.indices[currentTriangleIndicesCount+1];
|
|
139328
|
+
let x1 = dbMesh.coordinates[indexForPoint1*3];
|
|
139329
|
+
let y1 = dbMesh.coordinates[indexForPoint1*3+1];
|
|
139330
|
+
let z1 = dbMesh.coordinates[indexForPoint1*3+2];
|
|
139331
|
+
let indexForPoint2 = dbMesh.indices[currentTriangleIndicesCount+2];
|
|
139332
|
+
let x2 = dbMesh.coordinates[indexForPoint2*3];
|
|
139333
|
+
let y2 = dbMesh.coordinates[indexForPoint2*3+1];
|
|
139334
|
+
let z2 = dbMesh.coordinates[indexForPoint2*3+2];
|
|
139335
|
+
coloredTrianglesDictionary[faceColor].push(x0, y0, z0, x1, y1, z1, x2, y2, z2);
|
|
139336
|
+
|
|
139337
|
+
currentTriangleIndicesCount += 3;
|
|
139338
|
+
}
|
|
139339
|
+
let meshIds = [];
|
|
139340
|
+
for (const [faceColor, trianglesCoordinates] of Object.entries(coloredTrianglesDictionary)) {
|
|
139341
|
+
sceneModel.createGeometry({
|
|
139342
|
+
id: `${dbMeshId}-${faceColor}`,
|
|
139343
|
+
primitive: "triangles",
|
|
139344
|
+
positions: trianglesCoordinates,
|
|
139345
|
+
indices: [...Array(trianglesCoordinates.length).keys()]
|
|
139346
|
+
});
|
|
139347
|
+
const meshId = `${objectId}-mesh-${faceColor}`;
|
|
139348
|
+
const faceColorArray = faceColor.split(',').map(Number);
|
|
139283
139349
|
|
|
139284
|
-
|
|
139285
|
-
|
|
139286
|
-
geometryId: dbMeshId,
|
|
139287
|
-
color,
|
|
139288
|
-
opacity,
|
|
139289
|
-
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
139290
|
-
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
139291
|
-
});
|
|
139350
|
+
let color = [faceColorArray[0] / 255.0, faceColorArray[1] / 255.0, faceColorArray[2] / 255.0];
|
|
139351
|
+
let opacity = faceColorArray[3] / 255.0;
|
|
139292
139352
|
|
|
139293
|
-
|
|
139294
|
-
|
|
139295
|
-
|
|
139296
|
-
|
|
139297
|
-
|
|
139298
|
-
|
|
139299
|
-
|
|
139353
|
+
if (props) {
|
|
139354
|
+
if (props.visible === false) {
|
|
139355
|
+
visible = false;
|
|
139356
|
+
}
|
|
139357
|
+
if (props.pickable === false) {
|
|
139358
|
+
pickable = false;
|
|
139359
|
+
}
|
|
139360
|
+
if (props.colorize) {
|
|
139361
|
+
color = props.colorize;
|
|
139362
|
+
}
|
|
139363
|
+
if (props.opacity !== undefined && props.opacity !== null) {
|
|
139364
|
+
opacity = props.opacity;
|
|
139365
|
+
}
|
|
139366
|
+
}
|
|
139367
|
+
|
|
139368
|
+
sceneModel.createMesh({
|
|
139369
|
+
id: meshId,
|
|
139370
|
+
geometryId: `${dbMeshId}-${faceColor}`,
|
|
139371
|
+
color: color,
|
|
139372
|
+
opacity: opacity,
|
|
139373
|
+
quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
|
|
139374
|
+
position: vector ? [vector.x, vector.y, vector.z] : undefined
|
|
139375
|
+
});
|
|
139376
|
+
meshIds.push(meshId);
|
|
139377
|
+
}
|
|
139378
|
+
sceneModel.createEntity({
|
|
139379
|
+
id: objectId,
|
|
139380
|
+
meshIds: meshIds,
|
|
139381
|
+
visible: visible,
|
|
139382
|
+
pickable: pickable,
|
|
139383
|
+
isObject: true
|
|
139384
|
+
});
|
|
139385
|
+
}
|
|
139300
139386
|
|
|
139301
139387
|
for (let infoKey in info) {
|
|
139302
139388
|
let properties;
|