Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hungry-areas-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@viamrobotics/motion-tools': patch
---

Clamp geometry dimensions to 0 when editing
16 changes: 11 additions & 5 deletions src/lib/components/SelectedTransformControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,32 @@
captureScaleStart()
}

// Clamp at 0 — the gizmo can produce negative scale factors when
// dragged past the origin, which would yield negative dimensions
// and a degenerate OBB.
if (scaleStart?.type === 'box') {
const next = {
x: scaleStart.x * ref.scale.x,
y: scaleStart.y * ref.scale.y,
z: scaleStart.z * ref.scale.z,
x: Math.max(0, scaleStart.x * ref.scale.x),
y: Math.max(0, scaleStart.y * ref.scale.y),
z: Math.max(0, scaleStart.z * ref.scale.z),
}
if (isFrameEntity) {
session?.stageGeometry(entity, { type: 'box', ...next })
} else {
entity.set(traits.Box, next)
}
} else if (scaleStart?.type === 'sphere') {
const next = { r: scaleStart.r * ref.scale.x }
const next = { r: Math.max(0, scaleStart.r * ref.scale.x) }
if (isFrameEntity) {
session?.stageGeometry(entity, { type: 'sphere', ...next })
} else {
entity.set(traits.Sphere, next)
}
} else if (scaleStart?.type === 'capsule') {
const next = { r: scaleStart.r * ref.scale.x, l: scaleStart.l * ref.scale.y }
const next = {
r: Math.max(0, scaleStart.r * ref.scale.x),
l: Math.max(0, scaleStart.l * ref.scale.y),
}
if (isFrameEntity) {
session?.stageGeometry(entity, { type: 'capsule', ...next })
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/components/overlay/Details.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@
y: box.current.y,
z: box.current.z,
}}
min={0}
on:change={handleBoxChange}
/>
</div>
Expand All @@ -596,6 +597,7 @@
<Slider
label="r"
value={sphere.current.r}
min={0}
on:change={handleSphereRChange}
/>
</div>
Expand All @@ -607,11 +609,13 @@
<Slider
label="r"
value={capsule.current.r}
min={0}
on:change={handleCapsuleRChange}
/>
<Slider
label="l"
value={capsule.current.l}
min={0}
on:change={handleCapsuleLChange}
/>
</div>
Expand Down
Loading