local-knowledge-graph 1.10.1 → 1.10.3
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/package.json +1 -1
- package/public/app.js +9 -6
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -298,7 +298,7 @@ function makeRelLine(pa, pb, arc, color, dashed, opacity, dashSize, gapSize) {
|
|
|
298
298
|
return line;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
//
|
|
301
|
+
// 每帧根据节点最新位置刷新弧线几何与标签位置(Sprite 标签贴线、近大远小)
|
|
302
302
|
const _arcDir = new THREE.Vector3(), _arcOff = new THREE.Vector3(), _arcTmp = new THREE.Vector3();
|
|
303
303
|
function updateRelLine(l) {
|
|
304
304
|
if (!l.arc) {
|
|
@@ -307,7 +307,7 @@ function updateRelLine(l) {
|
|
|
307
307
|
posAttr.setXYZ(1, l.b.pos.x, l.b.pos.y, l.b.pos.z);
|
|
308
308
|
posAttr.needsUpdate = true;
|
|
309
309
|
if (l.dashed) l.line.computeLineDistances();
|
|
310
|
-
l.label.position.copy(l.a.pos).add(l.b.pos).multiplyScalar(0.5);
|
|
310
|
+
if (l.label) l.label.position.copy(l.a.pos).add(l.b.pos).multiplyScalar(0.5);
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
313
|
_arcDir.subVectors(l.b.pos, l.a.pos);
|
|
@@ -320,17 +320,19 @@ function updateRelLine(l) {
|
|
|
320
320
|
posAttr.needsUpdate = true;
|
|
321
321
|
if (l.dashed) l.line.computeLineDistances();
|
|
322
322
|
// 标签置于弧顶(t=0.5)外移一点,跟随弧线弯曲
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
323
|
+
if (l.label) {
|
|
324
|
+
arcPoint(_arcTmp, l.a.pos, l.b.pos, _arcDir, _arcOff, 0.5);
|
|
325
|
+
l.label.position.copy(_arcTmp).addScaledVector(_arcOff, 6);
|
|
326
|
+
}
|
|
326
327
|
}
|
|
327
328
|
|
|
329
|
+
// 弧顶标签初始定位(构建时用;此后每帧由 updateRelLine 跟随)
|
|
328
330
|
function setRelLabelPos(lbl, pa, pb, arc) {
|
|
329
331
|
if (!arc) { lbl.position.copy(pa).add(pb).multiplyScalar(0.5); return; }
|
|
330
332
|
const dir = pb.clone().sub(pa);
|
|
331
333
|
const off = arcOffsetVec(dir, arc);
|
|
332
334
|
const p = arcPoint(new THREE.Vector3(), pa, pb, dir, off, 0.5);
|
|
333
|
-
lbl.position.copy(p).
|
|
335
|
+
lbl.position.copy(p).addScaledVector(off, 6);
|
|
334
336
|
}
|
|
335
337
|
|
|
336
338
|
function buildNodeMesh(category) {
|
|
@@ -444,6 +446,7 @@ function rebuildGraph() {
|
|
|
444
446
|
line.userData.relationId = r.id;
|
|
445
447
|
line.userData.baseOpacity = op;
|
|
446
448
|
linkGroup.add(line);
|
|
449
|
+
// 线标注显示具体关系名(如"父子"),线型/颜色仍由大类规定;Sprite 保持贴线与近大远小
|
|
447
450
|
const lbl = makeLabelSprite(r.name, st.css, 24);
|
|
448
451
|
lbl.userData.text = r.name;
|
|
449
452
|
setRelLabelPos(lbl, a.pos, b.pos, arc);
|