fl-web-component 2.0.19 → 2.1.1-beta.1
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.1.js.map +1 -1
- package/dist/fl-web-component.common.2.js.map +1 -1
- package/dist/fl-web-component.common.js +5871 -1872
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/package.json +4 -3
- package/packages/components/com-flcanvas/components/entityFormatting.js +134 -1
- package/packages/components/com-flcanvas/index.vue +335 -239
- package/packages/components/com-graphics/index.vue +433 -35
- package/packages/components/com-graphics/mock.json +115 -0
- package/packages/utils/StreamLoader.js +250 -107
- package/packages/utils/StreamLoaderParser.worker.js +180 -72
- package/src/utils/dxf-parser/AutoCadColorIndex.js +265 -0
- package/src/utils/dxf-parser/DimStyleCodes.js +33 -0
- package/src/utils/dxf-parser/DxfArrayScanner.js +151 -0
- package/src/utils/dxf-parser/DxfParser.js +918 -0
- package/src/utils/dxf-parser/ExtendedDataParser.js +117 -0
- package/src/utils/dxf-parser/LICENSE +21 -0
- package/src/utils/dxf-parser/ParseHelpers.js +140 -0
- package/src/utils/dxf-parser/README.md +8 -0
- package/src/utils/dxf-parser/entities/3dface.js +83 -0
- package/src/utils/dxf-parser/entities/arc.js +38 -0
- package/src/utils/dxf-parser/entities/attdef.js +89 -0
- package/src/utils/dxf-parser/entities/attribute.js +109 -0
- package/src/utils/dxf-parser/entities/circle.js +43 -0
- package/src/utils/dxf-parser/entities/dimension.js +71 -0
- package/src/utils/dxf-parser/entities/ellipse.js +48 -0
- package/src/utils/dxf-parser/entities/hatch.js +348 -0
- package/src/utils/dxf-parser/entities/insert.js +57 -0
- package/src/utils/dxf-parser/entities/line.js +34 -0
- package/src/utils/dxf-parser/entities/lwpolyline.js +103 -0
- package/src/utils/dxf-parser/entities/mtext.js +57 -0
- package/src/utils/dxf-parser/entities/point.js +35 -0
- package/src/utils/dxf-parser/entities/polyline.js +92 -0
- package/src/utils/dxf-parser/entities/solid.js +40 -0
- package/src/utils/dxf-parser/entities/spline.js +70 -0
- package/src/utils/dxf-parser/entities/text.js +50 -0
- package/src/utils/dxf-parser/entities/vertex.js +62 -0
- package/src/utils/flgltf-parser.js +21 -9
- package/src/utils/instance-parser.js +59 -59
- package/src/utils/threejs/measure-clear-distance.js +149 -123
- package/packages/components/com-graphics/box.json +0 -77
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'MTEXT';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity = { type: curr.value };
|
|
10
|
+
curr = scanner.next();
|
|
11
|
+
while(curr !== 'EOF') {
|
|
12
|
+
if(curr.code === 0) break;
|
|
13
|
+
|
|
14
|
+
switch(curr.code) {
|
|
15
|
+
case 3:
|
|
16
|
+
case 1:
|
|
17
|
+
entity.text ? entity.text += curr.value : entity.text = curr.value;
|
|
18
|
+
break;
|
|
19
|
+
case 10:
|
|
20
|
+
entity.position = helpers.parsePoint(scanner);
|
|
21
|
+
break;
|
|
22
|
+
case 11:
|
|
23
|
+
entity.direction = helpers.parsePoint(scanner);
|
|
24
|
+
break;
|
|
25
|
+
case 40:
|
|
26
|
+
//Note: this is the text height
|
|
27
|
+
entity.height = curr.value;
|
|
28
|
+
break;
|
|
29
|
+
case 41:
|
|
30
|
+
entity.width = curr.value;
|
|
31
|
+
break;
|
|
32
|
+
case 44:
|
|
33
|
+
entity.lineSpacing = curr.value;
|
|
34
|
+
break;
|
|
35
|
+
case 50:
|
|
36
|
+
entity.rotation = curr.value;
|
|
37
|
+
break;
|
|
38
|
+
case 7: // Text style name
|
|
39
|
+
entity.styleName = curr.value;
|
|
40
|
+
break;
|
|
41
|
+
case 71:
|
|
42
|
+
entity.attachmentPoint = curr.value;
|
|
43
|
+
break;
|
|
44
|
+
case 72:
|
|
45
|
+
entity.drawingDirection = curr.value;
|
|
46
|
+
break;
|
|
47
|
+
case 101:
|
|
48
|
+
helpers.skipEmbeddedObject(scanner);
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
curr = scanner.next();
|
|
55
|
+
}
|
|
56
|
+
return entity;
|
|
57
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'POINT';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 10:
|
|
17
|
+
entity.position = helpers.parsePoint(scanner);
|
|
18
|
+
break;
|
|
19
|
+
case 39:
|
|
20
|
+
entity.thickness = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 210:
|
|
23
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
24
|
+
break;
|
|
25
|
+
case 100:
|
|
26
|
+
break;
|
|
27
|
+
default: // check common entity attributes
|
|
28
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
curr = scanner.next();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return entity;
|
|
35
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
import VertexParser from "./vertex.js";
|
|
4
|
+
|
|
5
|
+
export default function EntityParser() {}
|
|
6
|
+
|
|
7
|
+
EntityParser.ForEntityName = 'POLYLINE';
|
|
8
|
+
|
|
9
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
10
|
+
var entity = { type: curr.value, vertices: [] };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 10: // always 0
|
|
17
|
+
break;
|
|
18
|
+
case 20: // always 0
|
|
19
|
+
break;
|
|
20
|
+
case 30: // elevation
|
|
21
|
+
break;
|
|
22
|
+
case 39: // thickness
|
|
23
|
+
entity.thickness = curr.value;
|
|
24
|
+
break;
|
|
25
|
+
case 40: // start width
|
|
26
|
+
break;
|
|
27
|
+
case 41: // end width
|
|
28
|
+
break;
|
|
29
|
+
case 70:
|
|
30
|
+
entity.shape = (curr.value & 1) !== 0;
|
|
31
|
+
entity.includesCurveFitVertices = (curr.value & 2) !== 0;
|
|
32
|
+
entity.includesSplineFitVertices = (curr.value & 4) !== 0;
|
|
33
|
+
entity.is3dPolyline = (curr.value & 8) !== 0;
|
|
34
|
+
entity.is3dPolygonMesh = (curr.value & 16) !== 0;
|
|
35
|
+
entity.is3dPolygonMeshClosed = (curr.value & 32) !== 0; // 32 = The polygon mesh is closed in the N direction
|
|
36
|
+
entity.isPolyfaceMesh = (curr.value & 64) !== 0;
|
|
37
|
+
entity.hasContinuousLinetypePattern = (curr.value & 128) !== 0;
|
|
38
|
+
break;
|
|
39
|
+
case 71: // Polygon mesh M vertex count
|
|
40
|
+
break;
|
|
41
|
+
case 72: // Polygon mesh N vertex count
|
|
42
|
+
break;
|
|
43
|
+
case 73: // Smooth surface M density
|
|
44
|
+
break;
|
|
45
|
+
case 74: // Smooth surface N density
|
|
46
|
+
break;
|
|
47
|
+
case 75: // Curves and smooth surface type
|
|
48
|
+
break;
|
|
49
|
+
case 210:
|
|
50
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
curr = scanner.next();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
entity.vertices = parsePolylineVertices(scanner, curr);
|
|
60
|
+
|
|
61
|
+
return entity;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function parsePolylineVertices(scanner, curr) {
|
|
65
|
+
var vertexParser = new VertexParser();
|
|
66
|
+
|
|
67
|
+
var vertices = [];
|
|
68
|
+
while (!scanner.isEOF()) {
|
|
69
|
+
if (curr.code === 0) {
|
|
70
|
+
if (curr.value === 'VERTEX') {
|
|
71
|
+
vertices.push(vertexParser.parseEntity(scanner, curr));
|
|
72
|
+
curr = scanner.lastReadGroup;
|
|
73
|
+
} else if (curr.value === 'SEQEND') {
|
|
74
|
+
parseSeqEnd(scanner, curr);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return vertices;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function parseSeqEnd(scanner, curr) {
|
|
83
|
+
var entity = { type: curr.value };
|
|
84
|
+
curr = scanner.next();
|
|
85
|
+
while(curr != 'EOF') {
|
|
86
|
+
if (curr.code == 0) break;
|
|
87
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
88
|
+
curr = scanner.next();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return entity;
|
|
92
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'SOLID';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, currentGroup) {
|
|
9
|
+
var entity;
|
|
10
|
+
entity = { type: currentGroup.value };
|
|
11
|
+
entity.points = [];
|
|
12
|
+
currentGroup = scanner.next();
|
|
13
|
+
while(currentGroup !== 'EOF') {
|
|
14
|
+
if(currentGroup.code === 0) break;
|
|
15
|
+
|
|
16
|
+
switch(currentGroup.code) {
|
|
17
|
+
case 10:
|
|
18
|
+
entity.points[0] = helpers.parsePoint(scanner);
|
|
19
|
+
break;
|
|
20
|
+
case 11:
|
|
21
|
+
entity.points[1] = helpers.parsePoint(scanner);
|
|
22
|
+
break;
|
|
23
|
+
case 12:
|
|
24
|
+
entity.points[2] = helpers.parsePoint(scanner);
|
|
25
|
+
break;
|
|
26
|
+
case 13:
|
|
27
|
+
entity.points[3] = helpers.parsePoint(scanner);
|
|
28
|
+
break;
|
|
29
|
+
case 210:
|
|
30
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
31
|
+
break;
|
|
32
|
+
default: // check common entity attributes
|
|
33
|
+
helpers.checkCommonEntityProperties(entity, currentGroup, scanner);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
currentGroup = scanner.next();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return entity;
|
|
40
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'SPLINE';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF')
|
|
13
|
+
{
|
|
14
|
+
if(curr.code === 0) break;
|
|
15
|
+
|
|
16
|
+
switch(curr.code) {
|
|
17
|
+
case 10:
|
|
18
|
+
if (!entity.controlPoints) entity.controlPoints = [];
|
|
19
|
+
entity.controlPoints.push(helpers.parsePoint(scanner));
|
|
20
|
+
break;
|
|
21
|
+
case 11:
|
|
22
|
+
if (!entity.fitPoints) entity.fitPoints = [];
|
|
23
|
+
entity.fitPoints.push(helpers.parsePoint(scanner));
|
|
24
|
+
break;
|
|
25
|
+
case 12:
|
|
26
|
+
entity.startTangent = helpers.parsePoint(scanner);
|
|
27
|
+
break;
|
|
28
|
+
case 13:
|
|
29
|
+
entity.endTangent = helpers.parsePoint(scanner);
|
|
30
|
+
break;
|
|
31
|
+
case 40:
|
|
32
|
+
if (!entity.knotValues) entity.knotValues = [];
|
|
33
|
+
entity.knotValues.push(curr.value);
|
|
34
|
+
break;
|
|
35
|
+
case 70:
|
|
36
|
+
if ((curr.value & 1) != 0) entity.closed = true;
|
|
37
|
+
if ((curr.value & 2) != 0) entity.periodic = true;
|
|
38
|
+
if ((curr.value & 4) != 0) entity.rational = true;
|
|
39
|
+
if ((curr.value & 8) != 0) entity.planar = true;
|
|
40
|
+
if ((curr.value & 16) != 0)
|
|
41
|
+
{
|
|
42
|
+
entity.planar = true;
|
|
43
|
+
entity.linear = true;
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
|
|
47
|
+
case 71:
|
|
48
|
+
entity.degreeOfSplineCurve = curr.value;
|
|
49
|
+
break;
|
|
50
|
+
case 72:
|
|
51
|
+
entity.numberOfKnots = curr.value;
|
|
52
|
+
break;
|
|
53
|
+
case 73:
|
|
54
|
+
entity.numberOfControlPoints = curr.value;
|
|
55
|
+
break;
|
|
56
|
+
case 74:
|
|
57
|
+
entity.numberOfFitPoints = curr.value;
|
|
58
|
+
break;
|
|
59
|
+
case 210:
|
|
60
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
curr = scanner.next();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return entity;
|
|
70
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'TEXT';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
switch(curr.code) {
|
|
15
|
+
case 10: // X coordinate of 'first alignment point'
|
|
16
|
+
entity.startPoint = helpers.parsePoint(scanner);
|
|
17
|
+
break;
|
|
18
|
+
case 11: // X coordinate of 'second alignment point'
|
|
19
|
+
entity.endPoint = helpers.parsePoint(scanner);
|
|
20
|
+
break;
|
|
21
|
+
case 40: // Text height
|
|
22
|
+
entity.textHeight = curr.value;
|
|
23
|
+
break;
|
|
24
|
+
case 41:
|
|
25
|
+
entity.xScale = curr.value;
|
|
26
|
+
break;
|
|
27
|
+
case 50: // Rotation in degrees
|
|
28
|
+
entity.rotation = curr.value;
|
|
29
|
+
break;
|
|
30
|
+
case 7: // Text style name
|
|
31
|
+
entity.styleName = curr.value;
|
|
32
|
+
break;
|
|
33
|
+
case 1: // Text
|
|
34
|
+
entity.text = curr.value;
|
|
35
|
+
break;
|
|
36
|
+
// NOTE: 72 and 73 are meaningless without 11 (second alignment point)
|
|
37
|
+
case 72: // Horizontal alignment
|
|
38
|
+
entity.halign = curr.value;
|
|
39
|
+
break;
|
|
40
|
+
case 73: // Vertical alignment
|
|
41
|
+
entity.valign = curr.value;
|
|
42
|
+
break;
|
|
43
|
+
default: // check common entity attributes
|
|
44
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
curr = scanner.next();
|
|
48
|
+
}
|
|
49
|
+
return entity;
|
|
50
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'VERTEX';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity = { type: curr.value };
|
|
10
|
+
curr = scanner.next();
|
|
11
|
+
while(curr !== 'EOF') {
|
|
12
|
+
if(curr.code === 0) break;
|
|
13
|
+
|
|
14
|
+
switch(curr.code) {
|
|
15
|
+
case 10: // X
|
|
16
|
+
entity.x = curr.value;
|
|
17
|
+
break;
|
|
18
|
+
case 20: // Y
|
|
19
|
+
entity.y = curr.value;
|
|
20
|
+
break;
|
|
21
|
+
case 30: // Z
|
|
22
|
+
entity.z = curr.value;
|
|
23
|
+
break;
|
|
24
|
+
case 40: // start width
|
|
25
|
+
break;
|
|
26
|
+
case 41: // end width
|
|
27
|
+
break;
|
|
28
|
+
case 42: // bulge
|
|
29
|
+
if(curr.value != 0) entity.bulge = curr.value;
|
|
30
|
+
break;
|
|
31
|
+
case 70: // flags
|
|
32
|
+
entity.curveFittingVertex = (curr.value & 1) !== 0;
|
|
33
|
+
entity.curveFitTangent = (curr.value & 2) !== 0;
|
|
34
|
+
entity.splineVertex = (curr.value & 8) !== 0;
|
|
35
|
+
entity.splineControlPoint = (curr.value & 16) !== 0;
|
|
36
|
+
entity.threeDPolylineVertex = (curr.value & 32) !== 0;
|
|
37
|
+
entity.threeDPolylineMesh = (curr.value & 64) !== 0;
|
|
38
|
+
entity.polyfaceMeshVertex = (curr.value & 128) !== 0;
|
|
39
|
+
break;
|
|
40
|
+
case 50: // curve fit tangent direction
|
|
41
|
+
break;
|
|
42
|
+
case 71: // polyface mesh vertex index
|
|
43
|
+
entity.faces = [curr.value];
|
|
44
|
+
break;
|
|
45
|
+
case 72: // polyface mesh vertex index
|
|
46
|
+
entity.faces[1] = curr.value;
|
|
47
|
+
break;
|
|
48
|
+
case 73: // polyface mesh vertex index
|
|
49
|
+
entity.faces[2] = curr.value;
|
|
50
|
+
break;
|
|
51
|
+
case 74: // polyface mesh vertex index
|
|
52
|
+
entity.faces[3] = curr.value;
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
curr = scanner.next();
|
|
60
|
+
}
|
|
61
|
+
return entity;
|
|
62
|
+
};
|
|
@@ -24,8 +24,12 @@ function processMeshData(input, options) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const identity = new THREE.Matrix4().identity();
|
|
28
|
+
const identityElements = identity.elements;
|
|
29
|
+
|
|
27
30
|
input.mesh.forEach(meshItem => {
|
|
28
31
|
const geomList = [];
|
|
32
|
+
const meshMatrix = meshItem.matrix?.length ? meshItem.matrix : identityElements;
|
|
29
33
|
meshItem.primitives.forEach(primitive => {
|
|
30
34
|
const primitiveData = input.primitive.find(g => g.id === primitive.prmid);
|
|
31
35
|
if (primitiveData) {
|
|
@@ -34,26 +38,27 @@ function processMeshData(input, options) {
|
|
|
34
38
|
const material = mergedMaterial || baseMaterial;
|
|
35
39
|
const sourceVisible =
|
|
36
40
|
mergedMaterial?.visible === false || baseMaterial?.visible === false ? false : true;
|
|
41
|
+
const baseColor = [255, 255, 255, 1];
|
|
37
42
|
const prop = {
|
|
38
|
-
color: material?.color
|
|
43
|
+
color: material?.color
|
|
44
|
+
? material?.color.length
|
|
45
|
+
? material.color
|
|
46
|
+
: baseColor
|
|
47
|
+
: baseColor,
|
|
39
48
|
fontsize: material?.fontsize !== undefined ? material?.fontsize : 20,
|
|
40
49
|
frontname: material?.frontname !== undefined ? material?.frontname : '',
|
|
41
50
|
italic: material?.italic,
|
|
42
51
|
linepacing: 1, // 默认值
|
|
43
|
-
linewidth: material?.linewidth !== undefined ? material?.linewidth :
|
|
52
|
+
linewidth: material?.linewidth !== undefined ? material?.linewidth : 10, // 默认值
|
|
44
53
|
visible: sourceVisible,
|
|
45
54
|
sourceVisible,
|
|
46
55
|
transparent: material?.transp !== undefined ? material?.transp : 0,
|
|
47
56
|
};
|
|
48
57
|
|
|
49
|
-
const identity = new THREE.Matrix4().identity();
|
|
50
|
-
|
|
51
58
|
geomList.push({
|
|
52
59
|
matrix: {
|
|
53
|
-
val: primitive.matrix?.length ? primitive.matrix :
|
|
54
|
-
// val: identity.elements,
|
|
60
|
+
val: primitive.matrix?.length ? primitive.matrix : identityElements,
|
|
55
61
|
},
|
|
56
|
-
// originMatrix: meshItem.id == primitive.prmid ? [] : identity.elements,
|
|
57
62
|
prmid: primitive.prmid,
|
|
58
63
|
geomId: primitiveData.id,
|
|
59
64
|
type: primitiveData.geomType,
|
|
@@ -71,6 +76,9 @@ function processMeshData(input, options) {
|
|
|
71
76
|
|
|
72
77
|
drawObjMap.set(meshItem.id, {
|
|
73
78
|
drawObjId: meshItem.id,
|
|
79
|
+
matrix: {
|
|
80
|
+
val: meshMatrix,
|
|
81
|
+
},
|
|
74
82
|
geoms: geomList,
|
|
75
83
|
// lodLevel: meshItem.type || 2,
|
|
76
84
|
});
|
|
@@ -146,7 +154,7 @@ function processOnePrimtiveToMultiMesh(primitive) {
|
|
|
146
154
|
return {
|
|
147
155
|
instanceId: primitive.drawObjId, // 实例与drawObj一对多关系
|
|
148
156
|
drawObject: primitive.geoms[0]?.prmid || '',
|
|
149
|
-
matrix: primitive.
|
|
157
|
+
matrix: primitive.matrix || {},
|
|
150
158
|
};
|
|
151
159
|
}
|
|
152
160
|
|
|
@@ -240,6 +248,8 @@ function parseNode(node, isFlatNode) {
|
|
|
240
248
|
// 生成默认node节点
|
|
241
249
|
function generateNode(mesh) {
|
|
242
250
|
let nodes = [];
|
|
251
|
+
const identity = new THREE.Matrix4().identity();
|
|
252
|
+
const identityElements = identity.elements;
|
|
243
253
|
mesh.forEach(item => {
|
|
244
254
|
if (item.primitives.length) {
|
|
245
255
|
let tempNode = {
|
|
@@ -247,7 +257,9 @@ function generateNode(mesh) {
|
|
|
247
257
|
_batchId: item.id,
|
|
248
258
|
name: item.id,
|
|
249
259
|
mesh: item.id,
|
|
250
|
-
matrix: {
|
|
260
|
+
matrix: {
|
|
261
|
+
val: item.matrix?.length ? item.matrix : identityElements,
|
|
262
|
+
},
|
|
251
263
|
nodeType: 3,
|
|
252
264
|
};
|
|
253
265
|
nodes.push(tempNode);
|
|
@@ -5,7 +5,7 @@ import helvetikerFont from 'three/examples/fonts/helvetiker_regular.typeface.jso
|
|
|
5
5
|
import { MeshLineGeometry, MeshLineMaterial } from 'meshline';
|
|
6
6
|
import StreamLoaderParserWorker from '../../packages/utils/StreamLoaderParser.worker.js';
|
|
7
7
|
|
|
8
|
-
const GEOM_TYPES = {
|
|
8
|
+
export const GEOM_TYPES = {
|
|
9
9
|
geom_3d: 53248,
|
|
10
10
|
geom_3d_text: 53249,
|
|
11
11
|
geom_3d_mtext: 53250,
|
|
@@ -96,6 +96,37 @@ function getInstanceNormalSign(matrix) {
|
|
|
96
96
|
return matrix.determinant() < 0 ? -1 : 1;
|
|
97
97
|
}
|
|
98
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
|
+
|
|
99
130
|
/**
|
|
100
131
|
* 重置处理状态,用于新的批量加载会话
|
|
101
132
|
*/
|
|
@@ -434,44 +465,24 @@ function setInstanceMatricesAndColors(model, drawObj, mesh, meshName, customColo
|
|
|
434
465
|
|
|
435
466
|
// const instancedMesh = instanceToInstancedMeshMap.get(item.instanceId);
|
|
436
467
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (matrixVal) {
|
|
440
|
-
const m4 = new THREE.Matrix4();
|
|
441
|
-
const meshMatrix = new THREE.Matrix4();
|
|
442
|
-
const geomMatrix = new THREE.Matrix4();
|
|
443
|
-
|
|
444
|
-
meshMatrix.fromArray(matrixVal);
|
|
445
|
-
geomMatrix.fromArray(new THREE.Matrix4().identity().elements);
|
|
446
|
-
|
|
447
|
-
// 处理文本居中对齐
|
|
448
|
-
const { points, alignType } = mesh;
|
|
449
|
-
if (isTextType(mesh.type)) {
|
|
450
|
-
const positionMatrix = new THREE.Matrix4();
|
|
451
|
-
const alignMatrix = createAlignedText(alignType, model.geometry);
|
|
452
|
-
positionMatrix.identity().makeTranslation(points[0], points[1], points[2]);
|
|
453
|
-
geomMatrix.multiply(alignMatrix).multiply(positionMatrix);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
m4.multiplyMatrices(meshMatrix, geomMatrix);
|
|
457
|
-
model.setMatrixAt(index, m4);
|
|
468
|
+
const m4 = composeInstanceMatrix(item, mesh, model.geometry);
|
|
469
|
+
model.setMatrixAt(index, m4);
|
|
458
470
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
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
|
+
}
|
|
463
475
|
|
|
464
|
-
|
|
465
|
-
|
|
476
|
+
const copyMatrix = new THREE.Matrix4().copy(m4);
|
|
477
|
+
model.userData.copyMatrix = copyMatrix;
|
|
466
478
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
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);
|
|
475
486
|
}
|
|
476
487
|
|
|
477
488
|
// 设置颜色
|
|
@@ -549,25 +560,9 @@ function appendInstanceToInstancedMesh(model, drawObj, mesh, instance, customCol
|
|
|
549
560
|
? new THREE.Color(customColor)
|
|
550
561
|
: new THREE.Color(`rgb(${colorArr[0]}, ${colorArr[1]}, ${colorArr[2]})`);
|
|
551
562
|
|
|
552
|
-
|
|
553
|
-
if (!matrixVal || !mesh || !mesh.matrix || !mesh.matrix.val) return;
|
|
554
|
-
|
|
555
|
-
const m4 = new THREE.Matrix4();
|
|
556
|
-
const meshMatrix = new THREE.Matrix4();
|
|
557
|
-
const geomMatrix = new THREE.Matrix4();
|
|
558
|
-
|
|
559
|
-
meshMatrix.fromArray(instance.matrix.val);
|
|
560
|
-
geomMatrix.fromArray(new THREE.Matrix4().identity().elements);
|
|
561
|
-
|
|
562
|
-
const { points, alignType } = mesh;
|
|
563
|
-
if (isTextType(mesh.type)) {
|
|
564
|
-
const positionMatrix = new THREE.Matrix4();
|
|
565
|
-
const alignMatrix = createAlignedText(alignType, model.geometry);
|
|
566
|
-
positionMatrix.identity().makeTranslation(points[0], points[1], points[2]);
|
|
567
|
-
geomMatrix.multiply(alignMatrix).multiply(positionMatrix);
|
|
568
|
-
}
|
|
563
|
+
if (!mesh) return;
|
|
569
564
|
|
|
570
|
-
m4
|
|
565
|
+
const m4 = composeInstanceMatrix(instance, mesh, model.geometry);
|
|
571
566
|
const renderMatrix =
|
|
572
567
|
sourceVisible === false
|
|
573
568
|
? new THREE.Matrix4().copy(m4).makeTranslation(9999999, 9999999, 9999999)
|
|
@@ -679,7 +674,7 @@ function drawModel(geom, instanceName, instanceCount, nColor, nOpacity, options
|
|
|
679
674
|
let model;
|
|
680
675
|
// 处理二维几何体(普通2D图形和特殊2D图形)
|
|
681
676
|
if (geom.type == GEOM_TYPES.geom_2d || geom.type == GEOM_TYPES.geom_2d_others) {
|
|
682
|
-
model = draw2Dmodel(geom, instanceName, instanceCount, options); // TODO 该类型调试中
|
|
677
|
+
model = draw2Dmodel(geom, instanceName, instanceCount, nColor, nOpacity, options); // TODO 该类型调试中
|
|
683
678
|
// 处理二维文本类型
|
|
684
679
|
} else if (isTextType(geom.type)) {
|
|
685
680
|
model = drawText(geom, instanceName, instanceCount, options);
|
|
@@ -690,7 +685,7 @@ function drawModel(geom, instanceName, instanceCount, nColor, nOpacity, options
|
|
|
690
685
|
geom.type == GEOM_TYPES.geom_2d_ellipse ||
|
|
691
686
|
geom.type == GEOM_TYPES.geom_2d_ellipseArc
|
|
692
687
|
) {
|
|
693
|
-
model = drawCurves(geom, instanceName, instanceCount, options); // TODO 该类型调试中
|
|
688
|
+
model = drawCurves(geom, instanceName, instanceCount, nColor, nOpacity, options); // TODO 该类型调试中
|
|
694
689
|
// 处理三维几何体(普通3D模型和OBJ模型)
|
|
695
690
|
} else if (geom.type == GEOM_TYPES.geom_3d || geom.type == GEOM_TYPES.geom_3d_obj) {
|
|
696
691
|
model = draw3Dmodel(geom, instanceName, instanceCount, nColor, nOpacity, options);
|
|
@@ -719,7 +714,7 @@ function isTextType(type) {
|
|
|
719
714
|
* @param {String} instanceName- 曲线实例的名称
|
|
720
715
|
* @return {Object}- 包含曲线模型和曲线信息的对象
|
|
721
716
|
*/
|
|
722
|
-
function drawCurves(geom, instanceName, instanceCount, options = {}) {
|
|
717
|
+
function drawCurves(geom, instanceName, instanceCount, nColor, nOpacity, options = {}) {
|
|
723
718
|
let { points, normals } = geom;
|
|
724
719
|
let aX = points[0];
|
|
725
720
|
let aY = points[1];
|
|
@@ -760,6 +755,8 @@ function drawCurves(geom, instanceName, instanceCount, options = {}) {
|
|
|
760
755
|
},
|
|
761
756
|
instanceName,
|
|
762
757
|
instanceCount,
|
|
758
|
+
nColor,
|
|
759
|
+
nOpacity,
|
|
763
760
|
options
|
|
764
761
|
);
|
|
765
762
|
// model.rotation.x = -Math.PI / 2;
|
|
@@ -943,7 +940,8 @@ function draw3Dmodel(
|
|
|
943
940
|
// 处理transparent透明度
|
|
944
941
|
opacity = 1 - transparent;
|
|
945
942
|
|
|
946
|
-
const finalOpacity =
|
|
943
|
+
const finalOpacity =
|
|
944
|
+
nOpacity !== undefined && nOpacity !== null && nOpacity !== '' ? nOpacity : opacity;
|
|
947
945
|
|
|
948
946
|
// 判断是否全透明
|
|
949
947
|
const isTransparent = finalOpacity < 1.0;
|
|
@@ -1070,7 +1068,7 @@ function draw3Dmodel(
|
|
|
1070
1068
|
* @param {String} instanceName - 模型实例的名称
|
|
1071
1069
|
* @returns {Object} - 包含所有 2D 模型的组对象
|
|
1072
1070
|
*/
|
|
1073
|
-
function draw2Dmodel(geom, instanceName, instanceCount, options = {}) {
|
|
1071
|
+
function draw2Dmodel(geom, instanceName, instanceCount, nColor, nOpacity, options = {}) {
|
|
1074
1072
|
const points = geom.points;
|
|
1075
1073
|
const normals = geom.normals;
|
|
1076
1074
|
const geometry = new THREE.BufferGeometry();
|
|
@@ -1103,6 +1101,8 @@ function draw2Dmodel(geom, instanceName, instanceCount, options = {}) {
|
|
|
1103
1101
|
},
|
|
1104
1102
|
instanceName,
|
|
1105
1103
|
instanceCount,
|
|
1104
|
+
nColor,
|
|
1105
|
+
nOpacity,
|
|
1106
1106
|
options
|
|
1107
1107
|
);
|
|
1108
1108
|
// mesh.raycast = raycast;
|