Objets nouveaux, pose : arrêt de bus, colocation et potager posés (grille de place libre encadrée), navette sur l'anneau, atelier public de distillation à part, enclos fermé, libre() indexé par cases
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWGVmzHkRQiiivdZYKzLAP
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
34e0727572
commit
cce695b4e9
+16
-1
@@ -44,13 +44,21 @@ export function plan(D, arbres3D, el, transformees) {
|
||||
const boites = segs.map(([ax, az, bx, bz, r]) => [Math.min(ax, bx) - r, Math.max(ax, bx) + r, Math.min(az, bz) - r, Math.max(az, bz) + r]);
|
||||
const gArbres = grille(arbres), g3D = grille(arbres3D.map((a) => [a.x, a.z, a.centre, a.rx, a.ry]));
|
||||
const toits = D.maisons.map((m) => { const X = m.p.map((p) => p[0]), Z = m.p.map((p) => p[1]); return { x0: Math.min(...X) - 1.2, x1: Math.max(...X) + 1.2, z0: Math.min(...Z) - 1.2, z1: Math.max(...Z) + 1.2, H: m.t === 'grand' ? 12 : 8.5 }; });
|
||||
// les segments rangés par cases de 16 m (chacun dans toutes les cases à moins de LOIN de sa boîte) : `libre` ne lit que
|
||||
// ceux de sa case. Même résultat que la lecture de tous ; les poses des objets nouveaux (objets.js) l'appellent beaucoup.
|
||||
const CASE = 16, parCase = new Map(), cleC = (i, j) => (i + 512) * 1024 + j + 512;
|
||||
boites.forEach((b, n) => {
|
||||
for (let i = Math.floor((b[0] - LOIN) / CASE); i <= Math.floor((b[1] + LOIN) / CASE); i++) for (let j = Math.floor((b[2] - LOIN) / CASE); j <= Math.floor((b[3] + LOIN) / CASE); j++) {
|
||||
const k = cleC(i, j); let L = parCase.get(k); if (!L) parCase.set(k, (L = [])); L.push(n);
|
||||
}
|
||||
});
|
||||
const dSeg = (x, z, [ax, az, bx, bz]) => { const dx = bx - ax, dz = bz - az, l = dx * dx + dz * dz || 1, t = Math.max(0, Math.min(1, ((x - ax) * dx + (z - az) * dz) / l)); return Math.hypot(x - ax - t * dx, z - az - t * dz); };
|
||||
return {
|
||||
arbres,
|
||||
/** Place libre autour de (x, z), en mètres ; `avecArbres` : les troncs comptent (rayon 1,5 m). */
|
||||
libre(x, z, avecArbres = true) {
|
||||
let d = LOIN;
|
||||
segs.forEach((s, i) => { const b = boites[i]; if (x < b[0] - d || x > b[1] + d || z < b[2] - d || z > b[3] + d) return; d = Math.min(d, dSeg(x, z, s) - s[4]); });
|
||||
for (const i of parCase.get(cleC(Math.floor(x / CASE), Math.floor(z / CASE))) || []) { const b = boites[i]; if (x < b[0] - d || x > b[1] + d || z < b[2] - d || z > b[3] + d) continue; d = Math.min(d, dSeg(x, z, segs[i]) - segs[i][4]); }
|
||||
for (const [px, pz, r] of points) d = Math.min(d, Math.hypot(px - x, pz - z) - r);
|
||||
if (avecArbres) gArbres(x - d - 1.5, x + d + 1.5, z - d - 1.5, z + d + 1.5, ([px, pz]) => { d = Math.min(d, Math.hypot(px - x, pz - z) - 1.5); });
|
||||
return d;
|
||||
@@ -180,6 +188,13 @@ function enclos(a, b) {
|
||||
for (const y of [0.45, 0.8]) for (let i = 0; i < 4; i++) { const [p, q] = [coins[i], coins[(i + 1) % 4]]; fil.push(p[0], y, p[1], q[0], y, q[1]); }
|
||||
const geo = new THREE.BufferGeometry(); geo.setAttribute('position', new THREE.Float32BufferAttribute(fil, 3));
|
||||
g.add(new THREE.LineSegments(geo, new THREE.LineBasicMaterial({ color: COUL.fil, transparent: true, opacity: 0.8 })));
|
||||
// un grillage bas sur les quatre côtés : l'enclos est fermé aux sangliers (peste porcine africaine ; base de connaissances,
|
||||
// « Un cochon pour trois maisons », 03/11)
|
||||
const grillage = new THREE.MeshLambertMaterial({ color: COUL.fil, transparent: true, opacity: 0.3, depthWrite: false, side: THREE.DoubleSide });
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const [p, q] = [coins[i], coins[(i + 1) % 4]], L = Math.hypot(q[0] - p[0], q[1] - p[1]);
|
||||
const m = new THREE.Mesh(new THREE.PlaneGeometry(L, 0.7), grillage); m.position.set((p[0] + q[0]) / 2, 0.38, (p[1] + q[1]) / 2); m.rotation.y = -Math.atan2(q[1] - p[1], q[0] - p[0]); g.add(m);
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user