@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 CHANGED
@@ -2068,7 +2068,7 @@ function createPanUpdate(camera, controls, keys) {
2068
2068
  const target = controls.target;
2069
2069
  const dist = camera.position.distanceTo(target);
2070
2070
  if (dx || dy) {
2071
- const step = Math.max(dist, 50) * PAN_SPEED;
2071
+ const step = Math.max(dist, 50) * PAN_SPEED * (controls.panSpeed || 1);
2072
2072
  _panRight.setFromMatrixColumn(camera.matrix, 0);
2073
2073
  _panUp.setFromMatrixColumn(camera.matrix, 1);
2074
2074
  _panOffset.set(0, 0, 0).addScaledVector(_panRight, dx * step).addScaledVector(_panUp, dy * step);
@@ -2262,7 +2262,8 @@ function createScene(container, backgroundColor, style, rendererConfig) {
2262
2262
  const flags = {
2263
2263
  is2D: false,
2264
2264
  keyboardMode3D: cameraMode,
2265
- rotateButton: null
2265
+ rotateButton: null,
2266
+ panSpeedBase: 1
2266
2267
  };
2267
2268
  const _wheelOffset = new THREE__namespace.Vector3();
2268
2269
  const onWheel = (e) => {
@@ -2379,6 +2380,8 @@ function applyNavigationMode(state, is2D, nav) {
2379
2380
  controls.touches = left === "pan" ? { ONE: THREE__namespace.TOUCH.PAN, TWO: THREE__namespace.TOUCH.DOLLY_PAN } : { ONE: THREE__namespace.TOUCH.ROTATE, TWO: THREE__namespace.TOUCH.DOLLY_PAN };
2380
2381
  controls.enableZoom = is2D;
2381
2382
  controls.screenSpacePanning = true;
2383
+ state.flags.panSpeedBase = (nav == null ? void 0 : nav.panSpeed) ?? 1;
2384
+ controls.panSpeed = state.flags.panSpeedBase;
2382
2385
  const kb = (nav == null ? void 0 : nav.keyboard) ?? (is2D ? "pan" : state.flags.keyboardMode3D);
2383
2386
  if (kb === "off") {
2384
2387
  keyboard.setEnabled(false);
@@ -3224,7 +3227,29 @@ function NetworkGraph3DInner(props, ref) {
3224
3227
  rendererProp
3225
3228
  );
3226
3229
  sceneRef.current = state;
3230
+ let panBoostAt = 0;
3231
+ let graphRadius = 0;
3227
3232
  const cancelAnim = startAnimationLoop(state, () => {
3233
+ const nowMs = performance.now();
3234
+ if (nowMs - panBoostAt > 400) {
3235
+ panBoostAt = nowMs;
3236
+ const pos = dataRef.current.positions;
3237
+ if (pos) {
3238
+ let maxSq = 0;
3239
+ for (let i = 0; i < pos.length; i += 3) {
3240
+ const sq = pos[i] * pos[i] + pos[i + 1] * pos[i + 1] + pos[i + 2] * pos[i + 2];
3241
+ if (sq > maxSq) maxSq = sq;
3242
+ }
3243
+ graphRadius = Math.sqrt(maxSq);
3244
+ }
3245
+ if (graphRadius > 0) {
3246
+ const dist = state.camera.position.distanceTo(
3247
+ state.controls.target
3248
+ );
3249
+ const boost = Math.min(3, Math.max(1, graphRadius / (3 * dist)));
3250
+ state.controls.panSpeed = state.flags.panSpeedBase * boost;
3251
+ }
3252
+ }
3228
3253
  updateLabels(
3229
3254
  state.labels,
3230
3255
  dataRef.current.nodes,