Skip to content

Commit 48766e8

Browse files
authored
refactor(voxel-renderer): remove PoleCross and PoleX and keep PoleZ as Pole (#271)
1 parent 6781b69 commit 48766e8

File tree

12 files changed

+21
-290
lines changed

12 files changed

+21
-290
lines changed

.changeset/warm-donuts-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@jolly-pixel/voxel.renderer": minor
3+
---
4+
5+
Remove PoleCross and PoleX shape and keep PoleZ as Pole

docs/llms/voxel-renderer-llms-full.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ type BlockShapeID =
251251
| "slabBottom"
252252
| "slabTop"
253253
| "poleY"
254-
| "poleX"
255-
| "poleZ"
256-
| "poleCross"
254+
| "pole"
257255
| "ramp"
258256
| "rampFlip"
259257
| "rampCornerInner"
@@ -408,16 +406,9 @@ All pole shapes use `collisionHint: "trimesh"` and occlude no faces (sub-voxel c
408406
- **`PoleY`**`shapeId: "poleY"`.
409407
Narrow vertical post (3/8–5/8 cross-section) running the full block height.
410408

411-
- **`Pole`**`shapeId: "poleX"`.
412-
Narrow horizontal beam running along the X axis (full width, centered on Y/Z).
413-
414-
- **`Pole`**`shapeId: "poleZ"`.
409+
- **`Pole`**`shapeId: "pole"`.
415410
Narrow horizontal beam running along the Z axis (full depth, centered on X/Y).
416-
417-
- **`PoleCross`**`shapeId: "poleCross"`.
418-
Horizontal plus-connector at mid-height — X and Z beams merged at the centre.
419-
Internal intersection faces are omitted to avoid overdraw.
420-
411+
421412
### Ramps
422413

423414
All ramp shapes use `collisionHint: "trimesh"`.

packages/editors/voxel-map/src/ui/BlockLibrary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const kAllShapeIds: BlockShapeID[] = [
3434
"slabBottom",
3535
"slabTop",
3636
"poleY",
37-
"poleX",
37+
"pole",
3838
"ramp",
3939
"rampCornerInner",
4040
"rampCornerOuter",

packages/voxel-renderer/docs/Blocks.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ type BlockShapeID =
4646
| "slabBottom"
4747
| "slabTop"
4848
| "poleY"
49-
| "poleX"
50-
| "poleZ"
51-
| "poleCross"
49+
| "pole"
5250
| "ramp"
5351
| "rampCornerInner"
5452
| "rampCornerOuter"

packages/voxel-renderer/docs/BuiltInShapes.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,7 @@ All pole shapes use **collisionHint**: [trimesh](./Collision.md) and occlude no
3131
| Shape ID | Occludes |
3232
|---:|---|
3333
| `poleY` ||
34-
| `poleX` ||
35-
| `poleZ` ||
36-
| `poleCross` ||
37-
38-
```ts
39-
type PoleAxis = "x" | "z";
40-
```
41-
42-
Passed to the `Pole` constructor to select the axis along which the beam runs.
43-
The default is `"z"`.
34+
| `pole` ||
4435

4536
### Ramps
4637

packages/voxel-renderer/examples/scripts/demo-shapes.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { Cube } from "../../src/blocks/shapes/Cube.ts";
1717
import { Slab } from "../../src/blocks/shapes/Slab.ts";
1818
import { PoleY } from "../../src/blocks/shapes/PoleY.ts";
1919
import { Pole } from "../../src/blocks/shapes/Pole.ts";
20-
import { PoleCross } from "../../src/blocks/shapes/PoleCross.ts";
2120
import { Ramp } from "../../src/blocks/shapes/Ramp.ts";
2221
import {
2322
RampCornerInner,
@@ -64,20 +63,10 @@ const kShapes: ShapeEntry[] = [
6463
color: "#26c6da"
6564
},
6665
{
67-
shape: new Pole("x"),
68-
label: "poleX",
69-
color: "#ff7043"
70-
},
71-
{
72-
shape: new Pole("z"),
73-
label: "poleZ",
66+
shape: new Pole(),
67+
label: "pole",
7468
color: "#ab47bc"
7569
},
76-
{
77-
shape: new PoleCross(),
78-
label: "poleCross",
79-
color: "#66bb6a"
80-
},
8170

8271
// ── Ramp ────────────────────────────────────────────────────────────────────
8372
{

packages/voxel-renderer/src/blocks/BlockShape.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ export type BlockShapeID =
3838
| "slabBottom"
3939
| "slabTop"
4040
| "poleY"
41-
| "poleX"
42-
| "poleZ"
43-
| "poleCross"
41+
| "pole"
4442
| "ramp"
4543
| "rampCornerInner"
4644
| "rampCornerOuter"

packages/voxel-renderer/src/blocks/BlockShapeRegistry.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Ramp } from "./shapes/Ramp.ts";
66
import { RampCornerInner, RampCornerOuter } from "./shapes/RampCorner.ts";
77
import { PoleY } from "./shapes/PoleY.ts";
88
import { Pole } from "./shapes/Pole.ts";
9-
import { PoleCross } from "./shapes/PoleCross.ts";
109
import {
1110
Stair,
1211
StairCornerInner,
@@ -48,9 +47,7 @@ export class BlockShapeRegistry {
4847
.register(new Slab("bottom"))
4948
.register(new Slab("top"))
5049
.register(new PoleY())
51-
.register(new Pole("x"))
52-
.register(new Pole("z"))
53-
.register(new PoleCross())
50+
.register(new Pole())
5451
.register(new Ramp())
5552
.register(new RampCornerInner())
5653
.register(new RampCornerOuter())

packages/voxel-renderer/src/blocks/shapes/Pole.ts

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,21 @@ import type {
1313
const kW = 3 / 8;
1414
const kH = 5 / 8;
1515

16-
export type PoleAxis = "x" | "z";
17-
1816
/**
1917
* Pole — a narrow horizontal beam running along the X or Z axis.
2018
* Cross-section: 0.25×0.25 centered at 0.5, full length along the chosen axis.
2119
* Uses trimesh collision for accurate sub-voxel physics.
2220
*
23-
* "poleZ": z=[0,1], centered x=[kW,kH], y=[kW,kH]
24-
* "poleX": x=[0,1], centered z=[kW,kH], y=[kW,kH]
21+
* "pole": z=[0,1], centered x=[kW,kH], y=[kW,kH]
2522
*/
2623
export class Pole implements BlockShape {
2724
readonly id: BlockShapeID;
2825
readonly collisionHint: BlockCollisionHint = "trimesh";
2926
readonly faces: readonly FaceDefinition[];
3027

31-
constructor(
32-
axis: PoleAxis = "z"
33-
) {
34-
this.id = axis === "z" ? "poleZ" : "poleX";
35-
this.faces = axis === "z" ?
36-
Pole.#buildZFaces() :
37-
Pole.#buildXFaces();
28+
constructor() {
29+
this.id = "pole";
30+
this.faces = Pole.#buildZFaces();
3831
}
3932

4033
occludes(
@@ -96,58 +89,4 @@ export class Pole implements BlockShape {
9689
}
9790
];
9891
}
99-
100-
static #buildXFaces(): FaceDefinition[] {
101-
// Beam along X: x=[0,1], centered z=[kW,kH], y=[kW,kH]
102-
return [
103-
{
104-
// NegX cap (x=0)
105-
// e1=[0,kH-kW,0], e2=[0,kH-kW,kW-kH] → cross=[-(kH-kW)^2,0,0] ✓
106-
face: FACE.NegX,
107-
normal: [-1, 0, 0],
108-
vertices: [[0, kW, kH], [0, kH, kH], [0, kH, kW], [0, kW, kW]],
109-
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
110-
},
111-
{
112-
// PosX cap (x=1)
113-
// e1=[0,kH-kW,0], e2=[0,kH-kW,kH-kW] → cross=[(kH-kW)^2,0,0] ✓
114-
face: FACE.PosX,
115-
normal: [1, 0, 0],
116-
vertices: [[1, kW, kW], [1, kH, kW], [1, kH, kH], [1, kW, kH]],
117-
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
118-
},
119-
{
120-
// Top (PosY, y=kH)
121-
// e1=[0,0,kH-kW], e2=[1,0,kH-kW] → cross=[0,(kH-kW),0] ✓
122-
face: FACE.PosY,
123-
normal: [0, 1, 0],
124-
vertices: [[0, kH, kW], [0, kH, kH], [1, kH, kH], [1, kH, kW]],
125-
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
126-
},
127-
{
128-
// Bottom (NegY, y=kW)
129-
// e1=[0,0,kW-kH], e2=[1,0,kW-kH] → cross=[0,kW-kH,0] ✓
130-
face: FACE.NegY,
131-
normal: [0, -1, 0],
132-
vertices: [[0, kW, kH], [0, kW, kW], [1, kW, kW], [1, kW, kH]],
133-
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
134-
},
135-
{
136-
// NegZ side (z=kW)
137-
// e1=[-1,0,0], e2=[-1,kH-kW,0] → cross=[0,0,-(kH-kW)] ✓
138-
face: FACE.NegZ,
139-
normal: [0, 0, -1],
140-
vertices: [[1, kW, kW], [0, kW, kW], [0, kH, kW], [1, kH, kW]],
141-
uvs: [[0, 0], [1, 0], [1, 1], [0, 1]]
142-
},
143-
{
144-
// PosZ side (z=kH)
145-
// e1=[1,0,0], e2=[1,kH-kW,0] → cross=[0,0,kH-kW] ✓
146-
face: FACE.PosZ,
147-
normal: [0, 0, 1],
148-
vertices: [[0, kW, kH], [1, kW, kH], [1, kH, kH], [0, kH, kH]],
149-
uvs: [[0, 0], [1, 0], [1, 1], [0, 1]]
150-
}
151-
];
152-
}
15392
}

0 commit comments

Comments
 (0)