three-cad-viewer 2.2.4 → 3.0.2
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/three-cad-viewer.css +4 -0
- package/dist/three-cad-viewer.esm.js +2209 -1779
- package/dist/three-cad-viewer.esm.min.js +2 -2
- package/dist/three-cad-viewer.js +2209 -1779
- package/dist/three-cad-viewer.min.js +2 -2
- package/package.json +15 -15
- package/src/_version.js +1 -1
- package/src/bbox.js +0 -3
- package/src/cad_tools/measure.js +9 -9
- package/src/display.js +29 -3
- package/src/nestedgroup.js +10 -9
- package/src/timer.js +4 -4
- package/src/utils.js +4 -1
- package/src/viewer.js +224 -120
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-cad-viewer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
"author": "Bernhard Walter",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"three": "0.
|
|
27
|
+
"three": "0.166.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@babel/core": "^7.
|
|
31
|
-
"@babel/eslint-parser": "^7.
|
|
32
|
-
"@rollup/plugin-image": "^3.0.
|
|
33
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
34
|
-
"@rollup/plugin-terser": "^0.4.
|
|
35
|
-
"eslint": "^
|
|
36
|
-
"eslint-config-prettier": "^
|
|
37
|
-
"prettier": "^
|
|
38
|
-
"rimraf": "^
|
|
39
|
-
"rollup": "^
|
|
30
|
+
"@babel/core": "^7.24.7",
|
|
31
|
+
"@babel/eslint-parser": "^7.24.7",
|
|
32
|
+
"@rollup/plugin-image": "^3.0.3",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
34
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
35
|
+
"eslint": "^9.6.0",
|
|
36
|
+
"eslint-config-prettier": "^9.1.0",
|
|
37
|
+
"prettier": "^3.3.2",
|
|
38
|
+
"rimraf": "^6.0.0",
|
|
39
|
+
"rollup": "^4.18.1",
|
|
40
40
|
"rollup-plugin-html": "^0.2.1",
|
|
41
|
-
"rollup-plugin-import-css": "^3.
|
|
41
|
+
"rollup-plugin-import-css": "^3.5.0",
|
|
42
42
|
"rollup-plugin-livereload": "^2.0.5",
|
|
43
|
-
"rollup-plugin-serve": "^
|
|
43
|
+
"rollup-plugin-serve": "^1.1.1",
|
|
44
44
|
"rollup-plugin-string": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"babel": {}
|
|
47
|
-
}
|
|
47
|
+
}
|
package/src/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "
|
|
1
|
+
export const version = "3.0.2";
|
package/src/bbox.js
CHANGED
package/src/cad_tools/measure.js
CHANGED
|
@@ -440,7 +440,7 @@ class DistanceMeasurement extends Measurement {
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
_makeLines() {
|
|
443
|
-
const lineWidth =
|
|
443
|
+
const lineWidth = 1.5;
|
|
444
444
|
const distanceLine = new DistanceLineArrow(
|
|
445
445
|
this.coneLength,
|
|
446
446
|
this.point1,
|
|
@@ -494,12 +494,12 @@ class PropertiesMeasurement extends Measurement {
|
|
|
494
494
|
const subheader = isSolid
|
|
495
495
|
? "Solid"
|
|
496
496
|
: isVertex
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
497
|
+
? "Vertex"
|
|
498
|
+
: isLine
|
|
499
|
+
? "Edge"
|
|
500
|
+
: isFace
|
|
501
|
+
? "Face"
|
|
502
|
+
: "Unknown";
|
|
503
503
|
this.panel.subheader = subheader;
|
|
504
504
|
const debugProps = {
|
|
505
505
|
volume: 0.44,
|
|
@@ -526,7 +526,7 @@ class PropertiesMeasurement extends Measurement {
|
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
_makeLines() {
|
|
529
|
-
const lineWidth =
|
|
529
|
+
const lineWidth = 1.5;
|
|
530
530
|
|
|
531
531
|
const middlePoint = DEBUG
|
|
532
532
|
? this.selectedShapes[0].obj.children[0].geometry.boundingSphere.center
|
|
@@ -600,7 +600,7 @@ class AngleMeasurement extends Measurement {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
_makeLines() {
|
|
603
|
-
const lineWidth =
|
|
603
|
+
const lineWidth = 1.5;
|
|
604
604
|
this._getPoints();
|
|
605
605
|
const item1Line = new DistanceLineArrow(
|
|
606
606
|
this.coneLength,
|
package/src/display.js
CHANGED
|
@@ -89,6 +89,8 @@ class Display {
|
|
|
89
89
|
this.clipSliders = null;
|
|
90
90
|
this.explodeFlag = false;
|
|
91
91
|
|
|
92
|
+
this.currentButton = null;
|
|
93
|
+
|
|
92
94
|
this.lastPlaneState = false;
|
|
93
95
|
|
|
94
96
|
var theme;
|
|
@@ -676,14 +678,18 @@ class Display {
|
|
|
676
678
|
*/
|
|
677
679
|
setTool = (name, flag) => {
|
|
678
680
|
this.viewer.toggleAnimationLoop(flag);
|
|
679
|
-
this.viewer.setPickHandler(!flag);
|
|
680
|
-
this.viewer.setRaycastMode(flag);
|
|
681
681
|
|
|
682
682
|
if (flag) {
|
|
683
683
|
if (this.viewer.hasAnimation()) {
|
|
684
684
|
this.viewer.backupAnimation();
|
|
685
685
|
}
|
|
686
|
-
|
|
686
|
+
if (
|
|
687
|
+
["distance", "properties", "angle"].includes(name) &&
|
|
688
|
+
!["distance", "properties", "angle"].includes(this.currentButton)
|
|
689
|
+
) {
|
|
690
|
+
this.viewer.toggleGroup(true);
|
|
691
|
+
}
|
|
692
|
+
this.viewer.setRaycastMode(flag);
|
|
687
693
|
this.shapeFilterDropDownMenu.setRaycaster(this.viewer.raycaster);
|
|
688
694
|
|
|
689
695
|
if (name == "distance") {
|
|
@@ -696,7 +702,12 @@ class Display {
|
|
|
696
702
|
this.viewer.cadTools.enable(ToolTypes.ANGLE);
|
|
697
703
|
this.viewer.checkChanges({ activeTool: ToolTypes.ANGLE });
|
|
698
704
|
}
|
|
705
|
+
this.currentButton = name;
|
|
699
706
|
} else {
|
|
707
|
+
if (this.currentButton == name) {
|
|
708
|
+
this.viewer.toggleGroup(false);
|
|
709
|
+
this.currentButton = null;
|
|
710
|
+
}
|
|
700
711
|
this.viewer.checkChanges({ activeTool: ToolTypes.NONE });
|
|
701
712
|
this.viewer.clearSelection();
|
|
702
713
|
if (this.viewer.hasAnimation()) {
|
|
@@ -704,7 +715,9 @@ class Display {
|
|
|
704
715
|
this.viewer.clearAnimation();
|
|
705
716
|
this.viewer.restoreAnimation();
|
|
706
717
|
}
|
|
718
|
+
this.viewer.setRaycastMode(flag);
|
|
707
719
|
}
|
|
720
|
+
this.viewer.setPickHandler(!flag);
|
|
708
721
|
this.shapeFilterDropDownMenu.show(flag);
|
|
709
722
|
};
|
|
710
723
|
|
|
@@ -1019,6 +1032,19 @@ class Display {
|
|
|
1019
1032
|
}
|
|
1020
1033
|
}
|
|
1021
1034
|
|
|
1035
|
+
/**
|
|
1036
|
+
* Toggle visibility of the clipping tab
|
|
1037
|
+
* @function
|
|
1038
|
+
*/
|
|
1039
|
+
toggleClippingTab = (flag) => {
|
|
1040
|
+
if (flag) {
|
|
1041
|
+
this.tabClip.removeAttribute("disabled");
|
|
1042
|
+
} else {
|
|
1043
|
+
this.tabClip.setAttribute("disabled", "true");
|
|
1044
|
+
}
|
|
1045
|
+
this.tabClip.classList.toggle("tcv_tab-disabled", !flag);
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1022
1048
|
/**
|
|
1023
1049
|
* Collapse nodes handler
|
|
1024
1050
|
* @function
|
package/src/nestedgroup.js
CHANGED
|
@@ -5,6 +5,7 @@ import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
|
|
|
5
5
|
import { VertexNormalsHelper } from "three/examples/jsm/helpers/VertexNormalsHelper.js";
|
|
6
6
|
import { BoundingBox } from "./bbox.js";
|
|
7
7
|
import { ObjectGroup } from "./objectgroup.js";
|
|
8
|
+
import { flatten } from "./utils.js";
|
|
8
9
|
|
|
9
10
|
class NestedGroup {
|
|
10
11
|
constructor(
|
|
@@ -55,7 +56,7 @@ class NestedGroup {
|
|
|
55
56
|
var positions =
|
|
56
57
|
edgeList instanceof Float32Array
|
|
57
58
|
? edgeList
|
|
58
|
-
: new Float32Array(edgeList
|
|
59
|
+
: new Float32Array(flatten(edgeList, 3));
|
|
59
60
|
|
|
60
61
|
const lineGeometry = new LineSegmentsGeometry();
|
|
61
62
|
lineGeometry.setPositions(positions);
|
|
@@ -103,7 +104,7 @@ class NestedGroup {
|
|
|
103
104
|
var edges = this._renderEdges(
|
|
104
105
|
edgeList.edges
|
|
105
106
|
? edgeList.edges // protocol version 2
|
|
106
|
-
: edgeList, // protocol version 1
|
|
107
|
+
: flatten(edgeList), // protocol version 1
|
|
107
108
|
lineWidth,
|
|
108
109
|
color,
|
|
109
110
|
state,
|
|
@@ -142,8 +143,8 @@ class NestedGroup {
|
|
|
142
143
|
// protocol version 1
|
|
143
144
|
positions =
|
|
144
145
|
vertexList instanceof Float32Array
|
|
145
|
-
? vertexList
|
|
146
|
-
: new Float32Array(vertexList
|
|
146
|
+
? vertexList
|
|
147
|
+
: new Float32Array(flatten(vertexList));
|
|
147
148
|
}
|
|
148
149
|
const geometry = new THREE.BufferGeometry();
|
|
149
150
|
geometry.setAttribute(
|
|
@@ -190,15 +191,15 @@ class NestedGroup {
|
|
|
190
191
|
const positions =
|
|
191
192
|
shape.vertices instanceof Float32Array
|
|
192
193
|
? shape.vertices
|
|
193
|
-
: new Float32Array(shape.vertices
|
|
194
|
+
: new Float32Array(flatten(shape.vertices));
|
|
194
195
|
const normals =
|
|
195
196
|
shape.normals instanceof Float32Array
|
|
196
197
|
? shape.normals
|
|
197
|
-
: new Float32Array(shape.normals
|
|
198
|
+
: new Float32Array(flatten(shape.normals));
|
|
198
199
|
const triangles =
|
|
199
200
|
shape.triangles instanceof Uint32Array
|
|
200
201
|
? shape.triangles
|
|
201
|
-
: new Uint32Array(shape.triangles
|
|
202
|
+
: new Uint32Array(flatten(shape.triangles));
|
|
202
203
|
|
|
203
204
|
var group = new ObjectGroup(
|
|
204
205
|
this.defaultOpacity,
|
|
@@ -273,7 +274,7 @@ class NestedGroup {
|
|
|
273
274
|
side: THREE.FrontSide,
|
|
274
275
|
visible: states[0] == 1,
|
|
275
276
|
map: texture,
|
|
276
|
-
name:"frontMaterial"
|
|
277
|
+
name: "frontMaterial",
|
|
277
278
|
});
|
|
278
279
|
}
|
|
279
280
|
|
|
@@ -296,7 +297,7 @@ class NestedGroup {
|
|
|
296
297
|
depthTest: true,
|
|
297
298
|
clipIntersection: false,
|
|
298
299
|
visible: states[0] == 1 && (renderback || this.backVisible),
|
|
299
|
-
name: "backMaterial"
|
|
300
|
+
name: "backMaterial",
|
|
300
301
|
});
|
|
301
302
|
|
|
302
303
|
const back = new THREE.Mesh(shapeGeometry, backMaterial);
|
package/src/timer.js
CHANGED
|
@@ -4,7 +4,7 @@ class Timer {
|
|
|
4
4
|
this.timeit = timeit;
|
|
5
5
|
this.start = performance.now();
|
|
6
6
|
if (timeit) {
|
|
7
|
-
console.info(`three-cad-viewer:
|
|
7
|
+
console.info(`three-cad-viewer: ${prefix}:timer start`);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ class Timer {
|
|
|
12
12
|
if (this.timeit) {
|
|
13
13
|
const t = performance.now();
|
|
14
14
|
console.info(
|
|
15
|
-
`three-cad-viewer:
|
|
15
|
+
`three-cad-viewer: ${this.prefix}:${msg}:timer split ${(
|
|
16
16
|
t - this.start
|
|
17
17
|
).toFixed(1)} ms`,
|
|
18
18
|
);
|
|
@@ -23,9 +23,9 @@ class Timer {
|
|
|
23
23
|
if (this.timeit) {
|
|
24
24
|
const t = performance.now();
|
|
25
25
|
console.info(
|
|
26
|
-
`three-cad-viewer:
|
|
26
|
+
`three-cad-viewer: ${this.prefix}:timer stop ${(t - this.start).toFixed(
|
|
27
27
|
1,
|
|
28
|
-
)} ms
|
|
28
|
+
)} ms:`,
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/utils.js
CHANGED
|
@@ -11,6 +11,9 @@ function clone(obj) {
|
|
|
11
11
|
return obj;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
function flatten(arr, depth = 1) {
|
|
15
|
+
return (Array.isArray(arr)) ? arr.flat(depth) : arr;
|
|
16
|
+
}
|
|
14
17
|
|
|
15
18
|
function isEqual(obj1, obj2, tol = 1e-9) {
|
|
16
19
|
if (Array.isArray(obj1) && Array.isArray(obj2)) {
|
|
@@ -96,4 +99,4 @@ function scaleLight(intensity) {
|
|
|
96
99
|
|
|
97
100
|
const KeyMapper = new _KeyMapper();
|
|
98
101
|
|
|
99
|
-
export { clone, isEqual, sceneTraverse, prettyPrintVector, KeyMapper, scaleLight };
|
|
102
|
+
export { clone, flatten, isEqual, sceneTraverse, prettyPrintVector, KeyMapper, scaleLight };
|