La caméra du mode fond (?mode=fond) quitte l'orbite continue : image fixe 6 s, puis un tour des éléments (approche 18 s, arrêt 7 s, glissement de l'un à l'autre), retour à la vue d'ensemble 14 s, pause 10 s, et le tour recommence. Seuls x, z et la largeur vue bougent, jamais l'azimut ni l'élévation. Fonction pure vueScenario (maquette/mode.ts, SCENARIO_FOND), testée en Node ; le temps est celui de la boucle (s'arrête sous document.hidden). La démo ne change pas de comportement ; PLAFONDS_FOND.derive retiré (seul le mode fond s'en servait). Les gestes du Tour (directive du 20/10, priorité A), en formes de jouet en bois, dans les deux régimes : le convoi de sept vélos et sa remorque chargée, trois cuves sous un appentis, une baissière plantée d'arbres d'ombre, un tube de cuisson solaire, deux cochons dans un enclos sous des arbres, un panneau d'affichage au chantier, une boîte à surplus, des planches bâchées et paillées (maquette/gestes.js, animaux.js). Places calculées à la construction depuis data/scene2035.json, là où la caméra les voit ; aucune texture, aucun texte. docs/EMBED.md mis à jour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3iHV9X8C4SaLQH1tn1UQQ
157 lines
9.4 KiB
JavaScript
157 lines
9.4 KiB
JavaScript
// La vie de 2035 (retours de Jules du 30/09) : moutons et chèvres sous les haies, poules près des maisons, canards
|
|
// sur la mare, oiseaux, et sur les routes des vélos, des vélos-cargos, un attelage et une seule voiture, partagée.
|
|
// Formes de jouet en bois : quelques volumes simples, dans les couleurs de la planche.
|
|
import * as THREE from 'three';
|
|
import { rnd } from './vegetal.js';
|
|
|
|
const lam = (c) => new THREE.MeshLambertMaterial({ color: c, emissive: '#000000' });
|
|
const mesh = (geo, m, x = 0, y = 0, z = 0, ombre = true) => { const o = new THREE.Mesh(geo, m); o.position.set(x, y, z); o.castShadow = ombre; return o; };
|
|
const boule = (r, sx = 1, sy = 1, sz = 1) => new THREE.SphereGeometry(r, 10, 7).scale(sx, sy, sz);
|
|
const boite = (x, y, z) => new THREE.BoxGeometry(x, y, z);
|
|
|
|
export const MAT = {
|
|
laine: lam('#f3eee2'), tete: lam('#4f463e'), chevre: lam('#b49a78'), poule: lam('#c98a52'), pouleB: lam('#f1ebdf'), crete: lam('#c0443a'),
|
|
canard: lam('#e9e3d2'), canardT: lam('#4f7a5a'), bec: lam('#e0a33a'), cheval: lam('#8a5f3c'), criniere: lam('#4a3628'), bois: lam('#b68f5f'),
|
|
roue: lam('#5c4c3c'), velo: lam('#3e3c37'), caisse: lam('#c9a46a'), partage: lam('#7fa3a6'), toitP: lam('#f2efe6'), oiseau: lam('#5a5650'),
|
|
chien: lam('#9a7350'),
|
|
};
|
|
|
|
export function mouton() {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boule(0.55, 1.35, 0.85, 0.95), MAT.laine, 0, 0.75, 0));
|
|
g.add(mesh(boule(0.22, 1.2, 1, 0.9), MAT.tete, 0.78, 0.9, 0));
|
|
for (const [x, z] of [[0.4, 0.25], [0.4, -0.25], [-0.4, 0.25], [-0.4, -0.25]]) g.add(mesh(boite(0.08, 0.42, 0.08), MAT.tete, x, 0.21, z, false));
|
|
return g;
|
|
}
|
|
export function chevre() {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boule(0.42, 1.45, 0.85, 0.85), MAT.chevre, 0, 0.82, 0));
|
|
g.add(mesh(boule(0.18, 1.4, 1, 0.85), MAT.chevre, 0.7, 1.12, 0));
|
|
g.add(mesh(new THREE.ConeGeometry(0.04, 0.22, 4), MAT.tete, 0.66, 1.33, 0.06, false), mesh(new THREE.ConeGeometry(0.04, 0.22, 4), MAT.tete, 0.66, 1.33, -0.06, false));
|
|
for (const [x, z] of [[0.35, 0.18], [0.35, -0.18], [-0.35, 0.18], [-0.35, -0.18]]) g.add(mesh(boite(0.07, 0.5, 0.07), MAT.tete, x, 0.25, z, false));
|
|
return g;
|
|
}
|
|
export function poule(i) {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boule(0.17, 1.3, 1, 1), i % 3 ? MAT.poule : MAT.pouleB, 0, 0.24, 0));
|
|
g.add(mesh(boule(0.09), i % 3 ? MAT.poule : MAT.pouleB, 0.17, 0.4, 0));
|
|
g.add(mesh(boite(0.05, 0.07, 0.03), MAT.crete, 0.18, 0.5, 0, false));
|
|
return g;
|
|
}
|
|
export function canard() {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boule(0.2, 1.5, 0.75, 1), MAT.canard, 0, 0.1, 0));
|
|
g.add(mesh(boule(0.1), MAT.canardT, 0.26, 0.28, 0));
|
|
g.add(mesh(boite(0.1, 0.03, 0.06), MAT.bec, 0.38, 0.26, 0, false));
|
|
return g;
|
|
}
|
|
export function attelage() {
|
|
const g = new THREE.Group();
|
|
const cheval = new THREE.Group();
|
|
cheval.add(mesh(boule(0.5, 1.6, 0.85, 0.75), MAT.cheval, 0, 1.45, 0));
|
|
cheval.add(mesh(boite(0.32, 0.75, 0.3), MAT.cheval, 0.78, 1.85, 0));
|
|
cheval.add(mesh(boule(0.22, 1.5, 0.9, 0.9), MAT.cheval, 1.0, 2.2, 0));
|
|
cheval.add(mesh(boite(0.5, 0.12, 0.08), MAT.criniere, 0.62, 2.12, 0, false));
|
|
for (const [x, z] of [[0.5, 0.2], [0.5, -0.2], [-0.5, 0.2], [-0.5, -0.2]]) cheval.add(mesh(boite(0.12, 1.05, 0.12), MAT.cheval, x, 0.52, z, false));
|
|
cheval.position.x = 1.7; g.add(cheval);
|
|
g.add(mesh(boite(2.2, 0.5, 1.4), MAT.bois, -0.6, 1.0, 0));
|
|
g.add(mesh(boite(0.6, 0.35, 0.5), MAT.caisse, -0.9, 1.42, 0.2), mesh(boite(0.5, 0.3, 0.45), lam('#a9be7c'), -0.2, 1.4, -0.25));
|
|
for (const z of [0.78, -0.78]) g.add(mesh(new THREE.CylinderGeometry(0.55, 0.55, 0.12, 14).rotateX(Math.PI / 2), MAT.roue, -0.6, 0.55, z));
|
|
g.add(mesh(new THREE.CapsuleGeometry(0.24, 0.55, 3, 8), lam('#6f8fa8'), 0.25, 1.65, 0));
|
|
return g;
|
|
}
|
|
export function velo(couleur) {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boite(1.7, 0.1, 0.12), MAT.velo, 0, 0.62, 0));
|
|
for (const x of [0.7, -0.7]) g.add(mesh(new THREE.TorusGeometry(0.32, 0.04, 5, 14), MAT.velo, x, 0.34, 0, false));
|
|
g.add(mesh(new THREE.CapsuleGeometry(0.24, 0.62, 3, 8), lam(couleur), -0.1, 1.32, 0));
|
|
return g;
|
|
}
|
|
export function veloCargo(couleur) {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boite(2.5, 0.1, 0.12), MAT.velo, 0, 0.55, 0));
|
|
for (const x of [1.05, -0.95]) g.add(mesh(new THREE.TorusGeometry(0.3, 0.04, 5, 14), MAT.velo, x, 0.32, 0, false));
|
|
g.add(mesh(boite(0.85, 0.6, 0.8), MAT.caisse, 0.75, 0.88, 0));
|
|
g.add(mesh(boule(0.18), lam('#c8553d'), 0.6, 1.25, 0.15), mesh(boule(0.16), lam('#a9be7c'), 0.9, 1.24, -0.15));
|
|
g.add(mesh(new THREE.CapsuleGeometry(0.24, 0.62, 3, 8), lam(couleur), -0.55, 1.28, 0));
|
|
return g;
|
|
}
|
|
export function voiture(couleur, partagee = false) {
|
|
const g = new THREE.Group(), m = partagee ? MAT.partage : lam(couleur);
|
|
g.add(mesh(boite(4.2, 0.9, 1.8), m, 0, 0.65, 0));
|
|
g.add(mesh(boite(2.3, 0.75, 1.62), m, -0.25, 1.45, 0));
|
|
if (partagee) {
|
|
g.add(mesh(boite(0.7, 0.28, 0.5), MAT.toitP, -0.25, 1.98, 0));
|
|
for (const [x, z] of [[0.3, 0.45], [-0.6, 0.45], [-0.6, -0.45]]) g.add(mesh(boule(0.2), lam('#e6c96a'), x, 1.55, z, false));
|
|
}
|
|
return g;
|
|
}
|
|
export function chien() {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boule(0.18, 1.6, 0.9, 0.8), MAT.chien, 0, 0.36, 0));
|
|
g.add(mesh(boule(0.12), MAT.chien, 0.3, 0.5, 0));
|
|
for (const [x, z] of [[0.18, 0.08], [0.18, -0.08], [-0.18, 0.08], [-0.18, -0.08]]) g.add(mesh(boite(0.05, 0.26, 0.05), MAT.chien, x, 0.13, z, false));
|
|
return g;
|
|
}
|
|
// Le cochon (22/10, directive Tour 3.4 : « un cochon pour trois maisons ») : corps, tête qui tourne, groin, oreilles
|
|
// rabattues, quatre pattes, la queue en tire-bouchon. `userData.corps` et `userData.tete` s'animent sur place.
|
|
export function cochon(couleur = '#d8a090') {
|
|
const g = new THREE.Group(), m = lam(couleur), fonce = lam('#b9786a');
|
|
const corps = new THREE.Group(); g.add(corps);
|
|
corps.add(mesh(boule(0.42, 1.6, 0.95, 0.95), m, 0, 0.66, 0));
|
|
corps.add(mesh(new THREE.TorusGeometry(0.07, 0.025, 4, 8, 4.4), fonce, -0.7, 0.8, 0, false));
|
|
const tete = new THREE.Group(); tete.position.set(0.58, 0.72, 0); corps.add(tete);
|
|
tete.add(mesh(boule(0.27, 1.1, 0.95, 1), m, 0.14, 0, 0));
|
|
tete.add(mesh(new THREE.CylinderGeometry(0.12, 0.14, 0.14, 10).rotateZ(Math.PI / 2), fonce, 0.45, -0.05, 0, false));
|
|
for (const z of [0.15, -0.15]) tete.add(mesh(new THREE.ConeGeometry(0.09, 0.2, 4).rotateZ(-1.0), fonce, 0.16, 0.24, z, false));
|
|
for (const [x, z] of [[0.38, 0.17], [0.38, -0.17], [-0.38, 0.17], [-0.38, -0.17]]) g.add(mesh(boite(0.12, 0.36, 0.12), fonce, x, 0.18, z, false));
|
|
g.userData = { corps, tete };
|
|
return g;
|
|
}
|
|
// La remorque du convoi (directive 3.1 : une remorque chargée, tirée par un vélo) : caisse basse sur deux roues, timon
|
|
// vers l'avant (+x), chargée de bottes de paille et d'une caisse.
|
|
export function remorque() {
|
|
const g = new THREE.Group();
|
|
g.add(mesh(boite(1.5, 0.32, 0.95), MAT.bois, 0, 0.56, 0));
|
|
for (const z of [0.56, -0.56]) g.add(mesh(new THREE.CylinderGeometry(0.32, 0.32, 0.08, 12).rotateX(Math.PI / 2), MAT.roue, 0, 0.32, z, false));
|
|
g.add(mesh(boite(1.0, 0.06, 0.06), MAT.velo, 1.2, 0.62, 0, false));
|
|
const paille = lam('#e6cf8a');
|
|
g.add(mesh(boite(0.62, 0.34, 0.42), paille, -0.35, 0.89, 0.2), mesh(boite(0.62, 0.34, 0.42), paille, -0.35, 0.89, -0.24), mesh(boite(0.62, 0.34, 0.42), paille, -0.35, 1.23, 0));
|
|
g.add(mesh(boite(0.5, 0.4, 0.5), MAT.caisse, 0.42, 0.92, 0));
|
|
return g;
|
|
}
|
|
export function oiseau() {
|
|
const g = new THREE.Group(), geo = new THREE.BufferGeometry();
|
|
geo.setAttribute('position', new THREE.Float32BufferAttribute([0, 0, 0, -0.25, 0, 0.55, 0.15, 0, 0, 0, 0, 0, 0.15, 0, 0, -0.25, 0, -0.55], 3));
|
|
geo.computeVertexNormals();
|
|
const ailes = new THREE.Mesh(geo, new THREE.MeshLambertMaterial({ color: '#5a5650', side: THREE.DoubleSide }));
|
|
g.add(ailes); g.userData.ailes = ailes;
|
|
return g;
|
|
}
|
|
|
|
// ---------------------------------------------------------------- troupeau, basse-cour, canards, oiseaux
|
|
export function vieAnimale(D, G2035) {
|
|
const anim = [];
|
|
const troupeau = new THREE.Group(), basse = new THREE.Group(), mare = new THREE.Group(), ciel = new THREE.Group();
|
|
G2035.add(troupeau, basse, mare, ciel);
|
|
D.troupeaux.forEach(([x, z, espece, rot], i) => {
|
|
const o = espece === 0 ? mouton() : chevre(); o.position.set(x, 0, z); o.rotation.y = rot; troupeau.add(o);
|
|
anim.push((t) => { o.rotation.y = rot + Math.sin(t * 0.3 + i) * 0.35; o.children[1].position.y = (espece === 0 ? 0.9 : 1.12) - (Math.sin(t * 0.8 + i * 2) > 0.6 ? 0.18 : 0); });
|
|
});
|
|
D.poules.forEach(([x, z, rot], i) => {
|
|
const o = poule(i); o.position.set(x, 0, z); o.rotation.y = rot; basse.add(o);
|
|
anim.push((t) => { const k = Math.sin(t * 2.2 + i * 1.7); o.rotation.z = k > 0.5 ? -0.5 : 0; o.position.x = x + Math.sin(t * 0.25 + i) * 0.4; });
|
|
});
|
|
const { c, r, n } = D.canards;
|
|
for (let i = 0; i < n; i++) {
|
|
const o = canard(); mare.add(o);
|
|
anim.push((t) => { const a = t * 0.12 + (i / n) * Math.PI * 2, rr = r * (0.55 + 0.35 * Math.sin(i * 1.7)); o.position.set(c[0] + Math.cos(a) * rr, 0.05, c[1] + Math.sin(a) * rr); o.rotation.y = -a - Math.PI / 2; });
|
|
}
|
|
const centres = [[c[0], c[1]], [100, -40]];
|
|
for (let i = 0; i < 9; i++) {
|
|
const o = oiseau(); ciel.add(o); const [cx, cz] = centres[i % 2]; const R = 9 + (i % 4) * 4, h = 13 + (i % 3) * 3, v = 0.25 + rnd(i) * 0.15;
|
|
anim.push((t) => { const a = t * v + i; o.position.set(cx + Math.cos(a) * R, h + Math.sin(t * 0.7 + i) * 0.8, cz + Math.sin(a) * R); o.rotation.y = -a; o.userData.ailes.scale.z = 0.4 + 0.6 * Math.abs(Math.sin(t * 7 + i)); });
|
|
}
|
|
return { anim, troupeau, basse, mare };
|
|
}
|