@cocorof/graphier 1.4.4 → 1.4.5
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.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -185,6 +185,13 @@ export declare interface NavigationConfig {
|
|
|
185
185
|
* (default: cameraMode in 3D, "pan" in 2D)
|
|
186
186
|
*/
|
|
187
187
|
keyboard?: "fly" | "orbit" | "pan" | "off";
|
|
188
|
+
/**
|
|
189
|
+
* Base drag-pan speed multiplier (default: 1 = cursor-accurate at the
|
|
190
|
+
* orbit-target depth). On top of this, pan automatically accelerates
|
|
191
|
+
* up to 3x as the camera zooms deep into the graph — otherwise
|
|
192
|
+
* traversing a large graph while zoomed in takes dozens of drags.
|
|
193
|
+
*/
|
|
194
|
+
panSpeed?: number;
|
|
188
195
|
}
|
|
189
196
|
|
|
190
197
|
export declare const neon: ThemeConfig;
|
package/dist/index.js
CHANGED
|
@@ -2050,7 +2050,7 @@ function createPanUpdate(camera, controls, keys) {
|
|
|
2050
2050
|
const target = controls.target;
|
|
2051
2051
|
const dist = camera.position.distanceTo(target);
|
|
2052
2052
|
if (dx || dy) {
|
|
2053
|
-
const step = Math.max(dist, 50) * PAN_SPEED;
|
|
2053
|
+
const step = Math.max(dist, 50) * PAN_SPEED * (controls.panSpeed || 1);
|
|
2054
2054
|
_panRight.setFromMatrixColumn(camera.matrix, 0);
|
|
2055
2055
|
_panUp.setFromMatrixColumn(camera.matrix, 1);
|
|
2056
2056
|
_panOffset.set(0, 0, 0).addScaledVector(_panRight, dx * step).addScaledVector(_panUp, dy * step);
|
|
@@ -2244,7 +2244,8 @@ function createScene(container, backgroundColor, style, rendererConfig) {
|
|
|
2244
2244
|
const flags = {
|
|
2245
2245
|
is2D: false,
|
|
2246
2246
|
keyboardMode3D: cameraMode,
|
|
2247
|
-
rotateButton: null
|
|
2247
|
+
rotateButton: null,
|
|
2248
|
+
panSpeedBase: 1
|
|
2248
2249
|
};
|
|
2249
2250
|
const _wheelOffset = new THREE.Vector3();
|
|
2250
2251
|
const onWheel = (e) => {
|
|
@@ -2361,6 +2362,8 @@ function applyNavigationMode(state, is2D, nav) {
|
|
|
2361
2362
|
controls.touches = left === "pan" ? { ONE: THREE.TOUCH.PAN, TWO: THREE.TOUCH.DOLLY_PAN } : { ONE: THREE.TOUCH.ROTATE, TWO: THREE.TOUCH.DOLLY_PAN };
|
|
2362
2363
|
controls.enableZoom = is2D;
|
|
2363
2364
|
controls.screenSpacePanning = true;
|
|
2365
|
+
state.flags.panSpeedBase = (nav == null ? void 0 : nav.panSpeed) ?? 1;
|
|
2366
|
+
controls.panSpeed = state.flags.panSpeedBase;
|
|
2364
2367
|
const kb = (nav == null ? void 0 : nav.keyboard) ?? (is2D ? "pan" : state.flags.keyboardMode3D);
|
|
2365
2368
|
if (kb === "off") {
|
|
2366
2369
|
keyboard.setEnabled(false);
|
|
@@ -3206,7 +3209,29 @@ function NetworkGraph3DInner(props, ref) {
|
|
|
3206
3209
|
rendererProp
|
|
3207
3210
|
);
|
|
3208
3211
|
sceneRef.current = state;
|
|
3212
|
+
let panBoostAt = 0;
|
|
3213
|
+
let graphRadius = 0;
|
|
3209
3214
|
const cancelAnim = startAnimationLoop(state, () => {
|
|
3215
|
+
const nowMs = performance.now();
|
|
3216
|
+
if (nowMs - panBoostAt > 400) {
|
|
3217
|
+
panBoostAt = nowMs;
|
|
3218
|
+
const pos = dataRef.current.positions;
|
|
3219
|
+
if (pos) {
|
|
3220
|
+
let maxSq = 0;
|
|
3221
|
+
for (let i = 0; i < pos.length; i += 3) {
|
|
3222
|
+
const sq = pos[i] * pos[i] + pos[i + 1] * pos[i + 1] + pos[i + 2] * pos[i + 2];
|
|
3223
|
+
if (sq > maxSq) maxSq = sq;
|
|
3224
|
+
}
|
|
3225
|
+
graphRadius = Math.sqrt(maxSq);
|
|
3226
|
+
}
|
|
3227
|
+
if (graphRadius > 0) {
|
|
3228
|
+
const dist = state.camera.position.distanceTo(
|
|
3229
|
+
state.controls.target
|
|
3230
|
+
);
|
|
3231
|
+
const boost = Math.min(3, Math.max(1, graphRadius / (3 * dist)));
|
|
3232
|
+
state.controls.panSpeed = state.flags.panSpeedBase * boost;
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3210
3235
|
updateLabels(
|
|
3211
3236
|
state.labels,
|
|
3212
3237
|
dataRef.current.nodes,
|