move speed control
This commit is contained in:
@@ -116,10 +116,12 @@ function MoveControls3D({
|
|||||||
if (pastedObjects.length > 0 || duplicatedObjects.length > 0 || rotatedObjects.length > 0)
|
if (pastedObjects.length > 0 || duplicatedObjects.length > 0 || rotatedObjects.length > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (keyCombination === "Ctrl" || keyCombination === "Ctrl+Shift" || keyCombination === "Shift") {
|
if (keyCombination !== keyEvent) {
|
||||||
setKeyEvent(keyCombination);
|
if (keyCombination === "Ctrl" || keyCombination === "Ctrl+Shift" || keyCombination === "Shift") {
|
||||||
} else {
|
setKeyEvent(keyCombination);
|
||||||
setKeyEvent("");
|
} else {
|
||||||
|
setKeyEvent("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCombination === "G") {
|
if (keyCombination === "G") {
|
||||||
@@ -204,11 +206,18 @@ function MoveControls3D({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dragOffset) {
|
if (dragOffset) {
|
||||||
const baseNewPosition = new THREE.Vector3().addVectors(intersectionPoint, dragOffset);
|
const rawBasePosition = new THREE.Vector3().addVectors(intersectionPoint, dragOffset);
|
||||||
|
|
||||||
let moveSpeed = keyEvent === "Shift" || "Ctrl+Shift" ? 0.25 : 1;
|
let moveSpeed = keyEvent.includes("Shift") ? 0.25 : 1;
|
||||||
|
|
||||||
if (keyEvent === "Ctrl") {
|
const initialBasePosition = initialPositions[movedObjects[0].uuid];
|
||||||
|
const positionDifference = new THREE.Vector3().subVectors(rawBasePosition, initialBasePosition);
|
||||||
|
|
||||||
|
const adjustedDifference = positionDifference.multiplyScalar(moveSpeed);
|
||||||
|
|
||||||
|
const baseNewPosition = new THREE.Vector3().addVectors(initialBasePosition, adjustedDifference);
|
||||||
|
|
||||||
|
if (keyEvent.includes("Ctrl")) {
|
||||||
baseNewPosition.x = snapControls(baseNewPosition.x, "Ctrl");
|
baseNewPosition.x = snapControls(baseNewPosition.x, "Ctrl");
|
||||||
baseNewPosition.z = snapControls(baseNewPosition.z, "Ctrl");
|
baseNewPosition.z = snapControls(baseNewPosition.z, "Ctrl");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user