Skip to content

Commit

Permalink
Add options to clip placing and filling
Browse files Browse the repository at this point in the history
  • Loading branch information
kettek committed Jan 10, 2025
1 parent e46b196 commit fe0046a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions frontend/src/components/3d/Scene.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
if (z === -1 || z === file.frameHeight) return
if (y === -1 || y === file.frame?.slices.length) return
// Prevent placing if we're using the clipped view.
if ($editor3DSettings.useClipping && $editor3DSettings.clipPlace) {
if (y < $editor3DSettings.clipY || y > $editor3DSettings.clipY + $editor3DSettings.clipH) return
if (x < $editor3DSettings.clipX || x > $editor3DSettings.clipX + $editor3DSettings.clipW) return
if (z < $editor3DSettings.clipZ || z > $editor3DSettings.clipZ + $editor3DSettings.clipD) return
}
let slice = file.frame?.slices[y]
if (!slice) return
let p = file.canvas.getPixel(slice.x + x, slice.y + z)
Expand Down Expand Up @@ -103,6 +110,14 @@
if (x === -1 || x === file.frameWidth) continue
if (z === -1 || z === file.frameHeight) continue
if (y === -1 || y === file.frame?.slices.length) continue
// Also prevent filling if we're using the clipped view.
if ($editor3DSettings.useClipping && $editor3DSettings.clipFill) {
if (y < $editor3DSettings.clipY || y > $editor3DSettings.clipY + $editor3DSettings.clipH) continue
if (x < $editor3DSettings.clipX || x > $editor3DSettings.clipX + $editor3DSettings.clipW) continue
if (z < $editor3DSettings.clipZ || z > $editor3DSettings.clipZ + $editor3DSettings.clipD) continue
}
let index = y * file.frameWidth * file.frameHeight + z * file.frameWidth + x
if (traversed.has(index)) continue
traversed.add(index)
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/sections/Clip3D.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

<main>
<Checkbox labelText="Clip View" bind:checked={$editor3DSettings.useClipping}></Checkbox>
<Checkbox labelText="Clip Place" bind:checked={$editor3DSettings.clipPlace}></Checkbox>
<Checkbox labelText="Clip Fill" bind:checked={$editor3DSettings.clipFill}></Checkbox>
<hr />
<Input labelWidth="3" label="X" type="number" size="small" width={4} showSpinner bind:value={$editor3DSettings.clipX} />
<Input labelWidth="3" label="Y" type="number" size="small" width={4} showSpinner bind:value={$editor3DSettings.clipY} />
<Input labelWidth="3" label="Z" type="number" size="small" width={4} showSpinner bind:value={$editor3DSettings.clipZ} />
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/stores/editor3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Editor3DSettings = {
hoverScale: boolean
// Clipping
useClipping: boolean
clipFill: boolean
clipPlace: boolean
clipX: number
clipY: number
clipZ: number
Expand Down Expand Up @@ -50,6 +52,8 @@ export const editor3DSettings = makeLocalStorageStore<Editor3DSettings>('editor3
hoverScale: true,
// Clipping
useClipping: false,
clipFill: true,
clipPlace: true,
clipX: 0,
clipY: 0,
clipZ: 0,
Expand Down

0 comments on commit fe0046a

Please sign in to comment.