退役(零视觉影响:NEXT_PUBLIC_HERO_SCENE 从未在任何 .env* 设置): - 删 hero-scene.tsx(694行)/caption/单测/文案真源/CC0 机柜/海报帧 - R26 删除、R22 登记归零、e2e heroSceneMask 移除(无命中的假安全网) - R22 自证改可注入(夹具不再依赖生产条目) 落库(flag NEXT_PUBLIC_HERO_FIELD 样期默认关 ⇒ 基线零影响): - hero-field.tsx 三拍:噪声→增长→判断;bloom 半分辨率;DPR≤1.5 - 降级统一看结论帧(reduced-motion 定格 T_HOLD=40500 非 0) - 文案真源含承诺词正则守卫(禁帮助/赋能/提升/%/倍) - 海报帧 capture 脚本与资产同批入库(1920x864/26.9KB,可复现) - eslint 忽略 demo/**/vendor/**(vendored three 不可被 lint-staged --fix 改写) 守卫重建:R26 指向 hero-field(43260ms/3 拍合规);R22 登记 HeroField 条目 验证:tsc 0 / eslint 0 error / jest 162 套件 1906 例 / check:grammar 26+26 / check:a11y 0 违规 / 默认构建首页 DOM 冒烟 E 案不变
937 lines
45 KiB
HTML
937 lines
45 KiB
HTML
<!doctype html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<title>Hero 内容方案对照 · 数据驱动决策</title>
|
||
<style>
|
||
:root { --ink:#0b0a08; --line:rgba(255,255,255,.12); --amber:#ffb457; }
|
||
* { box-sizing:border-box; }
|
||
html, body { height:100%; margin:0; }
|
||
body {
|
||
background:var(--ink); color:#fff; overflow:hidden;
|
||
font-family:-apple-system,BlinkMacSystemFont,'PingFang SC','Helvetica Neue',Arial,sans-serif;
|
||
-webkit-font-smoothing:antialiased;
|
||
}
|
||
#host { position:fixed; inset:0; }
|
||
#host canvas { display:block; width:100%; height:100%; }
|
||
#veil { position:fixed; inset:0; background:#07080a; opacity:0; pointer-events:none; }
|
||
#vignette { position:fixed; inset:0; pointer-events:none;
|
||
background:radial-gradient(120% 95% at 50% 45%,transparent 48%,rgba(0,0,0,.62) 100%); }
|
||
|
||
/* 文案层(默认关,用来最后判断合成后可读性) */
|
||
#scrim { position:fixed; inset:0; pointer-events:none; opacity:0;
|
||
background:linear-gradient(90deg,rgba(11,10,8,.94) 0%,rgba(11,10,8,.9) 32%,rgba(11,10,8,.62) 55%,rgba(11,10,8,.16) 100%); }
|
||
#copy { position:fixed; left:6vw; top:50%; transform:translateY(-50%); width:min(36rem,44vw); pointer-events:none; opacity:0; transition:opacity .2s; }
|
||
#copy .eyebrow { display:flex; align-items:center; gap:12px; }
|
||
#copy .eyebrow i { display:block; width:32px; height:1px; background:#c41e3a; }
|
||
#copy .eyebrow span { font-size:13px; font-weight:500; letter-spacing:.15em; color:rgba(255,255,255,.75); }
|
||
#copy h1 { margin:24px 0 0; font-size:clamp(26px,2.9vw,42px); line-height:1.14; font-weight:700; }
|
||
#copy p { margin:16px 0 0; font-size:14.5px; line-height:1.72; color:rgba(255,255,255,.75); max-width:30rem; }
|
||
#copy .ctas { display:flex; gap:16px; margin-top:28px; }
|
||
#copy .cta { padding:12px 24px; font-size:14px; font-weight:600; border-radius:2px; }
|
||
#copy .cta.primary { background:#c41e3a; }
|
||
#copy .cta.secondary { border:1px solid rgba(255,255,255,.4); }
|
||
|
||
#caption { position:fixed; left:6vw; bottom:24px; display:flex; align-items:center; gap:12px; pointer-events:none; font-size:13px; }
|
||
#caption i { display:block; width:24px; height:1px; background:rgba(255,255,255,.3); }
|
||
#caption b { font-weight:500; letter-spacing:.08em; color:rgba(255,255,255,.7); }
|
||
#caption span { color:rgba(255,255,255,.5); }
|
||
|
||
#panel {
|
||
position:fixed; top:16px; right:16px; width:330px; padding:15px 15px 13px;
|
||
background:rgba(14,13,12,.9); border:1px solid var(--line); border-radius:4px;
|
||
backdrop-filter:blur(14px); font-size:12px;
|
||
}
|
||
#panel h2 { margin:0 0 2px; font-size:12px; font-weight:600; letter-spacing:.06em; }
|
||
#panel .sub { margin:0 0 11px; font-size:11px; line-height:1.6; color:rgba(255,255,255,.42); }
|
||
.variants { display:grid; gap:5px; }
|
||
.vbtn {
|
||
display:block; width:100%; text-align:left; padding:7px 9px; cursor:pointer;
|
||
background:transparent; border:1px solid rgba(255,255,255,.1); border-radius:3px;
|
||
color:rgba(255,255,255,.72); font-size:12px; font-family:inherit; transition:120ms;
|
||
}
|
||
.vbtn:hover { border-color:rgba(255,255,255,.28); color:#fff; }
|
||
.vbtn.on { border-color:rgba(255,255,255,.55); background:rgba(255,255,255,.07); color:#fff; }
|
||
.vbtn em { display:block; font-style:normal; margin-top:3px; font-size:10.5px; line-height:1.5; color:rgba(255,255,255,.38); }
|
||
.vbtn.on em { color:rgba(255,255,255,.55); }
|
||
.vbtn .k { display:inline-block; margin-right:6px; color:rgba(255,255,255,.3); font-variant-numeric:tabular-nums; }
|
||
.acts { display:flex; gap:5px; margin-top:11px; }
|
||
.acts button { flex:1; padding:5px 0; cursor:pointer; font-size:10.5px; font-family:inherit;
|
||
background:transparent; border:1px solid rgba(255,255,255,.1); border-radius:3px; color:rgba(255,255,255,.55); }
|
||
.acts button:hover { border-color:rgba(255,255,255,.3); color:#fff; }
|
||
.row { display:flex; gap:6px; margin-top:6px; }
|
||
.row button { flex:1; padding:6px 0; cursor:pointer; font-size:11px; font-family:inherit;
|
||
background:transparent; border:1px solid rgba(255,255,255,.1); border-radius:3px; color:rgba(255,255,255,.6); }
|
||
.row button:hover { border-color:rgba(255,255,255,.3); color:#fff; }
|
||
#tl { width:100%; margin:11px 0 3px; accent-color:#c41e3a; }
|
||
.ticks { display:flex; justify-content:space-between; font-size:10px; color:rgba(255,255,255,.28); font-variant-numeric:tabular-nums; }
|
||
#readout { margin-top:9px; padding-top:9px; border-top:1px solid rgba(255,255,255,.08);
|
||
display:flex; justify-content:space-between; font-size:10.5px; color:rgba(255,255,255,.42); font-variant-numeric:tabular-nums; }
|
||
#readout b { color:var(--amber); font-weight:500; }
|
||
#hint { position:fixed; left:50%; bottom:24px; transform:translateX(-50%); font-size:11px; color:rgba(255,255,255,.25); pointer-events:none; }
|
||
#err { position:fixed; inset:0; display:none; place-items:center; text-align:center; padding:40px; font-size:13px; color:#ff9b9b; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="host"></div>
|
||
<div id="vignette"></div>
|
||
<div id="veil"></div>
|
||
<div id="scrim"></div>
|
||
|
||
<div id="copy">
|
||
<div class="eyebrow"><i></i><span>企业数字化转型</span></div>
|
||
<h1>让每一家企业都拥有数据驱动的决策能力</h1>
|
||
<p>专业核心团队,以结果导向的服务理念,做中国企业数字化转型的同行者与成长伙伴,从战略诊断到系统落地、再到持续陪跑。</p>
|
||
<div class="ctas"><span class="cta primary">预约咨询</span><span class="cta secondary">看行业实践</span></div>
|
||
</div>
|
||
|
||
<div id="caption"><i></i><b id="cap-label">01 噪声</b><span id="cap-detail">数据尚未被理解</span></div>
|
||
|
||
<div id="panel">
|
||
<h2>Hero 内容方案对照</h2>
|
||
<p class="sub">三拍等长(16 / 13 / 13s + 压黑),只换「动画讲什么」。</p>
|
||
<div class="variants" id="variants"></div>
|
||
<div class="acts">
|
||
<button data-t="8000">拍一</button>
|
||
<button data-t="22000">拍二</button>
|
||
<button data-t="40500">拍三·落定</button>
|
||
</div>
|
||
<input id="tl" type="range" min="0" max="43260" step="10" value="0" />
|
||
<div class="ticks"><span>0s</span><span>16.4s</span><span>29.8s</span><span>42.8s</span></div>
|
||
<div class="row">
|
||
<button id="btn-play">暂停</button>
|
||
<button id="btn-copy">叠文案层</button>
|
||
</div>
|
||
<div id="readout"><span>拍 <b id="ro-act">1</b></span><span>k <b id="ro-k">0.00</b></span><span>t <b id="ro-t">0.0s</b></span></div>
|
||
</div>
|
||
|
||
<div id="hint">键盘 1–3 切方案 · 空格播放/暂停</div>
|
||
<div id="err"></div>
|
||
|
||
<script type="importmap">
|
||
{ "imports": {
|
||
"three": "./vendor/three.module.js",
|
||
"three/addons/": "./vendor/addons/"
|
||
} }
|
||
</script>
|
||
|
||
<script type="module">
|
||
import * as THREE from 'three';
|
||
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
||
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
|
||
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
|
||
import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
|
||
|
||
const ACTS = [16000, 13000, 13000];
|
||
const DIP = 420;
|
||
const CYCLE = ACTS.reduce((a, b) => a + b + DIP, 0);
|
||
const SETTLE = 0.62;
|
||
const T2 = ACTS[0] + DIP;
|
||
const T3 = T2 + ACTS[1] + DIP;
|
||
|
||
const CASE_LABEL = {
|
||
void: [
|
||
{ label:'01 噪声', detail:'数据尚未被理解' },
|
||
{ label:'02 增长', detail:'曲线被逐列画出' },
|
||
{ label:'03 判断', detail:'一点越过判据' },
|
||
],
|
||
map: [
|
||
{ label:'01 流量', detail:'路网正常运转' },
|
||
{ label:'02 评估', detail:'三条替代被比较' },
|
||
{ label:'03 改道', detail:'一条新路由生效' },
|
||
],
|
||
room: [
|
||
{ label:'01 数据成形', detail:'散点归成分布' },
|
||
{ label:'02 三案并置', detail:'候选同框比较' },
|
||
{ label:'03 选定', detail:'一个方案被点中' },
|
||
],
|
||
};
|
||
|
||
const CASES = [
|
||
{ id:'void', name:'1 抽象数据场', desc:'噪声散点 → 从左向右画出上升曲线 → 越过判据的那一点亮起。行业中立、无人、无数字。' },
|
||
{ id:'map', name:'2 业务场景剖面', desc:'物流路网:某段拥塞 → 三条候选被评估 → 改道执行 → 流量恢复。可指认,但锁定行业。' },
|
||
{ id:'room', name:'4 决策现场', desc:'人与大屏:数据成形 → 三个方案并置 → 一个被选中。人物是剪影代理,非成品。' },
|
||
];
|
||
|
||
const host = document.getElementById('host');
|
||
const veil = document.getElementById('veil');
|
||
const errBox = document.getElementById('err');
|
||
|
||
let renderer;
|
||
try {
|
||
renderer = new THREE.WebGLRenderer({ antialias:true, alpha:false, powerPreference:'high-performance' });
|
||
} catch (e) {
|
||
errBox.style.display='grid'; errBox.textContent='WebGL 不可用:'+e.message; throw e;
|
||
}
|
||
renderer.setPixelRatio(Math.min(window.devicePixelRatio||1, 1.5));
|
||
renderer.setSize(host.clientWidth, host.clientHeight, false);
|
||
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
||
renderer.toneMappingExposure = 1.25;
|
||
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
||
host.appendChild(renderer.domElement);
|
||
|
||
const smoothstep = (x,a,b) => { const t=Math.min(1,Math.max(0,(x-a)/(b-a))); return t*t*(3-2*t); };
|
||
const lerp = (a,b,t) => a + (b-a)*t;
|
||
const BG = 0x07080a;
|
||
|
||
/* ═════════════ 1 · 抽象数据场 ═════════════ */
|
||
function makeVoid() {
|
||
const scene = new THREE.Scene();
|
||
scene.background = new THREE.Color(BG);
|
||
scene.fog = new THREE.Fog(BG, 22, 68);
|
||
const camera = new THREE.PerspectiveCamera(38, 16/9, .1, 400);
|
||
|
||
/* 光斑贴图 —— 方点是"粗糙感"的第一来源。点必须是柔光,不是像素块 */
|
||
const spriteTex = (() => {
|
||
const S=128, cv=document.createElement('canvas'); cv.width=cv.height=S;
|
||
const g=cv.getContext('2d');
|
||
const rg=g.createRadialGradient(S/2,S/2,0,S/2,S/2,S/2);
|
||
rg.addColorStop(0,'rgba(255,255,255,1)');
|
||
rg.addColorStop(.20,'rgba(255,255,255,.66)');
|
||
rg.addColorStop(.52,'rgba(255,255,255,.15)');
|
||
rg.addColorStop(1,'rgba(255,255,255,0)');
|
||
g.fillStyle=rg; g.fillRect(0,0,S,S);
|
||
const t=new THREE.CanvasTexture(cv); t.colorSpace=THREE.SRGBColorSpace; return t;
|
||
})();
|
||
const softPlane = (size, inner, outer, w, h) => {
|
||
const cv=document.createElement('canvas'); cv.width=cv.height=size;
|
||
const g=cv.getContext('2d');
|
||
const rg=g.createRadialGradient(size/2,size/2,0,size/2,size/2,size/2);
|
||
rg.addColorStop(0,inner); rg.addColorStop(.45,outer); rg.addColorStop(1,'rgba(0,0,0,0)');
|
||
g.fillStyle=rg; g.fillRect(0,0,size,size);
|
||
const t=new THREE.CanvasTexture(cv); t.colorSpace=THREE.SRGBColorSpace;
|
||
return new THREE.MeshBasicMaterial({ map:t, transparent:true, opacity:0,
|
||
blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false });
|
||
};
|
||
|
||
/* 背景:纯黑虚空会把一切压成剪贴画。垫一层几乎看不见的冷雾光,空间才成立 */
|
||
const bgMat = softPlane(256, 'rgba(28,62,104,.30)', 'rgba(16,34,58,.10)');
|
||
const bgPlane = new THREE.Mesh(new THREE.PlaneGeometry(58, 34), bgMat);
|
||
bgPlane.position.set(-2, 3.4, -20);
|
||
scene.add(bgPlane);
|
||
|
||
/* 分布形状:对数正态长尾 —— 单一峰 + 右侧拖尾,是一眼可认的「真实分布」。
|
||
原来的正弦堆叠像随机柱状图,读不出「数据」只读出「图表」。 */
|
||
const BARS = 42, LAYERS = 132, N = BARS*LAYERS;
|
||
const BAR_STEP = 0.112; // 42 × 0.112 ≈ 4.6m 宽:让开左侧文字块与右侧面板
|
||
/* 分布形状 = **增长态势**:单调上升 + 轻微起伏。
|
||
完全单调会像一根斜坡,加 2~3% 起伏才像真实数据;钟形分布则不表达"增长"。 */
|
||
const HMAX = 2.9;
|
||
const BARS_N = BARS;
|
||
const barH = [];
|
||
for (let b=0;b<BARS_N;b++) {
|
||
const tt = b/(BARS_N-1);
|
||
const base = Math.pow(tt, 1.62); // 前段缓、后段陡 = 增长的形状
|
||
const ripple = 1 + 0.028*Math.sin(b*0.9) + 0.016*Math.cos(b*2.7);
|
||
barH.push(0.22 + HMAX*base*ripple);
|
||
}
|
||
/* 判据线压在中段偏上 ⇒ 曲线在中右部越过它,结论点正好落在文字块与右侧面板之间 */
|
||
const thrY = 0.22 + HMAX*0.58;
|
||
const CROSS = Math.max(0, barH.findIndex(v => v >= thrY));
|
||
const bxOf = (b) => (b-(BARS-1)/2)*BAR_STEP;
|
||
|
||
const noiseP = new Float32Array(N*3);
|
||
const gridP = new Float32Array(N*3);
|
||
const pos = new Float32Array(N*3);
|
||
const col = new Float32Array(N*3);
|
||
const phase = new Float32Array(N*2);
|
||
for (let i=0;i<N;i++) {
|
||
const b = i % BARS, l = Math.floor(i / BARS);
|
||
const jx = (Math.random()-0.5) * BAR_STEP * 0.78;
|
||
const jz = (Math.random()-0.5) * 0.62;
|
||
noiseP[i*3] = (Math.random()-0.5)*9.4;
|
||
noiseP[i*3+1] = Math.random()*3.6 + 0.2;
|
||
noiseP[i*3+2] = (Math.random()-0.5)*5.6;
|
||
gridP[i*3] = bxOf(b) + jx;
|
||
gridP[i*3+1] = ((l+0.5)/LAYERS) * barH[b];
|
||
gridP[i*3+2] = jz;
|
||
pos[i*3]=noiseP[i*3]; pos[i*3+1]=noiseP[i*3+1]; pos[i*3+2]=noiseP[i*3+2];
|
||
col[i*3]=0.10; col[i*3+1]=0.22; col[i*3+2]=0.46;
|
||
phase[i*2] = Math.random()*Math.PI*2;
|
||
phase[i*2+1] = Math.random()*Math.PI*2;
|
||
}
|
||
const geo = new THREE.BufferGeometry();
|
||
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
|
||
geo.setAttribute('color', new THREE.BufferAttribute(col, 3));
|
||
const dotMat = new THREE.PointsMaterial({
|
||
size:0.092, sizeAttenuation:true, vertexColors:true, transparent:true,
|
||
map:spriteTex, blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false, opacity:.95,
|
||
});
|
||
const pts = new THREE.Points(geo, dotMat);
|
||
scene.add(pts);
|
||
|
||
/* 包络:柱顶连成一条平滑曲线(Catmull-Rom),再沿曲线铺一串更亮的小点 ——
|
||
1px 折线是「Excel 图表」,一条发光曲线才是「被读出来的分布」 */
|
||
const tops = [];
|
||
for (let b=0;b<BARS;b++) tops.push(new THREE.Vector3(bxOf(b), barH[b], 0));
|
||
const curve = new THREE.CatmullRomCurve3(tops);
|
||
const CS = 420;
|
||
const cPos = curve.getPoints(CS-1);
|
||
const cArr = new Float32Array(CS*3), cCol = new Float32Array(CS*3);
|
||
for (let i=0;i<CS;i++) {
|
||
cArr[i*3]=cPos[i].x; cArr[i*3+1]=cPos[i].y; cArr[i*3+2]=cPos[i].z;
|
||
const t = i/(CS-1);
|
||
cCol[i*3]=0.55; cCol[i*3+1]=0.86; cCol[i*3+2]=1.0;
|
||
// 两端渐隐
|
||
const edge = Math.min(1, Math.min(t, 1-t)*7);
|
||
cCol[i*3]*=edge; cCol[i*3+1]*=edge; cCol[i*3+2]*=edge;
|
||
}
|
||
const cGeo = new THREE.BufferGeometry();
|
||
cGeo.setAttribute('position', new THREE.BufferAttribute(cArr,3));
|
||
cGeo.setAttribute('color', new THREE.BufferAttribute(cCol,3));
|
||
const cMat = new THREE.PointsMaterial({
|
||
size:0.096, sizeAttenuation:true, vertexColors:true, transparent:true, opacity:0,
|
||
map:spriteTex, blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false,
|
||
});
|
||
const envPts = new THREE.Points(cGeo, cMat);
|
||
scene.add(envPts);
|
||
|
||
/* 每个柱顶对应的曲线高度:收束时点落到「曲线上」而不是折线上 */
|
||
const curveY = (b) => {
|
||
const idx = Math.round(b/(BARS-1) * (CS-1));
|
||
return cArr[idx*3+1];
|
||
};
|
||
|
||
/* 判据线:横向渐变(中间实、两端散)比一条白棒干净得多 */
|
||
const thrTex = (() => {
|
||
const W=256, H=16, cv=document.createElement('canvas'); cv.width=W; cv.height=H;
|
||
const g=cv.getContext('2d');
|
||
const lg=g.createLinearGradient(0,0,W,0);
|
||
lg.addColorStop(0,'rgba(255,255,255,0)');
|
||
lg.addColorStop(.18,'rgba(255,255,255,.55)');
|
||
lg.addColorStop(.5,'rgba(255,255,255,1)');
|
||
lg.addColorStop(.82,'rgba(255,255,255,.55)');
|
||
lg.addColorStop(1,'rgba(255,255,255,0)');
|
||
g.fillStyle=lg; g.fillRect(0,0,W,H);
|
||
const t=new THREE.CanvasTexture(cv); t.colorSpace=THREE.SRGBColorSpace; return t;
|
||
})();
|
||
const thrMat = new THREE.MeshBasicMaterial({ map:thrTex, transparent:true, opacity:0,
|
||
blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false });
|
||
const thr = new THREE.Mesh(new THREE.PlaneGeometry(5.6, 0.032), thrMat);
|
||
thr.position.set(0, thrY, 0);
|
||
scene.add(thr);
|
||
|
||
/* 基线:没有基线,投影线就是一根悬空的线;有了基线,整幅才读成"一张图" */
|
||
const baseMat = new THREE.MeshBasicMaterial({ color:0x9fd8ff, transparent:true, opacity:0,
|
||
blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false });
|
||
const baseLine = new THREE.Mesh(new THREE.PlaneGeometry(5.0, 0.010), baseMat);
|
||
baseLine.position.set(0, 0.22, 0);
|
||
scene.add(baseLine);
|
||
|
||
/* 结论标记:**不用"放射"**。光晕 + 扩散环读成爆炸特效,不像读数。
|
||
改用图表注解语法:一个小实心点 + 一圈细目标环 + 一条垂到基线的投影线 + 判据线上的一小段高亮。 */
|
||
/* 结论点必须精确落在「曲线与判据线的交点」上:按列取第一个越线柱会偏高半个柱宽,
|
||
近景下一眼就能看出点和线没对上(实测) */
|
||
let DOT_X = bxOf(CROSS);
|
||
for (let b=1;b<BARS;b++) {
|
||
const y0 = barH[b-1], y1 = barH[b];
|
||
if (y0 < thrY && y1 >= thrY) {
|
||
const t = (thrY - y0) / (y1 - y0);
|
||
DOT_X = bxOf(b-1) + (bxOf(b) - bxOf(b-1)) * t;
|
||
break;
|
||
}
|
||
}
|
||
const DOT_Y = thrY;
|
||
|
||
const dotCoreMat = new THREE.MeshBasicMaterial({ color:0xffe0b4, toneMapped:false, transparent:true, opacity:0,
|
||
blending:THREE.AdditiveBlending, depthWrite:false });
|
||
const dotCore = new THREE.Mesh(new THREE.CircleGeometry(0.042, 24), dotCoreMat);
|
||
dotCore.position.set(DOT_X, DOT_Y, 0);
|
||
scene.add(dotCore);
|
||
|
||
const ringMat = new THREE.MeshBasicMaterial({ color:0xffb457, transparent:true, opacity:0,
|
||
blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false });
|
||
const ring = new THREE.Mesh(new THREE.RingGeometry(0.105, 0.118, 56), ringMat);
|
||
ring.position.set(DOT_X, DOT_Y, 0);
|
||
scene.add(ring);
|
||
|
||
/* 投影线:从结论点垂到基线 —— "读数"的标准注解,比任何光效都可信 */
|
||
const dropMat = new THREE.MeshBasicMaterial({ color:0xffb457, transparent:true, opacity:0,
|
||
blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false });
|
||
const dropH = Math.max(0.05, DOT_Y - 0.22);
|
||
const drop = new THREE.Mesh(new THREE.PlaneGeometry(0.006, 1), dropMat);
|
||
drop.scale.y = dropH;
|
||
drop.position.set(DOT_X, 0.22 + dropH/2, 0);
|
||
scene.add(drop);
|
||
|
||
/* 判据线在交点处的一小段高亮:让"越过"有落点 */
|
||
const tickMat = new THREE.MeshBasicMaterial({ color:0xffb457, transparent:true, opacity:0,
|
||
blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false });
|
||
const tick = new THREE.Mesh(new THREE.PlaneGeometry(0.46, 0.020), tickMat);
|
||
tick.position.set(DOT_X, thrY, 0);
|
||
scene.add(tick);
|
||
|
||
/* 地面冷光:让分布"落"在某个平面上,而不是漂在真空里 */
|
||
const groundMat = softPlane(256, 'rgba(46,110,180,.34)', 'rgba(24,58,100,.12)');
|
||
const ground = new THREE.Mesh(new THREE.PlaneGeometry(13, 9), groundMat);
|
||
ground.rotation.x = -Math.PI/2;
|
||
ground.position.set(0, -0.02, 0);
|
||
scene.add(ground);
|
||
|
||
const grid = new THREE.GridHelper(22, 44, 0x1a2a3c, 0x101a26);
|
||
grid.position.y = -0.01;
|
||
grid.material.transparent = true; grid.material.opacity = 0;
|
||
scene.add(grid);
|
||
|
||
/* 碎片:方向随机、互不相连的短线。让拍一读成「尚未被组织的数据」,
|
||
而不是均匀星点 —— 均匀星点会读成星空,与数据无关 */
|
||
const fragMat = new THREE.LineBasicMaterial({ color:0x2f5d92, transparent:true, opacity:.42, toneMapped:false });
|
||
{
|
||
const FN = 52;
|
||
const fpos = new Float32Array(FN*6);
|
||
for (let i=0;i<FN;i++) {
|
||
const x=(Math.random()-0.5)*9.4, y=Math.random()*3.6+0.25, z=(Math.random()-0.5)*5.6;
|
||
const a=Math.random()*Math.PI*2, L=0.22+Math.random()*0.62;
|
||
fpos[i*6]=x; fpos[i*6+1]=y; fpos[i*6+2]=z;
|
||
fpos[i*6+3]=x+Math.cos(a)*L; fpos[i*6+4]=y+Math.sin(a)*L*0.55; fpos[i*6+5]=z+Math.sin(a)*L;
|
||
}
|
||
const fg = new THREE.BufferGeometry();
|
||
fg.setAttribute('position', new THREE.BufferAttribute(fpos,3));
|
||
scene.add(new THREE.LineSegments(fg, fragMat));
|
||
}
|
||
|
||
function update(t, act, k, dt) {
|
||
const p = geo.attributes.position.array;
|
||
const setCol = (r,g,b) => { for (let i=0;i<N;i++) { col[i*3]=r; col[i*3+1]=g; col[i*3+2]=b; } };
|
||
|
||
if (act === 0) {
|
||
for (let i=0;i<N;i++) {
|
||
const i3=i*3, ph=phase[i*2], ph2=phase[i*2+1];
|
||
p[i3] = noiseP[i3] + Math.sin(t*0.00062 + ph)*0.34;
|
||
p[i3+1] = noiseP[i3+1] + Math.sin(t*0.00094 + ph2)*0.22;
|
||
p[i3+2] = noiseP[i3+2] + Math.cos(t*0.00071 + ph)*0.30;
|
||
const v = 0.55 + 0.45*Math.sin(t*0.0016 + ph2);
|
||
col[i3]=0.10+0.10*v; col[i3+1]=0.20+0.20*v; col[i3+2]=0.42+0.26*v;
|
||
}
|
||
cMat.opacity = 0; thrMat.opacity = 0; dotCoreMat.opacity = 0; ringMat.opacity = 0; dropMat.opacity = 0; tickMat.opacity = 0; baseMat.opacity = 0;
|
||
grid.material.opacity = 0;
|
||
groundMat.opacity = 0.10;
|
||
bgMat.opacity = 0.75;
|
||
} else if (act === 1) {
|
||
const g = smoothstep(k, .1, .8);
|
||
for (let i=0;i<N;i++) {
|
||
const i3=i*3, ph=phase[i*2], ph2=phase[i*2+1], b=i % BARS;
|
||
/* 按「列」延迟:从左到右一列一列落位 ⇒ 图是被"画"出来的。
|
||
配合单调上升的高度,整条曲线读成**增长态势**,而不是一团雾 */
|
||
const delay = (b / BARS) * 0.52;
|
||
const e = smoothstep(k, delay, delay + 0.34);
|
||
/* 起点用拍一的漂移公式现算(闭式),终点是格子 —— 全程无状态累积,
|
||
所以拖时间轴能精确停在任何一帧,不会因为「跳过去」而错位 */
|
||
const sx = noiseP[i3] + Math.sin(t*0.00062 + ph)*0.34;
|
||
const sy = noiseP[i3+1] + Math.sin(t*0.00094 + ph2)*0.22;
|
||
const sz = noiseP[i3+2] + Math.cos(t*0.00071 + ph)*0.30;
|
||
const arc = Math.sin(Math.PI*e) * 0.26; // 归位途中抬一点弧线,像被吸过去
|
||
p[i3] = lerp(sx, gridP[i3], e);
|
||
p[i3+1] = lerp(sy, gridP[i3+1], e) + arc;
|
||
p[i3+2] = lerp(sz, gridP[i3+2], e);
|
||
/* 高度越高的点越亮:分布顶部因此形成一条"密度脊",面积图才有边缘 */
|
||
const hg = 0.62 + 0.38*Math.min(1, gridP[i3+1]/(HMAX*0.92));
|
||
col[i3]=lerp(0.10,0.28,g)*hg; col[i3+1]=lerp(0.20,0.74,g)*hg; col[i3+2]=lerp(0.46,1.0,g)*hg;
|
||
}
|
||
cMat.opacity = smoothstep(k, .42, .82)*0.95;
|
||
thrMat.opacity = 0; dotCoreMat.opacity = 0; ringMat.opacity = 0; dropMat.opacity = 0; tickMat.opacity = 0;
|
||
baseMat.opacity = smoothstep(k, .5, .9)*0.10;
|
||
grid.material.opacity = smoothstep(k, .25, .9)*0.55;
|
||
groundMat.opacity = 0.10 + 0.30*smoothstep(k, .2, .9);
|
||
bgMat.opacity = 0.55;
|
||
} else {
|
||
/* ── 拍三:推进(已固化)──
|
||
镜头收向「曲线 × 判据线」的交点;点云按**到交点的距离**退场,越远越早退。
|
||
为什么不是统一淡出:统一淡出读成"被关灯",按距离退读成"注意力收窄到这一点"——
|
||
后者才是「结论」,前者只是「结束」。 */
|
||
const pushP = smoothstep(k, .08, .72); // 72% 处走完:留 3.6s 让结论态停住再切镜
|
||
const R = 4.6 - pushP*3.7; // 保留半径从"全覆盖"收到"一个小圈":边缘先退
|
||
for (let i=0;i<N;i++) {
|
||
const b = i % BARS, i3 = i*3;
|
||
p[i3] = gridP[i3];
|
||
p[i3+1] = gridP[i3+1];
|
||
p[i3+2] = gridP[i3+2];
|
||
const dx = bxOf(b) - DOT_X;
|
||
const dy = (gridP[i3+1] - DOT_Y) * 0.80;
|
||
const dist = Math.sqrt(dx*dx + dy*dy);
|
||
const vis = 1 - smoothstep(dist, R*0.72, R*1.06);
|
||
const hg = 0.62 + 0.38*Math.min(1, gridP[i3+1]/(HMAX*0.92));
|
||
const f = vis*0.95;
|
||
col[i3]=0.30*hg*f; col[i3+1]=0.74*hg*f; col[i3+2]=1.0*hg*f;
|
||
}
|
||
|
||
cMat.opacity = lerp(0.95, 1.0, smoothstep(k, 0, .3));
|
||
|
||
/* 判据线:到达那一刻"锁一下" —— 极短的一次亮度台阶(~120ms),之后恒定。
|
||
没有这一下,推近只是镜头运动;有了它,才是"确认"。 */
|
||
const lock = smoothstep(k, .62, .70);
|
||
const bump = lock * (1 - smoothstep(k, .72, .82));
|
||
thrMat.opacity = 0.26 + 0.28*lock + 0.30*bump;
|
||
|
||
/* 结论标记 */
|
||
const q = smoothstep(k, .42, .68);
|
||
dotCoreMat.opacity = q;
|
||
ringMat.opacity = q*0.8;
|
||
dropMat.opacity = 0;
|
||
tickMat.opacity = smoothstep(k, .26, .52)*0.9;
|
||
baseMat.opacity = 0;
|
||
ring.scale.setScalar(1 + 0.06*(1-q));
|
||
|
||
grid.material.opacity = 0;
|
||
groundMat.opacity = lerp(0.40, 0.24, pushP);
|
||
bgMat.opacity = 0.45;
|
||
}
|
||
geo.attributes.position.needsUpdate = true;
|
||
geo.attributes.color.needsUpdate = true;
|
||
fragMat.opacity = act === 0 ? .42 : act === 1 ? .42*(1-smoothstep(k,0,.3)) : 0;
|
||
|
||
/* 相机:缓慢推近 + 轻微横移。第三拍几乎停住 —— 「停」本身就是结论成立的语法 */
|
||
const ck = act === 2 ? Math.min(1, k/SETTLE) : k;
|
||
const z = act === 0 ? lerp(12.8, 11.6, ck) : act === 1 ? lerp(11.6, 10.0, ck) : lerp(10.0, 9.2, ck);
|
||
const cx = act === 0 ? lerp(-2.6, -1.0, ck) : act === 1 ? lerp(-1.0, 0.45, ck) : lerp(0.45, 0.5, ck);
|
||
const cy = act === 0 ? lerp(2.15, 1.92, ck) : act === 1 ? lerp(1.92, 1.72, ck) : lerp(1.72, 1.66, ck);
|
||
if (act === 2) {
|
||
/* 推进:不加任何新元素,只用镜头把"曲线穿过判据"这一处推到满画幅。
|
||
这是唯一不受构图限制的收尾 —— 曲线终点本就顶在画面上缘,往外延伸必出画。 */
|
||
const p = smoothstep(k, .10, .90);
|
||
camera.position.set(lerp(cx, 1.62, p), lerp(cy, 1.98, p), lerp(z, 5.2, p));
|
||
// 视线略偏左,把交点推到画面 60% 处 —— 左边是文字块,交点不能落在中线上
|
||
camera.lookAt(lerp(cx - 0.55, DOT_X - 0.30, p), lerp(1.50, DOT_Y * 0.94, p), 0);
|
||
} else {
|
||
camera.position.set(cx, cy, z);
|
||
camera.lookAt(cx - 0.55, 1.42, 0);
|
||
}
|
||
|
||
/* 判据线 / 结论标记一律朝向相机:它们是「读数」不是「场景里的物体」 */
|
||
thr.quaternion.copy(camera.quaternion);
|
||
baseLine.quaternion.copy(camera.quaternion);
|
||
dotCore.quaternion.copy(camera.quaternion);
|
||
ring.quaternion.copy(camera.quaternion);
|
||
drop.quaternion.copy(camera.quaternion);
|
||
tick.quaternion.copy(camera.quaternion);
|
||
}
|
||
|
||
return { scene, camera, update };
|
||
}
|
||
|
||
/* ═════════════ 2 · 业务场景剖面:物流路网 ═════════════ */
|
||
function makeMap() {
|
||
const scene = new THREE.Scene();
|
||
scene.background = new THREE.Color(BG);
|
||
scene.fog = new THREE.Fog(BG, 12, 34);
|
||
const camera = new THREE.PerspectiveCamera(42, 16/9, .1, 120);
|
||
|
||
const NODES = [
|
||
[-3.2,-2.6],[0.1,-3.3],[3.1,-2.4],
|
||
[-3.6, 0.3],[-1.1, 0.7],[1.5, 0.5],[3.5, 1.1],
|
||
[-2.9, 2.9],[-0.3, 3.3],[2.7, 3.1],
|
||
];
|
||
const EDGES = [
|
||
[0,1],[1,2],[0,3],[1,4],[2,5],[3,4],[4,5],[5,6],[3,7],[4,8],[5,8],[6,9],[7,8],[8,9],
|
||
[0,4],[2,6],[7,4],[9,5],
|
||
];
|
||
/* 主干道:0→3→4→5→6 ;替代道:0→3→7→8→5→6 */
|
||
const MAIN = [0,3,4,5,6];
|
||
const ALT = [0,3,7,8,5,6];
|
||
const CONGEST = [4,5]; // 拥塞段
|
||
|
||
const g = new THREE.Group();
|
||
g.rotation.x = 0;
|
||
scene.add(g);
|
||
|
||
/* 地面网格 */
|
||
const grid = new THREE.GridHelper(24, 48, 0x141c26, 0x0c141c);
|
||
grid.position.y = -0.01;
|
||
grid.material.transparent = true; grid.material.opacity = .55;
|
||
g.add(grid);
|
||
|
||
/* 节点 */
|
||
const nodeMat = new THREE.MeshBasicMaterial({ color:0x7fd4ff, toneMapped:false, transparent:true, opacity:.75 });
|
||
const nodeGeo = new THREE.CircleGeometry(0.085, 20);
|
||
const nodeMeshes = NODES.map(([x,z]) => {
|
||
const m = new THREE.Mesh(nodeGeo, nodeMat.clone());
|
||
m.rotation.x = -Math.PI/2; m.position.set(x, 0.012, z); g.add(m); return m;
|
||
});
|
||
|
||
/* 边:每条一个材质,便于单独改色 */
|
||
const edgeMeshes = EDGES.map(([a,b]) => {
|
||
const [x1,z1] = NODES[a], [x2,z2] = NODES[b];
|
||
const len = Math.hypot(x2-x1, z2-z1);
|
||
const mat = new THREE.MeshBasicMaterial({ color:0x2f5a80, toneMapped:false, transparent:true, opacity:.9 });
|
||
const m = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.01, len), mat);
|
||
m.position.set((x1+x2)/2, 0.008, (z1+z2)/2);
|
||
m.rotation.y = Math.atan2(x2-x1, z2-z1);
|
||
g.add(m);
|
||
return { mesh:m, mat, a, b };
|
||
});
|
||
const edgeOf = (a,b) => edgeMeshes.find(e => (e.a===a&&e.b===b)||(e.a===b&&e.b===a));
|
||
|
||
/* 车辆:沿折线匀速前进的光点 */
|
||
const routePts = (route) => route.map(i => NODES[i]);
|
||
function pathLen(pts) { let L=0; for (let i=1;i<pts.length;i++) L+=Math.hypot(pts[i][0]-pts[i-1][0], pts[i][1]-pts[i-1][1]); return L; }
|
||
function pointAt(pts, s) {
|
||
let acc=0;
|
||
for (let i=1;i<pts.length;i++) {
|
||
const d = Math.hypot(pts[i][0]-pts[i-1][0], pts[i][1]-pts[i-1][1]);
|
||
if (acc + d >= s) {
|
||
const t = (s-acc)/d;
|
||
return [lerp(pts[i-1][0],pts[i][0],t), lerp(pts[i-1][1],pts[i][1],t)];
|
||
}
|
||
acc += d;
|
||
}
|
||
return pts[pts.length-1];
|
||
}
|
||
const M = 70, A = 70;
|
||
const mkDots = (n, color) => {
|
||
const arr = new Float32Array(n*3), c = new Float32Array(n*3);
|
||
const cc = new THREE.Color(color);
|
||
for (let i=0;i<n;i++) { c[i*3]=cc.r; c[i*3+1]=cc.g; c[i*3+2]=cc.b; }
|
||
const geo = new THREE.BufferGeometry();
|
||
geo.setAttribute('position', new THREE.BufferAttribute(arr,3));
|
||
geo.setAttribute('color', new THREE.BufferAttribute(c,3));
|
||
const pts = new THREE.Points(geo, new THREE.PointsMaterial({
|
||
size:0.105, sizeAttenuation:true, vertexColors:true, transparent:true,
|
||
blending:THREE.AdditiveBlending, depthWrite:false, toneMapped:false, opacity:1,
|
||
}));
|
||
g.add(pts);
|
||
return { pts, arr, geo };
|
||
};
|
||
const mainDots = mkDots(M, 0x9fdcff);
|
||
const altDots = mkDots(A, 0x9fdcff);
|
||
const mainPts = routePts(MAIN), altPts = routePts(ALT);
|
||
const mainLen = pathLen(mainPts), altLen = pathLen(altPts);
|
||
|
||
function update(t, act, k, dt) {
|
||
const cg = edgeOf(CONGEST[0], CONGEST[1]);
|
||
const cAlt = [edgeOf(3,7), edgeOf(7,8), edgeOf(8,5)];
|
||
|
||
if (act === 0) {
|
||
/* 正常流量;末段主干道那段开始变慢变亮(拥塞正在形成) */
|
||
const load = smoothstep(k, .55, 1);
|
||
cg.mat.color.setHex(0x2f5a80).lerp(new THREE.Color(0xffb457), load);
|
||
cg.mat.opacity = 0.9;
|
||
for (const e of cAlt) { e.mat.color.setHex(0x2f5a80); e.mat.opacity = .9; }
|
||
nodeMeshes.forEach(m => m.material.color.setHex(0x7fd4ff));
|
||
} else if (act === 1) {
|
||
/* 三条候选替代段依次被评估(闪一下),随后一条被选定 */
|
||
cg.mat.color.setHex(0xffb457); cg.mat.opacity = .95;
|
||
cAlt.forEach((e,i) => {
|
||
const scan = smoothstep(k, i*0.16, i*0.16 + 0.14) * (1 - smoothstep(k, i*0.16+0.2, i*0.16+0.34));
|
||
e.mat.color.setHex(0x2f5a80).lerp(new THREE.Color(0xffffff), scan*0.9).lerp(new THREE.Color(0x63d2ff), smoothstep(k, .55, .8)*0.85);
|
||
e.mat.opacity = .9;
|
||
});
|
||
nodeMeshes[8].material.color.setHex(0xffd39a);
|
||
nodeMeshes.forEach((m,i) => { if (i!==8) m.material.color.setHex(0x7fd4ff); });
|
||
} else {
|
||
/* 执行改道:主干清空、替代道满流、拥塞段回落到常态 */
|
||
const done = smoothstep(k, .1, .75);
|
||
cg.mat.color.setHex(0xffb457).lerp(new THREE.Color(0x3a2a18), done*0.75);
|
||
for (const e of cAlt) { e.mat.color.setHex(0x63d2ff); e.mat.opacity = .95; }
|
||
nodeMeshes[8].material.color.setHex(0xffb457);
|
||
nodeMeshes.forEach((m,i) => { if (i!==8) m.material.color.setHex(0x7fd4ff); });
|
||
}
|
||
|
||
/* 车辆位置:主干速度在拍一末段下降(拥塞),拍二后逐步消失 */
|
||
const mainVisible = act === 0 ? 1 : act === 1 ? 1 - smoothstep(k, .45, .95) : 0;
|
||
const altVisible = act === 0 ? 0 : act === 1 ? smoothstep(k, .55, .95) : 1;
|
||
for (let i=0;i<M;i++) {
|
||
const s = ((i/M)*mainLen + t*0.0016*(act===0? 1 - 0.45*smoothstep(k,.55,1) : 1)) % mainLen;
|
||
const [x,z] = pointAt(mainPts, s);
|
||
mainDots.arr[i*3]=x; mainDots.arr[i*3+1]=0.026; mainDots.arr[i*3+2]=z;
|
||
}
|
||
for (let i=0;i<A;i++) {
|
||
const s = ((i/A)*altLen + t*0.0019) % altLen;
|
||
const [x,z] = pointAt(altPts, s);
|
||
altDots.arr[i*3]=x; altDots.arr[i*3+1]=0.026; altDots.arr[i*3+2]=z;
|
||
}
|
||
mainDots.geo.attributes.position.needsUpdate = true;
|
||
altDots.geo.attributes.position.needsUpdate = true;
|
||
mainDots.pts.material.opacity = mainVisible;
|
||
altDots.pts.material.opacity = altVisible;
|
||
|
||
/* 俯视缓推 + 轻旋:R 必须装得下整张路网(7.2 × 6.6),否则四边被裁 */
|
||
const ck = act === 2 ? Math.min(1, k/SETTLE) : k;
|
||
const ang = -0.34 + ck*0.04 + act*0.02;
|
||
const R = act === 0 ? lerp(12.8, 11.8, ck) : act === 1 ? 11.8 : lerp(11.8, 11.0, ck);
|
||
camera.position.set(Math.sin(ang)*R*0.55, R*0.95, Math.cos(ang)*R*0.62);
|
||
camera.lookAt(0.9, 0, 0.1);
|
||
}
|
||
|
||
return { scene, camera, update };
|
||
}
|
||
|
||
/* ═════════════ 4 · 决策现场:人与大屏 ═════════════ */
|
||
function makeRoom() {
|
||
const scene = new THREE.Scene();
|
||
scene.background = new THREE.Color(BG);
|
||
scene.fog = new THREE.Fog(BG, 5, 16);
|
||
const camera = new THREE.PerspectiveCamera(40, 16/9, .1, 60);
|
||
|
||
scene.add(new THREE.AmbientLight(0x223044, 0.55));
|
||
const screenLight = new THREE.PointLight(0x9fd8ff, 16, 14, 2);
|
||
screenLight.position.set(0, 1.6, -3.5);
|
||
scene.add(screenLight);
|
||
|
||
/* 房间:地板 + 后墙(墙要够大,否则画面里会露出墙的硬边) */
|
||
const floor = new THREE.Mesh(new THREE.PlaneGeometry(20,20),
|
||
new THREE.MeshStandardMaterial({ color:0x0a0c10, roughness:.55, metalness:.25 }));
|
||
floor.rotation.x = -Math.PI/2; scene.add(floor);
|
||
const wall = new THREE.Mesh(new THREE.PlaneGeometry(26,12),
|
||
new THREE.MeshStandardMaterial({ color:0x0b0e13, roughness:.95 }));
|
||
wall.position.set(0, 4, -4.7); scene.add(wall);
|
||
|
||
/* 大屏:CanvasTexture,内容按拍次重画 */
|
||
const SC = document.createElement('canvas');
|
||
SC.width = 1024; SC.height = 320;
|
||
const ctx = SC.getContext('2d');
|
||
const sTex = new THREE.CanvasTexture(SC);
|
||
sTex.colorSpace = THREE.SRGBColorSpace;
|
||
const screen = new THREE.Mesh(new THREE.PlaneGeometry(2.62, 0.82),
|
||
new THREE.MeshBasicMaterial({ map:sTex, toneMapped:false }));
|
||
screen.position.set(0, 1.72, -4.56);
|
||
scene.add(screen);
|
||
|
||
/* 桌子:压到接近黑 —— 桌面反光会把整块画面拉成一块白板(实测首版) */
|
||
const deskMat = new THREE.MeshStandardMaterial({ color:0x080a0d, roughness:.98, metalness:0 });
|
||
const desk = new THREE.Mesh(new THREE.BoxGeometry(1.7, 0.05, 0.72), deskMat);
|
||
desk.position.set(0.15, 0.74, -2.55); scene.add(desk);
|
||
for (const [dx,dz] of [[-0.7,-0.28],[0.7,-0.28]]) {
|
||
const leg = new THREE.Mesh(new THREE.BoxGeometry(0.05,0.74,0.05), deskMat);
|
||
leg.position.set(0.15+dx, 0.37, -2.55+dz); scene.add(leg);
|
||
}
|
||
|
||
/* 人:剪影几何(头 / 肩 / 躯干 / 腿 / 臂)。刻意不写实 —— 3D 写实人脸必假 */
|
||
const skin = new THREE.MeshStandardMaterial({ color:0x1a1d22, roughness:.85, metalness:.05 });
|
||
const person = new THREE.Group();
|
||
person.position.set(0.02, 0, -2.05);
|
||
|
||
const head = new THREE.Mesh(new THREE.SphereGeometry(0.108, 20, 16), skin);
|
||
head.position.set(0, 1.66, 0); head.scale.set(0.94, 1.1, 0.98); person.add(head);
|
||
const neck = new THREE.Mesh(new THREE.CylinderGeometry(0.045,0.055,0.09,12), skin);
|
||
neck.position.set(0,1.565,0); person.add(neck);
|
||
const torso = new THREE.Mesh(new THREE.CylinderGeometry(0.175,0.145,0.56,16), skin);
|
||
torso.position.set(0,1.28,0); torso.scale.set(1,1,0.62); person.add(torso);
|
||
/* 肩:没有肩,圆柱躯干会读成一根管子 */
|
||
const shoulders = new THREE.Mesh(new THREE.SphereGeometry(0.2,16,12), skin);
|
||
shoulders.position.set(0,1.5,0); shoulders.scale.set(1.26,0.52,0.72); person.add(shoulders);
|
||
const hip = new THREE.Mesh(new THREE.CylinderGeometry(0.145,0.13,0.22,16), skin);
|
||
hip.position.set(0,0.95,0); hip.scale.set(1,1,0.7); person.add(hip);
|
||
for (const sx of [-0.085, 0.085]) {
|
||
const leg = new THREE.Mesh(new THREE.CylinderGeometry(0.062,0.052,0.86,12), skin);
|
||
leg.position.set(sx, 0.44, 0); person.add(leg);
|
||
const foot = new THREE.Mesh(new THREE.BoxGeometry(0.09,0.05,0.22), skin);
|
||
foot.position.set(sx, 0.03, 0.05); person.add(foot);
|
||
}
|
||
/* 右臂:可抬起 —— 拍三的「他做了选择」由这个动作承担 */
|
||
const armPivot = new THREE.Group();
|
||
armPivot.position.set(0.185, 1.5, 0);
|
||
const upper = new THREE.Mesh(new THREE.CylinderGeometry(0.05,0.045,0.34,10), skin);
|
||
upper.position.set(0,-0.17,0); armPivot.add(upper);
|
||
const forePivot = new THREE.Group();
|
||
forePivot.position.set(0,-0.34,0);
|
||
const fore = new THREE.Mesh(new THREE.CylinderGeometry(0.043,0.038,0.3,10), skin);
|
||
fore.position.set(0,-0.15,0); forePivot.add(fore);
|
||
const hand = new THREE.Mesh(new THREE.SphereGeometry(0.047, 14, 12), skin);
|
||
hand.position.set(0,-0.315,0); forePivot.add(hand);
|
||
armPivot.add(forePivot);
|
||
person.add(armPivot);
|
||
const armL = new THREE.Mesh(new THREE.CylinderGeometry(0.05,0.045,0.62,10), skin);
|
||
armL.position.set(-0.19, 1.2, 0); person.add(armL);
|
||
scene.add(person);
|
||
|
||
/* 屏幕内容的分帧绘制 */
|
||
const dots = [];
|
||
for (let i=0;i<260;i++) dots.push({ x:Math.random(), y:Math.random(), b:Math.floor(Math.random()*14), h: Math.random() });
|
||
|
||
function drawScreen(act, k, t) {
|
||
const w = SC.width, h = SC.height;
|
||
ctx.fillStyle = '#080c12'; ctx.fillRect(0,0,w,h);
|
||
ctx.strokeStyle = 'rgba(120,190,255,.10)'; ctx.lineWidth = 2;
|
||
ctx.strokeRect(1,1,w-2,h-2);
|
||
|
||
if (act <= 1) {
|
||
/* 标题条 */
|
||
ctx.fillStyle = 'rgba(130,205,255,.30)'; ctx.fillRect(48, 34, 168, 7);
|
||
ctx.fillStyle = 'rgba(130,205,255,.16)'; ctx.fillRect(48, 52, 96, 5);
|
||
|
||
const sep = act === 0 ? 0 : smoothstep(k, 0.1, 0.75);
|
||
const barW = (w-120)/14;
|
||
for (const d of dots) {
|
||
let x, y;
|
||
if (sep < 0.02) {
|
||
x = 48 + d.x*(w-96) + Math.sin(t*0.001 + d.x*20)*6;
|
||
y = 96 + d.y*(h-150) + Math.cos(t*0.0013 + d.y*17)*5;
|
||
} else {
|
||
const targetX = 48 + (d.b+0.5)*barW + (d.h-0.5)*2;
|
||
const targetY = h-58 - (0.25+0.75*d.h) * (h-180) * (0.4 + 0.6*Math.abs(Math.sin(d.b*0.6)));
|
||
x = lerp(48 + d.x*(w-96), targetX, sep);
|
||
y = lerp(96 + d.y*(h-150), targetY, sep);
|
||
}
|
||
ctx.fillStyle = sep > 0.5 ? 'rgba(150,215,255,.85)' : 'rgba(120,180,255,.5)';
|
||
ctx.fillRect(x, y, 2.6, 2.6);
|
||
}
|
||
if (sep > 0.4) {
|
||
ctx.strokeStyle = 'rgba(120,190,255,.28)'; ctx.lineWidth = 1.5;
|
||
ctx.beginPath(); ctx.moveTo(48, h-56); ctx.lineTo(w-48, h-56); ctx.stroke();
|
||
}
|
||
} else {
|
||
/* 三个方案并置 → 一个被选中 */
|
||
ctx.fillStyle = 'rgba(130,205,255,.30)'; ctx.fillRect(48, 34, 210, 7);
|
||
const sel = smoothstep(k, 0.45, 0.7);
|
||
for (let i=0;i<3;i++) {
|
||
const bx = 48 + i*(w-96)/3 + 8;
|
||
const bw = (w-96)/3 - 26;
|
||
const on = i === 1;
|
||
const alpha = on ? 0.16 + 0.24*sel : 0.10 - 0.04*sel;
|
||
ctx.fillStyle = on ? `rgba(255,180,87,${alpha})` : `rgba(120,190,255,${alpha})`;
|
||
ctx.fillRect(bx, 92, bw, h-190);
|
||
ctx.strokeStyle = on ? `rgba(255,180,87,${0.3+0.55*sel})` : 'rgba(120,190,255,.22)';
|
||
ctx.lineWidth = on ? 3 : 1.5;
|
||
ctx.strokeRect(bx, 92, bw, h-190);
|
||
/* 方案内的抽象条 */
|
||
for (let b=0;b<5;b++) {
|
||
const bh = (0.25 + 0.6*Math.abs(Math.sin(i*2.1+b*1.3))) * (h-250);
|
||
ctx.fillStyle = on ? `rgba(255,200,130,${0.35+0.4*sel})` : 'rgba(120,190,255,.28)';
|
||
ctx.fillRect(bx+14+b*((bw-28)/5), h-98-bh, (bw-28)/5-8, bh);
|
||
}
|
||
ctx.fillStyle = on ? 'rgba(255,215,160,.85)' : 'rgba(150,205,255,.45)';
|
||
ctx.fillRect(bx+14, 110, 34, 6);
|
||
}
|
||
}
|
||
sTex.needsUpdate = true;
|
||
}
|
||
|
||
let lastDraw = -1;
|
||
function update(t, act, k, dt) {
|
||
if (Math.abs(t - lastDraw) > 60) { drawScreen(act, k, t); lastDraw = t; }
|
||
|
||
/* 拍三:手抬起指向屏幕(决策落定的身体动作) */
|
||
const raise = act === 2 ? smoothstep(Math.min(1,k/SETTLE), .25, .62) : 0;
|
||
armPivot.rotation.x = -raise * 1.05;
|
||
armPivot.rotation.z = raise * 0.16;
|
||
forePivot.rotation.x = -raise * 0.55;
|
||
person.rotation.y = act === 2 ? lerp(0, -0.06, raise) : 0;
|
||
|
||
/* 屏幕亮度随拍次升高:拍一是暗噪,拍三最亮 */
|
||
const bright = act === 0 ? 1.0 : act === 1 ? 1.25 : 1.45;
|
||
sTex.colorSpace = THREE.SRGBColorSpace;
|
||
screenLight.intensity = (18 + 10*bright) * (act===2 ? 0.85 + 0.15*Math.min(1,k/SETTLE) : 1);
|
||
|
||
/* 相机:侧后方推近,第三拍更低更近(像站在他身后) */
|
||
const ck = act === 2 ? Math.min(1, k/SETTLE) : k;
|
||
const x = act === 0 ? lerp(2.5, 2.05, ck) : act === 1 ? lerp(2.05, 1.72, ck) : lerp(1.72, 1.45, ck);
|
||
const y = act === 0 ? lerp(1.62, 1.56, ck) : act === 1 ? lerp(1.56, 1.5, ck) : lerp(1.5, 1.62, ck);
|
||
const z = act === 0 ? lerp(1.05, 0.5, ck) : act === 1 ? lerp(0.5, 0.05, ck) : lerp(0.05, -0.25, ck);
|
||
camera.position.set(x, y, z);
|
||
camera.lookAt(lerp(-0.12, -0.05, ck), 1.44, -4.4);
|
||
}
|
||
|
||
return { scene, camera, update };
|
||
}
|
||
|
||
/* ═════════════ 播放器 ═════════════ */
|
||
const built = { void: makeVoid(), map: makeMap(), room: makeRoom() };
|
||
let current = 'void';
|
||
let playing = true, clockT = 0, lastNow = performance.now();
|
||
|
||
/* 后处理:只给「抽象数据场」开 bloom。
|
||
点阵的柔光靠它才成立 —— 没有 bloom,加色混合的点在暗底上永远是"灰点"。 */
|
||
const composer = new EffectComposer(renderer);
|
||
composer.addPass(new RenderPass(built.void.scene, built.void.camera));
|
||
const bloom = new UnrealBloomPass(
|
||
new THREE.Vector2(host.clientWidth, host.clientHeight), 0.72, 0.62, 0.35,
|
||
);
|
||
composer.addPass(bloom);
|
||
// ?bloom=0 可关后处理;键盘 B 亦可切换,用来分离"点阵更新"与"后处理"两笔成本
|
||
if (new URLSearchParams(location.search).get("bloom") === "0") bloom.enabled = false;
|
||
// 初始也按半分辨率构建
|
||
bloom.setSize(Math.round(host.clientWidth*0.5), Math.round(host.clientHeight*0.5));
|
||
composer.addPass(new OutputPass());
|
||
|
||
function beatAt(t) {
|
||
let acc = 0;
|
||
for (let i=0;i<ACTS.length;i++) {
|
||
if (t < acc + ACTS[i]) return { act:i, k:(t-acc)/ACTS[i], dip:-1, prev:-1 };
|
||
acc += ACTS[i];
|
||
if (t < acc + DIP) return { act:(i+1)%3, k:0, dip:(t-acc)/DIP, prev:i };
|
||
acc += DIP;
|
||
}
|
||
return { act:0, k:0, dip:-1, prev:-1 };
|
||
}
|
||
|
||
function setCase(id) {
|
||
current = id;
|
||
for (const b of document.querySelectorAll('.vbtn')) b.classList.toggle('on', b.dataset.id === id);
|
||
const b = built[id];
|
||
b.camera.aspect = host.clientWidth/host.clientHeight;
|
||
b.camera.updateProjectionMatrix();
|
||
}
|
||
function setCopy(on) {
|
||
document.getElementById('copy').style.opacity = on ? '1' : '0';
|
||
document.getElementById('scrim').style.opacity = on ? '1' : '0';
|
||
}
|
||
|
||
const roAct=document.getElementById('ro-act'), roK=document.getElementById('ro-k'), roT=document.getElementById('ro-t');
|
||
function frame(now) {
|
||
const dt = Math.min(0.05, (now-lastNow)/1000); lastNow = now;
|
||
if (playing) clockT = (clockT + dt*1000) % CYCLE;
|
||
|
||
const beat = beatAt(clockT);
|
||
const b = built[current];
|
||
b.update(clockT, beat.act, beat.k, dt);
|
||
|
||
if (beat.dip >= 0) {
|
||
veil.style.opacity = String(beat.dip < .5 ? Math.min(1, beat.dip*2) : Math.max(0, (1-beat.dip)*2));
|
||
} else veil.style.opacity = '0';
|
||
|
||
if (current === 'void') composer.render();
|
||
else renderer.render(b.scene, b.camera);
|
||
|
||
const cap = CASE_LABEL[current][beat.act];
|
||
const cl = document.getElementById('cap-label'), cd = document.getElementById('cap-detail');
|
||
if (cl.textContent !== cap.label) { cl.textContent = cap.label; cd.textContent = cap.detail; }
|
||
roAct.textContent = String(beat.act+1);
|
||
roK.textContent = (beat.act===2 ? Math.min(1, beat.k/SETTLE) : beat.k).toFixed(2);
|
||
roT.textContent = (clockT/1000).toFixed(1)+'s';
|
||
document.getElementById('tl').value = String(Math.round(clockT));
|
||
requestAnimationFrame(frame);
|
||
}
|
||
|
||
const wrap = document.getElementById('variants');
|
||
CASES.forEach((v,i) => {
|
||
const el = document.createElement('button');
|
||
el.className='vbtn'; el.dataset.id=v.id;
|
||
el.innerHTML = `<b><span class="k">${i+1}</span>${v.name}</b><em>${v.desc}</em>`;
|
||
el.onclick = () => setCase(v.id);
|
||
wrap.appendChild(el);
|
||
});
|
||
for (const btn of document.querySelectorAll('.acts button[data-t]')) {
|
||
btn.onclick = () => { clockT = Number(btn.dataset.t); playing = false; syncPlay(); };
|
||
}
|
||
const tl = document.getElementById('tl');
|
||
tl.addEventListener('input', () => { clockT = Number(tl.value); playing = false; syncPlay(); });
|
||
const btnPlay = document.getElementById('btn-play');
|
||
function syncPlay(){ btnPlay.textContent = playing ? '暂停' : '播放'; }
|
||
btnPlay.onclick = () => { playing = !playing; syncPlay(); };
|
||
document.getElementById('btn-copy').onclick = () => {
|
||
const on = document.getElementById('copy').style.opacity !== '1';
|
||
setCopy(on);
|
||
};
|
||
window.addEventListener('keydown', (e) => {
|
||
const n = Number(e.key);
|
||
if (n>=1 && n<=CASES.length) setCase(CASES[n-1].id);
|
||
if (e.code === 'Space') { e.preventDefault(); playing = !playing; syncPlay(); }
|
||
if (e.key === "b" || e.key === "B") bloom.enabled = !bloom.enabled;
|
||
});
|
||
window.addEventListener('resize', () => {
|
||
const w=host.clientWidth, h=host.clientHeight; if (!w||!h) return;
|
||
renderer.setSize(w,h,false);
|
||
composer.setSize(w,h);
|
||
// bloom 半分辨率:软件渲染实测全分辨率 60fps→11fps,半分辨率回到可用区间
|
||
bloom.setSize(Math.round(w*0.5), Math.round(h*0.5));
|
||
for (const k of Object.keys(built)) { built[k].camera.aspect = w/h; built[k].camera.updateProjectionMatrix(); }
|
||
});
|
||
|
||
setCase('void');
|
||
setCopy(true); // 默认叠文案:交付判断的是"合成后"是否成立,不是裸画面
|
||
requestAnimationFrame(frame);
|
||
</script>
|
||
</body>
|
||
</html>
|