ugly-game 0.15.10 → 0.15.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,15 +82,33 @@ export declare const CUBE: {
82
82
  pos: string;
83
83
  nrm: string;
84
84
  };
85
+ /**
86
+ * HOW MANY SEGMENTS A ROUNDED CORNER IS CUT INTO. 1 is what this file did for its whole life: a
87
+ * chamfer, one flat 45° face per edge and one flat triangle per corner.
88
+ *
89
+ * ⚠️ A CHAMFER IS NOT A RADIUS, and only the EDGES got away with it. A band's shading normal sweeps
90
+ * 90° across the strip, which shades almost exactly like a cylinder, so a flat edge reads round. A
91
+ * corner has nowhere to sweep to: it is one triangle with one plane, its silhouette is a straight
92
+ * cut, and no amount of normal work fixes that. Reported as "all corners should be radiused, it
93
+ * seems like you are trying to draw a simple triangle for the corners" — which is what it was.
94
+ *
95
+ * The band's end arc and the facet's edge arc are THE SAME CIRCLE — radius b, centred at the corner
96
+ * pulled in by b on all three axes — so subdividing both is one construction and they meet arc for
97
+ * arc at every step. At 1 it reproduces the old geometry exactly.
98
+ */
99
+ export declare const BEVEL_SEG = 1;
85
100
  /** Vertex counts for the two cube geometries the camera pass can draw. */
86
101
  export declare const SHARP_VERTS = 36;
87
- export declare const BEVEL_VERTS = 276;
102
+ export declare const BEVEL_VERTS: number;
88
103
  /** What a vertex is, which decides how it is allowed to move. */
89
104
  export declare const ROLE_SHARP = 0;
90
105
  export declare const ROLE_CENTER = 1;
91
106
  export declare const ROLE_RIM = 2;
92
107
  export declare const ROLE_BAND = 3;
93
108
  export declare const ROLE_FACET = 4;
109
+ export declare const ROLE_FRIM = 5;
110
+ export declare const ROLE_FMID = 6;
111
+ export declare const ROLE_CARVE = 7;
94
112
  export interface BevelCube {
95
113
  /** Which of the 8 sharp corners each vertex sits on — always (±0.5, ±0.5, ±0.5), except a fan
96
114
  * hub, which sits at its face centre. */
@@ -105,6 +123,8 @@ export interface BevelCube {
105
123
  * face's two in-plane axes stays put), which is what splits one corner into two
106
124
  * points and turns the quad into a pentagon.
107
125
  * ROLE_FACET — the cube edge this facet vertex belongs to.
126
+ * ROLE_CARVE — the cube edge this patch vertex runs `b` down, which is the ONE axis it moves
127
+ * along. One per axis, so the three of them are the patch's three corners.
108
128
  * Zero for every other role. */
109
129
  axis: [number, number, number][];
110
130
  cornerWgsl: string;
@@ -124,27 +144,30 @@ export declare function occSolid(mask: number, o: readonly [number, number, numb
124
144
  * one that knows the other block is there.
125
145
  */
126
146
  export declare function edgeOpen(mask: number, a: readonly [number, number, number], b: readonly [number, number, number]): number;
147
+ /** `edgeOpen`, asked of the cell one step away at `off` — is the NEIGHBOUR chamfering this edge? */
148
+ export declare function edgeOpenAt(mask: number, off: readonly [number, number, number], a: readonly [number, number, number], b: readonly [number, number, number]): number;
127
149
  /**
128
- * THE TAPER — does this edge keep going in the next cell along it?
150
+ * Does the edge between exposed face `home` and its in-plane neighbour `e` get a FILLET?
129
151
  *
130
- * A chamfer used to be all-or-nothing per cell, so where a chamfered edge met a block that does not
131
- * chamfer (its own neighbour is solid) the rounding STOPPED DEAD in a step the height of the bevel.
132
- * That is the "concave corners are not rendering correctly" report: at every inside junction a
133
- * rounded edge ran into a square one and left a hard notch.
152
+ * Two bits, read from an exposed face, classify every edge there is — and they are the whole edge
153
+ * table from the design, with no case left over:
134
154
  *
135
- * `j` is the edge's own direction, signed toward the end this vertex sits at. Evaluating `edgeOpen`
136
- * one cell further along it asks whether the neighbour chamfers the same edge; multiplying, the band
137
- * fades to nothing across the last block instead of ending in a wall.
155
+ * occ(e) occ(home+e) cells solid class operation
156
+ * 0 0 1 convex CHAMFER (edgeOpen)
157
+ * 1 0 2 adj flat nothing
158
+ * 1 1 3 concave FILLET
159
+ * 0 1 2 diag saddle FILLET
138
160
  *
139
- * ⚠️ AND THIS IS WHY IT CANNOT TEAR, which the previous attempt at the same symptom could not claim.
140
- * Take the two cells sharing a vertex along the edge: one computes `edgeOpen(here) · edgeOpen(there)`
141
- * and the other computes `edgeOpen(there) · edgeOpen(here)`. The product is SYMMETRIC, so they agree
142
- * by construction rather than by luck — no block can cut a shared corner its neighbour keeps.
161
+ * So the fillet gate is just `occ(home+e)` on an exposed face — the cell diagonally across the edge
162
+ * being solid is exactly the thing that makes a groove. ⚠️ THE SADDLE FALLS OUT FOR FREE and needs no
163
+ * code of its own: from either solid cube's side, its near quadrant is an ordinary concave groove.
143
164
  *
144
- * Every cell it reads (a+j, b+j, a+b+j) has all components in {-1,0,1}, so it stays inside the
145
- * 27-neighbourhood the mask carries.
165
+ * ⚠️ A FILLET ADDS MATERIAL, WHICH IS WHY IT CANNOT OPEN A HOLE. Every other rounding term in this
166
+ * file is guarded against tearing the surface, because cutting is what tears. Filling never does —
167
+ * and it is why the diagonal case, which three earlier versions tried to CUT into a connection and
168
+ * turned into a see-through diamond, is safe here.
146
169
  */
147
- export declare function edgeOpenTapered(mask: number, a: readonly [number, number, number], b: readonly [number, number, number], j: readonly [number, number, number]): number;
170
+ export declare function edgeFillet(mask: number, home: readonly [number, number, number], e: readonly [number, number, number]): number;
148
171
  /**
149
172
  * THE NOTCH — the exact complement of `edgeOpen`: both faces SOLID, the diagonal between them AIR.
150
173
  *
@@ -189,7 +212,71 @@ export declare const NOTCH_SCALE = 0.5;
189
212
  * ground — "concave corners are not rendering correctly". The step is the correct trade.
190
213
  */
191
214
  export declare function case3(mask: number, a: readonly [number, number, number], corner: readonly [number, number, number]): number;
192
- export declare function bevelVertex(corner: readonly [number, number, number], home: readonly [number, number, number], mask: number, bevel: number, role?: number, axis?: readonly [number, number, number]): [number, number, number];
215
+ /**
216
+ * THE INSIDE CORNER, as an EIGHT-CELL configuration — `case3` plus the three cells above it.
217
+ *
218
+ * `case3` alone says the surface turns a corner here. It does NOT say the two chamfers this patch
219
+ * has to meet actually exist, and that is a different question: the neighbour at `fa` chamfers its
220
+ * edge into the notch only if the cells above IT and above the notch are air too. Where they are
221
+ * not, there is no band end to land on, the patch's sides find no partner, and both halves of this
222
+ * change open holes instead of closing them (measured: the random field went 21 unpaired edges to
223
+ * 34, six of them the patch's own sides).
224
+ *
225
+ * So the gate is the whole corner, all eight cells around the lattice point:
226
+ *
227
+ * LOWER layer — this cube SOLID, both in-plane neighbours SOLID, the notch AIR
228
+ * UPPER layer — all four AIR
229
+ *
230
+ * ⚠️ THIS IS A CASE TABLE ENTRY, NOT A HEURISTIC, and the narrowness is the point. It is the ONE
231
+ * configuration whose patch is watertight by construction, because every one of the three points is
232
+ * then already emitted by a neighbour. Any other corner is left exactly as it was — the design's own
233
+ * conclusion that a corner is a 256-case marching-cubes configuration rather than something to be
234
+ * hand-enumerated, and the rest of that table is not built yet.
235
+ *
236
+ * ⚠️ AND IT GATES THE RIM RETREAT TOO, not just the patch. The retreat is only safe where the
237
+ * neighbour retreats its own rim by the same b, which is the same condition. See bevelVertex.
238
+ */
239
+ export declare function carveOpen(mask: number, home: readonly [number, number, number], corner: readonly [number, number, number]): number;
240
+ /**
241
+ * THE SAME INSIDE CORNER, ASKED BY ANY OF THE EIGHT CELLS — the direction of the all-air layer, or
242
+ * null. `carveOpen` can only be asked by the ONE cube whose exposed face turns the corner; this is
243
+ * the frame-independent form, and the two neighbours need it.
244
+ *
245
+ * ⚠️ THEY NEED IT BECAUSE A FACE THAT DOES NOT RETREAT COVERS THE PATCH. The corner cube's two side
246
+ * faces at such a corner are BURIED — each is shared with one of the neighbours — so nothing in the
247
+ * chamfer rules touches them, and they keep their full square corner while the carve cuts the corner
248
+ * away in front of them. What is left is a thin triangular sheet of each standing in open air, two
249
+ * of them meeting in a V exactly where the rounded corner should be: the patch is drawn, and you
250
+ * cannot see it. It is the "little sheets between each cube" report again, at a carved corner.
251
+ *
252
+ * A buried face is drawn by BOTH cubes that share it, so both have to reach the same verdict or the
253
+ * clip opens a seam. Both see all eight cells (they are all within one step of either cube), and
254
+ * this asks only about those eight — so they cannot disagree.
255
+ */
256
+ export declare function carveCorner(mask: number, corner: readonly [number, number, number]): [number, number, number] | null;
257
+ /**
258
+ * WHICH face at this corner is the exposed one that the carve fires on — or null if none is.
259
+ *
260
+ * The corner carve (section 6) is a property of the CORNER, but a triangle's texture and shading
261
+ * normal come from a `home` face, and which of the three faces meeting here is the exposed one is
262
+ * something only the mask knows. So the patch's `home` is resolved at draw time, from this.
263
+ *
264
+ * ⚠️ AT MOST ONE FACE CAN ANSWER, which is what makes "the corner's verdict" well defined and means
265
+ * no election is needed. The gate on face `h` needs `h` AIR and both its in-plane neighbours SOLID;
266
+ * any other face at this corner is one of those in-plane neighbours, so it is solid and its own gate
267
+ * is false. The three tests are mutually exclusive by construction.
268
+ *
269
+ * ⚠️ AND ONLY ONE OF THE EIGHT CELLS CAN ANSWER AT ALL, which is what makes the patch need no
270
+ * ownership election. Of the three solid cells at such a corner, the two neighbours each see the
271
+ * notch across a FACE, not diagonally, so their own in-plane pair is never both-solid.
272
+ */
273
+ export declare function carveFace(mask: number, corner: readonly [number, number, number]): [number, number, number] | null;
274
+ export declare function bevelVertex(corner: readonly [number, number, number], home: readonly [number, number, number], mask: number, bevel: number, role?: number, axis?: readonly [number, number, number],
275
+ /** The CONCAVE radius. Separate from `bevel` (the convex one) so the two halves of the rounding
276
+ * can be turned up, down and off independently — the only way to tell which one a defect is in.
277
+ * Defaults to the convex radius, which is the "one uniformly rounded solid" the design wants. */
278
+ concave?: number): [number, number, number];
279
+ export declare const COMMON_WGSL: string;
193
280
  export declare class GpuShadowRenderer {
194
281
  private device;
195
282
  private instBuf;
@@ -245,6 +332,7 @@ export declare class GpuShadowRenderer {
245
332
  private matCutoff;
246
333
  private eye;
247
334
  private bevel;
335
+ private fillet;
248
336
  private alphaPipe;
249
337
  private alphaBGL;
250
338
  private overlayBuf;
@@ -349,7 +437,7 @@ export declare class GpuShadowRenderer {
349
437
  * The shadow pass keeps the sharp cube either way. At 0 the vertex count drops back to 36, so
350
438
  * leaving this alone costs exactly what it cost before the feature existed.
351
439
  */
352
- setBevel(amount: number): void;
440
+ setBevel(amount: number, concave?: number): void;
353
441
  setAtlas(tex: GPUTexture, layout: AtlasLayout): void;
354
442
  /** Static scene: sizes the buffer to exactly these instances. */
355
443
  setScene(instances: CubeInstance[]): void;