ui/scene: add different cursor type

This commit is contained in:
Johannes Kirschbauer
2025-08-29 13:54:32 +02:00
parent b2985b59e9
commit 6b4f79c9fa
2 changed files with 22 additions and 3 deletions

View File

@@ -1,7 +1,6 @@
.cubes-scene-container { .cubes-scene-container {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
cursor: pointer;
} }
/* <div class="absolute bottom-4 left-1/2 flex -translate-x-1/2 flex-col items-center"> /* <div class="absolute bottom-4 left-1/2 flex -translate-x-1/2 flex-col items-center">

View File

@@ -21,6 +21,7 @@ import { Accessor } from "solid-js";
import { renderLoop } from "./RenderLoop"; import { renderLoop } from "./RenderLoop";
import { ObjectRegistry } from "./ObjectRegistry"; import { ObjectRegistry } from "./ObjectRegistry";
import { MachineManager } from "./MachineManager"; import { MachineManager } from "./MachineManager";
import cx from "classnames";
function garbageCollectGroup(group: THREE.Group) { function garbageCollectGroup(group: THREE.Group) {
for (const child of group.children) { for (const child of group.children) {
@@ -101,6 +102,8 @@ export function CubeScene(props: {
const [positionMode, setPositionMode] = createSignal<"grid" | "circle">( const [positionMode, setPositionMode] = createSignal<"grid" | "circle">(
"grid", "grid",
); );
// Managed by controls
const [isDragging, setIsDragging] = createSignal(false);
const [cursorPosition, setCursorPosition] = createSignal<[number, number]>(); const [cursorPosition, setCursorPosition] = createSignal<[number, number]>();
@@ -273,6 +276,13 @@ export function CubeScene(props: {
bgCamera, bgCamera,
); );
controls.addEventListener("start", (e) => {
setIsDragging(true);
});
controls.addEventListener("end", (e) => {
setIsDragging(false);
});
// Lighting // Lighting
const ambientLight = new THREE.AmbientLight(0xd9f2f7, 0.72); const ambientLight = new THREE.AmbientLight(0xd9f2f7, 0.72);
scene.add(ambientLight); scene.add(ambientLight);
@@ -582,7 +592,17 @@ export function CubeScene(props: {
return ( return (
<> <>
<div class="cubes-scene-container" ref={(el) => (container = el)} /> <div
class={cx(
"cubes-scene-container",
worldMode() === "default" && "cursor-no-drop",
worldMode() === "select" && "cursor-pointer",
worldMode() === "service" && "cursor-pointer",
worldMode() === "create" && "cursor-cell",
isDragging() && "!cursor-grabbing",
)}
ref={(el) => (container = el)}
/>
<div class="toolbar-container"> <div class="toolbar-container">
<div class="absolute bottom-full left-1/2 mb-2 -translate-x-1/2"> <div class="absolute bottom-full left-1/2 mb-2 -translate-x-1/2">
{props.toolbarPopup} {props.toolbarPopup}
@@ -615,7 +635,7 @@ export function CubeScene(props: {
}} }}
/> />
<ToolbarButton <ToolbarButton
icon="Reload" icon="Update"
name="Reload" name="Reload"
description="Reload machines" description="Reload machines"
onClick={() => machinesQuery.refetch()} onClick={() => machinesQuery.refetch()}