@lv-x-software-house/x_view 1.2.6-dev.45 → 1.2.6-dev.47

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.js CHANGED
@@ -14403,7 +14403,8 @@ function XViewScene({
14403
14403
  maxAncestryRenderIndex: 0,
14404
14404
  lastRenderedAncestryId: null,
14405
14405
  lastDescriptionLength: 0,
14406
- highlightedNodeId: null
14406
+ highlightedNodeId: null,
14407
+ keysPressed: {}
14407
14408
  });
14408
14409
  const maxReadPanelW = typeof window !== "undefined" ? window.innerWidth * 0.92 : 1200;
14409
14410
  const {
@@ -14574,20 +14575,20 @@ function XViewScene({
14574
14575
  };
14575
14576
  const tweenToTarget = (0, import_react31.useCallback)(
14576
14577
  (target, zoomFactor = 1, forcedDirection = null) => {
14577
- const { camera, controls, tweenGroup } = stateRef.current;
14578
- if (!camera || !controls || !tweenGroup) return;
14578
+ const { camera: sceneCamera, controls: sceneControls, tweenGroup } = stateRef.current;
14579
+ if (!sceneCamera || !sceneControls || !tweenGroup) return;
14579
14580
  const targetPos = target instanceof THREE3.Mesh ? target.getWorldPosition(new THREE3.Vector3()) : target;
14580
- const controlsTween = new import_tween2.Tween(controls.target).to(targetPos, 1500).easing(import_tween2.Easing.Cubic.Out);
14581
+ const controlsTween = new import_tween2.Tween(sceneControls.target).to(targetPos, 1500).easing(import_tween2.Easing.Cubic.Out);
14581
14582
  tweenGroup.add(controlsTween);
14582
14583
  controlsTween.start();
14583
14584
  let offset;
14584
14585
  if (forcedDirection) {
14585
14586
  offset = forcedDirection.clone().normalize().multiplyScalar(x_view_config.CAMERA_ZOOM_DISTANCE / zoomFactor);
14586
14587
  } else {
14587
- offset = camera.position.clone().sub(controls.target).normalize().multiplyScalar(x_view_config.CAMERA_ZOOM_DISTANCE / zoomFactor);
14588
+ offset = sceneCamera.position.clone().sub(sceneControls.target).normalize().multiplyScalar(x_view_config.CAMERA_ZOOM_DISTANCE / zoomFactor);
14588
14589
  }
14589
14590
  const targetCameraPos = targetPos.clone().add(offset);
14590
- const cameraTween = new import_tween2.Tween(camera.position).to(targetCameraPos, 1500).easing(import_tween2.Easing.Cubic.Out);
14591
+ const cameraTween = new import_tween2.Tween(sceneCamera.position).to(targetCameraPos, 1500).easing(import_tween2.Easing.Cubic.Out);
14591
14592
  tweenGroup.add(cameraTween);
14592
14593
  cameraTween.start();
14593
14594
  },
@@ -15333,14 +15334,14 @@ function XViewScene({
15333
15334
  });
15334
15335
  });
15335
15336
  if (questCount > 0) {
15336
- const { camera, controls } = stateRef.current;
15337
+ const { camera: sceneCamera, controls: sceneControls } = stateRef.current;
15337
15338
  const centerX = sumX / questCount;
15338
15339
  const centerY = sumY / questCount;
15339
15340
  const targetFocus = new THREE3.Vector3(centerX, centerY, 0);
15340
- const targetTween = new import_tween2.Tween(controls.target).to({ x: targetFocus.x, y: targetFocus.y, z: targetFocus.z }, 1500).easing(import_tween2.Easing.Cubic.InOut);
15341
+ const targetTween = new import_tween2.Tween(sceneControls.target).to({ x: targetFocus.x, y: targetFocus.y, z: targetFocus.z }, 1500).easing(import_tween2.Easing.Cubic.InOut);
15341
15342
  tweenGroup.add(targetTween);
15342
15343
  targetTween.start();
15343
- const camTween = new import_tween2.Tween(camera.position).to({ x: targetFocus.x, y: targetFocus.y, z: 140 }, 1500).easing(import_tween2.Easing.Cubic.InOut);
15344
+ const camTween = new import_tween2.Tween(sceneCamera.position).to({ x: targetFocus.x, y: targetFocus.y, z: 140 }, 1500).easing(import_tween2.Easing.Cubic.InOut);
15344
15345
  tweenGroup.add(camTween);
15345
15346
  camTween.start();
15346
15347
  }
@@ -16020,6 +16021,28 @@ function XViewScene({
16020
16021
  ancestryData: ancestryDataRef.current
16021
16022
  });
16022
16023
  (_b2 = stateRef.current.tweenGroup) == null ? void 0 : _b2.update(time);
16024
+ const { keysPressed, controls: sceneControls, camera: sceneCamera } = stateRef.current;
16025
+ if (sceneControls && keysPressed) {
16026
+ const panSpeed = 0.8;
16027
+ const rotateSpeed = 0.025;
16028
+ const zoomSpeed = 1.025;
16029
+ const isShift = !!keysPressed["shiftKey"];
16030
+ const isCtrl = !!keysPressed["ctrlKey"];
16031
+ if (isCtrl) {
16032
+ if (keysPressed["ArrowLeft"]) sceneControls._rotateLeft(rotateSpeed);
16033
+ if (keysPressed["ArrowRight"]) sceneControls._rotateLeft(-rotateSpeed);
16034
+ if (keysPressed["ArrowUp"]) sceneControls._rotateUp(rotateSpeed);
16035
+ if (keysPressed["ArrowDown"]) sceneControls._rotateUp(-rotateSpeed);
16036
+ } else if (isShift) {
16037
+ if (keysPressed["ArrowUp"]) sceneControls._dollyIn(zoomSpeed);
16038
+ if (keysPressed["ArrowDown"]) sceneControls._dollyOut(zoomSpeed);
16039
+ } else {
16040
+ if (keysPressed["ArrowLeft"]) sceneControls.panLeft(panSpeed, sceneCamera.matrix);
16041
+ if (keysPressed["ArrowRight"]) sceneControls.panLeft(-panSpeed, sceneCamera.matrix);
16042
+ if (keysPressed["ArrowUp"]) sceneControls.panUp(panSpeed, sceneCamera.matrix);
16043
+ if (keysPressed["ArrowDown"]) sceneControls.panUp(-panSpeed, sceneCamera.matrix);
16044
+ }
16045
+ }
16023
16046
  stateRef.current.controls.update();
16024
16047
  renderer.autoClear = false;
16025
16048
  renderer.clear();
@@ -18495,9 +18518,9 @@ function XViewScene({
18495
18518
  if (isUiClear) {
18496
18519
  const isView = ((_c2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _c2.toLowerCase()) === "view";
18497
18520
  if (!isView) return;
18498
- const { graphGroup, glowTexture, controls, nodeObjects } = stateRef.current;
18521
+ const { graphGroup, glowTexture, controls: sceneControls, nodeObjects } = stateRef.current;
18499
18522
  if (graphGroup) {
18500
- let ghostPosition = controls.target.clone();
18523
+ let ghostPosition = sceneControls.target.clone();
18501
18524
  const existingNodes = Object.values(nodeObjects);
18502
18525
  let isOccupied = true;
18503
18526
  let radius = 18;
@@ -18509,9 +18532,9 @@ function XViewScene({
18509
18532
  (mesh) => mesh.position.distanceTo(ghostPosition) < MIN_CLEARANCE
18510
18533
  );
18511
18534
  if (isOccupied) {
18512
- ghostPosition.x = controls.target.x + Math.cos(angle) * radius;
18513
- ghostPosition.y = controls.target.y + (Math.random() - 0.5) * 8;
18514
- ghostPosition.z = controls.target.z + Math.sin(angle) * radius;
18535
+ ghostPosition.x = sceneControls.target.x + Math.cos(angle) * radius;
18536
+ ghostPosition.y = sceneControls.target.y + (Math.random() - 0.5) * 8;
18537
+ ghostPosition.z = sceneControls.target.z + Math.sin(angle) * radius;
18515
18538
  angle += Math.PI / 3;
18516
18539
  radius += 2.5;
18517
18540
  attempts++;
@@ -18555,35 +18578,26 @@ function XViewScene({
18555
18578
  if (isArrowKey) {
18556
18579
  const isUiClear = !stateRef.current.creation.isActive && !stateRef.current.connection.isActive && !stateRef.current.relink.isActive && !stateRef.current.ancestry.isActive && !((_d2 = context.versionMode) == null ? void 0 : _d2.isActive) && !contextMenu.visible && !multiContextMenu.visible && !relationshipMenu.visible && !readingMode.isActive && !isImportModalOpen && !isBoardsOpen && !isSidebarOpen && !isMilestoneManagerOpen && !detailsNode && !detailsLink && !ancestryLinkDetails && !imageViewer.visible && !editingAncestryRel.visible && !questMode.isActive;
18557
18580
  if (isUiClear) {
18558
- const { controls } = stateRef.current;
18559
- if (controls) {
18560
- event.preventDefault();
18561
- const rotateAngle = Math.PI / 36;
18562
- const zoomScale = 1.1;
18563
- if (event.key === "ArrowLeft") {
18564
- controls._rotateLeft(rotateAngle);
18565
- } else if (event.key === "ArrowRight") {
18566
- controls._rotateLeft(-rotateAngle);
18567
- } else if (event.key === "ArrowUp") {
18568
- if (event.shiftKey) {
18569
- controls._dollyIn(zoomScale);
18570
- } else {
18571
- controls._rotateUp(rotateAngle);
18572
- }
18573
- } else if (event.key === "ArrowDown") {
18574
- if (event.shiftKey) {
18575
- controls._dollyOut(zoomScale);
18576
- } else {
18577
- controls._rotateUp(-rotateAngle);
18578
- }
18579
- }
18580
- controls.update();
18581
- }
18581
+ event.preventDefault();
18582
+ stateRef.current.keysPressed[event.key] = true;
18583
+ stateRef.current.keysPressed["shiftKey"] = event.shiftKey;
18584
+ stateRef.current.keysPressed["ctrlKey"] = event.ctrlKey || event.metaKey;
18582
18585
  }
18583
18586
  }
18584
18587
  }
18588
+ function handleKeyUp(event) {
18589
+ if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key)) {
18590
+ stateRef.current.keysPressed[event.key] = false;
18591
+ }
18592
+ stateRef.current.keysPressed["shiftKey"] = event.shiftKey;
18593
+ stateRef.current.keysPressed["ctrlKey"] = event.ctrlKey || event.metaKey;
18594
+ }
18585
18595
  window.addEventListener("keydown", handleKeyDown);
18586
- return () => window.removeEventListener("keydown", handleKeyDown);
18596
+ window.addEventListener("keyup", handleKeyUp);
18597
+ return () => {
18598
+ window.removeEventListener("keydown", handleKeyDown);
18599
+ window.removeEventListener("keyup", handleKeyUp);
18600
+ };
18587
18601
  }, [
18588
18602
  contextMenu.visible,
18589
18603
  multiContextMenu.visible,
package/dist/index.mjs CHANGED
@@ -14459,7 +14459,8 @@ function XViewScene({
14459
14459
  maxAncestryRenderIndex: 0,
14460
14460
  lastRenderedAncestryId: null,
14461
14461
  lastDescriptionLength: 0,
14462
- highlightedNodeId: null
14462
+ highlightedNodeId: null,
14463
+ keysPressed: {}
14463
14464
  });
14464
14465
  const maxReadPanelW = typeof window !== "undefined" ? window.innerWidth * 0.92 : 1200;
14465
14466
  const {
@@ -14630,20 +14631,20 @@ function XViewScene({
14630
14631
  };
14631
14632
  const tweenToTarget = useCallback6(
14632
14633
  (target, zoomFactor = 1, forcedDirection = null) => {
14633
- const { camera, controls, tweenGroup } = stateRef.current;
14634
- if (!camera || !controls || !tweenGroup) return;
14634
+ const { camera: sceneCamera, controls: sceneControls, tweenGroup } = stateRef.current;
14635
+ if (!sceneCamera || !sceneControls || !tweenGroup) return;
14635
14636
  const targetPos = target instanceof THREE3.Mesh ? target.getWorldPosition(new THREE3.Vector3()) : target;
14636
- const controlsTween = new Tween2(controls.target).to(targetPos, 1500).easing(Easing2.Cubic.Out);
14637
+ const controlsTween = new Tween2(sceneControls.target).to(targetPos, 1500).easing(Easing2.Cubic.Out);
14637
14638
  tweenGroup.add(controlsTween);
14638
14639
  controlsTween.start();
14639
14640
  let offset;
14640
14641
  if (forcedDirection) {
14641
14642
  offset = forcedDirection.clone().normalize().multiplyScalar(x_view_config.CAMERA_ZOOM_DISTANCE / zoomFactor);
14642
14643
  } else {
14643
- offset = camera.position.clone().sub(controls.target).normalize().multiplyScalar(x_view_config.CAMERA_ZOOM_DISTANCE / zoomFactor);
14644
+ offset = sceneCamera.position.clone().sub(sceneControls.target).normalize().multiplyScalar(x_view_config.CAMERA_ZOOM_DISTANCE / zoomFactor);
14644
14645
  }
14645
14646
  const targetCameraPos = targetPos.clone().add(offset);
14646
- const cameraTween = new Tween2(camera.position).to(targetCameraPos, 1500).easing(Easing2.Cubic.Out);
14647
+ const cameraTween = new Tween2(sceneCamera.position).to(targetCameraPos, 1500).easing(Easing2.Cubic.Out);
14647
14648
  tweenGroup.add(cameraTween);
14648
14649
  cameraTween.start();
14649
14650
  },
@@ -15389,14 +15390,14 @@ function XViewScene({
15389
15390
  });
15390
15391
  });
15391
15392
  if (questCount > 0) {
15392
- const { camera, controls } = stateRef.current;
15393
+ const { camera: sceneCamera, controls: sceneControls } = stateRef.current;
15393
15394
  const centerX = sumX / questCount;
15394
15395
  const centerY = sumY / questCount;
15395
15396
  const targetFocus = new THREE3.Vector3(centerX, centerY, 0);
15396
- const targetTween = new Tween2(controls.target).to({ x: targetFocus.x, y: targetFocus.y, z: targetFocus.z }, 1500).easing(Easing2.Cubic.InOut);
15397
+ const targetTween = new Tween2(sceneControls.target).to({ x: targetFocus.x, y: targetFocus.y, z: targetFocus.z }, 1500).easing(Easing2.Cubic.InOut);
15397
15398
  tweenGroup.add(targetTween);
15398
15399
  targetTween.start();
15399
- const camTween = new Tween2(camera.position).to({ x: targetFocus.x, y: targetFocus.y, z: 140 }, 1500).easing(Easing2.Cubic.InOut);
15400
+ const camTween = new Tween2(sceneCamera.position).to({ x: targetFocus.x, y: targetFocus.y, z: 140 }, 1500).easing(Easing2.Cubic.InOut);
15400
15401
  tweenGroup.add(camTween);
15401
15402
  camTween.start();
15402
15403
  }
@@ -16076,6 +16077,28 @@ function XViewScene({
16076
16077
  ancestryData: ancestryDataRef.current
16077
16078
  });
16078
16079
  (_b2 = stateRef.current.tweenGroup) == null ? void 0 : _b2.update(time);
16080
+ const { keysPressed, controls: sceneControls, camera: sceneCamera } = stateRef.current;
16081
+ if (sceneControls && keysPressed) {
16082
+ const panSpeed = 0.8;
16083
+ const rotateSpeed = 0.025;
16084
+ const zoomSpeed = 1.025;
16085
+ const isShift = !!keysPressed["shiftKey"];
16086
+ const isCtrl = !!keysPressed["ctrlKey"];
16087
+ if (isCtrl) {
16088
+ if (keysPressed["ArrowLeft"]) sceneControls._rotateLeft(rotateSpeed);
16089
+ if (keysPressed["ArrowRight"]) sceneControls._rotateLeft(-rotateSpeed);
16090
+ if (keysPressed["ArrowUp"]) sceneControls._rotateUp(rotateSpeed);
16091
+ if (keysPressed["ArrowDown"]) sceneControls._rotateUp(-rotateSpeed);
16092
+ } else if (isShift) {
16093
+ if (keysPressed["ArrowUp"]) sceneControls._dollyIn(zoomSpeed);
16094
+ if (keysPressed["ArrowDown"]) sceneControls._dollyOut(zoomSpeed);
16095
+ } else {
16096
+ if (keysPressed["ArrowLeft"]) sceneControls.panLeft(panSpeed, sceneCamera.matrix);
16097
+ if (keysPressed["ArrowRight"]) sceneControls.panLeft(-panSpeed, sceneCamera.matrix);
16098
+ if (keysPressed["ArrowUp"]) sceneControls.panUp(panSpeed, sceneCamera.matrix);
16099
+ if (keysPressed["ArrowDown"]) sceneControls.panUp(-panSpeed, sceneCamera.matrix);
16100
+ }
16101
+ }
16079
16102
  stateRef.current.controls.update();
16080
16103
  renderer.autoClear = false;
16081
16104
  renderer.clear();
@@ -18551,9 +18574,9 @@ function XViewScene({
18551
18574
  if (isUiClear) {
18552
18575
  const isView = ((_c2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _c2.toLowerCase()) === "view";
18553
18576
  if (!isView) return;
18554
- const { graphGroup, glowTexture, controls, nodeObjects } = stateRef.current;
18577
+ const { graphGroup, glowTexture, controls: sceneControls, nodeObjects } = stateRef.current;
18555
18578
  if (graphGroup) {
18556
- let ghostPosition = controls.target.clone();
18579
+ let ghostPosition = sceneControls.target.clone();
18557
18580
  const existingNodes = Object.values(nodeObjects);
18558
18581
  let isOccupied = true;
18559
18582
  let radius = 18;
@@ -18565,9 +18588,9 @@ function XViewScene({
18565
18588
  (mesh) => mesh.position.distanceTo(ghostPosition) < MIN_CLEARANCE
18566
18589
  );
18567
18590
  if (isOccupied) {
18568
- ghostPosition.x = controls.target.x + Math.cos(angle) * radius;
18569
- ghostPosition.y = controls.target.y + (Math.random() - 0.5) * 8;
18570
- ghostPosition.z = controls.target.z + Math.sin(angle) * radius;
18591
+ ghostPosition.x = sceneControls.target.x + Math.cos(angle) * radius;
18592
+ ghostPosition.y = sceneControls.target.y + (Math.random() - 0.5) * 8;
18593
+ ghostPosition.z = sceneControls.target.z + Math.sin(angle) * radius;
18571
18594
  angle += Math.PI / 3;
18572
18595
  radius += 2.5;
18573
18596
  attempts++;
@@ -18611,35 +18634,26 @@ function XViewScene({
18611
18634
  if (isArrowKey) {
18612
18635
  const isUiClear = !stateRef.current.creation.isActive && !stateRef.current.connection.isActive && !stateRef.current.relink.isActive && !stateRef.current.ancestry.isActive && !((_d2 = context.versionMode) == null ? void 0 : _d2.isActive) && !contextMenu.visible && !multiContextMenu.visible && !relationshipMenu.visible && !readingMode.isActive && !isImportModalOpen && !isBoardsOpen && !isSidebarOpen && !isMilestoneManagerOpen && !detailsNode && !detailsLink && !ancestryLinkDetails && !imageViewer.visible && !editingAncestryRel.visible && !questMode.isActive;
18613
18636
  if (isUiClear) {
18614
- const { controls } = stateRef.current;
18615
- if (controls) {
18616
- event.preventDefault();
18617
- const rotateAngle = Math.PI / 36;
18618
- const zoomScale = 1.1;
18619
- if (event.key === "ArrowLeft") {
18620
- controls._rotateLeft(rotateAngle);
18621
- } else if (event.key === "ArrowRight") {
18622
- controls._rotateLeft(-rotateAngle);
18623
- } else if (event.key === "ArrowUp") {
18624
- if (event.shiftKey) {
18625
- controls._dollyIn(zoomScale);
18626
- } else {
18627
- controls._rotateUp(rotateAngle);
18628
- }
18629
- } else if (event.key === "ArrowDown") {
18630
- if (event.shiftKey) {
18631
- controls._dollyOut(zoomScale);
18632
- } else {
18633
- controls._rotateUp(-rotateAngle);
18634
- }
18635
- }
18636
- controls.update();
18637
- }
18637
+ event.preventDefault();
18638
+ stateRef.current.keysPressed[event.key] = true;
18639
+ stateRef.current.keysPressed["shiftKey"] = event.shiftKey;
18640
+ stateRef.current.keysPressed["ctrlKey"] = event.ctrlKey || event.metaKey;
18638
18641
  }
18639
18642
  }
18640
18643
  }
18644
+ function handleKeyUp(event) {
18645
+ if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key)) {
18646
+ stateRef.current.keysPressed[event.key] = false;
18647
+ }
18648
+ stateRef.current.keysPressed["shiftKey"] = event.shiftKey;
18649
+ stateRef.current.keysPressed["ctrlKey"] = event.ctrlKey || event.metaKey;
18650
+ }
18641
18651
  window.addEventListener("keydown", handleKeyDown);
18642
- return () => window.removeEventListener("keydown", handleKeyDown);
18652
+ window.addEventListener("keyup", handleKeyUp);
18653
+ return () => {
18654
+ window.removeEventListener("keydown", handleKeyDown);
18655
+ window.removeEventListener("keyup", handleKeyUp);
18656
+ };
18643
18657
  }, [
18644
18658
  contextMenu.visible,
18645
18659
  multiContextMenu.visible,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lv-x-software-house/x_view",
3
- "version": "1.2.6-dev.45",
3
+ "version": "1.2.6-dev.47",
4
4
  "description": "Pacote privado contendo os componentes e lógica de renderização 3D do X View.",
5
5
  "author": "iv.x - Engenharia de Software - ivxsoftwarehouse@gmail.com",
6
6
  "license": "UNLICENSED",