fl-web-component 2.1.1-beta.2 → 2.1.1-beta.21
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/fl-web-component.common.js +11172 -951
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/package.json +1 -1
- package/packages/components/com-flcanvas/components/entityFormatting.js +52 -43
- package/packages/components/com-flcanvas/index.vue +360 -326
- package/packages/components/com-graphics/index.vue +946 -164
- package/packages/utils/StreamLoader.js +1 -1
- package/packages/utils/StreamLoaderParser.worker.js +20 -20
- package/src/utils/instance-parser.js +69 -64
|
@@ -402,26 +402,26 @@ function parsePrimitive(dataView, uint8Array, offset, isFullProps = true) {
|
|
|
402
402
|
primitive.documentId = '';
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
if (dataView.byteLength < offset + 4) {
|
|
406
|
-
throw new Error('Insufficient data for Material length');
|
|
407
|
-
}
|
|
408
|
-
const materialTextLen = dataView.getUint32(offset, false);
|
|
409
|
-
offset += 4;
|
|
410
|
-
if (materialTextLen === 0xffffffff) {
|
|
411
|
-
primitive.material = null;
|
|
412
|
-
} else if (materialTextLen > 0) {
|
|
413
|
-
if (dataView.byteLength < offset + materialTextLen) {
|
|
414
|
-
throw new Error('Insufficient data for Material content');
|
|
415
|
-
}
|
|
416
|
-
const textBytes = uint8Array.subarray(offset, offset + materialTextLen);
|
|
417
|
-
primitive.material = utf8Decoder.decode(textBytes);
|
|
418
|
-
offset += materialTextLen;
|
|
419
|
-
} else {
|
|
420
|
-
primitive.material = '';
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (dataView.byteLength < offset + 4) {
|
|
424
|
-
throw new Error('Insufficient data for GeomText length');
|
|
405
|
+
if (dataView.byteLength < offset + 4) {
|
|
406
|
+
throw new Error('Insufficient data for Material length');
|
|
407
|
+
}
|
|
408
|
+
const materialTextLen = dataView.getUint32(offset, false);
|
|
409
|
+
offset += 4;
|
|
410
|
+
if (materialTextLen === 0xffffffff) {
|
|
411
|
+
primitive.material = null;
|
|
412
|
+
} else if (materialTextLen > 0) {
|
|
413
|
+
if (dataView.byteLength < offset + materialTextLen) {
|
|
414
|
+
throw new Error('Insufficient data for Material content');
|
|
415
|
+
}
|
|
416
|
+
const textBytes = uint8Array.subarray(offset, offset + materialTextLen);
|
|
417
|
+
primitive.material = utf8Decoder.decode(textBytes);
|
|
418
|
+
offset += materialTextLen;
|
|
419
|
+
} else {
|
|
420
|
+
primitive.material = '';
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (dataView.byteLength < offset + 4) {
|
|
424
|
+
throw new Error('Insufficient data for GeomText length');
|
|
425
425
|
}
|
|
426
426
|
const geomTextLen = dataView.getUint32(offset, false);
|
|
427
427
|
offset += 4;
|
|
@@ -91,46 +91,46 @@ function requestInstancedMapping(instances, drawObjs) {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
function getInstanceNormalSign(matrix) {
|
|
95
|
-
if (!matrix || typeof matrix.determinant !== 'function') return 1;
|
|
96
|
-
return matrix.determinant() < 0 ? -1 : 1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function getMatrixVal(matrix) {
|
|
100
|
-
const val = matrix && matrix.val ? matrix.val : matrix;
|
|
101
|
-
return val && val.length >= 16 ? val : null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function composeInstanceMatrix(instance, mesh, geometry) {
|
|
105
|
-
const resultMatrix = new THREE.Matrix4();
|
|
106
|
-
const meshMatrix = new THREE.Matrix4();
|
|
107
|
-
const primitiveMatrix = new THREE.Matrix4();
|
|
108
|
-
const meshMatrixVal = getMatrixVal(instance && instance.matrix);
|
|
109
|
-
const primitiveMatrixVal = getMatrixVal(mesh && mesh.matrix);
|
|
110
|
-
|
|
111
|
-
if (meshMatrixVal) {
|
|
112
|
-
meshMatrix.fromArray(meshMatrixVal);
|
|
113
|
-
}
|
|
114
|
-
if (primitiveMatrixVal) {
|
|
115
|
-
primitiveMatrix.fromArray(primitiveMatrixVal);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const { points, alignType } = mesh || {};
|
|
119
|
-
if (mesh && isTextType(mesh.type) && points && points.length >= 3) {
|
|
120
|
-
const positionMatrix = new THREE.Matrix4();
|
|
121
|
-
const alignMatrix = createAlignedText(alignType, geometry);
|
|
122
|
-
positionMatrix.identity().makeTranslation(points[0], points[1], points[2]);
|
|
123
|
-
primitiveMatrix.multiply(alignMatrix).multiply(positionMatrix);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
resultMatrix.multiplyMatrices(meshMatrix, primitiveMatrix);
|
|
127
|
-
return resultMatrix;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 重置处理状态,用于新的批量加载会话
|
|
132
|
-
*/
|
|
133
|
-
function resetProcessingState() {
|
|
94
|
+
function getInstanceNormalSign(matrix) {
|
|
95
|
+
if (!matrix || typeof matrix.determinant !== 'function') return 1;
|
|
96
|
+
return matrix.determinant() < 0 ? -1 : 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getMatrixVal(matrix) {
|
|
100
|
+
const val = matrix && matrix.val ? matrix.val : matrix;
|
|
101
|
+
return val && val.length >= 16 ? val : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function composeInstanceMatrix(instance, mesh, geometry) {
|
|
105
|
+
const resultMatrix = new THREE.Matrix4();
|
|
106
|
+
const meshMatrix = new THREE.Matrix4();
|
|
107
|
+
const primitiveMatrix = new THREE.Matrix4();
|
|
108
|
+
const meshMatrixVal = getMatrixVal(instance && instance.matrix);
|
|
109
|
+
const primitiveMatrixVal = getMatrixVal(mesh && mesh.matrix);
|
|
110
|
+
|
|
111
|
+
if (meshMatrixVal) {
|
|
112
|
+
meshMatrix.fromArray(meshMatrixVal);
|
|
113
|
+
}
|
|
114
|
+
if (primitiveMatrixVal) {
|
|
115
|
+
primitiveMatrix.fromArray(primitiveMatrixVal);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const { points, alignType } = mesh || {};
|
|
119
|
+
if (mesh && isTextType(mesh.type) && points && points.length >= 3) {
|
|
120
|
+
const positionMatrix = new THREE.Matrix4();
|
|
121
|
+
const alignMatrix = createAlignedText(alignType, geometry);
|
|
122
|
+
positionMatrix.identity().makeTranslation(points[0], points[1], points[2]);
|
|
123
|
+
primitiveMatrix.multiply(alignMatrix).multiply(positionMatrix);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
resultMatrix.multiplyMatrices(meshMatrix, primitiveMatrix);
|
|
127
|
+
return resultMatrix;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 重置处理状态,用于新的批量加载会话
|
|
132
|
+
*/
|
|
133
|
+
function resetProcessingState() {
|
|
134
134
|
drawObjMapInstance = {};
|
|
135
135
|
// instanceToInstancedMeshMap.clear();
|
|
136
136
|
// processedDrawObjects.clear();
|
|
@@ -465,27 +465,27 @@ function setInstanceMatricesAndColors(model, drawObj, mesh, meshName, customColo
|
|
|
465
465
|
|
|
466
466
|
// const instancedMesh = instanceToInstancedMeshMap.get(item.instanceId);
|
|
467
467
|
|
|
468
|
-
const m4 = composeInstanceMatrix(item, mesh, model.geometry);
|
|
469
|
-
model.setMatrixAt(index, m4);
|
|
470
|
-
|
|
471
|
-
const normalSignAttr = model.geometry && model.geometry.getAttribute('instanceNormalSign');
|
|
472
|
-
if (normalSignAttr && normalSignAttr.array && index < normalSignAttr.array.length) {
|
|
473
|
-
normalSignAttr.array[index] = getInstanceNormalSign(m4);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
const copyMatrix = new THREE.Matrix4().copy(m4);
|
|
477
|
-
model.userData.copyMatrix = copyMatrix;
|
|
478
|
-
|
|
479
|
-
const temp = model.userData.instancesMap.get(item.instanceId);
|
|
480
|
-
temp.copyMatrix = copyMatrix;
|
|
481
|
-
if (sourceVisible === false) {
|
|
482
|
-
const offsetMatrix = new THREE.Matrix4()
|
|
483
|
-
.copy(copyMatrix)
|
|
484
|
-
.makeTranslation(9999999, 9999999, 9999999);
|
|
485
|
-
model.setMatrixAt(index, offsetMatrix);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// 设置颜色
|
|
468
|
+
const m4 = composeInstanceMatrix(item, mesh, model.geometry);
|
|
469
|
+
model.setMatrixAt(index, m4);
|
|
470
|
+
|
|
471
|
+
const normalSignAttr = model.geometry && model.geometry.getAttribute('instanceNormalSign');
|
|
472
|
+
if (normalSignAttr && normalSignAttr.array && index < normalSignAttr.array.length) {
|
|
473
|
+
normalSignAttr.array[index] = getInstanceNormalSign(m4);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const copyMatrix = new THREE.Matrix4().copy(m4);
|
|
477
|
+
model.userData.copyMatrix = copyMatrix;
|
|
478
|
+
|
|
479
|
+
const temp = model.userData.instancesMap.get(item.instanceId);
|
|
480
|
+
temp.copyMatrix = copyMatrix;
|
|
481
|
+
if (sourceVisible === false) {
|
|
482
|
+
const offsetMatrix = new THREE.Matrix4()
|
|
483
|
+
.copy(copyMatrix)
|
|
484
|
+
.makeTranslation(9999999, 9999999, 9999999);
|
|
485
|
+
model.setMatrixAt(index, offsetMatrix);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// 设置颜色
|
|
489
489
|
model.setColorAt(index, meshColor);
|
|
490
490
|
});
|
|
491
491
|
|
|
@@ -560,9 +560,9 @@ function appendInstanceToInstancedMesh(model, drawObj, mesh, instance, customCol
|
|
|
560
560
|
? new THREE.Color(customColor)
|
|
561
561
|
: new THREE.Color(`rgb(${colorArr[0]}, ${colorArr[1]}, ${colorArr[2]})`);
|
|
562
562
|
|
|
563
|
-
if (!mesh) return;
|
|
564
|
-
|
|
565
|
-
const m4 = composeInstanceMatrix(instance, mesh, model.geometry);
|
|
563
|
+
if (!mesh) return;
|
|
564
|
+
|
|
565
|
+
const m4 = composeInstanceMatrix(instance, mesh, model.geometry);
|
|
566
566
|
const renderMatrix =
|
|
567
567
|
sourceVisible === false
|
|
568
568
|
? new THREE.Matrix4().copy(m4).makeTranslation(9999999, 9999999, 9999999)
|
|
@@ -1085,9 +1085,14 @@ function draw2Dmodel(geom, instanceName, instanceCount, nColor, nOpacity, option
|
|
|
1085
1085
|
|
|
1086
1086
|
const { color, linewidth } = geom.prop;
|
|
1087
1087
|
const formatLinewidth = (linewidth < 1 ? linewidth * 50 : linewidth) || 5;
|
|
1088
|
+
const meshLineResolution = options.meshLineResolution || {};
|
|
1089
|
+
const resolutionWidth = meshLineResolution.width || window.innerWidth || 1;
|
|
1090
|
+
const resolutionHeight = meshLineResolution.height || window.innerHeight || 1;
|
|
1088
1091
|
const material = new MeshLineMaterial({
|
|
1089
1092
|
color: new THREE.Color(`rgb(${color[0]}, ${color[1]}, ${color[2]})`),
|
|
1090
1093
|
lineWidth: formatLinewidth,
|
|
1094
|
+
resolution: new THREE.Vector2(resolutionWidth, resolutionHeight),
|
|
1095
|
+
sizeAttenuation: 0,
|
|
1091
1096
|
});
|
|
1092
1097
|
|
|
1093
1098
|
const lineGeometry = new MeshLineGeometry();
|