dsh-nook 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +36 -0
- package/README.md +88 -2
- package/client.js +1004 -0
- package/cordis.patch.yml +23 -0
- package/icon.svg +11 -0
- package/index.js +190 -0
- package/locale/en.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +70 -4
- package/scenes/L2_2529_D3_Towns_Plazas.html +1097 -0
- package/scenes/L2_6206_D5_Markets_Shops.html +822 -0
- package/scenes/L2_6834_D6_Courtyards_Gardens.html +735 -0
- package/scenes/L2_7180_D7_NightSky_DeepSea.html +819 -0
- package/scenes/L3_1356_D2_Waterside_HotSprings.html +2726 -0
- package/scenes/L3_171_D1_Nature_Terrain.html +750 -0
- package/scenes/L3_1966_D4_Travel_Transit.html +1590 -0
- package/scenes/L3_2464_D1_Nature_Terrain.html +867 -0
- package/scenes/L3_2559_D3_Towns_Plazas.html +1099 -0
- package/scenes/L3_2869_D3_Towns_Plazas.html +2677 -0
- package/scenes/L3_3241_D2_Waterside_HotSprings.html +1821 -0
- package/scenes/L3_3557_D4_Travel_Transit.html +1872 -0
- package/scenes/L3_6122_D5_Markets_Shops.html +1084 -0
- package/scenes/L3_6184_D5_Markets_Shops.html +1479 -0
- package/scenes/L3_6362_D5_Markets_Shops.html +993 -0
- package/scenes/L3_6656_D6_Courtyards_Gardens.html +916 -0
- package/scenes/L3_6754_D6_Courtyards_Gardens.html +1013 -0
- package/scenes/L4_179_D1_Nature_Terrain.html +1628 -0
- package/scenes/L4_2585_D3_Towns_Plazas.html +1369 -0
- package/scenes/L4_3186_D2_Waterside_HotSprings.html +1669 -0
- package/scenes/L4_3679_D4_Travel_Transit.html +1256 -0
- package/scenes/L4_7283_D7_NightSky_DeepSea.html +1400 -0
- package/scenes/L4_7698_D8_Interiors_Workshops.html +760 -0
- package/scenes/L4_7733_D8_Interiors_Workshops.html +697 -0
- package/scenes/L5_1297_D2_Waterside_HotSprings.html +1018 -0
- package/scenes/L5_2090_D1_Nature_Terrain.html +1630 -0
- package/scenes/L5_3999_D4_Travel_Transit.html +2318 -0
- package/scenes/L5_6993_D6_Courtyards_Gardens.html +1732 -0
- package/scenes/L5_7365_D7_NightSky_DeepSea.html +1569 -0
- package/scenes/L5_7381_D7_NightSky_DeepSea.html +1779 -0
- package/scenes/L5_7874_D8_Interiors_Workshops.html +1488 -0
- package/scenes/L5_7993_D8_Interiors_Workshops.html +1367 -0
- package/scenes/catalog.json +197 -0
- package/scenes/three.module.min.js +6 -0
- package/scripts/build-scenes.mjs +184 -0
- package/scripts/check-scenes.mjs +296 -0
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
6
|
+
<title>下一首,月亮听见</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root { color-scheme: dark; }
|
|
9
|
+
html, body {
|
|
10
|
+
width: 100%; height: 100%; margin: 0; overflow: hidden;
|
|
11
|
+
background: #222c45;
|
|
12
|
+
}
|
|
13
|
+
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
|
|
14
|
+
.actions {
|
|
15
|
+
position: fixed;
|
|
16
|
+
top: max(16px, env(safe-area-inset-top));
|
|
17
|
+
right: max(16px, env(safe-area-inset-right));
|
|
18
|
+
display: flex;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
}
|
|
21
|
+
button {
|
|
22
|
+
display: grid; place-items: center;
|
|
23
|
+
width: 36px; height: 36px;
|
|
24
|
+
padding: 0;
|
|
25
|
+
border: 1px solid #e5e6f127;
|
|
26
|
+
border-radius: 50%;
|
|
27
|
+
color: #f1e9e2;
|
|
28
|
+
background: #242e4666;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
button:hover { background: #48526caa; }
|
|
32
|
+
button:focus-visible { outline: 2px solid #f3c796; outline-offset: 3px; }
|
|
33
|
+
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
|
|
34
|
+
#notice {
|
|
35
|
+
position: fixed; inset: 0; place-items: center; padding: 24px;
|
|
36
|
+
color: #f1e9e2; font: 15px/1.6 system-ui, sans-serif; text-align: center;
|
|
37
|
+
}
|
|
38
|
+
#notice:not([hidden]) { display: grid; }
|
|
39
|
+
</style>
|
|
40
|
+
</head>
|
|
41
|
+
<body>
|
|
42
|
+
<nav class="actions" aria-label="赏景控制">
|
|
43
|
+
<button id="pause" type="button" aria-label="暂停微动" title="暂停微动">
|
|
44
|
+
<svg viewBox="0 0 20 20" aria-hidden="true">
|
|
45
|
+
<path id="pause-icon" d="M7 4.5v11m6-11v11"/>
|
|
46
|
+
</svg>
|
|
47
|
+
</button>
|
|
48
|
+
<button id="reset" type="button" aria-label="复位视角" title="复位视角">
|
|
49
|
+
<svg viewBox="0 0 20 20" aria-hidden="true">
|
|
50
|
+
<path d="M4 9a6 6 0 1 1 1 5m-1-9v4h4"/>
|
|
51
|
+
</svg>
|
|
52
|
+
</button>
|
|
53
|
+
</nav>
|
|
54
|
+
<div id="notice" role="status" hidden></div>
|
|
55
|
+
<style>
|
|
56
|
+
/* Background chrome: the dioramas ship drag hints, toolbars and a station
|
|
57
|
+
readout for standalone use; as a backdrop they would float over chat text. */
|
|
58
|
+
aside, nav, header, section.line, button { display: none !important; }
|
|
59
|
+
</style>
|
|
60
|
+
<script>
|
|
61
|
+
(function () {
|
|
62
|
+
var nativeRaf = window.requestAnimationFrame.bind(window);
|
|
63
|
+
var nativeCancel = window.cancelAnimationFrame.bind(window);
|
|
64
|
+
var paused = false;
|
|
65
|
+
var nextId = 1e9;
|
|
66
|
+
var held = new Map();
|
|
67
|
+
window.requestAnimationFrame = function (callback) {
|
|
68
|
+
if (!paused) return nativeRaf(callback);
|
|
69
|
+
var id = nextId++;
|
|
70
|
+
held.set(id, callback);
|
|
71
|
+
return id;
|
|
72
|
+
};
|
|
73
|
+
window.cancelAnimationFrame = function (id) {
|
|
74
|
+
if (held.delete(id)) return;
|
|
75
|
+
nativeCancel(id);
|
|
76
|
+
};
|
|
77
|
+
function drain() {
|
|
78
|
+
var queued = held;
|
|
79
|
+
held = new Map();
|
|
80
|
+
queued.forEach(function (callback) {
|
|
81
|
+
nativeRaf(function (time) { callback(time); });
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
window.addEventListener('message', function (event) {
|
|
85
|
+
var data = event.data;
|
|
86
|
+
if (data === null || typeof data !== 'object' || data.__nookScene !== true) return;
|
|
87
|
+
if (data.action === 'pause') {
|
|
88
|
+
paused = true;
|
|
89
|
+
} else if (data.action === 'resume' && paused) {
|
|
90
|
+
paused = false;
|
|
91
|
+
drain();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
})();
|
|
95
|
+
</script>
|
|
96
|
+
<script type="module">
|
|
97
|
+
async function start() {
|
|
98
|
+
const THREE = await import(
|
|
99
|
+
'./three.module.min.js'
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const TAU = Math.PI * 2;
|
|
103
|
+
const rad = THREE.MathUtils.degToRad;
|
|
104
|
+
const clamp = THREE.MathUtils.clamp;
|
|
105
|
+
const vec = (x, y, z) => new THREE.Vector3(x, y, z);
|
|
106
|
+
|
|
107
|
+
function seedRandom(seed) {
|
|
108
|
+
let state = seed >>> 0;
|
|
109
|
+
return () => {
|
|
110
|
+
state = (Math.imul(1664525, state) + 1013904223) >>> 0;
|
|
111
|
+
return state / 4294967296;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const rand = seedRandom(1229);
|
|
115
|
+
|
|
116
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
117
|
+
renderer.setClearColor(0x222c45);
|
|
118
|
+
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
119
|
+
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
120
|
+
renderer.toneMappingExposure = 1.06;
|
|
121
|
+
renderer.shadowMap.enabled = true;
|
|
122
|
+
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
123
|
+
document.body.prepend(renderer.domElement);
|
|
124
|
+
renderer.domElement.setAttribute('role', 'img');
|
|
125
|
+
renderer.domElement.setAttribute(
|
|
126
|
+
'aria-label', '月夜广场上的半圆木乐亭,里面有兔子乐师、手风琴和等待下一曲的小鸟'
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const scene = new THREE.Scene();
|
|
130
|
+
scene.background = new THREE.Color(0x29334e);
|
|
131
|
+
const world = new THREE.Group();
|
|
132
|
+
world.name = '月夜广场';
|
|
133
|
+
scene.add(world);
|
|
134
|
+
|
|
135
|
+
// 环境只用于反射,不作为可见天空。灯板保留线性 HDR 亮度。
|
|
136
|
+
function studioEnvironment() {
|
|
137
|
+
const studio = new THREE.Scene();
|
|
138
|
+
studio.background = new THREE.Color(0x64749a);
|
|
139
|
+
|
|
140
|
+
function panel(w, h, color, power, x, y, z) {
|
|
141
|
+
const material = new THREE.MeshBasicMaterial({
|
|
142
|
+
color: new THREE.Color(color).multiplyScalar(power),
|
|
143
|
+
side: THREE.DoubleSide
|
|
144
|
+
});
|
|
145
|
+
const card = new THREE.Mesh(new THREE.PlaneGeometry(w, h), material);
|
|
146
|
+
card.position.set(x, y, z);
|
|
147
|
+
card.lookAt(0, 0, 0);
|
|
148
|
+
studio.add(card);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
panel(9, 6, 0xcddcff, 2.2, -6, 9, 5);
|
|
152
|
+
panel(5, 7, 0xaebcff, 1.1, 7, 3, -7);
|
|
153
|
+
panel(5, 4, 0xffd4a1, 1.35, -2, 2, 8);
|
|
154
|
+
panel(12, 8, 0x727db2, 0.75, 1, -7, 1);
|
|
155
|
+
|
|
156
|
+
const pmrem = new THREE.PMREMGenerator(renderer);
|
|
157
|
+
const target = pmrem.fromScene(studio, 0.055, 0.1, 40);
|
|
158
|
+
pmrem.dispose();
|
|
159
|
+
studio.traverse(object => {
|
|
160
|
+
if (!object.isMesh) return;
|
|
161
|
+
object.geometry.dispose();
|
|
162
|
+
object.material.dispose();
|
|
163
|
+
});
|
|
164
|
+
return target;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const environment = studioEnvironment();
|
|
168
|
+
scene.environment = environment.texture;
|
|
169
|
+
|
|
170
|
+
scene.add(new THREE.HemisphereLight(0xc4d4ff, 0x81718f, 0.92));
|
|
171
|
+
const moon = new THREE.DirectionalLight(0xd1deff, 1.72);
|
|
172
|
+
moon.position.set(-4.8, 8, 4.1);
|
|
173
|
+
moon.target.position.set(0, 0, -0.35);
|
|
174
|
+
moon.castShadow = true;
|
|
175
|
+
moon.shadow.mapSize.set(2048, 2048);
|
|
176
|
+
Object.assign(moon.shadow.camera, {
|
|
177
|
+
near: 0.5, far: 21, left: -5.8, right: 5.8, top: 5.5, bottom: -5.5
|
|
178
|
+
});
|
|
179
|
+
moon.shadow.normalBias = 0.025;
|
|
180
|
+
moon.shadow.bias = -0.00018;
|
|
181
|
+
scene.add(moon, moon.target);
|
|
182
|
+
|
|
183
|
+
const rim = new THREE.DirectionalLight(0xa1b5ff, 0.75);
|
|
184
|
+
rim.position.set(2.8, 4.1, -5);
|
|
185
|
+
scene.add(rim);
|
|
186
|
+
const bounce = new THREE.DirectionalLight(0xe3bdb0, 0.25);
|
|
187
|
+
bounce.position.set(1, -3, 4);
|
|
188
|
+
scene.add(bounce);
|
|
189
|
+
|
|
190
|
+
// Canvas 贴图:每类用独立种子,修改布局不会改变材质。
|
|
191
|
+
function texture(w, h, paint, color = true) {
|
|
192
|
+
const canvas = document.createElement('canvas');
|
|
193
|
+
canvas.width = w;
|
|
194
|
+
canvas.height = h;
|
|
195
|
+
paint(canvas.getContext('2d'), w, h);
|
|
196
|
+
const map = new THREE.CanvasTexture(canvas);
|
|
197
|
+
map.colorSpace = color ? THREE.SRGBColorSpace : THREE.NoColorSpace;
|
|
198
|
+
map.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
|
|
199
|
+
return map;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function woodTexture() {
|
|
203
|
+
return texture(512, 256, (ctx, w, h) => {
|
|
204
|
+
const rng = seedRandom(51);
|
|
205
|
+
ctx.fillStyle = '#c9aea0';
|
|
206
|
+
ctx.fillRect(0, 0, w, h);
|
|
207
|
+
for (let i = 0; i < 410; i++) {
|
|
208
|
+
const y = rng() * h;
|
|
209
|
+
const phi = rng() * TAU;
|
|
210
|
+
const a = 0.6 + rng() * 3.0;
|
|
211
|
+
ctx.beginPath();
|
|
212
|
+
for (let x = 0; x <= w; x += 8) {
|
|
213
|
+
const v = y + Math.sin(x * 0.019 + phi) * a
|
|
214
|
+
+ Math.sin(x * 0.046 + phi * 2) * 0.6;
|
|
215
|
+
if (x === 0) ctx.moveTo(x, v);
|
|
216
|
+
else ctx.lineTo(x, v);
|
|
217
|
+
}
|
|
218
|
+
ctx.lineWidth = 0.35 + rng() * 1.15;
|
|
219
|
+
ctx.strokeStyle = i % 3
|
|
220
|
+
? `rgba(92,52,45,${0.035 + rng() * 0.14})`
|
|
221
|
+
: `rgba(255,235,206,${0.10 + rng() * 0.20})`;
|
|
222
|
+
ctx.stroke();
|
|
223
|
+
}
|
|
224
|
+
for (const [x, y, angle] of [[130, 72, -.1], [383, 189, .06]]) {
|
|
225
|
+
ctx.strokeStyle = 'rgba(103,58,44,.16)';
|
|
226
|
+
for (let j = 1; j < 7; j++) {
|
|
227
|
+
ctx.beginPath();
|
|
228
|
+
ctx.ellipse(x, y, 8 + j * 4.3, 0.8 + j * 1.35, angle, 0, TAU);
|
|
229
|
+
ctx.stroke();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function stoneTexture() {
|
|
236
|
+
return texture(256, 256, (ctx, w, h) => {
|
|
237
|
+
const rng = seedRandom(193);
|
|
238
|
+
ctx.fillStyle = '#d6dce5';
|
|
239
|
+
ctx.fillRect(0, 0, w, h);
|
|
240
|
+
for (let i = 0; i < 42; i++) {
|
|
241
|
+
const x = rng() * w;
|
|
242
|
+
const y = rng() * h;
|
|
243
|
+
const r = 12 + rng() * 48;
|
|
244
|
+
const g = ctx.createRadialGradient(x, y, 0, x, y, r);
|
|
245
|
+
g.addColorStop(0, i % 2 ? '#838fba24' : '#fff4dd5c');
|
|
246
|
+
g.addColorStop(1, '#d6dce500');
|
|
247
|
+
ctx.fillStyle = g;
|
|
248
|
+
ctx.fillRect(0, 0, w, h);
|
|
249
|
+
}
|
|
250
|
+
for (let i = 0; i < 4900; i++) {
|
|
251
|
+
ctx.fillStyle = i % 3 ? '#66739117' : '#fbf9f333';
|
|
252
|
+
ctx.fillRect(rng() * w, rng() * h, 0.5 + rng() * 1.3, 0.65);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function scoreTexture(secondPage) {
|
|
258
|
+
return texture(384, 512, (ctx, w, h) => {
|
|
259
|
+
const rng = seedRandom(secondPage ? 42 : 17);
|
|
260
|
+
ctx.fillStyle = secondPage ? '#ede0ca' : '#f8edda';
|
|
261
|
+
ctx.fillRect(0, 0, w, h);
|
|
262
|
+
for (let i = 0; i < 2800; i++) {
|
|
263
|
+
ctx.fillStyle = i % 2 ? '#8f746916' : '#fffdf64f';
|
|
264
|
+
ctx.fillRect(rng() * w, rng() * h, 1 + rng(), 1);
|
|
265
|
+
}
|
|
266
|
+
ctx.strokeStyle = '#a87f7370';
|
|
267
|
+
ctx.lineWidth = 2;
|
|
268
|
+
ctx.strokeRect(21, 20, w - 42, h - 40);
|
|
269
|
+
ctx.fillStyle = '#655067';
|
|
270
|
+
ctx.font = 'italic 28px Georgia, serif';
|
|
271
|
+
ctx.textAlign = 'center';
|
|
272
|
+
ctx.fillText(secondPage ? 'Reprise' : 'Clair de lune', w / 2, 66);
|
|
273
|
+
|
|
274
|
+
for (let staff = 0; staff < 4; staff++) {
|
|
275
|
+
const y = 110 + staff * 91;
|
|
276
|
+
ctx.strokeStyle = '#796878';
|
|
277
|
+
ctx.lineWidth = 1.45;
|
|
278
|
+
for (let line = 0; line < 5; line++) {
|
|
279
|
+
const yy = y + line * 9;
|
|
280
|
+
ctx.beginPath();
|
|
281
|
+
ctx.moveTo(38, yy);
|
|
282
|
+
ctx.lineTo(w - 38, yy);
|
|
283
|
+
ctx.stroke();
|
|
284
|
+
}
|
|
285
|
+
ctx.fillStyle = '#59495e';
|
|
286
|
+
ctx.textAlign = 'left';
|
|
287
|
+
ctx.font = '27px serif';
|
|
288
|
+
ctx.fillText('𝄞', 42, y + 29);
|
|
289
|
+
for (let n = 0; n < 8; n++) {
|
|
290
|
+
const x = 84 + n * 32;
|
|
291
|
+
const yy = y + 4.5 * Math.floor(rng() * 10);
|
|
292
|
+
ctx.beginPath();
|
|
293
|
+
ctx.ellipse(x, yy, 5.8, 3.8, -.25, 0, TAU);
|
|
294
|
+
ctx.fill();
|
|
295
|
+
ctx.fillRect(x + 4.5, yy - 23, 1.9, 23);
|
|
296
|
+
if (n === 2 || n === 6) {
|
|
297
|
+
ctx.beginPath();
|
|
298
|
+
ctx.moveTo(x + 6, yy - 23);
|
|
299
|
+
ctx.quadraticCurveTo(x + 18, yy - 17, x + 13, yy - 9);
|
|
300
|
+
ctx.stroke();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
ctx.fillRect(213, y, 1.5, 36);
|
|
304
|
+
ctx.fillRect(344, y, 1.9, 36);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function softSpotTexture() {
|
|
310
|
+
return texture(128, 128, (ctx, w, h) => {
|
|
311
|
+
const g = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, w/2 - 2);
|
|
312
|
+
g.addColorStop(0, 'rgba(255,255,255,0.88)');
|
|
313
|
+
g.addColorStop(.28, 'rgba(255,255,255,0.66)');
|
|
314
|
+
g.addColorStop(.62, 'rgba(255,255,255,0.21)');
|
|
315
|
+
g.addColorStop(1, 'rgba(255,255,255,0)');
|
|
316
|
+
ctx.fillStyle = g;
|
|
317
|
+
ctx.fillRect(0, 0, w, h);
|
|
318
|
+
}, false);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const grain = woodTexture();
|
|
322
|
+
const mineral = stoneTexture();
|
|
323
|
+
const softSpot = softSpotTexture();
|
|
324
|
+
|
|
325
|
+
function matte(color, options = {}) {
|
|
326
|
+
return new THREE.MeshStandardMaterial({
|
|
327
|
+
color, roughness: 0.8, envMapIntensity: 0.32, ...options
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function lacquer(color, options = {}) {
|
|
331
|
+
return new THREE.MeshPhysicalMaterial({
|
|
332
|
+
color, roughness: 0.36, clearcoat: 0.48, clearcoatRoughness: 0.15,
|
|
333
|
+
envMapIntensity: 0.55, ...options
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function timber(color) {
|
|
337
|
+
return matte(color, { map: grain, roughness: 0.64 });
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const mat = {
|
|
341
|
+
table: matte(0x303952, { roughness: 0.96 }),
|
|
342
|
+
stoneBase: matte(0x77839d, { map: mineral }),
|
|
343
|
+
grout: matte(0x78869f),
|
|
344
|
+
strips: matte(0x9daed0, { roughness: 0.66 }),
|
|
345
|
+
walnut: timber(0x805751),
|
|
346
|
+
endWood: timber(0x714640),
|
|
347
|
+
rimWood: timber(0xae7862),
|
|
348
|
+
seatWood: timber(0xb78570),
|
|
349
|
+
darkWood: timber(0x603d3b),
|
|
350
|
+
roof: lacquer(0x4e546e, { roughness: 0.51, clearcoat: 0.24 }),
|
|
351
|
+
seam: matte(0x777d93),
|
|
352
|
+
brass: matte(0xc58d57, { metalness: .72, roughness: .35, envMapIntensity: .88 }),
|
|
353
|
+
fur: lacquer(0xe6ccbb, { roughness: .65, clearcoat: .12 }),
|
|
354
|
+
muzzle: matte(0xf4e4d1),
|
|
355
|
+
ear: matte(0xd39d9d),
|
|
356
|
+
blush: matte(0xe2a6a0),
|
|
357
|
+
ink: lacquer(0x4a394b, { roughness: .43, clearcoat: .19 }),
|
|
358
|
+
gleam: matte(0xf3e8da),
|
|
359
|
+
vest: matte(0x74818e),
|
|
360
|
+
scarf: matte(0xa45162),
|
|
361
|
+
bird: lacquer(0x8499aa, { roughness: .58, clearcoat: .14 }),
|
|
362
|
+
wing: matte(0x697f99),
|
|
363
|
+
bib: matte(0xe4ccab),
|
|
364
|
+
beak: lacquer(0xf0b475),
|
|
365
|
+
shell: lacquer(0xa55061),
|
|
366
|
+
bellows: matte(0x50394e),
|
|
367
|
+
folds: matte(0x87667a),
|
|
368
|
+
ivory: lacquer(0xf4e6cf),
|
|
369
|
+
lamp: new THREE.MeshPhysicalMaterial({
|
|
370
|
+
color: 0xffce97, emissive: 0xffa34d, emissiveIntensity: .72,
|
|
371
|
+
roughness: .31, clearcoat: .38, envMapIntensity: .60
|
|
372
|
+
})
|
|
373
|
+
};
|
|
374
|
+
const deckMats = [0x9e6a57, 0xa4725f, 0x976553, 0xaf7b67].map(timber);
|
|
375
|
+
|
|
376
|
+
const ballGeo = new THREE.SphereGeometry(1, 28, 18);
|
|
377
|
+
|
|
378
|
+
function mesh(parent, geometry, material, x, y, z, shadows = true) {
|
|
379
|
+
const m = new THREE.Mesh(geometry, material);
|
|
380
|
+
m.position.set(x, y, z);
|
|
381
|
+
m.castShadow = shadows;
|
|
382
|
+
m.receiveShadow = shadows;
|
|
383
|
+
parent.add(m);
|
|
384
|
+
return m;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function group(parent, x = 0, y = 0, z = 0) {
|
|
388
|
+
const g = new THREE.Group();
|
|
389
|
+
g.position.set(x, y, z);
|
|
390
|
+
parent.add(g);
|
|
391
|
+
return g;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function oval(parent, material, x, y, z, sx, sy, sz, shadows = true) {
|
|
395
|
+
const m = mesh(parent, ballGeo, material, x, y, z, shadows);
|
|
396
|
+
m.scale.set(sx, sy, sz);
|
|
397
|
+
return m;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// 挤出面使用 0–1 局部 UV;原生挤出 UV 以世界单位计,
|
|
401
|
+
// 不重映射会让单条地板的纹理越界。
|
|
402
|
+
function localUV(geometry, axis = 'y') {
|
|
403
|
+
geometry.computeBoundingBox();
|
|
404
|
+
const { min, max } = geometry.boundingBox;
|
|
405
|
+
const pos = geometry.attributes.position;
|
|
406
|
+
const uv = geometry.attributes.uv;
|
|
407
|
+
const getV = axis === 'y' ? i => pos.getY(i) : i => pos.getZ(i);
|
|
408
|
+
for (let i = 0; i < pos.count; i++) {
|
|
409
|
+
uv.setXY(i,
|
|
410
|
+
(pos.getX(i) - min.x) / Math.max(.001, max.x - min.x),
|
|
411
|
+
(getV(i) - min[axis]) / Math.max(.001, max[axis] - min[axis])
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
uv.needsUpdate = true;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function roundShape(w, h, r) {
|
|
418
|
+
const x = w / 2;
|
|
419
|
+
const y = h / 2;
|
|
420
|
+
r = Math.max(.001, Math.min(r, x, y));
|
|
421
|
+
const s = new THREE.Shape();
|
|
422
|
+
s.moveTo(-x+r, -y);
|
|
423
|
+
s.lineTo(x-r, -y);
|
|
424
|
+
s.quadraticCurveTo(x, -y, x, -y+r);
|
|
425
|
+
s.lineTo(x, y-r);
|
|
426
|
+
s.quadraticCurveTo(x, y, x-r, y);
|
|
427
|
+
s.lineTo(-x+r, y);
|
|
428
|
+
s.quadraticCurveTo(-x, y, -x, y-r);
|
|
429
|
+
s.lineTo(-x, -y+r);
|
|
430
|
+
s.quadraticCurveTo(-x, -y, -x+r, -y);
|
|
431
|
+
return s;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const boxCache = new Map();
|
|
435
|
+
function pillGeometry(w, h, d, r, horizontal = false) {
|
|
436
|
+
const key = [w,h,d,r,horizontal].join('/');
|
|
437
|
+
if (boxCache.has(key)) return boxCache.get(key);
|
|
438
|
+
|
|
439
|
+
const planarH = horizontal ? d : h;
|
|
440
|
+
const thickness = horizontal ? h : d;
|
|
441
|
+
const b = Math.min(r * .57, w * .17, planarH * .17, thickness * .28);
|
|
442
|
+
const shape = roundShape(w - 2*b, planarH - 2*b, r - b);
|
|
443
|
+
const g = new THREE.ExtrudeGeometry(shape, {
|
|
444
|
+
depth: thickness - 2*b, steps: 1,
|
|
445
|
+
bevelEnabled: true, bevelThickness: b, bevelSize: b,
|
|
446
|
+
bevelSegments: 3, curveSegments: 7
|
|
447
|
+
});
|
|
448
|
+
g.center();
|
|
449
|
+
localUV(g);
|
|
450
|
+
if (horizontal) g.rotateX(-Math.PI / 2);
|
|
451
|
+
boxCache.set(key, g);
|
|
452
|
+
return g;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function pill(parent, material, x, y, z, w, h, d, r, horizontal = false) {
|
|
456
|
+
return mesh(parent, pillGeometry(w,h,d,r,horizontal), material, x,y,z);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function curvedTube(parent, material, points, radius, closed = false) {
|
|
460
|
+
const curve = new THREE.CatmullRomCurve3(
|
|
461
|
+
points.map(p => Array.isArray(p) ? vec(...p) : p), closed, 'centripetal'
|
|
462
|
+
);
|
|
463
|
+
const tube = new THREE.TubeGeometry(
|
|
464
|
+
curve, Math.max(16, points.length * 5), radius, 10, closed
|
|
465
|
+
);
|
|
466
|
+
return mesh(parent, tube, material, 0, 0, 0);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function turn(parent, material, profile, x, y, z) {
|
|
470
|
+
const g = new THREE.LatheGeometry(
|
|
471
|
+
profile.map(([r, height]) => new THREE.Vector2(r, height)), 32
|
|
472
|
+
);
|
|
473
|
+
g.center();
|
|
474
|
+
return mesh(parent, g, material, x, y, z);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 重复构件按材质分批;个体仍有各自偏角、尺度或色差。
|
|
478
|
+
function batch(parent, geo, material, entries) {
|
|
479
|
+
const m = new THREE.InstancedMesh(geo, material, entries.length);
|
|
480
|
+
const pose = new THREE.Object3D();
|
|
481
|
+
entries.forEach((entry, i) => {
|
|
482
|
+
const { x, y, z, rx = 0, ry = 0, rz = 0, sx = 1, sy = 1, sz = 1, color } = entry;
|
|
483
|
+
pose.position.set(x,y,z);
|
|
484
|
+
pose.rotation.set(rx,ry,rz);
|
|
485
|
+
pose.scale.set(sx,sy,sz);
|
|
486
|
+
pose.updateMatrix();
|
|
487
|
+
m.setMatrixAt(i, pose.matrix);
|
|
488
|
+
if (color !== undefined) m.setColorAt(i, new THREE.Color(color));
|
|
489
|
+
});
|
|
490
|
+
m.instanceMatrix.needsUpdate = true;
|
|
491
|
+
if (m.instanceColor) m.instanceColor.needsUpdate = true;
|
|
492
|
+
m.castShadow = m.receiveShadow = true;
|
|
493
|
+
parent.add(m);
|
|
494
|
+
return m;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const plane = new THREE.PlaneGeometry(1, 1);
|
|
498
|
+
function spot(parent, x, y, z, w, d, color, opacity, additive = false) {
|
|
499
|
+
const material = new THREE.MeshBasicMaterial({
|
|
500
|
+
color, map: softSpot, transparent: true, opacity,
|
|
501
|
+
depthWrite: false, toneMapped: false,
|
|
502
|
+
blending: additive ? THREE.AdditiveBlending : THREE.NormalBlending,
|
|
503
|
+
polygonOffset: true, polygonOffsetFactor: -1
|
|
504
|
+
});
|
|
505
|
+
const m = mesh(parent, plane, material, x, y, z, false);
|
|
506
|
+
m.rotation.x = -Math.PI / 2;
|
|
507
|
+
m.scale.set(w, d, 1);
|
|
508
|
+
m.renderOrder = additive ? 1 : 2;
|
|
509
|
+
return m;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// 冷色桌面与浅浅的广场边沿。
|
|
513
|
+
const ground = mesh(scene, new THREE.PlaneGeometry(160,160), mat.table, 0,-.36,0,false);
|
|
514
|
+
ground.rotation.x = -Math.PI / 2;
|
|
515
|
+
ground.receiveShadow = true;
|
|
516
|
+
spot(world,0,-.358,-.10,10.8,7.9,0x17213a,.54);
|
|
517
|
+
const plaza = group(world, 0, 0, -.10);
|
|
518
|
+
pill(plaza,mat.stoneBase,0,-.20,0,7.42,.31,5.48,.42,true);
|
|
519
|
+
pill(plaza,mat.strips,0,-.139,0,7.44,.038,5.50,.42,true);
|
|
520
|
+
pill(plaza,mat.grout,0,-.061,0,7.33,.104,5.39,.38,true);
|
|
521
|
+
|
|
522
|
+
const tileGeo = pillGeometry(.775,.065,.635,.043,true);
|
|
523
|
+
const tileMat = matte(0xe5e9f2,{ map:mineral, roughness:.91 });
|
|
524
|
+
const tiles = [];
|
|
525
|
+
const tileColors = [0xe5eaf5,0xd6dfef,0xdde4ed,0xe9e7ed,0xc9d4e8];
|
|
526
|
+
for (let row=0; row<8; row++) {
|
|
527
|
+
for (let col=-4; col<=4; col++) {
|
|
528
|
+
const x = col*.794;
|
|
529
|
+
const z = (row-3.5)*.652;
|
|
530
|
+
tiles.push({
|
|
531
|
+
x:x+(rand()-.5)*.007, y:-.0325, z,
|
|
532
|
+
ry:(rand()-.5)*.021 + (row % 2 ? Math.PI : 0),
|
|
533
|
+
sx:Math.abs(col)===4 && (row===0 || row===7) ? .88 : 1,
|
|
534
|
+
color:tileColors[Math.floor(rand()*tileColors.length)]
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
batch(plaza,tileGeo,tileMat,tiles);
|
|
539
|
+
|
|
540
|
+
// D 形台面:z=front 为开口,向后展开半圆。
|
|
541
|
+
const front = .88;
|
|
542
|
+
const stageTop = .178;
|
|
543
|
+
const R = 2.57;
|
|
544
|
+
|
|
545
|
+
function dSlab(parent, material, radius, thickness, y, frontZ, bevel) {
|
|
546
|
+
const s = new THREE.Shape();
|
|
547
|
+
const r = radius - bevel;
|
|
548
|
+
s.moveTo(r,0);
|
|
549
|
+
s.absarc(0,0,r,0,Math.PI,false);
|
|
550
|
+
s.lineTo(r,0);
|
|
551
|
+
const g = new THREE.ExtrudeGeometry(s,{
|
|
552
|
+
depth:thickness-2*bevel, steps:1, curveSegments:44,
|
|
553
|
+
bevelEnabled:true, bevelSegments:3,
|
|
554
|
+
bevelSize:bevel, bevelThickness:bevel
|
|
555
|
+
});
|
|
556
|
+
g.center();
|
|
557
|
+
localUV(g);
|
|
558
|
+
g.rotateX(-Math.PI/2);
|
|
559
|
+
return mesh(parent,g,material,0,y,frontZ-radius/2+bevel/2);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
const stage = group(world);
|
|
563
|
+
stage.name = '半级演出台';
|
|
564
|
+
spot(stage,0,.003,-.04,5.94,3.8,0x353247,.41);
|
|
565
|
+
dSlab(stage,mat.darkWood,R,.145,.066,front,.024);
|
|
566
|
+
dSlab(stage,mat.rimWood,R+.018,.052,.134,front,.016);
|
|
567
|
+
dSlab(stage,mat.walnut,R-.043,.030,.150,front-.008,.008);
|
|
568
|
+
|
|
569
|
+
for (let i=0; i<10; i++) {
|
|
570
|
+
const back = .08+i*.239;
|
|
571
|
+
const half = Math.sqrt((R-.087)**2-(back+.117)**2);
|
|
572
|
+
const board = pill(stage,deckMats[i%4],0,stageTop-.014,front-back-.036,
|
|
573
|
+
2*half,.028,i===0?.158:.224,.036,true);
|
|
574
|
+
if (i % 2) board.rotation.y = Math.PI;
|
|
575
|
+
}
|
|
576
|
+
// 最前缘一条浅色防滑木嵌条,不再加第二级台阶。
|
|
577
|
+
pill(stage,mat.seatWood,0,.161,front+.001,4.98,.035,.076,.021,true);
|
|
578
|
+
|
|
579
|
+
function arc(radius, y, start, end, count, cz = front) {
|
|
580
|
+
return Array.from({length:count}, (_,i) => {
|
|
581
|
+
const a = start+(end-start)*i/(count-1);
|
|
582
|
+
const yy = typeof y === 'function' ? y(a) : y;
|
|
583
|
+
return [Math.cos(a)*radius, yy, cz-Math.sin(a)*radius];
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// 半亭的后屏只遮到腰线,檐下保留夜色与留白。
|
|
588
|
+
const pavilion = group(world);
|
|
589
|
+
pavilion.name = '半圆木乐亭';
|
|
590
|
+
const frameR = 2.43;
|
|
591
|
+
const railY = .914;
|
|
592
|
+
const baseY = stageTop - .02;
|
|
593
|
+
|
|
594
|
+
curvedTube(pavilion,mat.darkWood,arc(frameR,.268,.07,Math.PI-.07,28),.050);
|
|
595
|
+
curvedTube(pavilion,mat.rimWood,arc(frameR,railY,.065,Math.PI-.065,34),.067);
|
|
596
|
+
|
|
597
|
+
const pickets = [];
|
|
598
|
+
for (let i=0; i<27; i++) {
|
|
599
|
+
const a = .12+i*(Math.PI-.24)/26;
|
|
600
|
+
const y = .305 + (railY-.305)/2 - .015;
|
|
601
|
+
pickets.push({
|
|
602
|
+
x:Math.cos(a)*frameR, y, z:front-Math.sin(a)*frameR,
|
|
603
|
+
ry:a-.5*Math.PI, rz:(rand()-.5)*.022,
|
|
604
|
+
color:[0xefdbd0,0xfff1e0,0xdccbd4][i%3]
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
batch(pavilion,pillGeometry(.066,.625,.081,.021),mat.walnut,pickets);
|
|
608
|
+
|
|
609
|
+
const posts = [];
|
|
610
|
+
const foots = [];
|
|
611
|
+
const caps = [];
|
|
612
|
+
for (const [i,a] of [.085,.92,1.63,2.30,Math.PI-.085].entries()) {
|
|
613
|
+
const x = Math.cos(a)*frameR;
|
|
614
|
+
const z = front-Math.sin(a)*frameR;
|
|
615
|
+
const h = i===0 || i===4 ? 2.36 : 2.39;
|
|
616
|
+
posts.push({x,y:baseY+h/2,z,ry:a-Math.PI/2});
|
|
617
|
+
foots.push({x,y:baseY+.071,z,ry:a-Math.PI/2});
|
|
618
|
+
caps.push({x,y:2.45,z,ry:a-Math.PI/2});
|
|
619
|
+
spot(pavilion,x,stageTop+.003,z,.42,.34,0x403240,.48);
|
|
620
|
+
}
|
|
621
|
+
batch(pavilion,pillGeometry(.147,2.37,.161,.026),mat.endWood,posts);
|
|
622
|
+
batch(pavilion,pillGeometry(.219,.145,.232,.035),mat.rimWood,foots);
|
|
623
|
+
batch(pavilion,pillGeometry(.225,.097,.237,.026),mat.seatWood,caps);
|
|
624
|
+
|
|
625
|
+
// 实心檐底与薄扇形坡顶。坡顶的弧度用连续曲面生成。
|
|
626
|
+
const roofR = 2.68;
|
|
627
|
+
const roofZ = .87;
|
|
628
|
+
const eave = 2.565;
|
|
629
|
+
const roofRise = .365;
|
|
630
|
+
dSlab(pavilion,mat.darkWood,roofR,.123,2.505,roofZ,.035);
|
|
631
|
+
dSlab(pavilion,mat.rimWood,roofR+.026,.053,2.558,roofZ,.018);
|
|
632
|
+
|
|
633
|
+
function roofY(u) {
|
|
634
|
+
return eave + roofRise*(1-Math.pow(u,1.56));
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function fanRoof() {
|
|
638
|
+
const sections = 64;
|
|
639
|
+
const tracks = 16;
|
|
640
|
+
const vertices = [0,roofY(0),roofZ];
|
|
641
|
+
const uvs = [.5,0];
|
|
642
|
+
const indices = [];
|
|
643
|
+
const step = sections+1;
|
|
644
|
+
for (let j=1; j<=tracks; j++) {
|
|
645
|
+
const u = j/tracks;
|
|
646
|
+
for (let i=0; i<=sections; i++) {
|
|
647
|
+
const a = Math.PI*i/sections;
|
|
648
|
+
const x = Math.cos(a)*roofR*u;
|
|
649
|
+
const z = roofZ-Math.sin(a)*roofR*u;
|
|
650
|
+
vertices.push(x,roofY(u),z);
|
|
651
|
+
uvs.push(.5+x/(2*roofR),(roofZ-z)/roofR);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
for (let i=0; i<sections; i++) indices.push(0,1+i,2+i);
|
|
655
|
+
for (let j=0; j<tracks-1; j++) {
|
|
656
|
+
for (let i=0; i<sections; i++) {
|
|
657
|
+
const a = 1+j*step+i;
|
|
658
|
+
const b = a+step;
|
|
659
|
+
indices.push(a,b,b+1,a,b+1,a+1);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
const g = new THREE.BufferGeometry();
|
|
663
|
+
g.setAttribute('position',new THREE.Float32BufferAttribute(vertices,3));
|
|
664
|
+
g.setAttribute('uv',new THREE.Float32BufferAttribute(uvs,2));
|
|
665
|
+
g.setIndex(indices);
|
|
666
|
+
g.computeVertexNormals();
|
|
667
|
+
mesh(pavilion,g,mat.roof,0,0,0);
|
|
668
|
+
}
|
|
669
|
+
fanRoof();
|
|
670
|
+
|
|
671
|
+
for (const u of [.38,.68,.91]) {
|
|
672
|
+
curvedTube(pavilion,mat.seam,arc(roofR*u,roofY(u)+.002,.012,Math.PI-.012,32,roofZ),.011);
|
|
673
|
+
}
|
|
674
|
+
curvedTube(pavilion,mat.seam,arc(roofR,eave+.005,0,Math.PI,43,roofZ),.024);
|
|
675
|
+
|
|
676
|
+
// 开口檐口的弧形包边与浅拱面,一起封住坡顶前缘。
|
|
677
|
+
const fasciaPositions = [];
|
|
678
|
+
const fasciaIndices = [];
|
|
679
|
+
const crown = [];
|
|
680
|
+
for (let i=0; i<=36; i++) {
|
|
681
|
+
const x = -roofR+2*roofR*i/36;
|
|
682
|
+
const y = roofY(Math.abs(x)/roofR);
|
|
683
|
+
crown.push([x,y,roofZ+.007]);
|
|
684
|
+
fasciaPositions.push(x,eave-.02,roofZ, x,y,roofZ);
|
|
685
|
+
if (i<36) {
|
|
686
|
+
const j = i*2;
|
|
687
|
+
fasciaIndices.push(j,j+2,j+1,j+1,j+2,j+3);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
const fasciaGeo = new THREE.BufferGeometry();
|
|
691
|
+
fasciaGeo.setAttribute('position',new THREE.Float32BufferAttribute(fasciaPositions,3));
|
|
692
|
+
fasciaGeo.setIndex(fasciaIndices);
|
|
693
|
+
fasciaGeo.computeVertexNormals();
|
|
694
|
+
mesh(pavilion,fasciaGeo,mat.roof,0,0,0);
|
|
695
|
+
curvedTube(pavilion,mat.rimWood,crown,.029);
|
|
696
|
+
const fasciaPins = [-2.01,-1.32,-.66,0,.66,1.32,2.01].map((x,i) => ({
|
|
697
|
+
x, y:roofY(Math.abs(x)/roofR)-.069, z:roofZ+.016,
|
|
698
|
+
sx:i===3?.028:.017, sy:i===3?.027:.017, sz:.009
|
|
699
|
+
}));
|
|
700
|
+
batch(pavilion,ballGeo,mat.brass,fasciaPins);
|
|
701
|
+
|
|
702
|
+
// 一盏真正投光的小壁灯,装在靠近手风琴的后柱上。
|
|
703
|
+
const lampAngle = 2.30;
|
|
704
|
+
const lamp = group(
|
|
705
|
+
pavilion,Math.cos(lampAngle)*frameR,1.82,front-Math.sin(lampAngle)*frameR
|
|
706
|
+
);
|
|
707
|
+
lamp.rotation.y = -.18;
|
|
708
|
+
pill(lamp,mat.darkWood,0,0,.091,.245,.432,.075,.075);
|
|
709
|
+
pill(lamp,mat.brass,0,.016,.133,.120,.211,.043,.048);
|
|
710
|
+
curvedTube(lamp,mat.brass,[
|
|
711
|
+
[0,-.096,.147],[0,-.140,.219],[0,-.125,.316],[0,-.064,.359]
|
|
712
|
+
],.026);
|
|
713
|
+
|
|
714
|
+
const glassProfile = [
|
|
715
|
+
[0,-.128],[.073,-.128],[.103,-.106],[.123,-.046],[.130,.015],
|
|
716
|
+
[.118,.081],[.088,.123],[.064,.130],[0,.130]
|
|
717
|
+
];
|
|
718
|
+
turn(lamp,mat.lamp,glassProfile,0,.050,.358);
|
|
719
|
+
turn(lamp,mat.brass,[
|
|
720
|
+
[0,-.035],[.096,-.035],[.114,-.020],[.119,.004],[.098,.030],[0,.035]
|
|
721
|
+
],0,-.083,.358);
|
|
722
|
+
turn(lamp,mat.brass,[
|
|
723
|
+
[0,-.041],[.109,-.041],[.116,-.020],[.084,.009],[.040,.046],[0,.052]
|
|
724
|
+
],0,.184,.358);
|
|
725
|
+
const stays = [];
|
|
726
|
+
for (let i=0;i<4;i++) {
|
|
727
|
+
const a = Math.PI/4+i*Math.PI/2;
|
|
728
|
+
stays.push({
|
|
729
|
+
x:.116*Math.cos(a),y:.050,z:.358+.116*Math.sin(a),
|
|
730
|
+
rz:.07*Math.cos(a),rx:-.07*Math.sin(a)
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
batch(lamp,pillGeometry(.014,.224,.014,.005),mat.brass,stays);
|
|
734
|
+
|
|
735
|
+
const lanternLight = new THREE.PointLight(0xffb16b, 14, 4.3, 2);
|
|
736
|
+
lanternLight.position.set(.015,.041,.49);
|
|
737
|
+
lamp.add(lanternLight);
|
|
738
|
+
|
|
739
|
+
// A broad, low-intensity pool carries the warm light down to the deck.
|
|
740
|
+
const pool = spot(stage,-1.04,stageTop+.002,-.18,3.15,2.25,0xffa263,.075,true);
|
|
741
|
+
const lampHaloMat = new THREE.SpriteMaterial({
|
|
742
|
+
map:softSpot,color:0xffb26f,opacity:.13,transparent:true,
|
|
743
|
+
blending:THREE.AdditiveBlending,depthWrite:false,toneMapped:false
|
|
744
|
+
});
|
|
745
|
+
const lampHalo = new THREE.Sprite(lampHaloMat);
|
|
746
|
+
lampHalo.position.set(0,.05,.489);
|
|
747
|
+
lampHalo.scale.set(.60,.66,1);
|
|
748
|
+
lampHalo.renderOrder = 3;
|
|
749
|
+
lamp.add(lampHalo);
|
|
750
|
+
|
|
751
|
+
// 乐师的椅子:从座面、椅腿到弧形椅背统一在局部空间。
|
|
752
|
+
const chair = group(stage,-.74,stageTop-.018,-.12);
|
|
753
|
+
chair.rotation.y = .14;
|
|
754
|
+
spot(chair,0,.022,0,1.24,.94,0x34293d,.64);
|
|
755
|
+
for (const x of [-.291,.291]) {
|
|
756
|
+
for (const z of [-.224,.214]) {
|
|
757
|
+
curvedTube(chair,mat.walnut,[
|
|
758
|
+
[x*1.09,0,z*1.13],[x,.084,z*1.04],[x*.95,.213,z],
|
|
759
|
+
[x*.94,.359,z]
|
|
760
|
+
],.044);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
pill(chair,mat.rimWood,0,.362,0,.746,.111,.613,.105,true);
|
|
764
|
+
pill(chair,mat.vest,0,.420,.005,.661,.069,.528,.098,true);
|
|
765
|
+
for (const x of [-.31,.31]) {
|
|
766
|
+
curvedTube(chair,mat.walnut,[
|
|
767
|
+
[x,.355,-.237],[x,.536,-.280],[x*.94,.725,-.309],
|
|
768
|
+
[x*.86,.876,-.299]
|
|
769
|
+
],.047);
|
|
770
|
+
}
|
|
771
|
+
curvedTube(chair,mat.seatWood,[
|
|
772
|
+
[-.275,.846,-.301],[-.201,.928,-.338],[0,.956,-.368],
|
|
773
|
+
[.207,.924,-.337],[.275,.846,-.301]
|
|
774
|
+
],.049);
|
|
775
|
+
curvedTube(chair,mat.rimWood,[
|
|
776
|
+
[-.277,.688,-.288],[-.149,.715,-.322],[.025,.722,-.340],
|
|
777
|
+
[.167,.707,-.327],[.277,.680,-.292]
|
|
778
|
+
],.031);
|
|
779
|
+
|
|
780
|
+
const rabbit = group(chair,-.016,.437,-.011);
|
|
781
|
+
rabbit.name = '刚停下一曲的兔子';
|
|
782
|
+
oval(rabbit,mat.fur,0,.192,-.020,.290,.295,.234);
|
|
783
|
+
oval(rabbit,mat.vest,0,.158,.046,.282,.213,.217);
|
|
784
|
+
oval(rabbit,mat.fur,-.135,-.002,.217,.118,.084,.174).rotation.y = -.17;
|
|
785
|
+
oval(rabbit,mat.fur,.149,.006,.211,.112,.089,.164).rotation.y = .11;
|
|
786
|
+
oval(rabbit,mat.muzzle,-.278,.046,-.162,.106,.100,.111);
|
|
787
|
+
|
|
788
|
+
const head = group(rabbit,-.018,.503,.028);
|
|
789
|
+
head.rotation.set(.025,-.062,-.052);
|
|
790
|
+
oval(head,mat.fur,0,0,0,.324,.280,.263);
|
|
791
|
+
for (const [x,angle,h] of [[-.160,.21,.270],[.150,-.28,.303]]) {
|
|
792
|
+
const ear = group(head,x,.299,-.042);
|
|
793
|
+
ear.rotation.z = angle;
|
|
794
|
+
ear.rotation.x = x<0 ? -.20 : .07;
|
|
795
|
+
oval(ear,mat.fur,0,.075,0,.104,h,.081);
|
|
796
|
+
oval(ear,mat.ear,0,.093,.058,.054,h*.72,.022);
|
|
797
|
+
}
|
|
798
|
+
oval(head,mat.muzzle,-.082,-.090,.198,.101,.076,.071);
|
|
799
|
+
oval(head,mat.muzzle,.067,-.092,.201,.101,.077,.068);
|
|
800
|
+
oval(head,mat.blush,-.215,-.058,.172,.058,.027,.026,false);
|
|
801
|
+
oval(head,mat.blush,.205,-.058,.178,.055,.026,.024,false);
|
|
802
|
+
oval(head,mat.ear,-.009,-.049,.267,.038,.026,.022);
|
|
803
|
+
curvedTube(head,mat.ink,[
|
|
804
|
+
[-.033,-.106,.262],[-.019,-.114,.265],[-.008,-.117,.266],
|
|
805
|
+
[.008,-.114,.264],[.023,-.105,.260]
|
|
806
|
+
],.0058);
|
|
807
|
+
for (const x of [-.133,.121]) {
|
|
808
|
+
oval(head,mat.ink,x,.024,.239,.033,.041,.019);
|
|
809
|
+
oval(head,mat.gleam,x-.008,.038,.255,.009,.010,.005,false);
|
|
810
|
+
}
|
|
811
|
+
oval(rabbit,mat.scarf,0,.366,.013,.241,.064,.193);
|
|
812
|
+
const knot = oval(rabbit,mat.scarf,-.121,.348,.175,.073,.063,.054);
|
|
813
|
+
knot.rotation.z = -.19;
|
|
814
|
+
pill(rabbit,mat.scarf,-.165,.269,.182,.085,.171,.039,.028).rotation.z = -.24;
|
|
815
|
+
|
|
816
|
+
// 小手风琴已合拢大半,坐在腿上;爪尖没再按住琴键。
|
|
817
|
+
const accordion = group(rabbit,.010,.176,.244);
|
|
818
|
+
accordion.name = '半合的手风琴';
|
|
819
|
+
accordion.rotation.set(-.17,-.10,.076);
|
|
820
|
+
pill(accordion,mat.bellows,0,0,0,.331,.212,.149,.022);
|
|
821
|
+
const pleats = [];
|
|
822
|
+
for (let i=0;i<7;i++) {
|
|
823
|
+
pleats.push({
|
|
824
|
+
x:-.131+i*.044,y:0,z:0,
|
|
825
|
+
sy:1-Math.abs(i-3)*.016
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
batch(accordion,pillGeometry(.024,.241,.182,.012),mat.folds,pleats);
|
|
829
|
+
|
|
830
|
+
pill(accordion,mat.shell,-.238,0,0,.183,.269,.214,.041);
|
|
831
|
+
pill(accordion,mat.shell,.233,0,0,.177,.266,.217,.042);
|
|
832
|
+
pill(accordion,mat.ink,.242,-.004,.112,.132,.217,.021,.019);
|
|
833
|
+
pill(accordion,mat.brass,-.241,.086,.112,.126,.036,.016,.011);
|
|
834
|
+
|
|
835
|
+
const keys = [];
|
|
836
|
+
for (let i=0;i<7;i++) {
|
|
837
|
+
keys.push({x:.244,y:-.081+i*.026,z:.128});
|
|
838
|
+
}
|
|
839
|
+
batch(accordion,pillGeometry(.107,.023,.020,.007),mat.ivory,keys);
|
|
840
|
+
batch(accordion,pillGeometry(.057,.013,.012,.004),mat.ink,
|
|
841
|
+
[0,1,3,4,5].map(i => ({x:.266,y:-.068+i*.026,z:.142}))
|
|
842
|
+
);
|
|
843
|
+
const buttons = [];
|
|
844
|
+
for (let i=0;i<3;i++) {
|
|
845
|
+
for (let j=0;j<3;j++) {
|
|
846
|
+
buttons.push({x:-.278+j*.038,y:-.074+i*.041,z:.117,sx:.013,sy:.013,sz:.009});
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
batch(accordion,ballGeo,mat.ivory,buttons);
|
|
850
|
+
oval(rabbit,mat.fur,-.275,.202,.141,.097,.153,.087).rotation.z = -.29;
|
|
851
|
+
oval(rabbit,mat.fur,.288,.163,.160,.096,.146,.086).rotation.z = .32;
|
|
852
|
+
oval(rabbit,mat.muzzle,-.330,.125,.286,.084,.074,.071);
|
|
853
|
+
oval(rabbit,mat.muzzle,.354,.115,.269,.078,.066,.071);
|
|
854
|
+
|
|
855
|
+
// 长凳右移且斜放一点,纸面朝前,避免被栏杆完全遮住。
|
|
856
|
+
const bench = group(stage,1.084,stageTop-.018,-.465);
|
|
857
|
+
bench.rotation.y = -.23;
|
|
858
|
+
spot(bench,0,.021,0,1.81,.81,0x403245,.56);
|
|
859
|
+
const legs = [];
|
|
860
|
+
for (const x of [-.54,.54]) {
|
|
861
|
+
for (const z of [-.15,.15]) {
|
|
862
|
+
legs.push({x,y:.159,z,rz:x>0?.053:-.053});
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
batch(bench,pillGeometry(.108,.337,.104,.026),mat.walnut,legs);
|
|
866
|
+
pill(bench,mat.darkWood,0,.280,0,1.296,.119,.371,.040);
|
|
867
|
+
pill(bench,mat.rimWood,0,.359,0,1.568,.102,.482,.066,true);
|
|
868
|
+
curvedTube(bench,mat.seatWood,[
|
|
869
|
+
[-.733,.370,.208],[-.366,.375,.224],[0,.375,.231],
|
|
870
|
+
[.369,.371,.223],[.733,.370,.208]
|
|
871
|
+
],.018);
|
|
872
|
+
|
|
873
|
+
const pages = [];
|
|
874
|
+
function sheet(x,z,w,d,angle,lift,second) {
|
|
875
|
+
const geo = new THREE.PlaneGeometry(w,d,16,18);
|
|
876
|
+
geo.rotateX(-Math.PI/2);
|
|
877
|
+
const sheetMat = matte(0xffffff,{
|
|
878
|
+
map:scoreTexture(second),side:THREE.DoubleSide,
|
|
879
|
+
roughness:.94, envMapIntensity:.22
|
|
880
|
+
});
|
|
881
|
+
const m = mesh(bench,geo,sheetMat,x,.413+lift,z);
|
|
882
|
+
m.rotation.y = angle;
|
|
883
|
+
m.frustumCulled = false;
|
|
884
|
+
const p = geo.attributes.position;
|
|
885
|
+
p.setUsage(THREE.DynamicDrawUsage);
|
|
886
|
+
pages.push({geo,w,d,second});
|
|
887
|
+
}
|
|
888
|
+
sheet(-.156,.006,.395,.333,.213,0,true);
|
|
889
|
+
sheet(.145,.037,.374,.321,-.174,.005,false);
|
|
890
|
+
|
|
891
|
+
function bendPages(t) {
|
|
892
|
+
for (const {geo,w,d,second} of pages) {
|
|
893
|
+
const p = geo.attributes.position;
|
|
894
|
+
for (let i=0;i<p.count;i++) {
|
|
895
|
+
const u = p.getX(i)/w+.5;
|
|
896
|
+
const v = p.getZ(i)/d+.5;
|
|
897
|
+
const corner = Math.pow(u,3.8)*Math.pow(1-v,2.2);
|
|
898
|
+
const lip = Math.pow(v,5)*Math.pow(1-u,3);
|
|
899
|
+
const flip = (.5+.5*Math.sin(t*2.05-.48))**3;
|
|
900
|
+
const bending = second ? .020 : .046+.041*flip;
|
|
901
|
+
p.setY(i,corner*bending+lip*.010+.002*Math.sin(Math.PI*u));
|
|
902
|
+
}
|
|
903
|
+
p.needsUpdate = true;
|
|
904
|
+
geo.computeVertexNormals();
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// 胖啾站在右边栏杆上。脚趾保持在木扶手上,只有上身呼吸。
|
|
909
|
+
const perchAngle = .38;
|
|
910
|
+
const birdRoot = group(
|
|
911
|
+
pavilion,Math.cos(perchAngle)*frameR,railY+.047,front-Math.sin(perchAngle)*frameR
|
|
912
|
+
);
|
|
913
|
+
birdRoot.name = '等下一首的小鸟';
|
|
914
|
+
birdRoot.rotation.y = -.59;
|
|
915
|
+
for (const x of [-.079,.072]) {
|
|
916
|
+
curvedTube(birdRoot,mat.beak,[
|
|
917
|
+
[x,-.019,-.028],[x,.004,.001],[x,.005,.057],[x,-.016,.085]
|
|
918
|
+
],.016);
|
|
919
|
+
}
|
|
920
|
+
const breath = group(birdRoot,0,.025,0);
|
|
921
|
+
oval(breath,mat.bird,0,.185,-.028,.223,.217,.210);
|
|
922
|
+
oval(breath,mat.bib,0,.160,.086,.172,.158,.119);
|
|
923
|
+
oval(breath,mat.bird,-.008,.313,.035,.185,.165,.166);
|
|
924
|
+
oval(breath,mat.wing,-.172,.169,-.026,.065,.122,.135).rotation.z = -.24;
|
|
925
|
+
oval(breath,mat.wing,.175,.173,-.035,.066,.117,.139).rotation.z = .29;
|
|
926
|
+
oval(breath,mat.wing,.041,.151,-.208,.092,.044,.130).rotation.x = -.29;
|
|
927
|
+
oval(breath,mat.beak,-.010,.282,.201,.046,.032,.048);
|
|
928
|
+
for (const x of [-.092,.077]) {
|
|
929
|
+
oval(breath,mat.ink,x,.342,.166,.025,.028,.015);
|
|
930
|
+
oval(breath,mat.gleam,x-.005,.352,.176,.006,.007,.004,false);
|
|
931
|
+
}
|
|
932
|
+
oval(breath,mat.bird,-.067,.448,.018,.026,.046,.025).rotation.z = .54;
|
|
933
|
+
|
|
934
|
+
// 窄视场:沿实际观察方向投影包围盒,自适应横竖屏。
|
|
935
|
+
// 相机瞄向台口上方,不使用大角度俯瞰或放宽焦距来塞下场景。
|
|
936
|
+
const camera = new THREE.PerspectiveCamera(27,1,.1,120);
|
|
937
|
+
const target = vec(0,1.12,-.18);
|
|
938
|
+
const frame = new THREE.Box3(vec(-3.73,-.32,-2.85),vec(3.73,2.98,2.65));
|
|
939
|
+
const corners = [];
|
|
940
|
+
for (const x of [frame.min.x,frame.max.x]) {
|
|
941
|
+
for (const y of [frame.min.y,frame.max.y]) {
|
|
942
|
+
for (const z of [frame.min.z,frame.max.z]) corners.push(vec(x,y,z).sub(target));
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
const home = { yaw:.27, pitch:rad(23.5), zoom:1 };
|
|
947
|
+
const orbit = {...home};
|
|
948
|
+
const goal = {...home};
|
|
949
|
+
const up = vec(0,1,0);
|
|
950
|
+
const out = vec(0,0,1);
|
|
951
|
+
const right = vec(1,0,0);
|
|
952
|
+
const screenUp = vec(0,1,0);
|
|
953
|
+
|
|
954
|
+
function poseCamera() {
|
|
955
|
+
const cp = Math.cos(orbit.pitch);
|
|
956
|
+
out.set(Math.sin(orbit.yaw)*cp,Math.sin(orbit.pitch),Math.cos(orbit.yaw)*cp);
|
|
957
|
+
right.crossVectors(up,out).normalize();
|
|
958
|
+
screenUp.crossVectors(out,right).normalize();
|
|
959
|
+
const tanY = Math.tan(rad(camera.fov*.5));
|
|
960
|
+
const tanX = tanY*camera.aspect;
|
|
961
|
+
let required = 0;
|
|
962
|
+
for (const p of corners) {
|
|
963
|
+
const depth = p.dot(out);
|
|
964
|
+
required = Math.max(required,
|
|
965
|
+
depth+Math.abs(p.dot(right))/(tanX*.92),
|
|
966
|
+
depth+Math.abs(p.dot(screenUp))/(tanY*.91)
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
camera.position.copy(target).addScaledVector(out,required*orbit.zoom);
|
|
970
|
+
camera.lookAt(target);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
function resize() {
|
|
974
|
+
const w = window.innerWidth;
|
|
975
|
+
const h = window.innerHeight;
|
|
976
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1,1.8));
|
|
977
|
+
renderer.setSize(w,h);
|
|
978
|
+
camera.aspect = w/Math.max(1,h);
|
|
979
|
+
camera.updateProjectionMatrix();
|
|
980
|
+
poseCamera();
|
|
981
|
+
}
|
|
982
|
+
window.addEventListener('resize',resize);
|
|
983
|
+
resize();
|
|
984
|
+
|
|
985
|
+
// 手写阻尼:目标角度和距离与实际机位分开;双指只缩放。
|
|
986
|
+
// 保持赏景正面在敞口一侧,限制俯仰,防止穿入桌面。
|
|
987
|
+
const surface = renderer.domElement;
|
|
988
|
+
const pointers = new Map();
|
|
989
|
+
function pinchDistance() {
|
|
990
|
+
const [a,b] = pointers.values();
|
|
991
|
+
return Math.max(1,Math.hypot(a.x-b.x,a.y-b.y));
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
surface.addEventListener('pointerdown',e => {
|
|
995
|
+
if ((e.pointerType==='mouse' && e.button!==0) || pointers.size>=2) return;
|
|
996
|
+
surface.setPointerCapture(e.pointerId);
|
|
997
|
+
pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});
|
|
998
|
+
surface.style.cursor = 'grabbing';
|
|
999
|
+
});
|
|
1000
|
+
surface.addEventListener('pointermove',e => {
|
|
1001
|
+
const p = pointers.get(e.pointerId);
|
|
1002
|
+
if (!p) return;
|
|
1003
|
+
const dx = e.clientX-p.x;
|
|
1004
|
+
const dy = e.clientY-p.y;
|
|
1005
|
+
const previous = pointers.size===2 ? pinchDistance() : 0;
|
|
1006
|
+
p.x = e.clientX;
|
|
1007
|
+
p.y = e.clientY;
|
|
1008
|
+
if (pointers.size===2) {
|
|
1009
|
+
goal.zoom = clamp(goal.zoom*previous/pinchDistance(),.73,1.58);
|
|
1010
|
+
} else {
|
|
1011
|
+
goal.yaw = clamp(goal.yaw-dx*.006,-.97,.97);
|
|
1012
|
+
goal.pitch = clamp(goal.pitch+dy*.004,rad(15),rad(43));
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
function dropPointer(e) {
|
|
1016
|
+
pointers.delete(e.pointerId);
|
|
1017
|
+
if (!pointers.size) surface.style.cursor = 'grab';
|
|
1018
|
+
}
|
|
1019
|
+
for (const name of ['pointerup','pointercancel','lostpointercapture']) {
|
|
1020
|
+
surface.addEventListener(name,dropPointer);
|
|
1021
|
+
}
|
|
1022
|
+
surface.style.cursor = 'grab';
|
|
1023
|
+
surface.addEventListener('wheel',e => {
|
|
1024
|
+
e.preventDefault();
|
|
1025
|
+
const units = e.deltaMode===1 ? 16 : e.deltaMode===2 ? innerHeight : 1;
|
|
1026
|
+
goal.zoom = clamp(goal.zoom*Math.exp(
|
|
1027
|
+
clamp(e.deltaY*units,-150,150)*.00165
|
|
1028
|
+
),.73,1.58);
|
|
1029
|
+
},{passive:false});
|
|
1030
|
+
|
|
1031
|
+
document.querySelector('#reset').addEventListener('click',() => {
|
|
1032
|
+
Object.assign(goal,home);
|
|
1033
|
+
});
|
|
1034
|
+
const reduce = matchMedia('(prefers-reduced-motion: reduce)');
|
|
1035
|
+
const pause = document.querySelector('#pause');
|
|
1036
|
+
const pauseIcon = document.querySelector('#pause-icon');
|
|
1037
|
+
let motion = !reduce.matches;
|
|
1038
|
+
|
|
1039
|
+
function updatePauseButton() {
|
|
1040
|
+
const label = motion ? '暂停微动' : '继续微动';
|
|
1041
|
+
pause.setAttribute('aria-label',label);
|
|
1042
|
+
pause.setAttribute('aria-pressed',String(!motion));
|
|
1043
|
+
pause.title = label;
|
|
1044
|
+
pauseIcon.setAttribute('d',motion ? 'M7 4.5v11m6-11v11' : 'M7 4.5l8 5.5-8 5.5z');
|
|
1045
|
+
}
|
|
1046
|
+
updatePauseButton();
|
|
1047
|
+
pause.addEventListener('click',() => {
|
|
1048
|
+
motion = !motion;
|
|
1049
|
+
updatePauseButton();
|
|
1050
|
+
});
|
|
1051
|
+
reduce.addEventListener('change',e => {
|
|
1052
|
+
motion = !e.matches;
|
|
1053
|
+
updatePauseButton();
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
function animateDetails(t) {
|
|
1057
|
+
const s = .029*Math.sin(t*2.48+.7);
|
|
1058
|
+
const horizontal = 1/Math.sqrt(1+s);
|
|
1059
|
+
breath.scale.set(horizontal,1+s,horizontal);
|
|
1060
|
+
breath.rotation.z = .010*Math.sin(t*1.11+.42);
|
|
1061
|
+
const flicker = 1 + .048*Math.sin(t*3.9+.3)
|
|
1062
|
+
+ .022*Math.sin(t*8.2) + .009*Math.sin(t*13.4+1.7);
|
|
1063
|
+
lanternLight.intensity = 14*flicker;
|
|
1064
|
+
mat.lamp.emissiveIntensity = .72*flicker;
|
|
1065
|
+
lampHaloMat.opacity = .13*flicker;
|
|
1066
|
+
pool.material.opacity = .075*flicker;
|
|
1067
|
+
bendPages(t);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
let last;
|
|
1071
|
+
let t = 0;
|
|
1072
|
+
animateDetails(t);
|
|
1073
|
+
renderer.setAnimationLoop(now => {
|
|
1074
|
+
const dt = last===undefined ? 0 : Math.min((now-last)/1000,.04);
|
|
1075
|
+
last = now;
|
|
1076
|
+
const damping = reduce.matches ? 1 : 1-Math.pow(.927,dt*60);
|
|
1077
|
+
for (const key of ['yaw','pitch','zoom']) {
|
|
1078
|
+
orbit[key] += (goal[key]-orbit[key])*damping;
|
|
1079
|
+
}
|
|
1080
|
+
if (motion) {
|
|
1081
|
+
t += dt;
|
|
1082
|
+
animateDetails(t);
|
|
1083
|
+
}
|
|
1084
|
+
poseCamera();
|
|
1085
|
+
renderer.render(scene,camera);
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
start().catch(error => {
|
|
1090
|
+
console.error(error);
|
|
1091
|
+
const notice = document.querySelector('#notice');
|
|
1092
|
+
notice.textContent = '暂时无法打开乐亭。请确认浏览器支持 WebGL,并可访问 cdnjs 后重试。';
|
|
1093
|
+
notice.hidden = false;
|
|
1094
|
+
});
|
|
1095
|
+
</script>
|
|
1096
|
+
</body>
|
|
1097
|
+
</html>
|