<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>AETHER · 星尘回响</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
width: 100%; height: 100%; overflow: hidden;
background: #000004;
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
-webkit-font-smoothing: antialiased;
}
canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.overlay {
position: fixed; left: 0; bottom: 0; padding: 46px 54px;
pointer-events: none; user-select: none;
mix-blend-mode: screen;
animation: fadeUp 2.6s cubic-bezier(.16,1,.3,1) .5s both;
}
.overlay h1 {
font-size: clamp(30px, 5.2vw, 66px);
font-weight: 200;
letter-spacing: 0.46em;
color: #eaf4ff;
text-shadow: 0 0 34px rgba(120,190,255,.55), 0 0 80px rgba(150,90,255,.35);
line-height: 1;
}
.overlay .sub {
margin-top: 18px;
font-size: 11px;
letter-spacing: 0.42em;
color: rgba(170, 205, 255, 0.62);
}
.hint {
position: fixed; right: 54px; bottom: 54px;
font-size: 11px; letter-spacing: 0.3em;
color: rgba(160, 200, 255, 0.45);
pointer-events: none; user-select: none;
animation: fadeUp 2.6s cubic-bezier(.16,1,.3,1) 1.4s both;
}
.hint b { font-weight: 400; color: rgba(200, 230, 255, 0.8); }
.vignette {
position: fixed; inset: 0; pointer-events: none;
background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 42%, rgba(0,0,6,0.55) 100%);
}
@
keyframes fadeUp {
from { opacity: 0; transform: translateY(22px); }
to { opacity: 1; transform: translateY(0); }
}
@
media (max-width: 700px) {
.overlay { padding: 26px 24px; }
.hint { right: 24px; bottom: 26px; font-size: 9px; letter-spacing: .2em; }
}
</style>
</head>
<body>
<canvas id="c"></canvas>
<div class="overlay">
<h1>AETHER</h1>
<p class="sub">星际尘埃 · 自适应粒子场</p>
</div>
<div class="hint"><b>移动鼠标</b> 拨动星尘 · <b>滚轮</b> 缩放</div>
<div class="vignette"></div>
<script type="importmap">
{
"imports": {
"three": "
https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
"three/addons/": "
https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
}
}
</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 { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
/* ============================================================
0. 基础设施
============================================================ */
const canvas = document.getElementById('c');
const isMobile = /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: !isMobile,
powerPreference: 'high-performance',
alpha: false
});
const DPR = Math.min(window.devicePixelRatio || 1, isMobile ? 1.6 : 2);
renderer.setPixelRatio(DPR);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
renderer.setClearColor(0x000004, 1);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(55, window.innerWidth / window.innerHeight, 0.1, 400);
const clock = new THREE.Clock();
let elapsed = 0;
/* ============================================================
1. 深空星云背景(域扭曲 FBM)
============================================================ */
const BG_VS = /* glsl */`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = vec4(position.xy, 1.0, 1.0);
}
`;
const BG_FS = /* glsl */`
precision highp float;
uniform float uTime;
uniform vec2 uRes;
uniform vec2 uPointer;
varying vec2 vUv;
float hash21(vec2 p) {
p = fract(p * vec2(123.34, 456.21));
p += dot(p, p + 45.32);
return fract(p.x * p.y);
}
float vnoise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
vec2 u = f * f * (3.0 - 2.0 * f);
float a = hash21(i);
float b = hash21(i + vec2(1.0, 0.0));
float c = hash21(i + vec2(0.0, 1.0));
float d = hash21(i + vec2(1.0, 1.0));
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}
float fbm(vec2 p) {
float v = 0.0;
float a = 0.5;
mat2 rot = mat2(0.80, 0.60, -0.60, 0.80);
for (int i = 0; i < 5; i++) {
v += a * vnoise(p);
p = rot * p * 2.03 + 7.13;
a *= 0.5;
}
return v;
}
void main() {
vec2 uv = (gl_FragCoord.xy - 0.5 * uRes) / uRes.y;
float t = uTime * 0.018;
vec2 p = uv * 1.55 + uPointer * 0.14;
// 双重域扭曲 —— 制造丝绸般的星云流场
vec2 q;
q.x = fbm(p + vec2(0.0, 0.0) + t);
q.y = fbm(p + vec2(5.2, 1.3) - t * 0.8);
vec2 r;
r.x = fbm(p + 2.6 * q + vec2(1.7, 9.2) + t * 1.6);
r.y = fbm(p + 2.6 * q + vec2(8.3, 2.8) - t * 1.2);
float f = fbm(p + 2.2 * r);
// 调色:深靛 → 幽蓝 → 紫罗兰 → 品红辉光
vec3 cDeep = vec3(0.012, 0.016, 0.045);
vec3 cBlue = vec3(0.055, 0.110, 0.330);
vec3 cViolet = vec3(0.300, 0.110, 0.560);
vec3 cPink = vec3(0.950, 0.480, 0.860);
vec3 col = mix(cDeep, cBlue, smoothstep(0.18, 0.78, f));
col = mix(col, cViolet, smoothstep(0.42, 0.96, length(q)) * 0.85);
col += cPink * pow(smoothstep(0.62, 1.0, r.x), 2.2) * 0.55;
// 核心区域增亮
float core = 1.0 - smoothstep(0.0, 1.05, length(uv));
col += vec3(0.16, 0.26, 0.60) * pow(core, 3.0) * 0.85;
// 微星
vec2 sp = uv * 210.0;
vec2 sid = floor(sp);
float s = hash21(sid);
if (s > 0.9965) {
vec2 so = fract(sp) - 0.5;
float d = dot(so, so);
float tw = 0.55 + 0.45 * sin(uTime * 2.4 + s * 120.0);
col += vec3(0.85, 0.93, 1.0) * smoothstep(0.09, 0.0, d) * tw * 1.7;
}
// 暗角
col *= mix(1.0, 0.30, smoothstep(0.35, 1.25, length(uv)));
gl_FragColor = vec4(col, 1.0);
}
`;
const bgMat = new THREE.ShaderMaterial({
uniforms: {
uTime: { value: 0 },
uRes: { value: new THREE.Vector2(window.innerWidth, window.innerHeight) },
uPointer: { value: new THREE.Vector2(0, 0) }
},
vertexShader: BG_VS,
fragmentShader: BG_FS,
depthTest: false,
depthWrite: false
});
const bgMesh = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), bgMat);
bgMesh.frustumCulled = false;
bgMesh.renderOrder = -1000;
scene.add(bgMesh);
/* ============================================================
2. 星系粒子系统
============================================================ */
const COUNT = isMobile ? 48000 : 165000;
const ARMS = 3;
const R_MAX = 7.6;
// 高斯随机
function gauss() {
let u = 0, v = 0;
while (u === 0) u = Math.random();
while (v === 0) v = Math.random();
return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
}
const positions = new Float32Array(COUNT * 3);
const aRand = new Float32Array(COUNT * 3);
const aSize = new Float32Array(COUNT);
for (let i = 0; i < COUNT; i++) {
const t = Math.random();
const r = 0.22 + Math.pow(t, 0.62) * R_MAX;
const arm = Math.floor(Math.random() * ARMS);
const baseAngle = (arm / ARMS) * Math.PI * 2.0;
const spin = Math.log(1.0 + r * 1.35) * 1.85;
const spread = 0.085 + 0.46 * (r / R_MAX);
const angle = baseAngle + spin + gauss() * spread;
const rr = r * (1.0 + gauss() * 0.055);
// 盘面厚度:越靠内越厚(核球)
const y = gauss() * (0.055 + 0.46 * Math.exp(-r * 0.52));
positions[i * 3 + 0] = Math.cos(angle) * rr;
positions[i * 3 + 1] = y;
positions[i * 3 + 2] = Math.sin(angle) * rr;
aRand[i * 3 + 0] = Math.random();
aRand[i * 3 + 1] = Math.random();
aRand[i * 3 + 2] = Math.random();
// 尺寸:大量细小微粒 + 少量亮星
aSize[i] = 0.55 + Math.pow(Math.random(), 3.2) * 3.2;
}
const pGeo = new THREE.BufferGeometry();
pGeo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
pGeo.setAttribute('aRand', new THREE.BufferAttribute(aRand, 3));
pGeo.setAttribute('aSize', new THREE.BufferAttribute(aSize, 1));
pGeo.boundingSphere = new THREE.Sphere(new THREE.Vector3(), 40);
const P_VS = /* glsl */`
uniform float uTime;
uniform float uPixelRatio;
uniform vec3 uMouse;
uniform float uMouseStrength;
attribute float aSize;
attribute vec3 aRand;
varying vec3 vColor;
varying float vAlpha;
void main() {
vec3 pos = position;
float r = length(pos.xz);
// ---- 差速旋转:内圈角速度更快,形成旋臂剪切 ----
float ang = uTime * (0.95 / (r * 0.42 + 1.0));
float c = cos(ang), s = sin(ang);
pos.xz = mat2(c, -s, s, c) * pos.xz;
// ---- 垂直行波:让盘面像水面一样起伏 ----
pos.y += sin(r * 0.92 - uTime * 0.72 + aRand.x * 6.2831) * (0.045 + r * 0.013);
// ---- 鼠标扰动场:指数衰减 + 径向推开 + 垂直涟漪 ----
vec3 d = pos - uMouse;
float dist = length(d);
float infl = exp(-dist * dist * 0.048);
vec3 dir = d / max(dist, 0.0001);
pos += dir * infl * uMouseStrength * 2.4;
pos.y += infl * uMouseStrength * 1.25 * sin(dist * 1.9 - uTime * 2.8);
vec4 mv = modelViewMatrix * vec4(pos, 1.0);
gl_Position = projectionMatrix * mv;
float size = aSize * (1.0 + infl * 2.0);
gl_PointSize = clamp(size * uPixelRatio * (255.0 / max(-mv.z, 0.5)), 1.0, 58.0);
// ---- 颜色:核心冷白 → 中段电蓝 → 外缘品红 ----
float f = clamp(r / R_MAX, 0.0, 1.0);
vec3 cCore = vec3(0.82, 0.96, 1.00);
vec3 cMid = vec3(0.32, 0.54, 1.00);
vec3 cOut = vec3(0.88, 0.24, 0.96);
vec3 col = mix(cCore, cMid, smoothstep(0.0, 0.58, f));
col = mix(col, cOut, smoothstep(0.52, 1.0, f));
col *= 0.72 + 0.60 * aRand.y;
col += infl * uMouseStrength * vec3(0.45, 0.90, 1.00) * 1.6;
vColor = col;
vAlpha = 0.32 + 0.58 * aRand.z;
}
`;
const P_FS = /* glsl */`
precision highp float;
varying vec3 vColor;
varying float vAlpha;