Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

fix(profile): name profile solid failures with PROFILE_SOLID_FAILED (#178)

Matt Kissinger7685d55c29f5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0dc178aa..bc875655 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -72,6 +72,14 @@ does not publish a package.
counts, achieved ratio and the simplifier's error; a missed target is a
`SIMPLIFY_TARGET_NOT_REACHED` build note. It never runs implicitly or to meet a budget.
The `defineLod` contract no longer says Kiln simplifies no geometry and points to it.
+- Name profile solid failures across the sandbox ([#178](https://github.com/instruktlabs/kiln/issues/178)).
+ An `extrudeProfile` or `revolveProfile` call whose outline, holes or bevel cannot become
+ a solid now rejects with the closed cause `PROFILE_SOLID_FAILED` and engine-written repair
+ advice, instead of the bare generic rejection; out-of-scale coordinates and holes that
+ consume the outline are two reduced cases. No library message crosses the boundary, and
+ `PROFILE_BEVEL_COLLAPSE` still names an over-large bevel. The generic rejection now says
+ that `kiln_validate` checks syntax and static rules but cannot see execution-time
+ failures, and points to reproducing them with `kiln_render`.
## 1.4.0 (2026-10-23)
diff --git a/docs/runtime.md b/docs/runtime.md
index 70e721a0..b50138a0 100644
--- a/docs/runtime.md
+++ b/docs/runtime.md
@@ -88,16 +88,18 @@ program crosses the worker boundary. The worker may add one closed cause, and th
turns it into engine-written advice. Causes include a binding read before its
declaration ran, a `build()` that is missing or returns no Object3D, a `materialRecipe`
override the recipe does not allow, a procedural texture usage that is unknown or does not
-match its slot, and a TypeError or RangeError. The host still has
+match its slot, an `extrudeProfile` or `revolveProfile` outline that cannot become a solid
+(`PROFILE_SOLID_FAILED`), and a TypeError or RangeError. The host still has
the source it sent. `kiln_render`, `kiln_inspect`, `kiln_view_interior`,
`kiln_screenshot_animation` and the CLI parse that source and append `Source check:`
with up to three codes and lines that `kiln_validate` reports for it. Examples are
`TEMPORAL_DEAD_ZONE`, `MATERIAL_RECIPE_OVERRIDE`, `UNSAFE_GLOBAL_ACCESS` and
`SYNTAX_ERROR`. An unrecognised exception stays generic: the sentence continues with a
-fixed engine-owned paragraph that says no message crosses the sandbox, that values are
-read with `kiln_inspect` on a rendered program rather than a thrown `Error`, and that
-`kiln_validate` (`kiln validate` from the CLI) names the line (`EXECUTION_REJECTED_ADVICE` in
-`src/evaluator/authoring-diagnostic.ts`).
+fixed engine-owned paragraph that says no message crosses the sandbox, that
+`kiln_validate` (`kiln validate` from the CLI) checks syntax and static rules but cannot see
+execution-time failures, which are reproduced with `kiln_render` by simplifying the failing
+part, and that values are read with `kiln_inspect` on a rendered program rather than a
+thrown `Error` (`EXECUTION_REJECTED_ADVICE` in `src/evaluator/authoring-diagnostic.ts`).
## Animation measurements
diff --git a/src/__tests__/profile.test.ts b/src/__tests__/profile.test.ts
index 90294bca..dcd550cd 100644
--- a/src/__tests__/profile.test.ts
+++ b/src/__tests__/profile.test.ts
@@ -458,3 +458,41 @@ async function build() {
expect(usage['roundedBoxGeo']).toBe(1);
});
});
+
+describe('profile solid failures (#178)', () => {
+ const diagnosticOf = (error: unknown) => (error as { diagnostic?: unknown }).diagnostic;
+
+ it('turns manifold and solid-path failures into the closed PROFILE_SOLID_FAILED cause', async () => {
+ // Out-of-scale coordinates make manifold throw a raw WASM exception (a number),
+ // and holes that consume the outline throw a plain Error: both used to cross the
+ // sandbox as the generic rejection with no repair advice.
+ const huge: Profile2D = [
+ [0, 0],
+ [1e15, 0],
+ [1e15, 1e15],
+ [0, 1e15],
+ ];
+ for (const attempt of [
+ () => extrudeProfile(huge, { depth: 1 }),
+ () => revolveProfile(huge, { bevel: 0.01 }),
+ () => extrudeProfile(UNIT_SQUARE, { holes: [UNIT_SQUARE] }),
+ ]) {
+ const error = await attempt().catch((e: unknown) => e);
+ expect(diagnosticOf(error)).toBe('PROFILE_SOLID_FAILED');
+ expect(String((error as Error).message)).toContain('twice the bevel');
+ }
+ });
+
+ it('keeps PROFILE_BEVEL_COLLAPSE for an over-large bevel and accepts the repaired bevel', async () => {
+ const thin: Profile2D = [
+ [0, 0],
+ [0.02, 0],
+ [0.02, 1],
+ [0, 1],
+ ];
+ const error = await revolveProfile(thin, { bevel: 0.02 }).catch((e: unknown) => e);
+ expect(diagnosticOf(error)).toBe('PROFILE_BEVEL_COLLAPSE');
+ const repaired = await revolveProfile(thin, { bevel: 0.005 });
+ expect(repaired.getAttribute('position').count).toBeGreaterThan(0);
+ });
+});
diff --git a/src/discovery/helper-contracts.ts b/src/discovery/helper-contracts.ts
index cd7421b2..b0fa226a 100644
--- a/src/discovery/helper-contracts.ts
+++ b/src/discovery/helper-contracts.ts
@@ -2296,7 +2296,7 @@ define(
parameters: [
'Finite closed outline, optional finite hole outlines, positive depth.',
'Twist is degrees; taper is dimensionless; divisions is a whole number >= 0 of intermediate rings, default 0 (16 when twisting).',
- 'Bevel uses profile units. If its inward offset empties the section, execution rejects with repair advice: reduce bevel below half the narrowest width, disable it, or widen the section.',
+ 'Bevel uses profile units. If its inward offset empties the section, execution rejects with PROFILE_BEVEL_COLLAPSE repair advice: reduce bevel below half the narrowest width, disable it, or widen the section. Any other failure to build the solid rejects with PROFILE_SOLID_FAILED repair advice. kiln_validate cannot see either; reproduce with kiln_render.',
],
},
{
@@ -2320,7 +2320,7 @@ define(
parameters: [
'Closed finite profile; only nonnegative radial side is used.',
'angle in (0,360] degrees; segments and bevel options control tessellation.',
- 'Bevel uses profile units. If its inward offset empties the section, execution rejects with repair advice: reduce bevel below half the narrowest width, disable it, or widen the section.',
+ 'Bevel uses profile units. If its inward offset empties the section, execution rejects with PROFILE_BEVEL_COLLAPSE repair advice: reduce bevel below half the narrowest width, disable it, or widen the section. Any other failure to build the solid rejects with PROFILE_SOLID_FAILED repair advice. kiln_validate cannot see either; reproduce with kiln_render.',
],
},
{
diff --git a/src/evaluator/authoring-diagnostic.test.ts b/src/evaluator/authoring-diagnostic.test.ts
index 135b28e9..ecda3c9e 100644
--- a/src/evaluator/authoring-diagnostic.test.ts
+++ b/src/evaluator/authoring-diagnostic.test.ts
@@ -7,7 +7,8 @@ import {
createEvaluatorPortV2,
} from './protocol';
import { renderGLBViaSubprocess } from './subprocess';
-import { authoringDiagnosticAdvice } from './authoring-diagnostic';
+import { authoringDiagnosticAdvice, EXECUTION_REJECTED_ADVICE } from './authoring-diagnostic';
+import { helperContracts } from '../discovery/helper-contracts';
import { TEXTURE_USAGES } from '../texture-contract';
import {
canonicalizeProceduralTextureSpecV2,
@@ -266,6 +267,71 @@ test('unsupported profile holes retain repair advice across the worker and share
}
});
+test('profile solid failures cross the worker as PROFILE_SOLID_FAILED without library text (#178)', async () => {
+ // Reduced from the grotto dogfood: out-of-scale coordinates make manifold throw a raw
+ // WASM exception, and holes that consume the outline throw a plain Error. Both used to
+ // reach the author as the bare generic rejection.
+ const square = '[[0,0],[1,0],[1,1],[0,1]]';
+ const huge = '[[0,0],[1e15,0],[1e15,1e15],[0,1e15]]';
+ const sources = [
+ `extrudeProfile(${huge},{depth:1})`,
+ `revolveProfile(${huge},{bevel:0.01})`,
+ `extrudeProfile(${square},{holes:[${square}]})`,
+ ].map(
+ (call) => `async function build(){await ${call};return createRoot('PRIVATE_SOURCE_MARKER');}`,
+ );
+ for (const source of sources) {
+ const wire = await evaluateEvaluatorRequestV2(
+ createEvaluatorRequestV2({ requestId: 'profile-solid', code: source }).json,
+ );
+ expect(JSON.parse(wire).error).toEqual({
+ code: 'EXECUTION_REJECTED',
+ message: 'Generated asset execution was rejected.',
+ diagnostic: 'PROFILE_SOLID_FAILED',
+ });
+ }
+ const defs = createKilnProgramToolRegistry({ evaluatorPort: { render: renderGLBViaSubprocess } });
+ const out = (await defs.find((d) => d.name === 'kiln_render')!.run({ code: sources[2]! })) as {
+ ok: boolean;
+ error: string;
+ };
+ expect(out.ok).toBe(false);
+ expect(out.error).toContain('PROFILE_SOLID_FAILED');
+ expect(out.error).toContain('twice the bevel');
+ expect(out.error).toContain('axis');
+ for (const privateValue of ['PRIVATE_SOURCE_MARKER', 'consume the whole profile', 'profile.ts'])
+ expect(out.error).not.toContain(privateValue);
+}, 20000);
+
+test('an over-large revolveProfile bevel keeps PROFILE_BEVEL_COLLAPSE and the repaired bevel renders', async () => {
+ const call = (bevel: number) =>
+ `async function build(){const root=createRoot('Beacon');createPart('Cap',await revolveProfile([[0,0],[0.02,0],[0.02,1],[0,1]],{bevel:${bevel}}),gameMaterial(0x888888),{parent:root});return root;}`;
+ const invalid = JSON.parse(
+ await evaluateEvaluatorRequestV2(
+ createEvaluatorRequestV2({ requestId: 'bevel', code: call(0.02) }).json,
+ ),
+ );
+ expect(invalid.error.diagnostic).toBe('PROFILE_BEVEL_COLLAPSE');
+ const repaired = JSON.parse(
+ await evaluateEvaluatorRequestV2(
+ createEvaluatorRequestV2({ requestId: 'bevel', code: call(0.005) }).json,
+ ),
+ );
+ expect(repaired.ok).toBe(true);
+}, 20000);
+
+test('generic rejection advice separates static validation from execution-time failures', () => {
+ expect(EXECUTION_REJECTED_ADVICE).toContain('kiln_validate');
+ expect(EXECUTION_REJECTED_ADVICE).toContain('cannot see execution-time');
+ expect(EXECUTION_REJECTED_ADVICE).toContain('kiln_render');
+ expect(EXECUTION_REJECTED_ADVICE).not.toContain('for the failing line and code');
+ for (const name of ['extrudeProfile', 'revolveProfile']) {
+ const parameters = helperContracts[name]!.contract.parameters.join(' ');
+ expect(parameters).toContain('PROFILE_BEVEL_COLLAPSE');
+ expect(parameters).toContain('PROFILE_SOLID_FAILED');
+ }
+});
+
test('material fraction mistakes receive actionable private-value-free advice across evaluator and tools', async () => {
const source = `function build(){proceduralTexture({schemaVersion:2,layers:[{op:'bricks',brick:0,mortar:0,mortarWidth:2}]});return createRoot('PRIVATE_SOURCE_MARKER');}`;
const wire = await evaluateEvaluatorRequestV2(
@@ -505,6 +571,7 @@ test('arbitrary exceptions and safety denials retain generic rejection', async (
`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'TUBE_RADIUS'});}`,
`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'TAPER_CONE_AXIS'});}`,
`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'PROFILE_BEVEL_COLLAPSE'});}`,
+ `function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'PROFILE_SOLID_FAILED'});}`,
`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'SOLID_FLOAT32_COLLAPSE'});}`,
`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'MESH_DATA_NONFINITE'});}`,
`function build(){return process.env.SECRET;}`,
diff --git a/src/evaluator/authoring-diagnostic.ts b/src/evaluator/authoring-diagnostic.ts
index d4a6deec..e7cdb6fb 100644
--- a/src/evaluator/authoring-diagnostic.ts
+++ b/src/evaluator/authoring-diagnostic.ts
@@ -27,6 +27,7 @@ export type AuthoringDiagnostic =
| 'PARAMETRIC_PERIODIC_ENDPOINT'
| 'PROFILE_HOLES_UNSUPPORTED'
| 'PROFILE_BEVEL_COLLAPSE'
+ | 'PROFILE_SOLID_FAILED'
| 'PROFILE_CORRESPONDENCE_COLLAPSE'
| 'UNINITIALIZED_BINDING'
| 'BUILD_RESULT'
@@ -64,6 +65,10 @@ export const PROFILE_HOLES_UNSUPPORTED_ADVICE =
'loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.';
export const PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE =
'loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.';
+// Engine-owned and bounded: no outline, coordinate or library message crosses the sandbox,
+// so the hint names the inputs that make the profile solid path fail (#178).
+export const PROFILE_SOLID_FAILED_ADVICE =
+ 'PROFILE_SOLID_FAILED: extrudeProfile or revolveProfile could not build a solid from this outline. Reduce bevel or set it to 0. Keep the outline one simple closed loop: no self-intersections, repeated points or zero-length edges, and no neck narrower than twice the bevel. Holes must lie inside the outline and leave material. For revolveProfile, keep points off the axis (x = 0) unless the solid should close there. Keep coordinates at asset scale. Render that helper call alone with kiln_render and simplify the outline until it builds. Call kiln_discover with ids ["extrudeProfile", "revolveProfile"].';
export const UNINITIALIZED_BINDING_ADVICE =
'A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.';
export const BUILD_RESULT_ADVICE =
@@ -89,7 +94,7 @@ export const REQUIRE_SOLID_ADVICE =
* bounding boxes and got the bare sentence, H30; decision 24).
*/
export const EXECUTION_REJECTED_ADVICE =
- 'No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate (CLI: kiln validate <program.js|ref>) on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.';
+ 'No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. kiln_validate (CLI: kiln validate <program.js|ref>) checks syntax and static source rules such as policy denials; it cannot see execution-time failures, such as geometry a helper rejects while build() runs. Reproduce those with kiln_render, simplifying or removing the failing part until the program renders. To read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable, build() mistake or profile solid failure is named when it is the cause.';
export function authoringDiagnosticAdvice(diagnostic: AuthoringDiagnostic | undefined): string {
if (diagnostic === 'PORTABLE_MATERIAL_V3_CONTRACT')
return 'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';
@@ -151,6 +156,7 @@ export function authoringDiagnosticAdvice(diagnostic: AuthoringDiagnostic | unde
if (diagnostic === 'PROCEDURAL_TEXTURE_USAGE') return PROCEDURAL_TEXTURE_USAGE_ADVICE;
if (diagnostic === 'MATERIAL_FRACTION_RANGE') return MATERIAL_FRACTION_RANGE_ADVICE;
if (diagnostic === 'PROFILE_HOLES_UNSUPPORTED') return PROFILE_HOLES_UNSUPPORTED_ADVICE;
+ if (diagnostic === 'PROFILE_SOLID_FAILED') return PROFILE_SOLID_FAILED_ADVICE;
if (diagnostic === 'PROFILE_CORRESPONDENCE_COLLAPSE')
return PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE;
return diagnostic === 'PARAMETRIC_PERIODIC_ENDPOINT' ? PARAMETRIC_PERIODIC_ENDPOINT_ADVICE : '';
diff --git a/src/evaluator/protocol.ts b/src/evaluator/protocol.ts
index e6250308..798281e2 100644
--- a/src/evaluator/protocol.ts
+++ b/src/evaluator/protocol.ts
@@ -455,6 +455,7 @@ export function decodeEvaluatorResultV2(
value.error.diagnostic !== 'PARAMETRIC_PERIODIC_ENDPOINT' &&
value.error.diagnostic !== 'PROFILE_HOLES_UNSUPPORTED' &&
value.error.diagnostic !== 'PROFILE_BEVEL_COLLAPSE' &&
+ value.error.diagnostic !== 'PROFILE_SOLID_FAILED' &&
value.error.diagnostic !== 'PROFILE_CORRESPONDENCE_COLLAPSE' &&
value.error.diagnostic !== 'REMOVED_HELPER' &&
value.error.diagnostic !== 'TUBE_RADIUS' &&
diff --git a/src/profile.ts b/src/profile.ts
index b7bc4589..370e185f 100644
--- a/src/profile.ts
+++ b/src/profile.ts
@@ -151,6 +151,32 @@ function orientSweep(geo: THREE.BufferGeometry, axis: SweepAxis): THREE.BufferGe
return geo;
}
+/** Resolve the bevel join before the solid path, so a bad style stays an argument error. */
+function bevelJoin(style: BevelStyle, label: string): JoinType {
+ const join = JOIN_FOR_STYLE[style];
+ if (!join) {
+ throw new Error(`${label}: bevelStyle must be 'round' or 'chamfer' (got ${String(style)}).`);
+ }
+ return join;
+}
+
+/**
+ * Run the manifold-backed solid path of a profile helper: cross-section, bevel,
+ * extrude or revolve, and the geometry bridge. A closed cause raised inside
+ * (`PROFILE_BEVEL_COLLAPSE`, `SOLID_FLOAT32_COLLAPSE`) passes through unchanged.
+ * Anything else, including a raw WASM exception value or a manifold error, becomes
+ * the closed `PROFILE_SOLID_FAILED` cause, so it crosses the sandbox with
+ * engine-owned repair advice instead of the bare generic rejection (#178).
+ */
+function profileSolid(build: () => THREE.BufferGeometry): THREE.BufferGeometry {
+ try {
+ return build();
+ } catch (error) {
+ if (error instanceof AuthoringDiagnosticError) throw error;
+ throw new AuthoringDiagnosticError('PROFILE_SOLID_FAILED');
+ }
+}
+
/**
* Round or chamfer every corner of a cross-section without moving its outer
* dimensions: erode by r, dilate by 2r, erode by r.
@@ -162,14 +188,9 @@ function orientSweep(geo: THREE.BufferGeometry, axis: SweepAxis): THREE.BufferGe
function bevelCrossSection(
cs: CrossSection,
bevel: number,
- style: BevelStyle,
+ join: JoinType,
segments: number,
- label: string,
): CrossSection {
- const join = JOIN_FOR_STYLE[style];
- if (!join) {
- throw new Error(`${label}: bevelStyle must be 'round' or 'chamfer' (got ${String(style)}).`);
- }
const eroded = cs.offset(-bevel, join, 2, segments);
if (eroded.isEmpty()) {
eroded.delete();
@@ -269,6 +290,12 @@ export async function extrudeProfile(
for (let i = 0; i < holes.length; i++) {
assertFiniteProfile(holes[i] as Profile2D, `extrudeProfile: holes[${i}]`);
}
+ const join = bevel > 0 ? bevelJoin(bevelStyle, 'extrudeProfile') : undefined;
+ const scaleTop = normalizeTaper(taper);
+ // Twist needs intermediate slices or it interpolates as a single shear. A
+ // straight or tapered sweep is exact with none: each ring would only add
+ // coplanar side triangles.
+ const nDivisions = divisions ?? (twist !== 0 ? 16 : 0);
const mod = await getManifoldModule();
const { CrossSection: CS } = mod;
@@ -279,37 +306,30 @@ export async function extrudeProfile(
return cs;
};
- try {
- let section: CrossSection = track(new CS([profile as Vec2[]], 'NonZero'));
- if (holes.length > 0) {
- // Subtract rather than relying on an EvenOdd fill rule: agent-written
- // hole outlines have arbitrary winding, and a wrong winding under
- // EvenOdd yields a filled disc instead of a hole with no error.
- const holeSections = holes.map((h) => track(new CS([h as Vec2[]], 'NonZero')));
- section = track(CS.difference(section, CS.union(holeSections)));
- if (section.isEmpty()) {
- throw new Error(
- 'extrudeProfile: the holes consume the whole profile — nothing left to extrude.',
- );
- }
- }
- if (bevel > 0) {
- section = track(bevelCrossSection(section, bevel, bevelStyle, segments, 'extrudeProfile'));
- }
-
- // Twist needs intermediate slices or it interpolates as a single shear. A
- // straight or tapered sweep is exact with none: each ring would only add
- // coplanar side triangles.
- const nDivisions = divisions ?? (twist !== 0 ? 16 : 0);
- const solid = section.extrude(depth, nDivisions, twist, normalizeTaper(taper), center);
+ const geometry = profileSolid(() => {
try {
- return orientSweep(manifoldToGeometry(solid, { smooth }), axis);
+ let section: CrossSection = track(new CS([profile as Vec2[]], 'NonZero'));
+ if (holes.length > 0) {
+ // Subtract rather than relying on an EvenOdd fill rule: agent-written
+ // hole outlines have arbitrary winding, and a wrong winding under
+ // EvenOdd yields a filled disc instead of a hole with no error.
+ const holeSections = holes.map((h) => track(new CS([h as Vec2[]], 'NonZero')));
+ section = track(CS.difference(section, CS.union(holeSections)));
+ // The holes consume the whole profile: nothing is left to extrude.
+ if (section.isEmpty()) throw new AuthoringDiagnosticError('PROFILE_SOLID_FAILED');
+ }
+ if (join) section = track(bevelCrossSection(section, bevel, join, segments));
+ const solid = section.extrude(depth, nDivisions, twist, scaleTop, center);
+ try {
+ return manifoldToGeometry(solid, { smooth });
+ } finally {
+ solid.delete();
+ }
} finally {
- solid.delete();
+ for (const cs of disposable) cs.delete();
}
- } finally {
- for (const cs of disposable) cs.delete();
- }
+ });
+ return orientSweep(geometry, axis);
}
/**
@@ -350,27 +370,31 @@ export async function revolveProfile(
if (!Number.isFinite(angle) || angle <= 0 || angle > 360) {
throw new Error(`revolveProfile: angle must be in (0, 360] degrees (got ${angle}).`);
}
+ const join = bevel > 0 ? bevelJoin(bevelStyle, 'revolveProfile') : undefined;
const mod = await getManifoldModule();
const { CrossSection: CS } = mod;
const disposable: CrossSection[] = [];
- try {
- let section: CrossSection = new CS([profile as Vec2[]], 'NonZero');
- disposable.push(section);
- if (bevel > 0) {
- section = bevelCrossSection(section, bevel, bevelStyle, bevelSegments, 'revolveProfile');
- disposable.push(section);
- }
- const solid = section.revolve(segments, angle);
+ const geometry = profileSolid(() => {
try {
- return orientSweep(manifoldToGeometry(solid, { smooth }), axis);
+ let section: CrossSection = new CS([profile as Vec2[]], 'NonZero');
+ disposable.push(section);
+ if (join) {
+ section = bevelCrossSection(section, bevel, join, bevelSegments);
+ disposable.push(section);
+ }
+ const solid = section.revolve(segments, angle);
+ try {
+ return manifoldToGeometry(solid, { smooth });
+ } finally {
+ solid.delete();
+ }
} finally {
- solid.delete();
+ for (const cs of disposable) cs.delete();
}
- } finally {
- for (const cs of disposable) cs.delete();
- }
+ });
+ return orientSweep(geometry, axis);
}
/**