Skip to content

Commit e3af261

Browse files
committed
fix: wedge positions
1 parent 1972d22 commit e3af261

7 files changed

Lines changed: 32 additions & 43 deletions

File tree

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>CSG Builder</title>
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
88
<meta name="theme-color" content="#f3f4f6" />
9-
<script type="module" crossorigin src="/csg-builder/assets/index-DeaveSRz.js"></script>
9+
<script type="module" crossorigin src="/csg-builder/assets/index-D34Lzmn4.js"></script>
1010
<link rel="stylesheet" crossorigin href="/csg-builder/assets/index-ByUqiuvw.css">
1111
</head>
1212

projects/examples/E.wallAndWindow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const brickItem = (): Solid => {
103103
* 💡 Can also specify spacing: { cols: 5, rows: 3, spacing: [1, 0.5] }
104104
*/
105105
export const brickWall = (cx: number, cy: number): Solid =>
106-
Solid.GRID_XY(brickItem(), { cols: cx, rows: cy });
106+
Solid.GRID_XYZ(brickItem(), { cols: cx, rows: 1, levels: cy });
107107

108108
/**
109109
* WINDOW - Multi-solid component with negative hole

projects/examples/J.grid3d.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,24 @@ const latticeStructure = (): Solid => {
135135
*/
136136
const checkerboard3D = (): Solid => {
137137
// Create two cube types (light and dark)
138-
const lightCube = Solid.sphere(2.5, { color: 'white' });
139-
const darkCube = Solid.cube(5, 5, 5, { color: 'black' });
138+
const sphere = Solid.sphere(2.5, { color: 'white' });
139+
const cube = Solid.cube(5, 5, 5, { color: 'black' });
140140

141141
// Strategy: Create alternating layers
142142
// Layer 1 (bottom): Start with light cube
143143
const layer1 = Solid.MERGE([
144144
// Light cubes at even positions
145-
Solid.GRID_XY(lightCube, { cols: 3, rows: 3 }).move({ x: 0, y: 0, z: 0 }),
146-
// Dark cubes fill gaps
147-
Solid.GRID_XY(darkCube, { cols: 2, rows: 2 }).move({ x: 5, y: 5, z: 0 })
145+
Solid.GRID_XY(sphere, { cols: 3, rows: 3 }).move({ x: 0, y: 0, z: 0 })
148146
]);
149147

150148
// Layer 2 (middle): Start with dark cube (inverted pattern)
151149
const layer2 = Solid.MERGE([
152-
Solid.GRID_XY(darkCube, { cols: 3, rows: 3 }).move({ x: 0, y: 0, z: 5 }),
153-
Solid.GRID_XY(lightCube, { cols: 2, rows: 2 }).move({ x: 5, y: 5, z: 5 })
150+
Solid.GRID_XY(cube, { cols: 3, rows: 3 }).move({ x: 0, y: 5, z: 0 })
154151
]);
155152

156153
// Layer 3 (top): Same as layer 1
157154
const layer3 = Solid.MERGE([
158-
Solid.GRID_XY(lightCube, { cols: 3, rows: 3 }).move({ x: 0, y: 0, z: 10 }),
159-
Solid.GRID_XY(darkCube, { cols: 2, rows: 2 }).move({ x: 5, y: 5, z: 10 })
155+
Solid.GRID_XY(sphere, { cols: 3, rows: 3 }).move({ x: 0, y: 10, z: 0 })
160156
]);
161157

162158
return Solid.MERGE([layer1, layer2, layer3]).center();

projects/examples/K.patterns3d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ const columnGrid = (): Solid => {
166166
// Create entablature (horizontal beam on top)
167167
const entablature = Solid.cube(50, 4, 12, { color: 'gray' })
168168
.align('bottom')
169-
.move({ y: 25, x: -22.5 })
170-
.center({ x: true, z: true });
169+
.move({ y: 25, x: 22.5 })
170+
.center({ z: true });
171171

172172
return Solid.MERGE([platform, columns, entablature]);
173173
};

projects/examples/L.optimization.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,9 @@ const inlineCaching = (): Solid => {
117117
const column1 = cachedColumn(20, 2).move({ x: -15 });
118118

119119
// Second call: Cached result (same params)
120-
const column2 = cachedColumn(20, 2).move({ x: 0 });
120+
const column2 = cachedColumn(20, 2).move({ x: 15 });
121121

122-
// Third call: Cached result (same params again)
123-
const column3 = cachedColumn(20, 2).move({ x: 15 });
124-
125-
return Solid.MERGE([column1, column2, column3]);
122+
return Solid.MERGE([column1, column2]);
126123
};
127124

128125
/**

src/lib/3d/Solid.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,8 @@ export class Solid {
198198
if (wedgePoints.length === 0) return fullCylinder;
199199

200200
// Create wedge prism (make it taller to ensure complete cut)
201-
const wedgeCutter = this.profilePrismFromPoints(height * 1.5, wedgePoints, { color }).move({
202-
y: height * 0.75
203-
}); // Center wedge on Y-axis
201+
// Both cylinder and wedge are centered at Y=0, so no positioning needed
202+
const wedgeCutter = this.profilePrismFromPoints(height * 2, wedgePoints, { color });
204203

205204
// Subtract wedge from cylinder to create closed partial geometry
206205
return Solid.SUBTRACT(fullCylinder, wedgeCutter);
@@ -241,9 +240,8 @@ export class Solid {
241240
if (wedgePoints.length === 0) return fullSphere;
242241

243242
// Create wedge prism tall enough to cut through entire sphere diameter
244-
const wedgeCutter = this.profilePrismFromPoints(radius * 4, wedgePoints, { color }).move({
245-
y: radius * 2
246-
}); // Center wedge on Y-axis
243+
// Both sphere and wedge are centered at Y=0, so no positioning needed
244+
const wedgeCutter = this.profilePrismFromPoints(radius * 4, wedgePoints, { color });
247245

248246
// Subtract wedge from sphere to create closed partial geometry
249247
return Solid.SUBTRACT(fullSphere, wedgeCutter);
@@ -291,9 +289,8 @@ export class Solid {
291289
if (wedgePoints.length === 0) return fullCone;
292290

293291
// Create wedge prism (make it taller to ensure complete cut)
294-
const wedgeCutter = this.profilePrismFromPoints(height * 1.5, wedgePoints, { color }).move({
295-
y: height * 0.75
296-
}); // Center wedge on Y-axis
292+
// Both cone and wedge are centered at Y=0, so no positioning needed
293+
const wedgeCutter = this.profilePrismFromPoints(height * 2, wedgePoints, { color });
297294

298295
// Subtract wedge from cone to create closed partial geometry
299296
return Solid.SUBTRACT(fullCone, wedgeCutter);
@@ -351,9 +348,8 @@ export class Solid {
351348
if (wedgePoints.length === 0) return fullPrism;
352349

353350
// Create wedge prism (make it taller to ensure complete cut)
354-
const wedgeCutter = this.profilePrismFromPoints(height * 1.5, wedgePoints, { color }).move({
355-
y: height * 0.75
356-
}); // Center wedge on Y-axis
351+
// Both prism and wedge are centered at Y=0, so no positioning needed
352+
const wedgeCutter = this.profilePrismFromPoints(height * 2, wedgePoints, { color });
357353

358354
// Subtract wedge from prism to create closed partial geometry
359355
return Solid.SUBTRACT(fullPrism, wedgeCutter);
@@ -670,8 +666,8 @@ export class Solid {
670666
// The wedge needs to extend through the entire height range of the profile
671667
const wedgeHeight = Math.max(profileHeight * 2, maxRadius * 4);
672668
const wedgeCutter = this.profilePrismFromPoints(wedgeHeight, wedgePoints, { color }).move({
673-
y: profileCenter + wedgeHeight / 2
674-
}); // Center the wedge on the profile
669+
y: profileCenter
670+
}); // Center the wedge on the profile center
675671

676672
// Subtract wedge from full revolution to create closed partial geometry
677673
return Solid.SUBTRACT(fullRevolution, wedgeCutter);

0 commit comments

Comments
 (0)