copper3d 3.6.1 → 3.6.4
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/Loader/copperNrrdLoader.js +1 -1
- package/dist/Loader/copperNrrdLoader.js.map +1 -1
- package/dist/Scene/copperScene.d.ts +4 -4
- package/dist/Scene/copperScene.js +4 -4
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/MeshGraph.d.ts +12 -10
- package/dist/Utils/surfaceAnnotation/MeshGraph.js +14 -12
- package/dist/Utils/surfaceAnnotation/MeshGraph.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +64 -17
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js +245 -35
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/annotationStore.d.ts +4 -4
- package/dist/Utils/surfaceAnnotation/annotationStore.js +4 -4
- package/dist/Utils/surfaceAnnotation/annotationStore.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/contourRender.d.ts +1 -1
- package/dist/Utils/surfaceAnnotation/contourRender.js +16 -11
- package/dist/Utils/surfaceAnnotation/contourRender.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/geodesicContour.d.ts +18 -4
- package/dist/Utils/surfaceAnnotation/geodesicContour.js +47 -8
- package/dist/Utils/surfaceAnnotation/geodesicContour.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/pointMarkers.d.ts +3 -2
- package/dist/Utils/surfaceAnnotation/pointMarkers.js +6 -2
- package/dist/Utils/surfaceAnnotation/pointMarkers.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/raycastSurface.d.ts +3 -2
- package/dist/Utils/surfaceAnnotation/raycastSurface.js +71 -5
- package/dist/Utils/surfaceAnnotation/raycastSurface.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/strokeContour.d.ts +9 -6
- package/dist/Utils/surfaceAnnotation/strokeContour.js +15 -10
- package/dist/Utils/surfaceAnnotation/strokeContour.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/types.d.ts +5 -5
- package/dist/Utils/surfaceAnnotation/types.js +2 -2
- package/dist/Utils/surfaceAnnotation/types.js.map +1 -1
- package/dist/Utils/texture2d.js +4 -2
- package/dist/Utils/texture2d.js.map +1 -1
- package/dist/Utils/workers/reformatSaveDataWorker.js +2 -2
- package/dist/Utils/workers/reformatSaveDataWorker.js.map +1 -1
- package/dist/bundle.esm.js +438 -107
- package/dist/bundle.umd.js +438 -107
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/three-vignette.js +8 -2
- package/dist/lib/three-vignette.js.map +1 -1
- package/dist/types/Scene/copperScene.d.ts +4 -4
- package/dist/types/Utils/surfaceAnnotation/MeshGraph.d.ts +12 -10
- package/dist/types/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +64 -17
- package/dist/types/Utils/surfaceAnnotation/annotationStore.d.ts +4 -4
- package/dist/types/Utils/surfaceAnnotation/contourRender.d.ts +1 -1
- package/dist/types/Utils/surfaceAnnotation/geodesicContour.d.ts +18 -4
- package/dist/types/Utils/surfaceAnnotation/pointMarkers.d.ts +3 -2
- package/dist/types/Utils/surfaceAnnotation/raycastSurface.d.ts +3 -2
- package/dist/types/Utils/surfaceAnnotation/strokeContour.d.ts +9 -6
- package/dist/types/Utils/surfaceAnnotation/types.d.ts +5 -5
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,9 +4,10 @@ import { LineGeometry } from "three/examples/jsm/lines/LineGeometry";
|
|
|
4
4
|
import { LineMaterial } from "three/examples/jsm/lines/LineMaterial";
|
|
5
5
|
import { localVertexToWorld } from "./types";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Flatten a sequence of annotation vertices (local) into the world [x,y,z, ...] that Line2 needs.
|
|
8
|
+
* Each point goes local→world, then is pushed outward along the world normal by epsilon to avoid
|
|
9
|
+
* z-fighting with the model surface.
|
|
10
|
+
* When closed, the first point is appended to the end to form a ring.
|
|
10
11
|
*/
|
|
11
12
|
function flatten(verts, closed, epsilon, mesh) {
|
|
12
13
|
const pts = [];
|
|
@@ -22,27 +23,31 @@ function flatten(verts, closed, epsilon, mesh) {
|
|
|
22
23
|
export function makeContourLine(verts, color, closed, container, epsilon, mesh) {
|
|
23
24
|
const geo = new LineGeometry();
|
|
24
25
|
const pos = flatten(verts, closed, epsilon, mesh);
|
|
25
|
-
// Line2
|
|
26
|
+
// Line2 needs at least 2 points; when there aren't enough, give a degenerate placeholder that a later update fills in.
|
|
26
27
|
geo.setPositions(pos.length >= 6 ? pos : [0, 0, 0, 0, 0, 0]);
|
|
27
28
|
const mat = new LineMaterial({
|
|
28
29
|
color: new THREE.Color(color).getHex(),
|
|
29
|
-
linewidth: 3, //
|
|
30
|
+
linewidth: 3, // width in pixels (requires resolution to be set)
|
|
31
|
+
// depthTest stays ON so the model correctly occludes the line when it is on the far side
|
|
32
|
+
// (no see-through). The host applies polygonOffset to the SURFACE material so the line still
|
|
33
|
+
// wins where it lies coplanar with the surface (no z-fighting / sinking on bumpy meshes).
|
|
30
34
|
});
|
|
31
35
|
mat.resolution.set(container.clientWidth, container.clientHeight);
|
|
32
36
|
const line = new Line2(geo, mat);
|
|
33
37
|
line.computeLineDistances();
|
|
34
38
|
line.renderOrder = 998;
|
|
35
|
-
//
|
|
36
|
-
//
|
|
39
|
+
// Important: Line2's bounding sphere stays at the initial point, so once the geometry grows by
|
|
40
|
+
// dragging, the real geometry gets wrongly culled. Disable frustum culling so the line always renders.
|
|
37
41
|
line.frustumCulled = false;
|
|
38
42
|
return line;
|
|
39
43
|
}
|
|
40
44
|
export function updateContourLine(line, verts, closed, epsilon, mesh) {
|
|
41
45
|
const pos = flatten(verts, closed, epsilon, mesh);
|
|
42
46
|
if (pos.length < 6)
|
|
43
|
-
return; // Line2
|
|
44
|
-
//
|
|
45
|
-
//
|
|
47
|
+
return; // Line2 needs >=2 points
|
|
48
|
+
// Important: calling setPositions on the existing geometry to grow it only renders the first
|
|
49
|
+
// segment (a known pitfall). Instead, rebuild and swap in a new LineGeometry each time so the
|
|
50
|
+
// instance count is correct and every segment renders.
|
|
46
51
|
const geo = new LineGeometry();
|
|
47
52
|
geo.setPositions(pos);
|
|
48
53
|
const old = line.geometry;
|
|
@@ -50,7 +55,7 @@ export function updateContourLine(line, verts, closed, epsilon, mesh) {
|
|
|
50
55
|
old.dispose();
|
|
51
56
|
line.computeLineDistances();
|
|
52
57
|
}
|
|
53
|
-
/**
|
|
58
|
+
/** Change the color of an existing contour line. */
|
|
54
59
|
export function setContourColor(line, color) {
|
|
55
60
|
line.material.color.set(color);
|
|
56
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contourRender.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/contourRender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"contourRender.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/contourRender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;GAKG;AACH,SAAS,OAAO,CACd,KAAyB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|
3
3
|
import { MeshGraph } from "./MeshGraph";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* State machine for mode B (geodesic): click anchors one by one, find the shortest path between
|
|
6
|
+
* adjacent anchors with MeshGraph, and stitch them into a polyline that hugs the surface.
|
|
7
|
+
* Enter finishes and can close the loop (computing one more segment between first and last).
|
|
7
8
|
*/
|
|
8
9
|
export declare class GeodesicContour {
|
|
9
10
|
private graph;
|
|
10
11
|
private mesh;
|
|
11
12
|
private anchors;
|
|
12
13
|
private segments;
|
|
14
|
+
private history;
|
|
13
15
|
constructor(graph: MeshGraph, mesh: THREE.Mesh);
|
|
14
|
-
/**
|
|
16
|
+
/** Save a snapshot before any anchor change (the vertex-index array is tiny, so snapshot cost is negligible). */
|
|
17
|
+
private snapshot;
|
|
18
|
+
/** Given a local hit point, snap to the nearest vertex and compute the path to the previous anchor. */
|
|
15
19
|
addAnchor(localHitPoint: THREE.Vector3): void;
|
|
20
|
+
/** Remove the anchor at the given index and recompute adjacent segments (allows canceling any middle point). */
|
|
21
|
+
removeAnchorAt(index: number): void;
|
|
22
|
+
/** Whether there is still an editable change to undo (add/remove point). */
|
|
23
|
+
canUndo(): boolean;
|
|
24
|
+
/** Undo the last anchor edit (add → remove it; remove → restore it). Returns false when no history. */
|
|
25
|
+
undoEdit(): boolean;
|
|
26
|
+
/** Recompute all adjacent-segment paths from the current anchor sequence. */
|
|
27
|
+
private rebuildSegments;
|
|
28
|
+
/** Local vertex of each anchor (used to draw visible anchor markers). */
|
|
29
|
+
getAnchorLocals(): AnnotationVertex[];
|
|
16
30
|
get anchorCount(): number;
|
|
17
|
-
/**
|
|
31
|
+
/** Stitch all path vertices (world) + normals into a polyline; when closed, add one first-to-last segment. */
|
|
18
32
|
buildVertices(closed: boolean): AnnotationVertex[];
|
|
19
33
|
}
|
|
@@ -1,27 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* State machine for mode B (geodesic): click anchors one by one, find the shortest path between
|
|
3
|
+
* adjacent anchors with MeshGraph, and stitch them into a polyline that hugs the surface.
|
|
4
|
+
* Enter finishes and can close the loop (computing one more segment between first and last).
|
|
4
5
|
*/
|
|
5
6
|
export class GeodesicContour {
|
|
6
7
|
constructor(graph, mesh) {
|
|
7
8
|
this.graph = graph;
|
|
8
9
|
this.mesh = mesh;
|
|
9
|
-
this.anchors = []; //
|
|
10
|
-
this.segments = []; //
|
|
10
|
+
this.anchors = []; // vertex indices
|
|
11
|
+
this.segments = []; // path between adjacent anchors (endpoints included)
|
|
12
|
+
this.history = []; // anchor snapshot before each add/remove, for undo
|
|
11
13
|
}
|
|
12
|
-
/**
|
|
14
|
+
/** Save a snapshot before any anchor change (the vertex-index array is tiny, so snapshot cost is negligible). */
|
|
15
|
+
snapshot() {
|
|
16
|
+
this.history.push(this.anchors.slice());
|
|
17
|
+
}
|
|
18
|
+
/** Given a local hit point, snap to the nearest vertex and compute the path to the previous anchor. */
|
|
13
19
|
addAnchor(localHitPoint) {
|
|
14
20
|
const v = this.graph.nearestVertex(localHitPoint);
|
|
21
|
+
this.snapshot();
|
|
15
22
|
if (this.anchors.length > 0) {
|
|
16
23
|
const prev = this.anchors[this.anchors.length - 1];
|
|
17
24
|
this.segments.push(this.graph.shortestPath(prev, v));
|
|
18
25
|
}
|
|
19
26
|
this.anchors.push(v);
|
|
20
27
|
}
|
|
28
|
+
/** Remove the anchor at the given index and recompute adjacent segments (allows canceling any middle point). */
|
|
29
|
+
removeAnchorAt(index) {
|
|
30
|
+
if (index < 0 || index >= this.anchors.length)
|
|
31
|
+
return;
|
|
32
|
+
this.snapshot();
|
|
33
|
+
this.anchors.splice(index, 1);
|
|
34
|
+
this.rebuildSegments();
|
|
35
|
+
}
|
|
36
|
+
/** Whether there is still an editable change to undo (add/remove point). */
|
|
37
|
+
canUndo() {
|
|
38
|
+
return this.history.length > 0;
|
|
39
|
+
}
|
|
40
|
+
/** Undo the last anchor edit (add → remove it; remove → restore it). Returns false when no history. */
|
|
41
|
+
undoEdit() {
|
|
42
|
+
const prev = this.history.pop();
|
|
43
|
+
if (!prev)
|
|
44
|
+
return false;
|
|
45
|
+
this.anchors = prev;
|
|
46
|
+
this.rebuildSegments();
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/** Recompute all adjacent-segment paths from the current anchor sequence. */
|
|
50
|
+
rebuildSegments() {
|
|
51
|
+
this.segments = [];
|
|
52
|
+
for (let i = 1; i < this.anchors.length; i++) {
|
|
53
|
+
this.segments.push(this.graph.shortestPath(this.anchors[i - 1], this.anchors[i]));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Local vertex of each anchor (used to draw visible anchor markers). */
|
|
57
|
+
getAnchorLocals() {
|
|
58
|
+
return this.anchors.map((i) => this.graph.vertexLocal(i));
|
|
59
|
+
}
|
|
21
60
|
get anchorCount() {
|
|
22
61
|
return this.anchors.length;
|
|
23
62
|
}
|
|
24
|
-
/**
|
|
63
|
+
/** Stitch all path vertices (world) + normals into a polyline; when closed, add one first-to-last segment. */
|
|
25
64
|
buildVertices(closed) {
|
|
26
65
|
const segs = this.segments.slice();
|
|
27
66
|
if (closed && this.anchors.length > 2) {
|
|
@@ -29,14 +68,14 @@ export class GeodesicContour {
|
|
|
29
68
|
}
|
|
30
69
|
const idxPath = [];
|
|
31
70
|
segs.forEach((s, si) => {
|
|
32
|
-
const start = si === 0 ? 0 : 1; //
|
|
71
|
+
const start = si === 0 ? 0 : 1; // dedupe the endpoint shared between adjacent segments
|
|
33
72
|
for (let k = start; k < s.length; k++)
|
|
34
73
|
idxPath.push(s[k]);
|
|
35
74
|
});
|
|
36
75
|
if (idxPath.length === 0 && this.anchors.length === 1) {
|
|
37
76
|
idxPath.push(this.anchors[0]);
|
|
38
77
|
}
|
|
39
|
-
//
|
|
78
|
+
// The graph geometry is already local space, so emit local vertices directly (world is derived at render time).
|
|
40
79
|
return idxPath.map((i) => this.graph.vertexLocal(i));
|
|
41
80
|
}
|
|
42
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geodesicContour.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/geodesicContour.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"geodesicContour.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/geodesicContour.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAK1B,YAAoB,KAAgB,EAAU,IAAgB;QAA1C,UAAK,GAAL,KAAK,CAAW;QAAU,SAAI,GAAJ,IAAI,CAAY;QAJtD,YAAO,GAAa,EAAE,CAAC,CAAC,iBAAiB;QACzC,aAAQ,GAAe,EAAE,CAAC,CAAC,qDAAqD;QAChF,YAAO,GAAe,EAAE,CAAC,CAAC,mDAAmD;IAEpB,CAAC;IAElE,iHAAiH;IACzG,QAAQ;QACd,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,uGAAuG;IACvG,SAAS,CAAC,aAA4B;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;SACtD;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,gHAAgH;IAChH,cAAc,CAAC,KAAa;QAC1B,IAAI,KAAK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
|
4
|
+
* Create a marker sphere (fiducial) at a local vertex. After local→world, nudge it
|
|
5
|
+
* outward along the world normal so it doesn't sink halfway into the surface.
|
|
6
|
+
* radius is passed in by the caller, scaled to the model bbox.
|
|
6
7
|
*/
|
|
7
8
|
export declare function makePointMarker(v: AnnotationVertex, mesh: THREE.Mesh, color: string, radius: number): THREE.Mesh;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import { localVertexToWorld } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Create a marker sphere (fiducial) at a local vertex. After local→world, nudge it
|
|
5
|
+
* outward along the world normal so it doesn't sink halfway into the surface.
|
|
6
|
+
* radius is passed in by the caller, scaled to the model bbox.
|
|
6
7
|
*/
|
|
7
8
|
export function makePointMarker(v, mesh, color, radius) {
|
|
8
9
|
const geo = new THREE.SphereGeometry(radius, 16, 16);
|
|
10
|
+
// depthTest ON so markers are occluded by the model when they are on the far side (no
|
|
11
|
+
// see-through), consistent with the contour lines. Markers are volumetric spheres lifted off
|
|
12
|
+
// the surface, so they still show on the visible side without z-fighting.
|
|
9
13
|
const mat = new THREE.MeshBasicMaterial({ color });
|
|
10
14
|
const m = new THREE.Mesh(geo, mat);
|
|
11
15
|
const { p, n } = localVertexToWorld(v, mesh);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointMarkers.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/pointMarkers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"pointMarkers.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/pointMarkers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,CAAmB,EACnB,IAAgB,EAChB,KAAa,EACb,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACrD,sFAAsF;IACtF,6FAA6F;IAC7F,0EAA0E;IAC1E,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,kBAAkB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { SurfaceHit } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Project screen coordinates (clientX/Y) onto the mesh surface, returning the hit point,
|
|
5
|
+
* world-space normal, and faceIndex. Returns null on a miss. Local implementation that does not
|
|
6
|
+
* depend on Copper3D's unexported raycast internals.
|
|
6
7
|
*/
|
|
7
8
|
export declare function raycastSurface(camera: THREE.PerspectiveCamera, container: HTMLElement, mesh: THREE.Mesh, clientX: number, clientY: number): SurfaceHit | null;
|
|
@@ -1,9 +1,69 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
const ray = new THREE.Raycaster();
|
|
3
3
|
const ndc = new THREE.Vector2();
|
|
4
|
+
// scratch objects for the smooth-normal interpolation (avoid per-call allocation)
|
|
5
|
+
const _nm = new THREE.Matrix3();
|
|
6
|
+
const _lp = new THREE.Vector3();
|
|
7
|
+
const _pa = new THREE.Vector3();
|
|
8
|
+
const _pb = new THREE.Vector3();
|
|
9
|
+
const _pc = new THREE.Vector3();
|
|
10
|
+
const _na = new THREE.Vector3();
|
|
11
|
+
const _nb = new THREE.Vector3();
|
|
12
|
+
const _nc = new THREE.Vector3();
|
|
13
|
+
const _v0 = new THREE.Vector3();
|
|
14
|
+
const _v1 = new THREE.Vector3();
|
|
15
|
+
const _v2 = new THREE.Vector3();
|
|
4
16
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
17
|
+
* Interpolate a "smooth per-vertex normal" across the hit triangle using barycentric coordinates,
|
|
18
|
+
* instead of using the per-face normal.
|
|
19
|
+
*
|
|
20
|
+
* Per-face normals on voxel / marching-cubes meshes are axis-aligned stair directions (±x/±y/±z);
|
|
21
|
+
* using them to push the annotation line outward along the normal shoves points toward neighboring
|
|
22
|
+
* stairs rather than cleanly "outward", making the line dip in and out on bumpy surfaces and get
|
|
23
|
+
* occluded by the steps. A smooth normal varies continuously along the surface, so the outward
|
|
24
|
+
* direction is stable and consistent and the line can float smoothly above the relief. Returns false
|
|
25
|
+
* when interpolation isn't possible (caller falls back to the face normal).
|
|
26
|
+
*/
|
|
27
|
+
function interpolateLocalNormal(geom, face, localPoint, out) {
|
|
28
|
+
const posAttr = geom.getAttribute("position");
|
|
29
|
+
const norAttr = geom.getAttribute("normal");
|
|
30
|
+
if (!posAttr || !norAttr)
|
|
31
|
+
return false;
|
|
32
|
+
_pa.fromBufferAttribute(posAttr, face.a);
|
|
33
|
+
_pb.fromBufferAttribute(posAttr, face.b);
|
|
34
|
+
_pc.fromBufferAttribute(posAttr, face.c);
|
|
35
|
+
// Barycentric coordinates (local space): u/v/w
|
|
36
|
+
_v0.subVectors(_pb, _pa);
|
|
37
|
+
_v1.subVectors(_pc, _pa);
|
|
38
|
+
_v2.subVectors(localPoint, _pa);
|
|
39
|
+
const d00 = _v0.dot(_v0);
|
|
40
|
+
const d01 = _v0.dot(_v1);
|
|
41
|
+
const d11 = _v1.dot(_v1);
|
|
42
|
+
const d20 = _v2.dot(_v0);
|
|
43
|
+
const d21 = _v2.dot(_v1);
|
|
44
|
+
const denom = d00 * d11 - d01 * d01;
|
|
45
|
+
if (Math.abs(denom) < 1e-12)
|
|
46
|
+
return false;
|
|
47
|
+
const v = (d11 * d20 - d01 * d21) / denom;
|
|
48
|
+
const w = (d00 * d21 - d01 * d20) / denom;
|
|
49
|
+
const u = 1 - v - w;
|
|
50
|
+
_na.fromBufferAttribute(norAttr, face.a);
|
|
51
|
+
_nb.fromBufferAttribute(norAttr, face.b);
|
|
52
|
+
_nc.fromBufferAttribute(norAttr, face.c);
|
|
53
|
+
out
|
|
54
|
+
.set(0, 0, 0)
|
|
55
|
+
.addScaledVector(_na, u)
|
|
56
|
+
.addScaledVector(_nb, v)
|
|
57
|
+
.addScaledVector(_nc, w);
|
|
58
|
+
if (out.lengthSq() < 1e-12)
|
|
59
|
+
return false;
|
|
60
|
+
out.normalize();
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Project screen coordinates (clientX/Y) onto the mesh surface, returning the hit point,
|
|
65
|
+
* world-space normal, and faceIndex. Returns null on a miss. Local implementation that does not
|
|
66
|
+
* depend on Copper3D's unexported raycast internals.
|
|
7
67
|
*/
|
|
8
68
|
export function raycastSurface(camera, container, mesh, clientX, clientY) {
|
|
9
69
|
var _a;
|
|
@@ -18,9 +78,15 @@ export function raycastSurface(camera, container, mesh, clientX, clientY) {
|
|
|
18
78
|
const point = h.point.clone();
|
|
19
79
|
const normal = new THREE.Vector3(0, 0, 1);
|
|
20
80
|
if (h.face) {
|
|
21
|
-
normal
|
|
22
|
-
|
|
23
|
-
|
|
81
|
+
// Prefer a smooth interpolated normal (stable outward direction on bumpy/voxel meshes);
|
|
82
|
+
// fall back to the flat face normal if the geometry has no normal attribute.
|
|
83
|
+
_lp.copy(h.point);
|
|
84
|
+
mesh.worldToLocal(_lp);
|
|
85
|
+
if (!interpolateLocalNormal(mesh.geometry, h.face, _lp, normal)) {
|
|
86
|
+
normal.copy(h.face.normal);
|
|
87
|
+
}
|
|
88
|
+
_nm.getNormalMatrix(mesh.matrixWorld);
|
|
89
|
+
normal.applyMatrix3(_nm).normalize();
|
|
24
90
|
}
|
|
25
91
|
return { point, normal, faceIndex: (_a = h.faceIndex) !== null && _a !== void 0 ? _a : -1 };
|
|
26
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raycastSurface.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/raycastSurface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;AAClC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAEhC
|
|
1
|
+
{"version":3,"file":"raycastSurface.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/raycastSurface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;AAClC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAEhC,kFAAkF;AAClF,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAChC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAChC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAChC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAChC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAChC,MAAM,G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CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;KACtC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAA,CAAC,CAAC,SAAS,mCAAI,CAAC,CAAC,EAAE,CAAC;AACzD,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { AnnotationVertex, SurfaceHit } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* pointermove
|
|
6
|
-
*
|
|
4
|
+
* State machine for one stroke in mode A (freehand).
|
|
5
|
+
* On pointermove it keeps calling addSample; samples whose world distance from the previous
|
|
6
|
+
* sample is < minGap are dropped to avoid over-density.
|
|
7
|
+
* Vertices are stored in local space (the mesh converts the world hit point to local).
|
|
7
8
|
*/
|
|
8
9
|
export declare class StrokeContour {
|
|
9
10
|
private minGap;
|
|
@@ -14,9 +15,11 @@ export declare class StrokeContour {
|
|
|
14
15
|
private lastNormal;
|
|
15
16
|
private has;
|
|
16
17
|
/**
|
|
17
|
-
* @param minGap
|
|
18
|
-
* @param maxJump
|
|
19
|
-
*
|
|
18
|
+
* @param minGap minimum sample spacing (world space), debounce
|
|
19
|
+
* @param maxJump jump threshold (world space): drop the sample when distance > maxJump and the
|
|
20
|
+
* normal flips sharply, to prevent adjacent points landing at different depths
|
|
21
|
+
* (and the straight segment cutting through the model) when the stroke grazes a
|
|
22
|
+
* groove or contour edge.
|
|
20
23
|
*/
|
|
21
24
|
constructor(minGap: number, maxJump: number, mesh: THREE.Mesh);
|
|
22
25
|
begin(): void;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import { worldHitToLocalVertex } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* pointermove
|
|
6
|
-
*
|
|
4
|
+
* State machine for one stroke in mode A (freehand).
|
|
5
|
+
* On pointermove it keeps calling addSample; samples whose world distance from the previous
|
|
6
|
+
* sample is < minGap are dropped to avoid over-density.
|
|
7
|
+
* Vertices are stored in local space (the mesh converts the world hit point to local).
|
|
7
8
|
*/
|
|
8
9
|
export class StrokeContour {
|
|
9
10
|
/**
|
|
10
|
-
* @param minGap
|
|
11
|
-
* @param maxJump
|
|
12
|
-
*
|
|
11
|
+
* @param minGap minimum sample spacing (world space), debounce
|
|
12
|
+
* @param maxJump jump threshold (world space): drop the sample when distance > maxJump and the
|
|
13
|
+
* normal flips sharply, to prevent adjacent points landing at different depths
|
|
14
|
+
* (and the straight segment cutting through the model) when the stroke grazes a
|
|
15
|
+
* groove or contour edge.
|
|
13
16
|
*/
|
|
14
17
|
constructor(minGap, maxJump, mesh) {
|
|
15
18
|
this.minGap = minGap;
|
|
@@ -28,10 +31,12 @@ export class StrokeContour {
|
|
|
28
31
|
if (this.has) {
|
|
29
32
|
const d = hit.point.distanceTo(this.last);
|
|
30
33
|
if (d < this.minGap)
|
|
31
|
-
return; //
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
34
|
+
return; // too close, debounce
|
|
35
|
+
// Jump rejection: distance suddenly large AND normal flips sharply (>~75°) → likely jumped to
|
|
36
|
+
// the back/far side, so drop it, otherwise the straight segment between adjacent points cuts
|
|
37
|
+
// through the model interior. Only reject when both conditions hold:
|
|
38
|
+
// fast drawing (large distance, similar normals) isn't falsely dropped, and drawing over a
|
|
39
|
+
// sharp edge (normal changes, distance small) isn't falsely dropped either.
|
|
35
40
|
if (d > this.maxJump && hit.normal.dot(this.lastNormal) < 0.25)
|
|
36
41
|
return;
|
|
37
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokeContour.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/strokeContour.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"stroke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AG,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -5,7 +5,7 @@ export interface SurfaceHit {
|
|
|
5
5
|
normal: THREE.Vector3;
|
|
6
6
|
faceIndex: number;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/** Annotation vertex: position and normal are both in **model local space** (single source of truth, unaffected by camera/placement). */
|
|
9
9
|
export interface AnnotationVertex {
|
|
10
10
|
x: number;
|
|
11
11
|
y: number;
|
|
@@ -26,14 +26,14 @@ export interface Annotation {
|
|
|
26
26
|
object3D: THREE.Object3D | null;
|
|
27
27
|
}
|
|
28
28
|
export interface ExportOptions {
|
|
29
|
-
/**
|
|
29
|
+
/** Export coordinate space, defaults to "local" (model space, reproducible and unaffected by camera/placement). */
|
|
30
30
|
space?: "local" | "world";
|
|
31
|
-
/**
|
|
31
|
+
/** Whether to attach a normal to each point [x,y,z,nx,ny,nz]. */
|
|
32
32
|
includeNormals?: boolean;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
34
|
+
/** World-space hit point → local vertex (position via worldToLocal, normal via inverse transform). */
|
|
35
35
|
export declare function worldHitToLocalVertex(h: SurfaceHit, mesh: THREE.Mesh): AnnotationVertex;
|
|
36
|
-
/**
|
|
36
|
+
/** Local vertex → world position + world normal (for rendering). */
|
|
37
37
|
export declare function localVertexToWorld(v: AnnotationVertex, mesh: THREE.Mesh): {
|
|
38
38
|
p: THREE.Vector3;
|
|
39
39
|
n: THREE.Vector3;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
const _inv = new THREE.Matrix4();
|
|
3
|
-
/**
|
|
3
|
+
/** World-space hit point → local vertex (position via worldToLocal, normal via inverse transform). */
|
|
4
4
|
export function worldHitToLocalVertex(h, mesh) {
|
|
5
5
|
const lp = mesh.worldToLocal(h.point.clone());
|
|
6
6
|
_inv.copy(mesh.matrixWorld).invert();
|
|
@@ -16,7 +16,7 @@ export function worldHitToLocalVertex(h, mesh) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
const _nm = new THREE.Matrix3();
|
|
19
|
-
/**
|
|
19
|
+
/** Local vertex → world position + world normal (for rendering). */
|
|
20
20
|
export function localVertexToWorld(v, mesh) {
|
|
21
21
|
const p = new THREE.Vector3(v.x, v.y, v.z).applyMatrix4(mesh.matrixWorld);
|
|
22
22
|
_nm.getNormalMatrix(mesh.matrixWorld);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuC/B,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAEjC,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuC/B,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAEjC,sGAAsG;AACtG,MAAM,UAAU,qBAAqB,CACnC,CAAa,EACb,IAAgB;IAEhB,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IACjE,OAAO;QACL,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,EAAE,EAAE,EAAE,CAAC,CAAC;QACR,EAAE,EAAE,EAAE,CAAC,CAAC;QACR,EAAE,EAAE,EAAE,CAAC,CAAC;QACR,SAAS,EAAE,CAAC,CAAC,SAAS;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAEhC,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CAChC,CAAmB,EACnB,IAAgB;IAEhB,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1E,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;IAC5E,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAClB,CAAC"}
|
package/dist/Utils/texture2d.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import { getLut } from "../Loader/copperDicomLoader";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// Loaded as raw strings (?raw) — no GLSL/glslify handler in this app's Vite build, and the
|
|
4
|
+
// 2D texture/volume path that uses these is never exercised by the surface annotator.
|
|
5
|
+
import vert_2d from "../lib/shader/texture2d_vertex.glsl?raw";
|
|
6
|
+
import frag_2d from "../lib/shader/texture2d_frag.glsl?raw";
|
|
5
7
|
let planeWidth = 80;
|
|
6
8
|
let planeHeight = 80;
|
|
7
9
|
// Build a quad from the 4 world-space image-plane corners (preserves real pose).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture2d.js","sourceRoot":"","sources":["../../src/Utils/texture2d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAGrD,OAAO,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"texture2d.js","sourceRoot":"","sources":["../../src/Utils/texture2d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAGrD,2FAA2F;AAC3F,sFAAsF;AACtF,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAC9D,OAAO,OAAO,MAAM,uCAAuC,CAAC;AAE5D,IAAI,UAAU,GAAG,EAAE,CAAC;AACpB,IAAI,WAAW,GAAG,EAAE,CAAC;AAUrB,iFAAiF;AACjF,SAAS,gBAAgB,CAAC,CAAe;IACvC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;IACrC,qCAAqC;IACrC,CAAC,CAAC,YAAY,CACZ,UAAU,EACV,IAAI,KAAK,CAAC,eAAe,CACvB,IAAI,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACxE,CAAC,CACF,CACF,CAAC;IACF,uFAAuF;IACvF,mFAAmF;IACnF,wCAAwC;IACxC,CAAC,CAAC,YAAY,CACZ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B,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAgB,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,SAAS,SAAS,CAAC,MAAc,EAAE,KAAa;QAC9C,YAAY,CAAC,YAAY,GAAG,MAAM,CAAC;QACnC,YAAY,CAAC,WAAW,GAAG,KAAK,CAAC;QACjC,aAAa,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
addEventListener("message", (event) => {
|
|
2
2
|
const data = event.data;
|
|
3
3
|
if (data.type === "reformat") {
|
|
4
|
-
//
|
|
4
|
+
// Run the compute-heavy code inside the Worker
|
|
5
5
|
const masks = restructData(data.masksData, data.len, data.width, data.height);
|
|
6
6
|
const result = {
|
|
7
7
|
masks,
|
|
8
8
|
type: "reformat",
|
|
9
9
|
};
|
|
10
|
-
//
|
|
10
|
+
// Send the computed result back to the main thread
|
|
11
11
|
postMessage(result);
|
|
12
12
|
}
|
|
13
13
|
else if (data.type === "saveBlob") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reformatSaveDataWorker.js","sourceRoot":"","sources":["../../../src/Utils/workers/reformatSaveDataWorker.ts"],"names":[],"mappings":"AAEA,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;QAC5B
|
|
1
|
+
{"version":3,"file":"reformatSaveDataWorker.js","sourceRoot":"","sources":["../../../src/Utils/workers/reformatSaveDataWorker.ts"],"names":[],"mappings":"AAEA,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,I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