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: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ your drag, and the surface updates when you release.

Select a visible, unlocked part and choose **Sculpt**. Draw builds or removes material, Clay
Buildup layers broad strokes, and Inflate/Deflate changes the volume of rounded details. Grab
moves a patch, Crease sharpens a groove or ridge, and Smooth and Flatten clean up the surface.
The brush adds mesh detail locally as needed. Adjust **Detail** to change the density.
moves a patch, Crease carves a groove, Ridge raises and pinches an edge, and Smooth and Flatten
clean up the surface. The brush adds mesh detail locally as needed. Adjust **Detail** to change
the density.

- Hold **Alt** to invert an applicable brush and **Shift** for temporary smoothing.
- Use **Mask** to protect areas. Hold **Alt** to erase protection or **Shift** to soften it.
Expand Down
7 changes: 5 additions & 2 deletions src/components/SculptControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const brushes: Record<SculptBrush, string> = {
smooth: 'Smooth',
flatten: 'Flatten',
crease: 'Crease',
ridge: 'Ridge',
clay: 'Clay Buildup',
inflate: 'Inflate/Deflate',
mask: 'Mask',
Expand Down Expand Up @@ -106,7 +107,9 @@ export function SculptControls() {
{brush === 'mask'
? 'Drag to paint protection. Hold Alt to erase or Shift to soften.'
: 'Drag on the part to sculpt. Hold Shift to smooth.'}
{['draw', 'crease', 'clay', 'inflate'].includes(brush) ? ' Hold Alt to invert.' : ''}
{['draw', 'crease', 'ridge', 'clay', 'inflate'].includes(brush)
? ' Hold Alt to invert.'
: ''}
</p>
<div className="sculpt-mask-controls" role="group" aria-label="Sculpt mask">
<label className="sculpt-check">
Expand Down Expand Up @@ -256,7 +259,7 @@ export function SculptControls() {
)}
</>
)}
{brush === 'crease' && (
{(brush === 'crease' || brush === 'ridge') && (
<NumberSetting
label="Pinch"
value={settings.pinch}
Expand Down
2 changes: 1 addition & 1 deletion src/components/SculptPointer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export function SculptPointer() {
if (!(strength > 0)) return;
const radius = s.radius * (s.pressureRadius ? Math.max(0.08, p) : 1);
let angle = footprint(s, sample);
if (brush === 'crease' && active.applied) {
if ((brush === 'crease' || brush === 'ridge') && active.applied) {
const dx = sample.clientX - active.applied.clientX;
const dy = active.applied.clientY - sample.clientY;
if (dx || dy) angle = Math.atan2(dy, dx);
Expand Down
6 changes: 4 additions & 2 deletions src/core/sculpt-mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,15 @@ export class SculptMesh {
.clone()
.multiplyScalar(sign * Math.min(layer, settings.radius * 0.22) * strength);
}
case 'crease': {
case 'crease':
case 'ridge': {
const toward = new Vector3().subVectors(hit.point, point);
toward.addScaledVector(normal, -toward.dot(normal));
if (hit.tangent) toward.addScaledVector(footprint.tangent, -toward.dot(footprint.tangent));
const direction = settings.brush === 'ridge' ? sign : -sign;
return toward
.multiplyScalar(MathUtils.clamp(settings.pinch ?? 0.5, 0, 1) * strength * 0.4)
.addScaledVector(normal, -sign * depth * 0.22);
.addScaledVector(normal, direction * depth * 0.22);
}
case 'smooth': {
const neighbors = this.neighborsOf(weld, footprint);
Expand Down
2 changes: 1 addition & 1 deletion src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type Tool =
| 'sculpt';

export type SculptBrush =
'draw' | 'grab' | 'smooth' | 'flatten' | 'crease' | 'clay' | 'inflate' | 'mask';
'draw' | 'grab' | 'smooth' | 'flatten' | 'crease' | 'ridge' | 'clay' | 'inflate' | 'mask';

export interface SculptureSettings {
brush: SculptBrush;
Expand Down
9 changes: 8 additions & 1 deletion src/docs/assembly-guides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export const assemblyGuides: DocArticle[] = [
id: 'brushes',
title: 'Choose a brush',
paragraphs: [
'To change the outline, use Grab. To build or cut relief, try Draw, Clay Buildup, Crease or Inflate/Deflate. Use Smooth for ripples, Flatten for a level patch, and Mask to protect a detail. Each example shows the same view before and after the stroke.',
'To change the outline, use Grab. To build or cut relief, try Draw, Clay Buildup, Crease, Ridge or Inflate/Deflate. Use Smooth for ripples, Flatten for a level patch, and Mask to protect a detail. Each illustrated example shows the same view before and after the stroke.',
],
},
{
Expand Down Expand Up @@ -455,6 +455,13 @@ export const assemblyGuides: DocArticle[] = [
caption: 'The surface draws inward along the stroke.',
},
},
{
id: 'ridge',
title: 'Ridge',
paragraphs: [
'Drag along an outer edge or where you want to raise a ridge. Increase Pinch to draw the surface closer to the stroke. Hold Alt to carve a groove.',
],
},
{
id: 'clay',
title: 'Clay Buildup',
Expand Down
41 changes: 41 additions & 0 deletions tests/e2e/sculpt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,47 @@ test('mask paint subdivides without displacement and restores weights with undo
expect(await weights()).toEqual(protection);
});

test('raises a ridge with a stroke and carves a groove with Alt', async ({ page }) => {
await openSculpt(page, {
...block,
parts: [
{
...block.parts[0],
geometry: serializeGeometry(new PlaneGeometry(8, 6, 40, 30).translate(0, 0, 2)),
},
],
});
const ridge = page.getByRole('button', { name: 'Ridge', exact: true });
await ridge.click();
await expect(ridge).toHaveAttribute('aria-pressed', 'true');
await page.getByText('Advanced brush settings', { exact: true }).click();
await expect(page.getByRole('spinbutton', { name: 'Pinch' })).toHaveValue('0.5');

const before = await mesh(page);
const start = await screen(page, [-1, 0, 2]);
const end = await screen(page, [1, 0, 2]);
const drag = async () => {
await page.mouse.move(start.x, start.y);
await page.mouse.down();
await page.mouse.move(end.x, end.y, { steps: 8 });
await page.mouse.up();
};
await drag();
await expect.poll(async () => (await mesh(page)).peak).toBeGreaterThan(before.peak + 0.01);
await page.keyboard.press('ControlOrMeta+z');
await expect.poll(() => mesh(page)).toEqual(before);

await page.keyboard.down('Alt');
try {
await drag();
} finally {
await page.keyboard.up('Alt');
}
await expect
.poll(async () => (await mesh(page)).positions.some((z, i) => i % 3 === 2 && z < 1.99))
.toBe(true);
});

test('applies Clay Buildup and Inflate and keeps their falloff settings independent', async ({
page,
}) => {
Expand Down
27 changes: 15 additions & 12 deletions tests/unit/sculpt-mesh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,27 @@ describe('sculpt mesh', () => {
expect(paint.getMask()).toHaveLength(painted.getAttribute('position').count);
});

it('cuts a pinched groove and uses inverted depth for a pinched ridge', () => {
it('pinches Crease and Ridge in opposite depth directions and inverts each brush', () => {
const source = mesh([0, 0, 0, 0.5, 0, 0, 0, 0.5, 0], [0, 1, 2]);
const settings = dab(new Vector3(), {
brush: 'crease',
pinch: 1,
tangent: new Vector3(0, 1, 0),
minEdge: 100,
});
const groove = new SculptMesh(source, identity);
const ridge = new SculptMesh(source, identity);
expect(groove.dab(settings)).toBe(true);
expect(ridge.dab({ ...settings, inverted: true })).toBe(true);
const cut = groove.finish()!.getAttribute('position');
const raised = ridge.finish()!.getAttribute('position');
expect(cut.getX(1)).toBeLessThan(0.5);
expect(raised.getX(1)).toBe(cut.getX(1));
expect(cut.getZ(0)).toBeLessThan(0);
expect(raised.getZ(0)).toBe(-cut.getZ(0));
const positions = (brush: 'crease' | 'ridge', inverted = false) => {
const draft = new SculptMesh(source, identity);
expect(draft.dab({ ...settings, brush, inverted })).toBe(true);
return draft.finish()!.getAttribute('position');
};

const groove = positions('crease');
const ridge = positions('ridge');
expect(groove.getX(1)).toBeLessThan(0.5);
expect(ridge.getX(1)).toBe(groove.getX(1));
expect(groove.getZ(0)).toBeLessThan(0);
expect(ridge.getZ(0)).toBe(-groove.getZ(0));
expect(ridge.array).toEqual(positions('crease', true).array);
expect(groove.array).toEqual(positions('ridge', true).array);
});

it('builds clay toward a surface plane and inflates using an individual vertex normal', () => {
Expand Down
Loading