feat: configure outdoor texture scale and rotation per area
This commit is contained in:
1 parent
d8cf076019
commit
c56f1a5ba9
26 files changed
+1958
-1778
No files matched your search
@@ -5,7 +5,7 @@
|
||||
// patches cut out of it.
|
||||
|
||||
import { Color } from "three";
|
||||
import { bounds, cutsOut, groundLevel, isAxisRect, OUTDOOR_TOP, outdoorDrop, outdoorStanding, pointInPolygon, type Floor, type OutdoorArea, type Vec2 } from "../../model.ts";
|
||||
import { bounds, cutsOut, groundLevel, isAxisRect, OUTDOOR_TOP, outdoorDrop, outdoorStanding, outdoorTextureSettings, pointInPolygon, type Floor, type OutdoorArea, type Vec2 } from "../../model.ts";
|
||||
import { ALWAYS, pushPrism, shade, triangulate, type GeoBuffer, type LineBuffer } from "../geo.ts";
|
||||
import { counterClockwise, pushBeam, pushPost } from "./beams.ts";
|
||||
import { gateLayout, gatesOnEdge } from "./gates.ts";
|
||||
@@ -194,6 +194,7 @@ export function outdoorOpacity(area: OutdoorArea): number {
|
||||
export function pushOutdoor(buf: GeoBuffer, lines: LineBuffer, floor: Floor, ghosts?: Map<number, GeoBuffer>, makeBuffer?: () => GeoBuffer): void {
|
||||
// The shared wall shader also serves floors without outdoor areas: supply a neutral ID there.
|
||||
buf.surface ??= Array(buf.p.length / 3).fill(0);
|
||||
buf.surfaceTransform ??= Array.from({ length: (buf.p.length / 3) * 2 }, (_, i) => i % 2 === 0 ? 1 : 0);
|
||||
const ground = groundLevel(floor);
|
||||
const areas = floor.outdoor ?? [];
|
||||
areas.forEach((area, index) => {
|
||||
@@ -209,6 +210,7 @@ export function pushOutdoor(buf: GeoBuffer, lines: LineBuffer, floor: Floor, gho
|
||||
target = ghosts.get(opacity)!;
|
||||
}
|
||||
target.surface ??= Array(target.p.length / 3).fill(0);
|
||||
target.surfaceTransform ??= Array.from({ length: (target.p.length / 3) * 2 }, (_, i) => i % 2 === 0 ? 1 : 0);
|
||||
const firstVertex = target.p.length / 3;
|
||||
const context: Context = {
|
||||
buf: target,
|
||||
@@ -229,5 +231,10 @@ export function pushOutdoor(buf: GeoBuffer, lines: LineBuffer, floor: Floor, gho
|
||||
else if (area.type === "pergola") buildPergola(context);
|
||||
else buildBlock(context, areas, index);
|
||||
target.surface.fill(OUTDOOR_MATERIAL[area.type], firstVertex);
|
||||
const texture = outdoorTextureSettings(area);
|
||||
for (let v = firstVertex; v < target.p.length / 3; v++) {
|
||||
target.surfaceTransform[v * 2] = texture.scale;
|
||||
target.surfaceTransform[v * 2 + 1] = texture.rotation * Math.PI / 180;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user