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: 5 additions & 0 deletions .changeset/warm-donuts-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@jolly-pixel/voxel.renderer": minor
---

Remove PoleCross and PoleX shape and keep PoleZ as Pole
15 changes: 3 additions & 12 deletions docs/llms/voxel-renderer-llms-full.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ type BlockShapeID =
| "slabBottom"
| "slabTop"
| "poleY"
| "poleX"
| "poleZ"
| "poleCross"
| "pole"
| "ramp"
| "rampFlip"
| "rampCornerInner"
Expand Down Expand Up @@ -408,16 +406,9 @@ All pole shapes use `collisionHint: "trimesh"` and occlude no faces (sub-voxel c
- **`PoleY`** — `shapeId: "poleY"`.
Narrow vertical post (3/8–5/8 cross-section) running the full block height.

- **`Pole`** — `shapeId: "poleX"`.
Narrow horizontal beam running along the X axis (full width, centered on Y/Z).

- **`Pole`** — `shapeId: "poleZ"`.
- **`Pole`** — `shapeId: "pole"`.
Narrow horizontal beam running along the Z axis (full depth, centered on X/Y).

- **`PoleCross`** — `shapeId: "poleCross"`.
Horizontal plus-connector at mid-height — X and Z beams merged at the centre.
Internal intersection faces are omitted to avoid overdraw.


### Ramps

All ramp shapes use `collisionHint: "trimesh"`.
Expand Down
2 changes: 1 addition & 1 deletion packages/editors/voxel-map/src/ui/BlockLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const kAllShapeIds: BlockShapeID[] = [
"slabBottom",
"slabTop",
"poleY",
"poleX",
"pole",
"ramp",
"rampCornerInner",
"rampCornerOuter",
Expand Down
4 changes: 1 addition & 3 deletions packages/voxel-renderer/docs/Blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ type BlockShapeID =
| "slabBottom"
| "slabTop"
| "poleY"
| "poleX"
| "poleZ"
| "poleCross"
| "pole"
| "ramp"
| "rampCornerInner"
| "rampCornerOuter"
Expand Down
11 changes: 1 addition & 10 deletions packages/voxel-renderer/docs/BuiltInShapes.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ All pole shapes use **collisionHint**: [trimesh](./Collision.md) and occlude no
| Shape ID | Occludes |
|---:|---|
| `poleY` | — |
| `poleX` | — |
| `poleZ` | — |
| `poleCross` | — |

```ts
type PoleAxis = "x" | "z";
```

Passed to the `Pole` constructor to select the axis along which the beam runs.
The default is `"z"`.
| `pole` | — |

### Ramps

Expand Down
15 changes: 2 additions & 13 deletions packages/voxel-renderer/examples/scripts/demo-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Cube } from "../../src/blocks/shapes/Cube.ts";
import { Slab } from "../../src/blocks/shapes/Slab.ts";
import { PoleY } from "../../src/blocks/shapes/PoleY.ts";
import { Pole } from "../../src/blocks/shapes/Pole.ts";
import { PoleCross } from "../../src/blocks/shapes/PoleCross.ts";
import { Ramp } from "../../src/blocks/shapes/Ramp.ts";
import {
RampCornerInner,
Expand Down Expand Up @@ -64,20 +63,10 @@ const kShapes: ShapeEntry[] = [
color: "#26c6da"
},
{
shape: new Pole("x"),
label: "poleX",
color: "#ff7043"
},
{
shape: new Pole("z"),
label: "poleZ",
shape: new Pole(),
label: "pole",
color: "#ab47bc"
},
{
shape: new PoleCross(),
label: "poleCross",
color: "#66bb6a"
},

// ── Ramp ────────────────────────────────────────────────────────────────────
{
Expand Down
4 changes: 1 addition & 3 deletions packages/voxel-renderer/src/blocks/BlockShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ export type BlockShapeID =
| "slabBottom"
| "slabTop"
| "poleY"
| "poleX"
| "poleZ"
| "poleCross"
| "pole"
| "ramp"
| "rampCornerInner"
| "rampCornerOuter"
Expand Down
5 changes: 1 addition & 4 deletions packages/voxel-renderer/src/blocks/BlockShapeRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Ramp } from "./shapes/Ramp.ts";
import { RampCornerInner, RampCornerOuter } from "./shapes/RampCorner.ts";
import { PoleY } from "./shapes/PoleY.ts";
import { Pole } from "./shapes/Pole.ts";
import { PoleCross } from "./shapes/PoleCross.ts";
import {
Stair,
StairCornerInner,
Expand Down Expand Up @@ -48,9 +47,7 @@ export class BlockShapeRegistry {
.register(new Slab("bottom"))
.register(new Slab("top"))
.register(new PoleY())
.register(new Pole("x"))
.register(new Pole("z"))
.register(new PoleCross())
.register(new Pole())
.register(new Ramp())
.register(new RampCornerInner())
.register(new RampCornerOuter())
Expand Down
69 changes: 4 additions & 65 deletions packages/voxel-renderer/src/blocks/shapes/Pole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,21 @@ import type {
const kW = 3 / 8;
const kH = 5 / 8;

export type PoleAxis = "x" | "z";

/**
* Pole — a narrow horizontal beam running along the X or Z axis.
* Cross-section: 0.25×0.25 centered at 0.5, full length along the chosen axis.
* Uses trimesh collision for accurate sub-voxel physics.
*
* "poleZ": z=[0,1], centered x=[kW,kH], y=[kW,kH]
* "poleX": x=[0,1], centered z=[kW,kH], y=[kW,kH]
* "pole": z=[0,1], centered x=[kW,kH], y=[kW,kH]
*/
export class Pole implements BlockShape {
readonly id: BlockShapeID;
readonly collisionHint: BlockCollisionHint = "trimesh";
readonly faces: readonly FaceDefinition[];

constructor(
axis: PoleAxis = "z"
) {
this.id = axis === "z" ? "poleZ" : "poleX";
this.faces = axis === "z" ?
Pole.#buildZFaces() :
Pole.#buildXFaces();
constructor() {
this.id = "pole";
this.faces = Pole.#buildZFaces();
}

occludes(
Expand Down Expand Up @@ -96,58 +89,4 @@ export class Pole implements BlockShape {
}
];
}

static #buildXFaces(): FaceDefinition[] {
// Beam along X: x=[0,1], centered z=[kW,kH], y=[kW,kH]
return [
{
// NegX cap (x=0)
// e1=[0,kH-kW,0], e2=[0,kH-kW,kW-kH] → cross=[-(kH-kW)^2,0,0] ✓
face: FACE.NegX,
normal: [-1, 0, 0],
vertices: [[0, kW, kH], [0, kH, kH], [0, kH, kW], [0, kW, kW]],
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
},
{
// PosX cap (x=1)
// e1=[0,kH-kW,0], e2=[0,kH-kW,kH-kW] → cross=[(kH-kW)^2,0,0] ✓
face: FACE.PosX,
normal: [1, 0, 0],
vertices: [[1, kW, kW], [1, kH, kW], [1, kH, kH], [1, kW, kH]],
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
},
{
// Top (PosY, y=kH)
// e1=[0,0,kH-kW], e2=[1,0,kH-kW] → cross=[0,(kH-kW),0] ✓
face: FACE.PosY,
normal: [0, 1, 0],
vertices: [[0, kH, kW], [0, kH, kH], [1, kH, kH], [1, kH, kW]],
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
},
{
// Bottom (NegY, y=kW)
// e1=[0,0,kW-kH], e2=[1,0,kW-kH] → cross=[0,kW-kH,0] ✓
face: FACE.NegY,
normal: [0, -1, 0],
vertices: [[0, kW, kH], [0, kW, kW], [1, kW, kW], [1, kW, kH]],
uvs: [[0, 0], [0, 1], [1, 1], [1, 0]]
},
{
// NegZ side (z=kW)
// e1=[-1,0,0], e2=[-1,kH-kW,0] → cross=[0,0,-(kH-kW)] ✓
face: FACE.NegZ,
normal: [0, 0, -1],
vertices: [[1, kW, kW], [0, kW, kW], [0, kH, kW], [1, kH, kW]],
uvs: [[0, 0], [1, 0], [1, 1], [0, 1]]
},
{
// PosZ side (z=kH)
// e1=[1,0,0], e2=[1,kH-kW,0] → cross=[0,0,kH-kW] ✓
face: FACE.PosZ,
normal: [0, 0, 1],
vertices: [[0, kW, kH], [1, kW, kH], [1, kH, kH], [0, kH, kH]],
uvs: [[0, 0], [1, 0], [1, 1], [0, 1]]
}
];
}
}
Loading
Loading