Try to fix AI playerss getting bankrupt all the time

Fix z-fighting
This commit is contained in:
tyuXX 2026-11-15 16:09:08 +03:00
parent 2e3cea5a30
commit 5878827d6c
14 changed files with 511 additions and 105 deletions

View file

@ -5,6 +5,7 @@ import {
buildOgiveFairingGeo,
buildParabolicBellGeo,
buildStageConnector,
cappedColumnGroup,
} from "./geometry.js";
import {
ACCENT_STRIPE_MAT,
@ -25,11 +26,14 @@ export function buildSinglePartCopy(
const g = new THREE.Group();
const r = comp.diameter / 2;
if (comp.role === "engine") {
const skirt = new THREE.Mesh(
new THREE.CylinderGeometry(r * 0.55, r * 0.38, comp.length * 0.22, 18),
const skirt = cappedColumnGroup(
r * 0.55,
r * 0.38,
comp.length * 0.22,
AVIONICS_RING_MAT,
{ radialSegs: 18 },
);
skirt.position.y = comp.length * 0.89;
skirt.position.y = comp.length * 0.78;
g.add(skirt);
const bellH = comp.length * 0.8;
const bell = new THREE.Mesh(
@ -53,28 +57,37 @@ export function buildSinglePartCopy(
const aftH = Math.max(0.28, comp.length * 0.06);
const noseH = Math.max(0.55, comp.length * 0.22);
const cylLen = Math.max(0.6, comp.length - aftH - noseH);
const aftCap = new THREE.Mesh(
new THREE.CylinderGeometry(r, r * 0.62, aftH, 32),
barrelMat,
);
aftCap.position.y = aftH / 2;
aftCap.castShadow = true;
aftCap.receiveShadow = true;
const aftCap = cappedColumnGroup(r, r * 0.62, aftH, barrelMat, {
radialSegs: 32,
});
aftCap.traverse((o) => {
if ((o as THREE.Mesh).isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
g.add(aftCap);
const tankMesh = new THREE.Mesh(
new THREE.CylinderGeometry(r, r, cylLen, 36),
barrelMat,
);
tankMesh.position.y = aftH + cylLen / 2;
tankMesh.castShadow = true;
tankMesh.receiveShadow = true;
const tankMesh = cappedColumnGroup(r, r, cylLen, barrelMat, {
radialSegs: 36,
});
tankMesh.position.y = aftH;
tankMesh.traverse((o) => {
if ((o as THREE.Mesh).isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
g.add(tankMesh);
const nose = new THREE.Mesh(
new THREE.CylinderGeometry(r * 0.14, r, noseH, 36),
barrelMat,
);
nose.position.y = aftH + cylLen + noseH / 2;
nose.castShadow = true;
const nose = cappedColumnGroup(r * 0.14, r, noseH, barrelMat, {
radialSegs: 36,
});
nose.position.y = aftH + cylLen;
nose.traverse((o) => {
if ((o as THREE.Mesh).isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
g.add(nose);
const noseTip = new THREE.Mesh(
new THREE.SphereGeometry(r * 0.14, 16, 10),
@ -91,13 +104,15 @@ export function buildSinglePartCopy(
g.add(band);
}
} else {
const tankMesh = new THREE.Mesh(
new THREE.CylinderGeometry(r, r, comp.length, 48),
tankMat,
);
tankMesh.position.y = comp.length / 2;
tankMesh.castShadow = true;
tankMesh.receiveShadow = true;
const tankMesh = cappedColumnGroup(r, r, comp.length, tankMat, {
radialSegs: 48,
});
tankMesh.traverse((o) => {
if ((o as THREE.Mesh).isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
g.add(tankMesh);
for (const frac of [0.15, 0.5, 0.85]) {
const ring = new THREE.Mesh(
@ -120,24 +135,28 @@ export function buildSinglePartCopy(
g.add(raceway);
}
} else if (comp.role === "heatshield") {
const shield = new THREE.Mesh(
new THREE.CylinderGeometry(r * 1.03, r * 1.03, comp.length, 32),
const shield = cappedColumnGroup(
r * 1.03,
r * 1.03,
comp.length,
new THREE.MeshStandardMaterial({
color: 0x451a03,
metalness: 0.3,
roughness: 0.85,
}),
{ radialSegs: 32 },
);
shield.position.y = comp.length / 2;
g.add(shield);
} else if (comp.role === "structure") {
const avionics = new THREE.Mesh(
new THREE.CylinderGeometry(r, r, comp.length, 48),
tankMat,
);
avionics.position.y = comp.length / 2;
avionics.castShadow = true;
avionics.receiveShadow = true;
const avionics = cappedColumnGroup(r, r, comp.length, tankMat, {
radialSegs: 48,
});
avionics.traverse((o) => {
if ((o as THREE.Mesh).isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
g.add(avionics);
const botTrim = new THREE.Mesh(
new THREE.CylinderGeometry(
@ -172,20 +191,19 @@ export function buildSinglePartCopy(
const topR = nextStageDia > 0.2 ? nextStageDia / 2 : r;
g.add(buildStageConnector(botR, topR, Math.max(0.6, comp.length), tankMat));
} else if (comp.role === "computer") {
const collar = new THREE.Mesh(
new THREE.CylinderGeometry(
r * 1.02,
r * 1.02,
Math.max(0.45, comp.length),
24,
),
const collarH = Math.max(0.45, comp.length);
const collar = cappedColumnGroup(
r * 1.02,
r * 1.02,
collarH,
new THREE.MeshStandardMaterial({
color: 0x0f172a,
metalness: 0.72,
roughness: 0.28,
}),
{ radialSegs: 24 },
);
collar.position.y = Math.max(0.45, comp.length) / 2;
g.add(collar);
const ledColor =
(comp.part.radHardeningLevel ?? 1) >= 3
? 0x34d399
@ -198,7 +216,7 @@ export function buildSinglePartCopy(
);
busRing.rotation.x = Math.PI / 2;
busRing.position.y = Math.max(0.45, comp.length) * 0.55;
g.add(collar, busRing);
g.add(busRing);
} else if (comp.role === "fairing") {
const shroud = new THREE.Mesh(
buildOgiveFairingGeo(r, comp.length),