copper3d 3.5.0 → 3.6.0
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/Scene/copperScene.d.ts +12 -0
- package/dist/Scene/copperScene.js +38 -44
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
- package/dist/Utils/surfaceAnnotation/MeshGraph.js +198 -0
- package/dist/Utils/surfaceAnnotation/MeshGraph.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +103 -0
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js +402 -0
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
- package/dist/Utils/surfaceAnnotation/annotationStore.js +105 -0
- package/dist/Utils/surfaceAnnotation/annotationStore.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
- package/dist/Utils/surfaceAnnotation/contourRender.js +57 -0
- package/dist/Utils/surfaceAnnotation/contourRender.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
- package/dist/Utils/surfaceAnnotation/geodesicContour.js +43 -0
- package/dist/Utils/surfaceAnnotation/geodesicContour.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/index.d.ts +3 -0
- package/dist/Utils/surfaceAnnotation/index.js +2 -0
- package/dist/Utils/surfaceAnnotation/index.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
- package/dist/Utils/surfaceAnnotation/pointMarkers.js +16 -0
- package/dist/Utils/surfaceAnnotation/pointMarkers.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
- package/dist/Utils/surfaceAnnotation/raycastSurface.js +27 -0
- package/dist/Utils/surfaceAnnotation/raycastSurface.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/strokeContour.d.ts +19 -0
- package/dist/Utils/surfaceAnnotation/strokeContour.js +35 -0
- package/dist/Utils/surfaceAnnotation/strokeContour.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/types.d.ts +40 -0
- package/dist/Utils/surfaceAnnotation/types.js +26 -0
- package/dist/Utils/surfaceAnnotation/types.js.map +1 -0
- package/dist/bundle.esm.js +2867 -79
- package/dist/bundle.umd.js +2867 -78
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/types/Scene/copperScene.d.ts +12 -0
- package/dist/types/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
- package/dist/types/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +103 -0
- package/dist/types/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
- package/dist/types/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
- package/dist/types/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
- package/dist/types/Utils/surfaceAnnotation/index.d.ts +3 -0
- package/dist/types/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
- package/dist/types/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
- package/dist/types/Utils/surfaceAnnotation/strokeContour.d.ts +19 -0
- package/dist/types/Utils/surfaceAnnotation/types.d.ts +40 -0
- package/dist/types/index.d.ts +5 -3
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import type { AnnotationVertex } from "./types";
|
|
3
|
+
import { MeshGraph } from "./MeshGraph";
|
|
4
|
+
/**
|
|
5
|
+
* 模式 B(测地线)状态机:逐次点击锚点,相邻锚点之间用 MeshGraph 求最短路径,
|
|
6
|
+
* 拼成一条贴合表面的折线。Enter 结束并可闭合(首尾再求一段)。
|
|
7
|
+
*/
|
|
8
|
+
export declare class GeodesicContour {
|
|
9
|
+
private graph;
|
|
10
|
+
private mesh;
|
|
11
|
+
private anchors;
|
|
12
|
+
private segments;
|
|
13
|
+
constructor(graph: MeshGraph, mesh: THREE.Mesh);
|
|
14
|
+
/** 传入 local 命中点,snap 到最近顶点并对上一锚点求路径。 */
|
|
15
|
+
addAnchor(localHitPoint: THREE.Vector3): void;
|
|
16
|
+
get anchorCount(): number;
|
|
17
|
+
/** 把所有路径顶点(world)+ 法线 拼成折线;closed 时补一段首尾路径。 */
|
|
18
|
+
buildVertices(closed: boolean): AnnotationVertex[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模式 B(测地线)状态机:逐次点击锚点,相邻锚点之间用 MeshGraph 求最短路径,
|
|
3
|
+
* 拼成一条贴合表面的折线。Enter 结束并可闭合(首尾再求一段)。
|
|
4
|
+
*/
|
|
5
|
+
export class GeodesicContour {
|
|
6
|
+
constructor(graph, mesh) {
|
|
7
|
+
this.graph = graph;
|
|
8
|
+
this.mesh = mesh;
|
|
9
|
+
this.anchors = []; // 顶点索引
|
|
10
|
+
this.segments = []; // 相邻锚点间路径(含端点)
|
|
11
|
+
}
|
|
12
|
+
/** 传入 local 命中点,snap 到最近顶点并对上一锚点求路径。 */
|
|
13
|
+
addAnchor(localHitPoint) {
|
|
14
|
+
const v = this.graph.nearestVertex(localHitPoint);
|
|
15
|
+
if (this.anchors.length > 0) {
|
|
16
|
+
const prev = this.anchors[this.anchors.length - 1];
|
|
17
|
+
this.segments.push(this.graph.shortestPath(prev, v));
|
|
18
|
+
}
|
|
19
|
+
this.anchors.push(v);
|
|
20
|
+
}
|
|
21
|
+
get anchorCount() {
|
|
22
|
+
return this.anchors.length;
|
|
23
|
+
}
|
|
24
|
+
/** 把所有路径顶点(world)+ 法线 拼成折线;closed 时补一段首尾路径。 */
|
|
25
|
+
buildVertices(closed) {
|
|
26
|
+
const segs = this.segments.slice();
|
|
27
|
+
if (closed && this.anchors.length > 2) {
|
|
28
|
+
segs.push(this.graph.shortestPath(this.anchors[this.anchors.length - 1], this.anchors[0]));
|
|
29
|
+
}
|
|
30
|
+
const idxPath = [];
|
|
31
|
+
segs.forEach((s, si) => {
|
|
32
|
+
const start = si === 0 ? 0 : 1; // 去重相邻段共享端点
|
|
33
|
+
for (let k = start; k < s.length; k++)
|
|
34
|
+
idxPath.push(s[k]);
|
|
35
|
+
});
|
|
36
|
+
if (idxPath.length === 0 && this.anchors.length === 1) {
|
|
37
|
+
idxPath.push(this.anchors[0]);
|
|
38
|
+
}
|
|
39
|
+
// 图几何即 local 空间,直接产出 local 顶点(渲染时再派生 world)。
|
|
40
|
+
return idxPath.map((i) => this.graph.vertexLocal(i));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=geodesicContour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geodesicContour.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/geodesicContour.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,OAAO,eAAe;IAI1B,YAAoB,KAAgB,EAAU,IAAgB;QAA1C,UAAK,GAAL,KAAK,CAAW;QAAU,SAAI,GAAJ,IAAI,CAAY;QAHtD,YAAO,GAAa,EAAE,CAAC,CAAC,OAAO;QAC/B,aAAQ,GAAe,EAAE,CAAC,CAAC,eAAe;IAEe,CAAC;IAElE,wCAAwC;IACxC,SAAS,CAAC,aAA4B;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAClD,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,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0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Utils/surfaceAnnotation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import type { AnnotationVertex } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 在 local 顶点处生成一个标记小球(fiducial)。local→world 后沿 world 法线略外移,
|
|
5
|
+
* 避免一半埋进表面。radius 由调用方按模型 bbox 缩放传入。
|
|
6
|
+
*/
|
|
7
|
+
export declare function makePointMarker(v: AnnotationVertex, mesh: THREE.Mesh, color: string, radius: number): THREE.Mesh;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { localVertexToWorld } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 在 local 顶点处生成一个标记小球(fiducial)。local→world 后沿 world 法线略外移,
|
|
5
|
+
* 避免一半埋进表面。radius 由调用方按模型 bbox 缩放传入。
|
|
6
|
+
*/
|
|
7
|
+
export function makePointMarker(v, mesh, color, radius) {
|
|
8
|
+
const geo = new THREE.SphereGeometry(radius, 16, 16);
|
|
9
|
+
const mat = new THREE.MeshBasicMaterial({ color });
|
|
10
|
+
const m = new THREE.Mesh(geo, mat);
|
|
11
|
+
const { p, n } = localVertexToWorld(v, mesh);
|
|
12
|
+
m.position.copy(p.addScaledVector(n, radius * 0.5));
|
|
13
|
+
m.renderOrder = 999;
|
|
14
|
+
return m;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=pointMarkers.js.map
|
|
@@ -0,0 +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;;;GAGG;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,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import type { SurfaceHit } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 把屏幕坐标(clientX/Y)投射到 mesh 表面,返回命中点、world-space 法线与 faceIndex。
|
|
5
|
+
* 未命中返回 null。本地实现,不依赖 Copper3D 未导出的 raycast 内部函数。
|
|
6
|
+
*/
|
|
7
|
+
export declare function raycastSurface(camera: THREE.PerspectiveCamera, container: HTMLElement, mesh: THREE.Mesh, clientX: number, clientY: number): SurfaceHit | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
const ray = new THREE.Raycaster();
|
|
3
|
+
const ndc = new THREE.Vector2();
|
|
4
|
+
/**
|
|
5
|
+
* 把屏幕坐标(clientX/Y)投射到 mesh 表面,返回命中点、world-space 法线与 faceIndex。
|
|
6
|
+
* 未命中返回 null。本地实现,不依赖 Copper3D 未导出的 raycast 内部函数。
|
|
7
|
+
*/
|
|
8
|
+
export function raycastSurface(camera, container, mesh, clientX, clientY) {
|
|
9
|
+
var _a;
|
|
10
|
+
const rect = container.getBoundingClientRect();
|
|
11
|
+
ndc.x = ((clientX - rect.left) / rect.width) * 2 - 1;
|
|
12
|
+
ndc.y = -((clientY - rect.top) / rect.height) * 2 + 1;
|
|
13
|
+
ray.setFromCamera(ndc, camera);
|
|
14
|
+
const hits = ray.intersectObject(mesh, false);
|
|
15
|
+
if (hits.length === 0)
|
|
16
|
+
return null;
|
|
17
|
+
const h = hits[0];
|
|
18
|
+
const point = h.point.clone();
|
|
19
|
+
const normal = new THREE.Vector3(0, 0, 1);
|
|
20
|
+
if (h.face) {
|
|
21
|
+
normal.copy(h.face.normal);
|
|
22
|
+
const nm = new THREE.Matrix3().getNormalMatrix(mesh.matrixWorld);
|
|
23
|
+
normal.applyMatrix3(nm).normalize();
|
|
24
|
+
}
|
|
25
|
+
return { point, normal, faceIndex: (_a = h.faceIndex) !== null && _a !== void 0 ? _a : -1 };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=raycastSurface.js.map
|
|
@@ -0,0 +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;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA+B,EAC/B,SAAsB,EACtB,IAAgB,EAChB,OAAe,EACf,OAAe;;IAEf,MAAM,IAAI,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;IAC/C,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,O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* pointermove 时不断 addSample;与上一采样点世界距离 < minGap 的样本丢弃,避免过密。
|
|
6
|
+
* 顶点以 local 存(由 mesh 把世界命中点转 local)。
|
|
7
|
+
*/
|
|
8
|
+
export declare class StrokeContour {
|
|
9
|
+
private minGap;
|
|
10
|
+
private mesh;
|
|
11
|
+
private verts;
|
|
12
|
+
private last;
|
|
13
|
+
private has;
|
|
14
|
+
constructor(minGap: number, mesh: THREE.Mesh);
|
|
15
|
+
begin(): void;
|
|
16
|
+
addSample(hit: SurfaceHit): void;
|
|
17
|
+
get vertices(): AnnotationVertex[];
|
|
18
|
+
end(): AnnotationVertex[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { worldHitToLocalVertex } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 模式 A(自由手绘)一笔的状态机。
|
|
5
|
+
* pointermove 时不断 addSample;与上一采样点世界距离 < minGap 的样本丢弃,避免过密。
|
|
6
|
+
* 顶点以 local 存(由 mesh 把世界命中点转 local)。
|
|
7
|
+
*/
|
|
8
|
+
export class StrokeContour {
|
|
9
|
+
constructor(minGap, mesh) {
|
|
10
|
+
this.minGap = minGap;
|
|
11
|
+
this.mesh = mesh;
|
|
12
|
+
this.verts = [];
|
|
13
|
+
this.last = new THREE.Vector3();
|
|
14
|
+
this.has = false;
|
|
15
|
+
}
|
|
16
|
+
begin() {
|
|
17
|
+
this.verts = [];
|
|
18
|
+
this.has = false;
|
|
19
|
+
}
|
|
20
|
+
addSample(hit) {
|
|
21
|
+
// gap 判定用世界距离(屏幕笔触在世界系采样)
|
|
22
|
+
if (this.has && hit.point.distanceTo(this.last) < this.minGap)
|
|
23
|
+
return;
|
|
24
|
+
this.verts.push(worldHitToLocalVertex(hit, this.mesh));
|
|
25
|
+
this.last.copy(hit.point);
|
|
26
|
+
this.has = true;
|
|
27
|
+
}
|
|
28
|
+
get vertices() {
|
|
29
|
+
return this.verts;
|
|
30
|
+
}
|
|
31
|
+
end() {
|
|
32
|
+
return this.verts;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=strokeContour.js.map
|
|
@@ -0,0 +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;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAKxB,YAAoB,MAAc,EAAU,IAAgB;QAAxC,WAAM,GAAN,MAAM,CAAQ;QAAU,SAAI,GAAJ,IAAI,CAAY;QAJpD,UAAK,GAAuB,EAAE,CAAC;QAC/B,SAAI,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAC3B,QAAG,GAAG,KAAK,CAAC;IAE2C,CAAC;IAEhE,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;IACnB,CAAC;IAED,SAAS,CAAC,GAAe;QACvB,0BAA0B;QAC1B,IAAI,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM;YAAE,OAAO;QACtE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC1B,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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
export type AnnotationMode = "navigate" | "freehand" | "geodesic" | "point";
|
|
3
|
+
export interface SurfaceHit {
|
|
4
|
+
point: THREE.Vector3;
|
|
5
|
+
normal: THREE.Vector3;
|
|
6
|
+
faceIndex: number;
|
|
7
|
+
}
|
|
8
|
+
/** 标注顶点:位置与法线均为 **模型 local 空间**(单一真源,不受相机/摆放影响)。 */
|
|
9
|
+
export interface AnnotationVertex {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z: number;
|
|
13
|
+
nx: number;
|
|
14
|
+
ny: number;
|
|
15
|
+
nz: number;
|
|
16
|
+
faceIndex: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Annotation {
|
|
19
|
+
id: string;
|
|
20
|
+
type: "contour" | "points";
|
|
21
|
+
mode: "freehand" | "geodesic" | null;
|
|
22
|
+
label: string;
|
|
23
|
+
color: string;
|
|
24
|
+
closed: boolean;
|
|
25
|
+
vertices: AnnotationVertex[];
|
|
26
|
+
object3D: THREE.Object3D | null;
|
|
27
|
+
}
|
|
28
|
+
export interface ExportOptions {
|
|
29
|
+
/** 导出坐标空间,默认 "local"(模型空间,可复现、不受相机/摆放影响)。 */
|
|
30
|
+
space?: "local" | "world";
|
|
31
|
+
/** 是否在每个点附带法线 [x,y,z,nx,ny,nz]。 */
|
|
32
|
+
includeNormals?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** 世界系命中点 → local 顶点(位置 worldToLocal,法线用逆变换)。 */
|
|
35
|
+
export declare function worldHitToLocalVertex(h: SurfaceHit, mesh: THREE.Mesh): AnnotationVertex;
|
|
36
|
+
/** local 顶点 → world 位置 + world 法线(供渲染)。 */
|
|
37
|
+
export declare function localVertexToWorld(v: AnnotationVertex, mesh: THREE.Mesh): {
|
|
38
|
+
p: THREE.Vector3;
|
|
39
|
+
n: THREE.Vector3;
|
|
40
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
const _inv = new THREE.Matrix4();
|
|
3
|
+
/** 世界系命中点 → local 顶点(位置 worldToLocal,法线用逆变换)。 */
|
|
4
|
+
export function worldHitToLocalVertex(h, mesh) {
|
|
5
|
+
const lp = mesh.worldToLocal(h.point.clone());
|
|
6
|
+
_inv.copy(mesh.matrixWorld).invert();
|
|
7
|
+
const ln = h.normal.clone().transformDirection(_inv).normalize();
|
|
8
|
+
return {
|
|
9
|
+
x: lp.x,
|
|
10
|
+
y: lp.y,
|
|
11
|
+
z: lp.z,
|
|
12
|
+
nx: ln.x,
|
|
13
|
+
ny: ln.y,
|
|
14
|
+
nz: ln.z,
|
|
15
|
+
faceIndex: h.faceIndex,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const _nm = new THREE.Matrix3();
|
|
19
|
+
/** local 顶点 → world 位置 + world 法线(供渲染)。 */
|
|
20
|
+
export function localVertexToWorld(v, mesh) {
|
|
21
|
+
const p = new THREE.Vector3(v.x, v.y, v.z).applyMatrix4(mesh.matrixWorld);
|
|
22
|
+
_nm.getNormalMatrix(mesh.matrixWorld);
|
|
23
|
+
const n = new THREE.Vector3(v.nx, v.ny, v.nz).applyMatrix3(_nm).normalize();
|
|
24
|
+
return { p, n };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +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,iDAAiD;AACjD,MAAM,UAAU,qBAAqB,CACnC,CAAa,EACb,IAAgB;IAEhB,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C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