@fusefactory/fuse-three-forcegraph 1.0.6 → 1.0.8
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/index.d.mts +2 -0
- package/dist/index.mjs +23 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -74,10 +74,12 @@ declare class CameraController {
|
|
|
74
74
|
camera: THREE.PerspectiveCamera;
|
|
75
75
|
controls: CameraControls;
|
|
76
76
|
private sceneBounds;
|
|
77
|
+
private domElement;
|
|
77
78
|
private autorotateEnabled;
|
|
78
79
|
private autorotateSpeed;
|
|
79
80
|
private userIsActive;
|
|
80
81
|
constructor(domelement: HTMLElement, config?: CameraConfig);
|
|
82
|
+
private handleWheel;
|
|
81
83
|
private setupDefaultControls;
|
|
82
84
|
/**
|
|
83
85
|
* Set camera control mode
|
package/dist/index.mjs
CHANGED
|
@@ -927,15 +927,30 @@ var CameraController = class {
|
|
|
927
927
|
camera;
|
|
928
928
|
controls;
|
|
929
929
|
sceneBounds = null;
|
|
930
|
+
domElement;
|
|
930
931
|
autorotateEnabled = false;
|
|
931
932
|
autorotateSpeed = .5;
|
|
932
933
|
userIsActive = true;
|
|
933
934
|
constructor(domelement, config) {
|
|
935
|
+
this.domElement = domelement;
|
|
934
936
|
this.camera = new THREE.PerspectiveCamera(config?.fov ?? 50, config?.aspect ?? window.innerWidth / window.innerHeight, config?.near ?? 1e-5, config?.far ?? 1e4);
|
|
935
937
|
if (config?.position) this.camera.position.copy(config.position);
|
|
936
938
|
else this.camera.position.set(0, 0, 2);
|
|
937
939
|
this.controls = new CameraControls(this.camera, domelement);
|
|
938
940
|
this.setupDefaultControls(config);
|
|
941
|
+
this.handleWheel = this.handleWheel.bind(this);
|
|
942
|
+
domelement.addEventListener("wheel", this.handleWheel, {
|
|
943
|
+
capture: true,
|
|
944
|
+
passive: true
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
handleWheel() {
|
|
948
|
+
if (!this.controls.dollyToCursor) return;
|
|
949
|
+
const c = this.controls;
|
|
950
|
+
if (c._spherical && c._sphericalEnd) {
|
|
951
|
+
c._spherical.theta = c._sphericalEnd.theta;
|
|
952
|
+
c._spherical.phi = c._sphericalEnd.phi;
|
|
953
|
+
}
|
|
939
954
|
}
|
|
940
955
|
setupDefaultControls(config) {
|
|
941
956
|
this.controls.smoothTime = .8;
|
|
@@ -1014,6 +1029,7 @@ var CameraController = class {
|
|
|
1014
1029
|
* Animate camera to look at a specific target from a specific position
|
|
1015
1030
|
*/
|
|
1016
1031
|
async setLookAt(position, target, enableTransition = true) {
|
|
1032
|
+
this.controls.normalizeRotations();
|
|
1017
1033
|
await this.controls.setLookAt(position.x, position.y, position.z, target.x, target.y, target.z, enableTransition);
|
|
1018
1034
|
}
|
|
1019
1035
|
/**
|
|
@@ -1043,6 +1059,7 @@ var CameraController = class {
|
|
|
1043
1059
|
* Dispose camera manager and clean up
|
|
1044
1060
|
*/
|
|
1045
1061
|
dispose() {
|
|
1062
|
+
this.domElement.removeEventListener("wheel", this.handleWheel, { capture: true });
|
|
1046
1063
|
this.controls.dispose();
|
|
1047
1064
|
}
|
|
1048
1065
|
/**
|
|
@@ -2290,10 +2307,7 @@ var NodesRenderer = class {
|
|
|
2290
2307
|
const radii = new Float32Array(totalTexels);
|
|
2291
2308
|
const colors = new Float32Array(totalTexels * 4);
|
|
2292
2309
|
const fovRadians = 75 * Math.PI / 180;
|
|
2293
|
-
const
|
|
2294
|
-
const REFERENCE_HEIGHT = 1080;
|
|
2295
|
-
const REFERENCE_DPR = 1;
|
|
2296
|
-
const pixelToWorldRatio = viewHeightAtDistance1 / REFERENCE_HEIGHT;
|
|
2310
|
+
const pixelToWorldRatio = 2 * Math.tan(fovRadians / 2) / this.renderer.getDrawingBufferSize(new THREE.Vector2()).y;
|
|
2297
2311
|
nodes.forEach((node, i) => {
|
|
2298
2312
|
const style = styleRegistry.getNodeStyle(node.category);
|
|
2299
2313
|
colorBuffer[i * 3] = style.color.r;
|
|
@@ -2305,7 +2319,7 @@ var NodesRenderer = class {
|
|
|
2305
2319
|
pointIndices[i * 2] = x;
|
|
2306
2320
|
pointIndices[i * 2 + 1] = y;
|
|
2307
2321
|
alphaIndex[i] = i;
|
|
2308
|
-
radii[i] = style.size *
|
|
2322
|
+
radii[i] = style.size * window.devicePixelRatio * pixelToWorldRatio / 2;
|
|
2309
2323
|
colors[i * 4] = style.color.r;
|
|
2310
2324
|
colors[i * 4 + 1] = style.color.g;
|
|
2311
2325
|
colors[i * 4 + 2] = style.color.b;
|
|
@@ -3284,6 +3298,7 @@ var ForceSimulation = class {
|
|
|
3284
3298
|
alphaDecay: .01,
|
|
3285
3299
|
deltaTime: .016,
|
|
3286
3300
|
spaceSize: 1e3,
|
|
3301
|
+
maxVelocity: 10,
|
|
3287
3302
|
is3D: true
|
|
3288
3303
|
};
|
|
3289
3304
|
this.velocityCarryPass = new VelocityCarryPass();
|
|
@@ -3407,6 +3422,7 @@ var ForceSimulation = class {
|
|
|
3407
3422
|
*/
|
|
3408
3423
|
fixedStep() {
|
|
3409
3424
|
const context = this.createContext();
|
|
3425
|
+
this.simulationBuffers.swapVelocities();
|
|
3410
3426
|
const currentVelocityTarget = this.simulationBuffers.getCurrentVelocityTarget();
|
|
3411
3427
|
if (currentVelocityTarget) {
|
|
3412
3428
|
this.renderer.setRenderTarget(currentVelocityTarget);
|
|
@@ -4246,6 +4262,7 @@ var Engine = class {
|
|
|
4246
4262
|
Object.assign(this.forceSimulation.config, preset.force);
|
|
4247
4263
|
this.forceSimulation.reheat();
|
|
4248
4264
|
}
|
|
4265
|
+
this.graphScene.camera.controls.normalizeRotations();
|
|
4249
4266
|
if (preset.camera) {
|
|
4250
4267
|
const { position, target, zoom, transitionDuration, mode, minDistance, maxDistance, boundary } = preset.camera;
|
|
4251
4268
|
if (mode) this.graphScene.camera.setMode(mode);
|
|
@@ -4257,7 +4274,7 @@ var Engine = class {
|
|
|
4257
4274
|
if (boundary) {
|
|
4258
4275
|
const box = new THREE.Box3(new THREE.Vector3(boundary.min.x, boundary.min.y, boundary.min.z), new THREE.Vector3(boundary.max.x, boundary.max.y, boundary.max.z));
|
|
4259
4276
|
this.graphScene.camera.setBoundary(box);
|
|
4260
|
-
}
|
|
4277
|
+
}
|
|
4261
4278
|
if (position && target) {
|
|
4262
4279
|
const posVec = new THREE.Vector3(position.x, position.y, position.z);
|
|
4263
4280
|
const targetVec = new THREE.Vector3(target.x, target.y, target.z);
|
|
@@ -4274,10 +4291,6 @@ var Engine = class {
|
|
|
4274
4291
|
this.forceSimulation.reheat();
|
|
4275
4292
|
}
|
|
4276
4293
|
}
|
|
4277
|
-
if (this.forceSimulation.config.enableRadial) {
|
|
4278
|
-
const rootCategories = preset.radial?.rootCategories ?? ["root"];
|
|
4279
|
-
this.computeRadialDepths(rootCategories);
|
|
4280
|
-
}
|
|
4281
4294
|
if (preset.links) {
|
|
4282
4295
|
const linkRenderer = this.graphScene.getLinkRenderer();
|
|
4283
4296
|
if (linkRenderer) linkRenderer.setOptions({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusefactory/fuse-three-forcegraph",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"packageManager": "pnpm@10.6.4",
|
|
6
6
|
"description": "A high-performance GPU-accelerated force-directed graph visualization library built with Three.js. Features a modular pass-based architecture for flexible and extensible force simulations.",
|
|
7
7
|
"author": "Matteo Amerena",
|