Skip to content
Snippets Groups Projects
Commit b5823c6e authored by Jakob Yanagibashi's avatar Jakob Yanagibashi
Browse files

Implement jump to key

parent f99a9385
No related branches found
No related tags found
2 merge requests!2CI improvements,!1Implement "Jump to" shortcut
Pipeline #260485 passed
...@@ -128,6 +128,7 @@ document.querySelector("#app").innerHTML = ` ...@@ -128,6 +128,7 @@ document.querySelector("#app").innerHTML = `
<li><i class="fa-solid fa-left-right"></i> <span class="helpControlText">Rotate horizontally: Drag</span></li> <li><i class="fa-solid fa-left-right"></i> <span class="helpControlText">Rotate horizontally: Drag</span></li>
<li><i class="fa-solid fa-up-down"></i> <span class="helpControlText">Rotate vertically: Shift+Drag</span></li> <li><i class="fa-solid fa-up-down"></i> <span class="helpControlText">Rotate vertically: Shift+Drag</span></li>
<li><i class="fa-solid fa-up-down-left-right"></i> <span class="helpControlText">Move: Opt/Alt+Drag</span></li> <li><i class="fa-solid fa-up-down-left-right"></i> <span class="helpControlText">Move: Opt/Alt+Drag</span></li>
<li><i class="fa-solid fa-share fa-rotate-90"></i> <span class="helpControlText">Jump to: O</span></li>
</ul> </ul>
</p> </p>
<form method="dialog"> <form method="dialog">
...@@ -513,14 +514,14 @@ function removeSelectedCommand() { ...@@ -513,14 +514,14 @@ function removeSelectedCommand() {
/* 3D & UI */ /* 3D & UI */
function initIllo() { function initIllo() {
window.illo = new Zdog.Illustration({ window.illo = new Zdog.Illustration({
element: ".zdog-canvas", element: ".zdog-canvas",
scale: 10, scale: 10,
centered: false,
translate: { x: 400, y: 400 },
resize: true, resize: true,
rotate: { x: Zdog.TAU * 0.2 }, rotate: { x: Zdog.TAU * 0.2 },
}); });
// Wheel (zoom) // Wheel (zoom)
window.illo.element.addEventListener("wheel", (e) => { window.illo.element.addEventListener("wheel", (e) => {
e.preventDefault(); e.preventDefault();
...@@ -535,6 +536,7 @@ function initIllo() { ...@@ -535,6 +536,7 @@ function initIllo() {
1 - Math.max(Math.min(e.deltaY / 40, 0.9), -0.9) 1 - Math.max(Math.min(e.deltaY / 40, 0.9), -0.9)
); );
}); });
// Drag (move) // Drag (move)
window.viewRotation = new Zdog.Vector(); window.viewRotation = new Zdog.Vector();
new Zdog.Dragger({ new Zdog.Dragger({
...@@ -569,6 +571,25 @@ function initIllo() { ...@@ -569,6 +571,25 @@ function initIllo() {
}, },
}); });
// O button (jump to)
window.addEventListener("keydown", (event) => {
if (event.isComposing || event.key !== "o" || !window.selectedListEntries[0]) {
return;
}
const jumpCmd = window.selectedListEntries[0];
if (!"goalx" in jumpCmd || !"goaly" in jumpCmd) {
return;
}
var illoTrans = new Zdog.Vector({
x: -jumpCmd.goaly.value * window.illo.scale.x,
y: -jumpCmd.goalx.value * window.illo.scale.y,
z: -jumpCmd.goalz.value * window.illo.scale.z,
});
illoTrans.rotate(window.illo.rotate);
console.log("jump to X: " + illoTrans.x + ", Y: " + illoTrans.y);
window.illo.translate = illoTrans;
});
window.currentProject.renderAll(); window.currentProject.renderAll();
animateIllo(); animateIllo();
...@@ -740,7 +761,7 @@ function initEditEventListeners() { ...@@ -740,7 +761,7 @@ function initEditEventListeners() {
} }
// Add selection // Add selection
if (e.target && e.target.matches("li")) { if (e.target && e.target.matches("li")) {
window.selectedListEntry = e.target; //window.selectedListEntry = e.target; TEST for removal
e.target.command.addSelection(); e.target.command.addSelection();
window.selectedListEntries.push(e.target.command); window.selectedListEntries.push(e.target.command);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment