Objets nouveaux : point de reprise du 03/11 (travail du 31/10, non relu)
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
f8ec86469f
commit
34e0727572
+15
-12
@@ -23,7 +23,7 @@ function grille(L, pas = 8) {
|
||||
for (const o of L) { const k = cle(Math.floor(o[0] / pas), Math.floor(o[1] / pas)); let c = g.get(k); if (!c) g.set(k, (c = [])); c.push(o); }
|
||||
return (x0, x1, z0, z1, f) => { for (let i = Math.floor(x0 / pas); i <= Math.floor(x1 / pas); i++) for (let j = Math.floor(z0 / pas); j <= Math.floor(z1 / pas); j++) { const c = g.get(cle(i, j)); if (c) for (const o of c) f(o); } };
|
||||
}
|
||||
function plan(D, arbres3D, el, transformees) {
|
||||
export function plan(D, arbres3D, el, transformees) {
|
||||
const segs = [], arbres = [];
|
||||
const poly = (p, r, ferme = false) => {
|
||||
const q = ferme ? [...p, p[0]] : p; let a = q[0];
|
||||
@@ -187,9 +187,11 @@ function enclos(a, b) {
|
||||
// ctx : { D, groupe, transformees, T (maison témoin), mats: { zinc, cuve }, matsArbres: { couronne, tronc, fruit },
|
||||
// potager: points du potager témoin, haiesT: haies du jardin témoin, arbres3D: tous les arbres posés
|
||||
// ({ x, z, centre, rx, ry } : ce qui peut cacher un objet), el: l'élévation de la caméra }
|
||||
// Rend { anim: [(t) => …], points: { cuves, baissiere, tube, cochon, chantier, surplus, planches } } (x, z du centre).
|
||||
// Rend { anim: [(t) => …], points: { cuves, baissiere, tube, cochon, chantier, surplus, planches } } (x, z du centre),
|
||||
// objets: { <même clé>: [THREE.Object3D] } (ce qu'on touche pour ouvrir la fiche, ce qui s'allume), et P, la grille
|
||||
// d'occupation, que les objets nouveaux (objets.js) reprennent : une seule grille pour les deux fichiers.
|
||||
export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, potager, haiesT, arbres3D, el }) {
|
||||
const P = plan(D, arbres3D, el, transformees), anim = [], points = {};
|
||||
const P = plan(D, arbres3D, el, transformees), anim = [], points = {}, objets = {};
|
||||
const pose = (o, x, z, rot = 0, r = 1.5) => { o.position.set(x, 0, z); o.rotation.y = rot; groupe.add(o); P.ajoute(x, z, r); return o; };
|
||||
// repère d'une maison : local (lx, lz) → monde
|
||||
const monde = (m, lx, lz) => { const v = m.g.localToWorld(new THREE.Vector3(lx, 0, lz)); return [v.x, v.z]; };
|
||||
@@ -214,7 +216,7 @@ export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, pot
|
||||
}
|
||||
if (best) {
|
||||
const m = best.m, a = appentisCuves(m, mats, best.dz);
|
||||
a.position.copy(m.g.position); a.rotation.y = m.g.rotation.y; groupe.add(a); prise.add(m);
|
||||
a.position.copy(m.g.position); a.rotation.y = m.g.rotation.y; groupe.add(a); prise.add(m); objets.cuves = [a];
|
||||
const [x, z] = monde(m, -(m.Lu + m.ite) / 2 - 1.8, best.dz); points.cuves = { x, z }; P.ajoute(x, z, 2.6);
|
||||
}
|
||||
}
|
||||
@@ -249,7 +251,8 @@ export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, pot
|
||||
const j = 0.9 + rnd(i * 3.1) * 0.25;
|
||||
items.push({ x: best.x + best.dx * s + best.nx * o, z: best.z + best.dz * s + best.nz * o, H: 7.2 * j, W: 2.3 * j, forme: 'ovoïde', couleur: teinte('#a6c27a', {}, 91000 + i), fruit: null, rot: rnd(i) * 6.28 });
|
||||
}
|
||||
groupe.add(lot(items, matsArbres, false));
|
||||
const arbresB = lot(items, matsArbres, false);
|
||||
groupe.add(arbresB); objets.baissiere = [b, arbresB];
|
||||
points.baissiere = { x: best.x + best.nx * 1.4, z: best.z + best.nz * 1.4 };
|
||||
}
|
||||
}
|
||||
@@ -268,7 +271,7 @@ export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, pot
|
||||
if (!best || score > best.score) best = { m, x, z, score };
|
||||
}
|
||||
}
|
||||
if (best) { pose(tubeSolaire(), best.x, best.z, 0); prise.add(best.m); points.tube = { x: best.x, z: best.z }; }
|
||||
if (best) { objets.tube = [pose(tubeSolaire(), best.x, best.z, 0)]; prise.add(best.m); points.tube = { x: best.x, z: best.z }; }
|
||||
}
|
||||
|
||||
// 4. Le cochon (ou deux) : sous des arbres, entre deux ou trois maisons, loin de la mare ; un enclos léger ; les deux
|
||||
@@ -290,9 +293,9 @@ export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, pot
|
||||
if (!best || score > best.score) best = { x, z, score, spots };
|
||||
}
|
||||
if (best) {
|
||||
pose(enclos(6, 4.4), best.x, best.z, R, 4);
|
||||
objets.cochon = [pose(enclos(6, 4.4), best.x, best.z, R, 4)];
|
||||
BETES.forEach(([c, , , rot], i) => {
|
||||
const o = pose(cochon(c), best.spots[i][0], best.spots[i][1], rot + R, 0.8);
|
||||
const o = pose(cochon(c), best.spots[i][0], best.spots[i][1], rot + R, 0.8); objets.cochon.push(o);
|
||||
const { corps, tete } = o.userData, ph = i * 2.3;
|
||||
anim.push((t) => {
|
||||
o.rotation.y = rot + R + Math.sin(t * 0.11 + ph) * 0.5;
|
||||
@@ -326,7 +329,7 @@ export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, pot
|
||||
}
|
||||
if (best) {
|
||||
// la planche regarde le chemin (sa face est en x local : on tourne x vers −n)
|
||||
pose(panneau(), best.x, best.z, Math.atan2(best.nz, -best.nx));
|
||||
objets.chantier = [pose(panneau(), best.x, best.z, Math.atan2(best.nz, -best.nx))];
|
||||
points.chantier = { x: (T.c.x + best.x) / 2, z: (T.c.y + best.z) / 2 };
|
||||
} else points.chantier = { x: T.c.x, z: T.c.y };
|
||||
}
|
||||
@@ -348,7 +351,7 @@ export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, pot
|
||||
}
|
||||
}
|
||||
}
|
||||
if (best) { pose(boiteSurplus(), best.x, best.z, best.rot); prise.add(best.m); points.surplus = { x: best.x, z: best.z }; }
|
||||
if (best) { objets.surplus = [pose(boiteSurplus(), best.x, best.z, best.rot)]; prise.add(best.m); points.surplus = { x: best.x, z: best.z }; }
|
||||
}
|
||||
|
||||
// 7. Les planches bâchées et paillées : à côté des rangs du potager témoin, une bâche noire et une planche de paille
|
||||
@@ -375,9 +378,9 @@ export function gestesDuTour({ D, groupe, transformees, T, mats, matsArbres, pot
|
||||
const paille = mesh(boite(2.6, 0.14, 1.1), lam(COUL.paille), 1.5, 0.07, 0); g.add(paille);
|
||||
// la paille n'est jamais lisse : quelques mottes
|
||||
for (let i = 0; i < 5; i++) g.add(mesh(new THREE.SphereGeometry(0.22, 6, 4).scale(1.4, 0.35, 1), paille.material, 0.5 + i * 0.5, 0.14, (rnd(i * 5.1) - 0.5) * 0.7));
|
||||
pose(g, best.x, best.z, Math.atan2(-best.r.dz, best.r.dx));
|
||||
objets.planches = [pose(g, best.x, best.z, Math.atan2(-best.r.dz, best.r.dx))];
|
||||
points.planches = { x: best.x, z: best.z };
|
||||
}
|
||||
}
|
||||
return { anim, points };
|
||||
return { anim, points, objets, P };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user