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,1569 @@
|
|
|
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; background: #22283e; color: #f6e6d0; }
|
|
9
|
+
* { box-sizing: border-box; }
|
|
10
|
+
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
|
|
11
|
+
body { font: 13px/1.5 system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; }
|
|
12
|
+
canvas.stage { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
|
|
13
|
+
canvas.stage.drag { cursor: grabbing; }
|
|
14
|
+
canvas.stage.hot { cursor: pointer; }
|
|
15
|
+
header { position: fixed; left: max(22px, env(safe-area-inset-left)); bottom: 22px; pointer-events: none; }
|
|
16
|
+
h1 { margin: 0; font-size: 15px; font-weight: 550; letter-spacing: .28em; }
|
|
17
|
+
header span { opacity: .61; font-size: 11px; letter-spacing: .12em; }
|
|
18
|
+
nav { position: fixed; right: max(16px, env(safe-area-inset-right)); top: max(16px, env(safe-area-inset-top)); display: flex; gap: 8px; }
|
|
19
|
+
button { width: 40px; height: 40px; border: 1px solid #eee0cc35; border-radius: 50%;
|
|
20
|
+
background: #22283d90; color: inherit; font: 19px system-ui; cursor: pointer; }
|
|
21
|
+
button:hover, button:focus-visible { background: #62647c; outline: 2px solid #ffe0a8; outline-offset: 3px; }
|
|
22
|
+
#message { position: fixed; bottom: 24px; right: 22px; max-width: min(310px, 56vw);
|
|
23
|
+
opacity: 0; transition: opacity .3s; pointer-events: none; text-align: right; color: #ffebca; }
|
|
24
|
+
#message.show { opacity: 1; }
|
|
25
|
+
#error { position: fixed; inset: 0; display: grid; place-items: center; padding: 32px; background: #22283e; }
|
|
26
|
+
#error[hidden] { display: none; }
|
|
27
|
+
@media (prefers-reduced-motion: reduce) { #message { transition: none; } }
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<header><h1>露尖夜值</h1><span>望星 · 修钟 · 读云</span></header>
|
|
32
|
+
<nav aria-label="沙盘操作">
|
|
33
|
+
<button id="home" aria-label="复位视角" title="复位视角">⌂</button>
|
|
34
|
+
<button id="hoist" aria-label="操作工具升降井" title="操作工具升降井">↕</button>
|
|
35
|
+
</nav>
|
|
36
|
+
<output id="message" aria-live="polite"></output>
|
|
37
|
+
<div id="error" hidden role="alert"></div>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
/* Background chrome: the dioramas ship drag hints, toolbars and a station
|
|
41
|
+
readout for standalone use; as a backdrop they would float over chat text. */
|
|
42
|
+
aside, nav, header, section.line, button { display: none !important; }
|
|
43
|
+
</style>
|
|
44
|
+
<script>
|
|
45
|
+
(function () {
|
|
46
|
+
var nativeRaf = window.requestAnimationFrame.bind(window);
|
|
47
|
+
var nativeCancel = window.cancelAnimationFrame.bind(window);
|
|
48
|
+
var paused = false;
|
|
49
|
+
var nextId = 1e9;
|
|
50
|
+
var held = new Map();
|
|
51
|
+
window.requestAnimationFrame = function (callback) {
|
|
52
|
+
if (!paused) return nativeRaf(callback);
|
|
53
|
+
var id = nextId++;
|
|
54
|
+
held.set(id, callback);
|
|
55
|
+
return id;
|
|
56
|
+
};
|
|
57
|
+
window.cancelAnimationFrame = function (id) {
|
|
58
|
+
if (held.delete(id)) return;
|
|
59
|
+
nativeCancel(id);
|
|
60
|
+
};
|
|
61
|
+
function drain() {
|
|
62
|
+
var queued = held;
|
|
63
|
+
held = new Map();
|
|
64
|
+
queued.forEach(function (callback) {
|
|
65
|
+
nativeRaf(function (time) { callback(time); });
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
window.addEventListener('message', function (event) {
|
|
69
|
+
var data = event.data;
|
|
70
|
+
if (data === null || typeof data !== 'object' || data.__nookScene !== true) return;
|
|
71
|
+
if (data.action === 'pause') {
|
|
72
|
+
paused = true;
|
|
73
|
+
} else if (data.action === 'resume' && paused) {
|
|
74
|
+
paused = false;
|
|
75
|
+
drain();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
})();
|
|
79
|
+
</script>
|
|
80
|
+
<script type="module">
|
|
81
|
+
try {
|
|
82
|
+
const T = await import('./three.module.min.js');
|
|
83
|
+
|
|
84
|
+
const TAU = Math.PI * 2;
|
|
85
|
+
const V = (x=0,y=0,z=0) => new T.Vector3(x,y,z);
|
|
86
|
+
const up = V(0,1,0);
|
|
87
|
+
const clamp = T.MathUtils.clamp;
|
|
88
|
+
const lerp = T.MathUtils.lerp;
|
|
89
|
+
const sin = Math.sin;
|
|
90
|
+
const smooth = (a,b,x) => {
|
|
91
|
+
const u = clamp((x-a)/(b-a),0,1);
|
|
92
|
+
return u*u*(3-2*u);
|
|
93
|
+
};
|
|
94
|
+
let seed = 42817;
|
|
95
|
+
function rand() {
|
|
96
|
+
seed = (Math.imul(seed,1664525)+1013904223) >>> 0;
|
|
97
|
+
return seed/4294967296;
|
|
98
|
+
}
|
|
99
|
+
const range = (a,b) => lerp(a,b,rand());
|
|
100
|
+
const pick = a => a[Math.floor(rand()*a.length)];
|
|
101
|
+
|
|
102
|
+
const scene = new T.Scene();
|
|
103
|
+
scene.background = new T.Color('#2a304a');
|
|
104
|
+
scene.fog = new T.FogExp2('#2a304a',.023);
|
|
105
|
+
const root = new T.Group();
|
|
106
|
+
scene.add(root);
|
|
107
|
+
|
|
108
|
+
const renderer = new T.WebGLRenderer({antialias:true,alpha:false,powerPreference:'high-performance'});
|
|
109
|
+
renderer.domElement.className = 'stage';
|
|
110
|
+
renderer.domElement.setAttribute('aria-label','可旋转的露尖夜值三维沙盘');
|
|
111
|
+
document.body.prepend(renderer.domElement);
|
|
112
|
+
renderer.outputColorSpace = T.SRGBColorSpace;
|
|
113
|
+
renderer.toneMapping = T.ACESFilmicToneMapping;
|
|
114
|
+
renderer.toneMappingExposure = 1.14;
|
|
115
|
+
renderer.shadowMap.enabled = true;
|
|
116
|
+
renderer.shadowMap.type = T.PCFSoftShadowMap;
|
|
117
|
+
|
|
118
|
+
const studio = new T.Scene();
|
|
119
|
+
studio.background = new T.Color('#888eb0');
|
|
120
|
+
function softbox(w,h,p,color,power) {
|
|
121
|
+
const m = new T.Mesh(
|
|
122
|
+
new T.PlaneGeometry(w,h),
|
|
123
|
+
new T.MeshBasicMaterial({color:new T.Color(color).multiplyScalar(power),side:T.DoubleSide})
|
|
124
|
+
);
|
|
125
|
+
m.position.set(...p);
|
|
126
|
+
m.lookAt(0,0,0);
|
|
127
|
+
studio.add(m);
|
|
128
|
+
}
|
|
129
|
+
softbox(9,14,[7,10,8],'#fff1d8',3.2);
|
|
130
|
+
softbox(4,12,[-10,3,-4],'#b9d9ff',2.7);
|
|
131
|
+
softbox(10,4,[0,7,-12],'#ddbcf7',1.65);
|
|
132
|
+
softbox(13,5,[1,-7,7],'#dea782',.75);
|
|
133
|
+
const pmrem = new T.PMREMGenerator(renderer);
|
|
134
|
+
const bakedLight = pmrem.fromScene(studio,.045);
|
|
135
|
+
scene.environment = bakedLight.texture;
|
|
136
|
+
pmrem.dispose();
|
|
137
|
+
for (const m of studio.children) { m.geometry.dispose(); m.material.dispose(); }
|
|
138
|
+
|
|
139
|
+
scene.add(new T.HemisphereLight('#e3ecff','#a78b9e',1.32));
|
|
140
|
+
const key = new T.DirectionalLight('#ffe6c9',2.0);
|
|
141
|
+
key.position.set(-7,14,9);
|
|
142
|
+
key.castShadow = true;
|
|
143
|
+
key.target.position.set(0,3,0);
|
|
144
|
+
Object.assign(key.shadow.camera,{left:-8.5,right:8.5,top:8.5,bottom:-8.5,near:.5,far:35});
|
|
145
|
+
key.shadow.mapSize.set(2048,2048);
|
|
146
|
+
key.shadow.normalBias = .038;
|
|
147
|
+
key.shadow.bias = -.0002;
|
|
148
|
+
scene.add(key,key.target);
|
|
149
|
+
function fill(color,intensity,x,y,z) {
|
|
150
|
+
const light = new T.DirectionalLight(color,intensity);
|
|
151
|
+
light.position.set(x,y,z);
|
|
152
|
+
scene.add(light);
|
|
153
|
+
}
|
|
154
|
+
fill('#a4cbff',1.22,6,7,-8);
|
|
155
|
+
fill('#f0bb9b',.31,1,-5,8);
|
|
156
|
+
|
|
157
|
+
function canvasTexture(w,h,draw,color=true) {
|
|
158
|
+
const c = document.createElement('canvas');
|
|
159
|
+
c.width=w; c.height=h;
|
|
160
|
+
draw(c.getContext('2d'),w,h);
|
|
161
|
+
const texture = new T.CanvasTexture(c);
|
|
162
|
+
if(color) texture.colorSpace=T.SRGBColorSpace;
|
|
163
|
+
texture.anisotropy=Math.min(8,renderer.capabilities.getMaxAnisotropy());
|
|
164
|
+
return texture;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const mineralMap = canvasTexture(512,512,(c,w,h)=>{
|
|
168
|
+
const g=c.createLinearGradient(0,0,0,h);
|
|
169
|
+
g.addColorStop(0,'#a8abc4'); g.addColorStop(.45,'#686f91'); g.addColorStop(1,'#444b6b');
|
|
170
|
+
c.fillStyle=g; c.fillRect(0,0,w,h);
|
|
171
|
+
for(let i=0;i<91;i++){
|
|
172
|
+
const y=range(0,h);
|
|
173
|
+
c.beginPath();
|
|
174
|
+
for(let x=0;x<=w;x+=8){
|
|
175
|
+
const yy=y+sin(x*.021+i*.19)*5+sin(x*.049+i)*1.3;
|
|
176
|
+
if(x===0)c.moveTo(x,yy); else c.lineTo(x,yy);
|
|
177
|
+
}
|
|
178
|
+
c.strokeStyle=i%5===0?'#dccee457':i%3?'#443f6061':'#9cc9cf35';
|
|
179
|
+
c.lineWidth=range(.4,i%7===0?7:2);
|
|
180
|
+
c.stroke();
|
|
181
|
+
}
|
|
182
|
+
for(let i=0;i<12000;i++){
|
|
183
|
+
const s=range(.3,2.4);
|
|
184
|
+
c.fillStyle=rand()>.53?'#eee4ed22':'#22283c2b';
|
|
185
|
+
c.fillRect(rand()*w,rand()*h,s,s*.7);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
mineralMap.wrapS=T.RepeatWrapping;
|
|
189
|
+
mineralMap.repeat.x=2;
|
|
190
|
+
|
|
191
|
+
const woodMap = canvasTexture(512,256,(c,w,h)=>{
|
|
192
|
+
c.fillStyle='#96786c'; c.fillRect(0,0,w,h);
|
|
193
|
+
const wash=c.createLinearGradient(0,0,0,h);
|
|
194
|
+
wash.addColorStop(0,'#e6b99655'); wash.addColorStop(.55,'#6a3e4333'); wash.addColorStop(1,'#33253866');
|
|
195
|
+
c.fillStyle=wash; c.fillRect(0,0,w,h);
|
|
196
|
+
for(let i=0;i<150;i++){
|
|
197
|
+
let y=rand()*h;
|
|
198
|
+
c.beginPath();
|
|
199
|
+
c.moveTo(0,y);
|
|
200
|
+
for(let x=0;x<=w;x+=8){
|
|
201
|
+
const knot=Math.exp(-Math.pow((x-335)/78,2))*sin(y*.08)*8;
|
|
202
|
+
c.lineTo(x,y+sin(x*.014+i*.31)*range(1,2.2)+knot);
|
|
203
|
+
}
|
|
204
|
+
c.strokeStyle=pick(['#f4cf9e44','#5e343d65','#784d4a88','#e5b0952e']);
|
|
205
|
+
c.lineWidth=range(.55,1.8); c.stroke();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const enamelMap = canvasTexture(256,256,(c,w,h)=>{
|
|
210
|
+
c.fillStyle='#e4d7c7'; c.fillRect(0,0,w,h);
|
|
211
|
+
for(let i=0;i<9000;i++){
|
|
212
|
+
c.fillStyle=rand()>.54?'#fcf1de35':'#6a5a5928';
|
|
213
|
+
const s=range(.25,1.5); c.fillRect(rand()*w,rand()*h,s,s);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const aoMap = canvasTexture(96,96,(c,w,h)=>{
|
|
218
|
+
const g=c.createRadialGradient(48,48,3,48,48,47);
|
|
219
|
+
g.addColorStop(0,'rgba(29,25,45,.74)');
|
|
220
|
+
g.addColorStop(.38,'rgba(33,27,48,.47)');
|
|
221
|
+
g.addColorStop(.76,'rgba(39,32,50,.12)');
|
|
222
|
+
g.addColorStop(1,'rgba(39,32,50,0)');
|
|
223
|
+
c.fillStyle=g; c.fillRect(0,0,w,h);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const starMap = canvasTexture(64,64,(c,w,h)=>{
|
|
227
|
+
const g=c.createRadialGradient(32,32,0,32,32,31);
|
|
228
|
+
g.addColorStop(0,'#fff7e6');
|
|
229
|
+
g.addColorStop(.16,'#fff1cfdd');
|
|
230
|
+
g.addColorStop(.42,'#c7d9ff65');
|
|
231
|
+
g.addColorStop(1,'#add2ff00');
|
|
232
|
+
c.fillStyle=g; c.fillRect(0,0,w,h);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const standard = (color,options={}) => new T.MeshStandardMaterial({color,roughness:.67,...options});
|
|
236
|
+
const glaze = (color,options={}) => new T.MeshPhysicalMaterial({
|
|
237
|
+
color,roughness:.36,clearcoat:.48,clearcoatRoughness:.16,...options
|
|
238
|
+
});
|
|
239
|
+
const lampMat = (color,power=.85) => standard(color,{emissive:color,emissiveIntensity:power,roughness:.45});
|
|
240
|
+
|
|
241
|
+
const m = {
|
|
242
|
+
rock:standard('#c5c8e2',{map:mineralMap,roughness:.92}),
|
|
243
|
+
slate:standard('#525b7f',{roughness:.9}),
|
|
244
|
+
slab:standard('#858aa7',{roughness:.86,map:enamelMap}),
|
|
245
|
+
grotto:standard('#514b62',{roughness:.93}),
|
|
246
|
+
plinth:glaze('#333850',{roughness:.43}),
|
|
247
|
+
plinthTop:standard('#505877',{roughness:.87}),
|
|
248
|
+
wood:standard('#ab8a79',{map:woodMap}),
|
|
249
|
+
edge:standard('#674d50',{map:woodMap}),
|
|
250
|
+
trim:standard('#e0b58a',{map:woodMap}),
|
|
251
|
+
brass:standard('#eac28a',{metalness:.78,roughness:.31}),
|
|
252
|
+
darkBrass:standard('#a87360',{metalness:.72,roughness:.43}),
|
|
253
|
+
steel:standard('#8798ab',{metalness:.63,roughness:.38}),
|
|
254
|
+
iron:standard('#3c465d',{metalness:.43,roughness:.49}),
|
|
255
|
+
rope:standard('#daba9e',{roughness:.94}),
|
|
256
|
+
cream:glaze('#f0decb',{map:enamelMap}),
|
|
257
|
+
milk:glaze('#f6e6d8'),
|
|
258
|
+
ink:glaze('#272c44',{roughness:.26}),
|
|
259
|
+
rose:glaze('#c27d84'),
|
|
260
|
+
pink:glaze('#eca8aa',{roughness:.45}),
|
|
261
|
+
wine:glaze('#675471'),
|
|
262
|
+
blue:glaze('#4e688c'),
|
|
263
|
+
pool:glaze('#83a7a5'),
|
|
264
|
+
mint:glaze('#a6c2ab'),
|
|
265
|
+
moss:standard('#667f80',{roughness:.95}),
|
|
266
|
+
mossLight:standard('#91a89a',{roughness:.94}),
|
|
267
|
+
lilac:glaze('#afa4c0'),
|
|
268
|
+
amber:lampMat('#ffd18e',1.16),
|
|
269
|
+
dimAmber:lampMat('#edaa69',.52),
|
|
270
|
+
blueLamp:lampMat('#addce5',.57),
|
|
271
|
+
paper:standard('#efe0c9',{roughness:.94}),
|
|
272
|
+
damp:standard('#a7b9b6',{roughness:.67}),
|
|
273
|
+
canvas:standard('#c2a9a3',{map:enamelMap,roughness:1})
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const ballGeo = new T.SphereGeometry(1,24,16);
|
|
277
|
+
const planeGeo = new T.PlaneGeometry(1,1);
|
|
278
|
+
const boxGeos = new Map();
|
|
279
|
+
const turnGeos = new Map();
|
|
280
|
+
|
|
281
|
+
function group(parent,x=0,y=0,z=0){
|
|
282
|
+
const item=new T.Group(); item.position.set(x,y,z); parent.add(item); return item;
|
|
283
|
+
}
|
|
284
|
+
function mesh(parent,geo,mat,x=0,y=0,z=0,shade=true){
|
|
285
|
+
const item=new T.Mesh(geo,mat);
|
|
286
|
+
item.position.set(x,y,z);
|
|
287
|
+
item.castShadow=shade; item.receiveShadow=shade;
|
|
288
|
+
parent.add(item);
|
|
289
|
+
return item;
|
|
290
|
+
}
|
|
291
|
+
function roundGeo(w,h,d,r){
|
|
292
|
+
const key=[w,h,d,r].map(n=>n.toFixed(4)).join('/');
|
|
293
|
+
if(boxGeos.has(key))return boxGeos.get(key);
|
|
294
|
+
const b=Math.min(r,w*.235,h*.235,d*.235);
|
|
295
|
+
const x=w/2-b,y=h/2-b,k=Math.min(x,y,b*1.3);
|
|
296
|
+
const s=new T.Shape();
|
|
297
|
+
s.moveTo(-x+k,-y);
|
|
298
|
+
s.lineTo(x-k,-y); s.quadraticCurveTo(x,-y,x,-y+k);
|
|
299
|
+
s.lineTo(x,y-k); s.quadraticCurveTo(x,y,x-k,y);
|
|
300
|
+
s.lineTo(-x+k,y); s.quadraticCurveTo(-x,y,-x,y-k);
|
|
301
|
+
s.lineTo(-x,-y+k); s.quadraticCurveTo(-x,-y,-x+k,-y);
|
|
302
|
+
const geo=new T.ExtrudeGeometry(s,{depth:d-2*b,bevelEnabled:true,bevelThickness:b,bevelSize:b,bevelSegments:3,curveSegments:4,steps:1});
|
|
303
|
+
geo.center();
|
|
304
|
+
// ExtrudeGeometry 默认使用世界单位 UV;在各面按局部尺寸重映射。
|
|
305
|
+
const pos=geo.attributes.position, norm=geo.attributes.normal, uv=geo.attributes.uv;
|
|
306
|
+
for(let i=0;i<pos.count;i++){
|
|
307
|
+
const nx=Math.abs(norm.getX(i)),ny=Math.abs(norm.getY(i)),nz=Math.abs(norm.getZ(i));
|
|
308
|
+
const u=(nx>nz&&nx>ny)?pos.getZ(i)/d:pos.getX(i)/w;
|
|
309
|
+
const v=(ny>nx&&ny>nz)?pos.getZ(i)/d:pos.getY(i)/h;
|
|
310
|
+
uv.setXY(i,.5+u,.5+v);
|
|
311
|
+
}
|
|
312
|
+
boxGeos.set(key,geo);
|
|
313
|
+
return geo;
|
|
314
|
+
}
|
|
315
|
+
function block(p,w,h,d,r,mat,x=0,y=0,z=0){
|
|
316
|
+
return mesh(p,roundGeo(w,h,d,r),mat,x,y,z);
|
|
317
|
+
}
|
|
318
|
+
function ball(p,sx,sy,sz,mat,x=0,y=0,z=0,shade=true){
|
|
319
|
+
const a=mesh(p,ballGeo,mat,x,y,z,shade);
|
|
320
|
+
a.scale.set(sx,sy,sz);
|
|
321
|
+
return a;
|
|
322
|
+
}
|
|
323
|
+
function turn(p,profile,mat,x=0,y=0,z=0,steps=36){
|
|
324
|
+
const key=JSON.stringify([profile,steps]);
|
|
325
|
+
let geo=turnGeos.get(key);
|
|
326
|
+
if(!geo){
|
|
327
|
+
geo=new T.LatheGeometry(profile.map(a=>new T.Vector2(...a)),steps);
|
|
328
|
+
geo.center(); turnGeos.set(key,geo);
|
|
329
|
+
}
|
|
330
|
+
return mesh(p,geo,mat,x,y,z);
|
|
331
|
+
}
|
|
332
|
+
function spool(p,r,h,mat,x=0,y=0,z=0){
|
|
333
|
+
const s=Math.min(h*.18,r*.19);
|
|
334
|
+
return turn(p,[[0,-h/2],[r*.81,-h/2],[r*.96,-h/2+s*.3],[r,-h/2+s],
|
|
335
|
+
[r,h/2-s],[r*.96,h/2-s*.3],[r*.81,h/2],[0,h/2]],mat,x,y,z,28);
|
|
336
|
+
}
|
|
337
|
+
function disc(p,r,d,mat,x=0,y=0,z=0){
|
|
338
|
+
const a=spool(p,r,d,mat,x,y,z);
|
|
339
|
+
a.rotation.x=Math.PI/2;
|
|
340
|
+
return a;
|
|
341
|
+
}
|
|
342
|
+
function ring(p,r,minor,mat,x=0,y=0,z=0){
|
|
343
|
+
return mesh(p,new T.TorusGeometry(r,minor,9,40),mat,x,y,z);
|
|
344
|
+
}
|
|
345
|
+
function between(p,a,b,r,mat){
|
|
346
|
+
const dir=b.clone().sub(a), mid=a.clone().lerp(b,.5);
|
|
347
|
+
const aMesh=spool(p,r,dir.length()+.008,mat,...mid.toArray());
|
|
348
|
+
aMesh.quaternion.setFromUnitVectors(up,dir.normalize());
|
|
349
|
+
return aMesh;
|
|
350
|
+
}
|
|
351
|
+
function beam(p,a,b,w,d,mat){
|
|
352
|
+
const dir=b.clone().sub(a),mid=a.clone().lerp(b,.5);
|
|
353
|
+
const o=block(p,w,dir.length()+.035,d,.018,mat,...mid.toArray());
|
|
354
|
+
o.quaternion.setFromUnitVectors(up,dir.normalize());
|
|
355
|
+
return o;
|
|
356
|
+
}
|
|
357
|
+
function tube(p,points,r,mat,steps=44){
|
|
358
|
+
const path=new T.CatmullRomCurve3(points.map(a=>a.isVector3?a:V(...a)));
|
|
359
|
+
return mesh(p,new T.TubeGeometry(path,steps,r,8,false),mat);
|
|
360
|
+
}
|
|
361
|
+
function ao(p,x,y,z,w,d,opacity=.7){
|
|
362
|
+
const o=mesh(p,planeGeo,new T.MeshBasicMaterial({
|
|
363
|
+
map:aoMap,transparent:true,depthWrite:false,opacity,polygonOffset:true,polygonOffsetFactor:-1
|
|
364
|
+
}),x,y,z,false);
|
|
365
|
+
o.rotation.x=-Math.PI/2; o.scale.set(w,d,1);
|
|
366
|
+
return o;
|
|
367
|
+
}
|
|
368
|
+
function panel(p,w,h,map,x,y,z){
|
|
369
|
+
return mesh(p,planeGeo,new T.MeshBasicMaterial({map,side:T.DoubleSide}),x,y,z,false).scale.set(w,h,1);
|
|
370
|
+
}
|
|
371
|
+
function sign(p,text,w,h,x,y,z,sub=''){
|
|
372
|
+
const a=block(p,w,h,.055,.017,m.edge,x,y,z);
|
|
373
|
+
const t=canvasTexture(384,128,(c,W,H)=>{
|
|
374
|
+
c.fillStyle='#3c3549'; c.fillRect(0,0,W,H);
|
|
375
|
+
c.strokeStyle='#cfac82'; c.lineWidth=3; c.strokeRect(8,8,W-16,H-16);
|
|
376
|
+
c.textAlign='center'; c.textBaseline='middle'; c.fillStyle='#f7dfb3';
|
|
377
|
+
c.font=`${sub?46:58}px serif`; c.fillText(text,W/2,sub?49:66);
|
|
378
|
+
if(sub){c.font='18px sans-serif';c.fillText(sub,W/2,95);}
|
|
379
|
+
});
|
|
380
|
+
panel(a,w*.94,h*.88,t,0,0,.029);
|
|
381
|
+
return a;
|
|
382
|
+
}
|
|
383
|
+
function point(p,color,power,distance,x,y,z){
|
|
384
|
+
const a=new T.PointLight(color,power,distance,2);
|
|
385
|
+
a.position.set(x,y,z); p.add(a); return a;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const ground = mesh(scene,new T.PlaneGeometry(350,350),standard('#30364f',{roughness:1}),0,-.055,0,false);
|
|
389
|
+
ground.rotation.x=-Math.PI/2;
|
|
390
|
+
ground.receiveShadow=true;
|
|
391
|
+
ao(scene,.1,-.044,.43,14,11,.87);
|
|
392
|
+
|
|
393
|
+
const base=group(root);
|
|
394
|
+
block(base,9.65,.25,6.92,.11,m.plinth,0,.13,.15);
|
|
395
|
+
block(base,9.55,.076,6.8,.03,m.darkBrass,0,.27,.15);
|
|
396
|
+
block(base,9.46,.22,6.72,.10,m.plinth,0,.398,.15);
|
|
397
|
+
block(base,9.22,.12,6.49,.05,m.plinthTop,0,.553,.15);
|
|
398
|
+
ao(base,.02,.618,.11,8.75,5.95,.74);
|
|
399
|
+
const title=sign(base,'露 尖 夜 值',1.78,.33,.17,.36,3.617);
|
|
400
|
+
title.rotation.z=-.028;
|
|
401
|
+
for(const x of [-.63,.96])disc(base,.044,.027,m.brass,x,.354,3.637);
|
|
402
|
+
for(const [x,z] of [[-4.01,-2.55],[4.01,-2.55],[-4.01,2.86],[4.01,2.86]]){
|
|
403
|
+
spool(base,.165,.056,m.steel,x,.612,z);
|
|
404
|
+
block(base,.122,.012,.011,.002,m.iron,x,.645,z).rotation.y=range(-.6,.6);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/* 同一块连续楔岩: y / 左缘 / 右缘 / 后缘 / 前缘 / 岩槽内凹深度。
|
|
408
|
+
岩槽不是贴图或另挂盒子;它直接进入岩体前侧放样。 */
|
|
409
|
+
const strata = [
|
|
410
|
+
[.53,-3.19,2.15,-1.66,1.96,0],
|
|
411
|
+
[.68,-3.58,2.76,-2.03,2.21,0],
|
|
412
|
+
[.95,-3.77,3.22,-2.27,2.42,0],
|
|
413
|
+
[1.39,-3.69,3.45,-2.40,2.49,0],
|
|
414
|
+
[1.90,-3.66,3.66,-2.42,2.61,0],
|
|
415
|
+
[2.085,-3.64,3.70,-2.42,2.66,0],
|
|
416
|
+
[2.145,-3.61,3.72,-2.42,2.66,.43],
|
|
417
|
+
[2.20,-3.58,3.73,-2.40,2.66,1.26],
|
|
418
|
+
[2.28,-3.58,3.74,-2.40,2.63,1.85],
|
|
419
|
+
[2.67,-3.57,3.76,-2.36,2.62,1.89],
|
|
420
|
+
[3.11,-3.52,3.79,-2.36,2.60,1.81],
|
|
421
|
+
[3.30,-3.48,3.78,-2.35,2.60,1.76],
|
|
422
|
+
[3.39,-3.44,3.75,-2.32,2.58,1.34],
|
|
423
|
+
[3.51,-3.38,3.71,-2.30,2.57,.36],
|
|
424
|
+
[3.62,-3.37,3.68,-2.26,2.53,0],
|
|
425
|
+
[3.76,-3.33,3.54,-2.19,2.42,0],
|
|
426
|
+
[3.83,-3.32,2.27,-2.14,2.22,0],
|
|
427
|
+
[4.07,-3.22,1.69,-2.01,1.94,0],
|
|
428
|
+
[4.30,-3.09,1.48,-1.92,1.63,0],
|
|
429
|
+
[4.55,-2.93,1.29,-1.78,1.37,0],
|
|
430
|
+
[4.75,-2.72,1.13,-1.66,1.12,0],
|
|
431
|
+
[4.92,-2.29,.96,-1.44,.95,0],
|
|
432
|
+
[5.03,-1.93,.72,-1.28,.81,0]
|
|
433
|
+
];
|
|
434
|
+
const rock=group(root);
|
|
435
|
+
function loftRock(){
|
|
436
|
+
const pos=[],uv=[],ids=[];
|
|
437
|
+
const sideN=40, N=sideN*4;
|
|
438
|
+
function contour(row,k){
|
|
439
|
+
const [y,L,R,B,F,recess]=row;
|
|
440
|
+
const side=Math.min(3,Math.floor(k/sideN));
|
|
441
|
+
const f=(k%sideN)/sideN;
|
|
442
|
+
let u,v;
|
|
443
|
+
if(side===0){u=-1+2*f;v=1;}
|
|
444
|
+
if(side===1){u=1;v=1-2*f;}
|
|
445
|
+
if(side===2){u=1-2*f;v=-1;}
|
|
446
|
+
if(side===3){u=-1;v=-1+2*f;}
|
|
447
|
+
const a=u*(1-.072*Math.pow(Math.abs(v*u),8));
|
|
448
|
+
const b=v*(1-.108*Math.pow(Math.abs(v*u),8));
|
|
449
|
+
const x=lerp(L,R,a*.5+.5);
|
|
450
|
+
const slot=smooth(-2.94,-2.47,x)*(1-smooth(.24,.75,x));
|
|
451
|
+
const relief=.045*sin(k*.35+y*3.5)+.033*sin(k*.67-y*4.8);
|
|
452
|
+
const z=lerp(B,F,b*.5+.5)+(side===0?-recess*slot:0)+relief;
|
|
453
|
+
return [x+relief*.63,y+.018*sin(k*.43+y*5),z];
|
|
454
|
+
}
|
|
455
|
+
for(const row of strata){
|
|
456
|
+
for(let k=0;k<=N;k++){
|
|
457
|
+
pos.push(...contour(row,k%N));
|
|
458
|
+
uv.push(k/N,(row[0]-.53)/4.50);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
for(let j=0;j<strata.length-1;j++)for(let k=0;k<N;k++){
|
|
462
|
+
const a=j*(N+1)+k,b=a+1,c=a+N+1,d=c+1;
|
|
463
|
+
ids.push(a,b,c,b,d,c);
|
|
464
|
+
}
|
|
465
|
+
for(const top of [false,true]){
|
|
466
|
+
const row=top?strata.at(-1):strata[0];
|
|
467
|
+
const mid=pos.length/3;
|
|
468
|
+
pos.push((row[1]+row[2])*.5,row[0],(row[3]+row[4])*.5);
|
|
469
|
+
uv.push(.5,top?1:0);
|
|
470
|
+
const start=pos.length/3;
|
|
471
|
+
for(let k=0;k<N;k++){pos.push(...contour(row,k));uv.push(k/N,top?1:0);}
|
|
472
|
+
for(let k=0;k<N;k++){
|
|
473
|
+
const a=start+k,b=start+(k+1)%N;
|
|
474
|
+
if(top)ids.push(mid,a,b); else ids.push(mid,b,a);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const g=new T.BufferGeometry();
|
|
478
|
+
g.setAttribute('position',new T.Float32BufferAttribute(pos,3));
|
|
479
|
+
g.setAttribute('uv',new T.Float32BufferAttribute(uv,2));
|
|
480
|
+
g.setIndex(ids); g.computeVertexNormals();
|
|
481
|
+
mesh(rock,g,m.rock);
|
|
482
|
+
}
|
|
483
|
+
loftRock();
|
|
484
|
+
|
|
485
|
+
// 卧在岩面的夹层、小裂纹和被潮气抛光的矿脉。
|
|
486
|
+
const seam=standard('#b196ac',{roughness:.76,metalness:.16});
|
|
487
|
+
for(const strip of [
|
|
488
|
+
[[-3.25,1.38,2.26],[-2.06,1.34,2.49],[-.78,1.39,2.54],[.24,1.47,2.54],[1.38,1.48,2.52]],
|
|
489
|
+
[[1.05,1.78,2.62],[1.92,1.83,2.61],[2.65,1.77,2.56],[3.39,1.69,2.32]],
|
|
490
|
+
[[-3.24,3.67,2.24],[-2.44,3.66,2.51],[-1.77,3.70,2.55],[-.94,3.64,2.55]],
|
|
491
|
+
[[3.66,2.37,1.69],[3.76,2.27,.83],[3.76,2.18,.02],[3.70,2.08,-1.18]]
|
|
492
|
+
])tube(rock,strip,.018,seam,26);
|
|
493
|
+
|
|
494
|
+
for(let i=0;i<39;i++){
|
|
495
|
+
const z=range(-2.88,3.05), x=range(-4.28,4.28);
|
|
496
|
+
if(Math.abs(x)<3.42&&Math.abs(z)<2.30)continue;
|
|
497
|
+
const s=range(.065,.26);
|
|
498
|
+
const a=ball(base,s,s*.37,s*.72,pick([m.slab,m.slate,m.moss,m.mossLight]),x,.608+s*.19,z);
|
|
499
|
+
a.rotation.y=range(0,TAU); a.rotation.z=range(-.22,.22);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/* 露滴轮廓偏心收尖。透射只属于景物;下面的测星程序不引用这张网格。 */
|
|
503
|
+
const dropParent=group(root,-.54,2.86,-.69);
|
|
504
|
+
const dropGlass=new T.MeshPhysicalMaterial({
|
|
505
|
+
color:'#d8f5f6',transmission:.96,thickness:1.12,ior:1.334,
|
|
506
|
+
roughness:.083,metalness:0,clearcoat:.36,clearcoatRoughness:.075,
|
|
507
|
+
attenuationColor:'#a5d4e2',attenuationDistance:4.7
|
|
508
|
+
});
|
|
509
|
+
const contour3=new T.CatmullRomCurve3([
|
|
510
|
+
V(.018,0,-.18),V(.69,.14,-.19),V(1.37,.48,-.22),V(1.65,1.00,-.24),
|
|
511
|
+
V(1.59,1.52,-.23),V(1.35,2.04,-.17),V(1.02,2.54,-.06),
|
|
512
|
+
V(.65,3.04,.15),V(.31,3.40,.43),V(.088,3.61,.66),V(.009,3.67,.73)
|
|
513
|
+
]);
|
|
514
|
+
function droplet(){
|
|
515
|
+
const vertices=[],uv=[],index=[];
|
|
516
|
+
const rows=66, radial=88;
|
|
517
|
+
for(let j=0;j<=rows;j++){
|
|
518
|
+
const c=contour3.getPoint(j/rows);
|
|
519
|
+
for(let k=0;k<=radial;k++){
|
|
520
|
+
const a=k/radial*TAU, f=1+.027*sin(a*3+c.y);
|
|
521
|
+
vertices.push(c.z+Math.max(.006,c.x)*f*Math.cos(a),c.y,.86*Math.max(.006,c.x)*f*sin(a)-.12*c.y/3.67);
|
|
522
|
+
uv.push(k/radial,j/rows);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
for(let j=0;j<rows;j++)for(let k=0;k<radial;k++){
|
|
526
|
+
const a=j*(radial+1)+k,b=a+1,c=a+radial+1;
|
|
527
|
+
index.push(a,c,b,b,c,c+1);
|
|
528
|
+
}
|
|
529
|
+
const g=new T.BufferGeometry();
|
|
530
|
+
g.setAttribute('position',new T.Float32BufferAttribute(vertices,3));
|
|
531
|
+
g.setAttribute('uv',new T.Float32BufferAttribute(uv,2));
|
|
532
|
+
g.setIndex(index);g.computeVertexNormals();
|
|
533
|
+
const normals=g.attributes.normal;
|
|
534
|
+
for(let j=0;j<=rows;j++){
|
|
535
|
+
const l=j*(radial+1),r=l+radial;
|
|
536
|
+
const n=V().fromBufferAttribute(normals,l).add(V().fromBufferAttribute(normals,r)).normalize();
|
|
537
|
+
normals.setXYZ(l,n.x,n.y,n.z);normals.setXYZ(r,n.x,n.y,n.z);
|
|
538
|
+
}
|
|
539
|
+
return mesh(dropParent,g,dropGlass,0,0,0,false);
|
|
540
|
+
}
|
|
541
|
+
droplet();
|
|
542
|
+
|
|
543
|
+
const refractionGlint=new T.MeshBasicMaterial({color:'#d4f8ff',transparent:true,opacity:.34,depthWrite:false});
|
|
544
|
+
tube(dropParent,[
|
|
545
|
+
[-1.47,1.84,.47],[-1.32,2.13,.44],[-1.04,2.47,.34],[-.75,2.73,.27]
|
|
546
|
+
],.012,refractionGlint,29).castShadow=false;
|
|
547
|
+
tube(dropParent,[
|
|
548
|
+
[-1.64,1.42,.47],[-1.62,1.54,.50],[-1.59,1.61,.49],[-1.56,1.66,.48]
|
|
549
|
+
],.012,refractionGlint,17).castShadow=false;
|
|
550
|
+
|
|
551
|
+
// 冠座的背脊从同一楔岩升起;其前缘套住露尖,不让玻璃裸尖作悬空连接。
|
|
552
|
+
const spine=group(root);
|
|
553
|
+
for(const [x,y,z,sx,sy,sz,rz] of [
|
|
554
|
+
[-1.17,4.73,-1.23,1.16,.53,.63,-.12],
|
|
555
|
+
[-1.09,5.11,-1.22,.93,.64,.48,-.16],
|
|
556
|
+
[-.95,5.56,-1.23,.81,.63,.43,-.18],
|
|
557
|
+
[-.75,6.02,-1.25,.69,.48,.39,-.13]
|
|
558
|
+
]){
|
|
559
|
+
const r=ball(spine,sx,sy,sz,m.slate,x,y,z);
|
|
560
|
+
r.rotation.z=rz;
|
|
561
|
+
}
|
|
562
|
+
const crownY=6.50;
|
|
563
|
+
const crown=group(root,-.70,crownY,-.58);
|
|
564
|
+
block(crown,3.60,.255,2.22,.11,m.slate,0,-.127,0);
|
|
565
|
+
block(crown,3.48,.12,2.12,.055,m.slab,0,-.018,0);
|
|
566
|
+
block(crown,2.77,.06,.55,.025,m.trim,-.02,.048,.82);
|
|
567
|
+
for(let i=0;i<17;i++){
|
|
568
|
+
const a=i/16;
|
|
569
|
+
block(crown,.125,.027,.40,.009,i%4===0?m.trim:m.wood,lerp(-1.27,1.26,a),.081,.82)
|
|
570
|
+
.rotation.z=range(-.025,.025);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/* 台阶用水平踏板,双边扶栏沿曲线走;每隔几步用斜撑咬回同一片岩壁。 */
|
|
574
|
+
function pathFrom(data){return new T.CatmullRomCurve3(data.map(a=>V(...a)),false,'centripetal');}
|
|
575
|
+
function walk(data,opt={}){
|
|
576
|
+
const path=pathFrom(data);
|
|
577
|
+
const deck=group(root);
|
|
578
|
+
const n=Math.ceil(path.getLength()/(opt.step??.207));
|
|
579
|
+
const width=opt.width??.69;
|
|
580
|
+
const centers=[], sides=[];
|
|
581
|
+
for(let i=0;i<=n;i++){
|
|
582
|
+
const t=i/n;
|
|
583
|
+
const a=path.getPointAt(t), d=path.getTangentAt(t);
|
|
584
|
+
const side=V(d.z,0,-d.x).normalize();
|
|
585
|
+
centers.push(a); sides.push(side);
|
|
586
|
+
const yaw=Math.atan2(d.x,d.z);
|
|
587
|
+
const foot=block(deck,width,.088,.233,.021,i%6===0?m.trim:m.wood,a.x,a.y-.043,a.z);
|
|
588
|
+
foot.rotation.y=yaw+range(-.021,.021);
|
|
589
|
+
for(const u of [-.245,.245]){
|
|
590
|
+
const p=a.clone().addScaledVector(side,u);
|
|
591
|
+
ball(deck,.018,.006,.018,m.darkBrass,p.x,p.y+.005,p.z,false);
|
|
592
|
+
}
|
|
593
|
+
if(i%5===0 && i!==0 && i!==n){
|
|
594
|
+
const tip=a.clone();tip.y-=.085;
|
|
595
|
+
const toward=opt.anchor(a,i/n);
|
|
596
|
+
beam(deck,tip,toward,.09,.09,m.edge);
|
|
597
|
+
const seat=tip.clone().addScaledVector(side,width*.49);
|
|
598
|
+
beam(deck,seat,toward,.068,.078,m.darkBrass);
|
|
599
|
+
beam(deck,tip.clone().addScaledVector(side,-width*.58),seat,.12,.10,m.edge);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
for(const s of [-1,1]){
|
|
603
|
+
const all=centers.map((a,i)=>a.clone().addScaledVector(sides[i],s*(width/2-.046)).add(V(0,.415,0)));
|
|
604
|
+
for(let i=0;i<=n;i++){
|
|
605
|
+
if(i%3!==0&&i!==n)continue;
|
|
606
|
+
const b=all[i];
|
|
607
|
+
spool(deck,.034,.446,m.darkBrass,b.x,b.y-.198,b.z);
|
|
608
|
+
ball(deck,.047,.037,.047,m.brass,b.x,b.y+.028,b.z);
|
|
609
|
+
}
|
|
610
|
+
for(const h of [0,-.178]){
|
|
611
|
+
tube(deck,all.map(p=>p.clone().add(V(0,h,0))),h===0?.033:.020,h===0?m.trim:m.darkBrass,n*2);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return deck;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
walk([
|
|
618
|
+
[-1.83,6.57,.19],[-2.16,6.25,.41],[-2.46,5.83,.62],[-2.75,5.35,.90],
|
|
619
|
+
[-3.06,4.89,1.13],[-3.38,4.47,1.56],[-3.67,4.04,2.00],
|
|
620
|
+
[-3.73,3.52,2.51],[-3.58,3.07,2.86],[-3.32,2.63,2.99],
|
|
621
|
+
[-2.91,2.30,2.98],[-2.43,2.26,2.92]
|
|
622
|
+
],{anchor:(a)=>a.y>5.0?V(Math.max(-2.08,a.x+.48),Math.min(5.98,a.y-.69),Math.min(.4,a.z-.55)):
|
|
623
|
+
V(a.x+.62,Math.max(1.92,a.y-.48),a.z-.62)});
|
|
624
|
+
|
|
625
|
+
const galleryY=2.23;
|
|
626
|
+
const gallery=group(root,-1.08,galleryY,1.88);
|
|
627
|
+
block(gallery,2.92,.143,2.29,.064,m.slate,0,-.062,.16);
|
|
628
|
+
block(gallery,2.88,.089,2.25,.033,m.edge,0,.028,.15);
|
|
629
|
+
const galleryFloor=.075;
|
|
630
|
+
for(let i=0;i<17;i++){
|
|
631
|
+
const a=block(gallery,.158,.049,2.13,.010,i%6===0?m.trim:m.wood,-1.36+.17*i,.054,.15);
|
|
632
|
+
a.rotation.y=range(-.011,.011);
|
|
633
|
+
}
|
|
634
|
+
block(gallery,2.91,.095,.12,.028,m.trim,0,.031,1.277);
|
|
635
|
+
for(let i=0;i<7;i++){
|
|
636
|
+
const x=-1.35+i*.45;
|
|
637
|
+
if(i===0||i===6)continue; // 两端留进出踏道的口
|
|
638
|
+
spool(gallery,.029,.385,m.darkBrass,x,.25,1.27);
|
|
639
|
+
}
|
|
640
|
+
tube(gallery,[[-1.26,.43,1.27],[-.62,.43,1.27],[.11,.432,1.27],[.75,.43,1.27],[1.23,.43,1.27]],.029,m.trim,22);
|
|
641
|
+
|
|
642
|
+
walk([
|
|
643
|
+
[.24,2.31,2.87],[.64,2.41,2.94],[1.08,2.61,2.97],
|
|
644
|
+
[1.56,2.88,2.88],[2.04,3.14,2.68],[2.48,3.43,2.40],
|
|
645
|
+
[2.88,3.68,2.14],[3.18,3.91,1.83]
|
|
646
|
+
],{width:.68,anchor:a=>V(a.x-.12,a.y-.48,a.z-.74)});
|
|
647
|
+
|
|
648
|
+
const terraceY=3.86;
|
|
649
|
+
const terrace=group(root,2.88,terraceY,.69);
|
|
650
|
+
block(terrace,2.49,.182,2.70,.072,m.slate,0,-.11,0);
|
|
651
|
+
block(terrace,2.40,.115,2.63,.039,m.edge,0,-.024,0);
|
|
652
|
+
for(let i=0;i<15;i++){
|
|
653
|
+
block(terrace,.151,.056,2.55,.014,i%5===0?m.trim:m.wood,(i-7)*.155,.04,0)
|
|
654
|
+
.rotation.y=range(-.011,.011);
|
|
655
|
+
}
|
|
656
|
+
for(const x of [-.89,.10,.99]){
|
|
657
|
+
beam(terrace,V(x,-.10,1.15),V(x-.45,-.71,.47),.135,.14,m.edge);
|
|
658
|
+
}
|
|
659
|
+
beam(terrace,V(1.18,-.11,-.55),V(.33,-.70,-.58),.14,.15,m.edge);
|
|
660
|
+
|
|
661
|
+
function fence(p,points){
|
|
662
|
+
const a=points.map(v=>V(...v));
|
|
663
|
+
for(const v of a){
|
|
664
|
+
spool(p,.033,.451,m.darkBrass,v.x,v.y+.23,v.z);
|
|
665
|
+
ball(p,.049,.035,.049,m.brass,v.x,v.y+.456,v.z);
|
|
666
|
+
}
|
|
667
|
+
for(const h of [.43,.239])tube(p,a.map(v=>v.clone().add(V(0,h,0))),h>.3?.03:.018,h>.3?m.trim:m.iron,Math.max(14,a.length*8));
|
|
668
|
+
}
|
|
669
|
+
fence(terrace,[[.72,.065,1.26],[1.10,.065,1.21],[1.18,.065,.73],[1.18,.065,.14],[1.18,.065,-.45],[1.13,.065,-1.10],[.72,.065,-1.23],[.25,.065,-1.23]]);
|
|
670
|
+
fence(terrace,[[-1.10,.065,-1.21],[-.76,.065,-1.24],[-.31,.065,-1.24]]);
|
|
671
|
+
fence(crown,[[-1.64,.081,.92],[-1.26,.081,1.035],[-.81,.081,1.045],[-.33,.081,1.04],[.15,.081,1.042],[.66,.081,1.038],[1.16,.081,1.026],[1.62,.081,.89],[1.68,.081,.51]]);
|
|
672
|
+
fence(crown,[[1.66,.021,-.48],[1.62,.021,-.93],[1.16,.021,-1.03],[.66,.021,-1.03]]);
|
|
673
|
+
sign(terrace,'观 云',.74,.22,.64,.29,1.254).rotation.z=-.049;
|
|
674
|
+
|
|
675
|
+
function lantern(p,x,y,z,s=1){
|
|
676
|
+
const a=group(p,x,y,z);a.scale.setScalar(s);
|
|
677
|
+
spool(a,.103,.047,m.darkBrass,0,.016,0);
|
|
678
|
+
turn(a,[[.064,-.085],[.078,-.05],[.085,.015],[.068,.079]],m.amber,0,.121,0,24);
|
|
679
|
+
spool(a,.107,.046,m.brass,0,.227,0);
|
|
680
|
+
spool(a,.071,.040,m.darkBrass,0,.266,0);
|
|
681
|
+
ring(a,.045,.012,m.darkBrass,0,.313,0);
|
|
682
|
+
for(let k=0;k<4;k++){
|
|
683
|
+
const t=(k+.5)*Math.PI/2;
|
|
684
|
+
between(a,V(.088*Math.cos(t),.033,.088*sin(t)),V(.071*Math.cos(t),.222,.071*sin(t)),.010,m.darkBrass);
|
|
685
|
+
}
|
|
686
|
+
return a;
|
|
687
|
+
}
|
|
688
|
+
const galleryLight=lantern(gallery,-1.19,.74,1.08,.72);
|
|
689
|
+
point(gallery,'#ffd3a0',8.0,4.4,-1.12,.96,1.12);
|
|
690
|
+
lantern(gallery,1.21,.082,.83,.75).rotation.z=.065;
|
|
691
|
+
point(gallery,'#ffbc8e',4.3,2.5,1.14,.39,.81);
|
|
692
|
+
lantern(terrace,1.0,.072,-.97,.76);
|
|
693
|
+
point(terrace,'#ffd9a4',3.1,2.6,1.03,.35,-.82);
|
|
694
|
+
lantern(crown,-1.49,.08,.69,.69);
|
|
695
|
+
point(crown,'#ffc38f',3.2,2.5,-1.48,.38,.66);
|
|
696
|
+
|
|
697
|
+
/* 峰冠:小城由穹顶、两座不等宽的阶檐小屋和独立的露天望远镜组成。 */
|
|
698
|
+
function windowUnit(p,w,h,x,y,z,mat=m.amber){
|
|
699
|
+
const a=group(p,x,y,z);
|
|
700
|
+
block(a,w+.065,h+.065,.079,.026,m.darkBrass);
|
|
701
|
+
block(a,w,h,.047,.018,mat,0,0,.045);
|
|
702
|
+
block(a,.022,h,.019,.005,m.trim,0,0,.075);
|
|
703
|
+
block(a,w,.019,.019,.004,m.trim,0,.033,.076);
|
|
704
|
+
block(a,w+.095,.052,.117,.017,m.cream,0,-h*.55,.037);
|
|
705
|
+
return a;
|
|
706
|
+
}
|
|
707
|
+
function hut(p,x,z,w,d,h,roofMat){
|
|
708
|
+
const a=group(p,x,.025,z);
|
|
709
|
+
ao(a,0,.014,0,w*1.42,d*1.42);
|
|
710
|
+
block(a,w+.085,.084,d+.08,.034,m.darkBrass,0,.037,0);
|
|
711
|
+
block(a,w,h,d,.085,m.cream,0,h/2+.027,0);
|
|
712
|
+
block(a,w+.14,.105,d+.14,.044,roofMat,0,h+.071,0);
|
|
713
|
+
block(a,w+.041,.096,d+.065,.043,roofMat,0,h+.145,0);
|
|
714
|
+
block(a,w*.67,.082,d*.82,.039,roofMat,0,h+.211,-.015);
|
|
715
|
+
for(const u of [-.28,.19])windowUnit(a,.14,.22,u*w,h*.60,d/2);
|
|
716
|
+
block(a,w*.25,.28,.069,.019,m.wood,w*.28,.166,d/2+.011);
|
|
717
|
+
ball(a,.019,.019,.017,m.brass,w*.34,.17,d/2+.054);
|
|
718
|
+
const chimney=block(a,.146,.25,.17,.038,m.wine,-w*.28,h+.189,-d*.21);
|
|
719
|
+
chimney.rotation.z=.056;
|
|
720
|
+
block(a,.177,.059,.197,.021,m.lilac,-w*.28,h+.311,-d*.21);
|
|
721
|
+
return a;
|
|
722
|
+
}
|
|
723
|
+
hut(crown,-1.25,-.34,.72,.70,.56,m.rose).rotation.y=.079;
|
|
724
|
+
hut(crown,-.60,-.76,.62,.52,.47,m.blue).rotation.y=-.067;
|
|
725
|
+
|
|
726
|
+
const dome=group(crown,.35,.035,-.43);
|
|
727
|
+
ao(dome,0,.013,0,1.66,1.56);
|
|
728
|
+
spool(dome,.672,.126,m.darkBrass,0,.05,0);
|
|
729
|
+
spool(dome,.610,.60,m.cream,0,.35,0);
|
|
730
|
+
spool(dome,.651,.10,m.blue,0,.64,0);
|
|
731
|
+
const domeProfile=[[.63,-.282],[.629,-.245],[.601,-.10],[.532,.040],[.419,.167],[.274,.260],[.112,.314],[.002,.325]];
|
|
732
|
+
turn(dome,domeProfile,m.blue,0,.935,0,64);
|
|
733
|
+
for(let i=0;i<8;i++){
|
|
734
|
+
const a=i*TAU/8+.17;
|
|
735
|
+
const obj=group(dome,0,0,0);obj.rotation.y=a;
|
|
736
|
+
if(i%2===0)windowUnit(obj,.19,.225,0,.367,.598,i===4?m.dimAmber:m.amber);
|
|
737
|
+
else block(obj,.065,.52,.060,.014,m.brass,0,.352,.605);
|
|
738
|
+
const pts=domeProfile.slice(0,-1).map(([r,y])=>V(0,.935+y,r+.013));
|
|
739
|
+
tube(obj,pts,.012,i%2===0?m.darkBrass:m.steel,27);
|
|
740
|
+
}
|
|
741
|
+
const shutter=group(dome,0,.9,0);
|
|
742
|
+
shutter.rotation.y=.32;
|
|
743
|
+
tube(shutter,[[0,-.254,.635],[0,-.08,.611],[0,.079,.512],[0,.209,.354],[0,.31,.118]],.056,m.iron);
|
|
744
|
+
for(const x of [-.073,.073])
|
|
745
|
+
tube(shutter,[[x,-.248,.634],[x,-.06,.605],[x,.102,.494],[x,.223,.333],[x*.7,.306,.119]],.017,m.brass);
|
|
746
|
+
ball(dome,.069,.071,.069,m.brass,0,1.259,0);
|
|
747
|
+
between(dome,V(0,1.276,0),V(0,1.52,0),.017,m.brass);
|
|
748
|
+
ring(dome,.108,.016,m.brass,0,1.465,0).rotation.y=-.36;
|
|
749
|
+
ball(dome,.038,.043,.038,m.blueLamp,0,1.463,.006);
|
|
750
|
+
sign(crown,'望 星 小 城',1.16,.198,-.74,.303,.945).rotation.z=.024;
|
|
751
|
+
point(crown,'#ffcf9c',4.3,3.1,.23,.43,.26);
|
|
752
|
+
|
|
753
|
+
const scope=group(crown,1.14,.073,.46);
|
|
754
|
+
ao(scope,0,.006,0,.79,.67);
|
|
755
|
+
spool(scope,.219,.079,m.iron,0,.032,0);
|
|
756
|
+
spool(scope,.173,.063,m.brass,0,.085,0);
|
|
757
|
+
for(let i=0;i<3;i++){
|
|
758
|
+
const a=i*TAU/3+.52;
|
|
759
|
+
const x=sin(a),z=Math.cos(a);
|
|
760
|
+
beam(scope,V(x*.135,.511,z*.135),V(x*.31,.050,z*.31),.075,.088,m.darkBrass);
|
|
761
|
+
ball(scope,.066,.032,.059,m.brass,x*.31,.027,z*.31);
|
|
762
|
+
}
|
|
763
|
+
spool(scope,.13,.39,m.wood,0,.327,0);
|
|
764
|
+
spool(scope,.20,.079,m.brass,0,.543,0);
|
|
765
|
+
const yoke=group(scope,0,.626,0);
|
|
766
|
+
for(const x of [-.171,.171]){
|
|
767
|
+
block(yoke,.075,.257,.14,.029,m.darkBrass,x,-.015,0);
|
|
768
|
+
const knob=spool(yoke,.082,.060,m.brass,x*1.25,.064,0);
|
|
769
|
+
knob.rotation.z=Math.PI/2;
|
|
770
|
+
}
|
|
771
|
+
const optic=group(yoke,0,.066,0);
|
|
772
|
+
turn(optic,[[.082,-.37],[.102,-.32],[.115,-.24],[.123,.18],[.148,.27],[.153,.41]],m.blue,0,.015,0);
|
|
773
|
+
for(const [r,h,y] of [[.11,.047,-.305],[.127,.046,-.13],[.149,.071,.26],[.167,.059,.426]]){
|
|
774
|
+
// 这些圆环位于镜筒自身的轴上,不与露滴相接。
|
|
775
|
+
ring(optic,r,h*.27,m.brass,0,y,0).rotation.x=Math.PI/2;
|
|
776
|
+
}
|
|
777
|
+
const lensMat=new T.MeshPhysicalMaterial({
|
|
778
|
+
color:'#75b7c6',metalness:.19,roughness:.13,clearcoat:1,clearcoatRoughness:.07,
|
|
779
|
+
emissive:'#47727f',emissiveIntensity:.23
|
|
780
|
+
});
|
|
781
|
+
ball(optic,.139,.025,.139,lensMat,0,.431,0);
|
|
782
|
+
spool(optic,.074,.082,m.iron,0,-.406,0);
|
|
783
|
+
ball(optic,.055,.015,.055,lensMat,0,-.451,0);
|
|
784
|
+
const finder=group(optic,.122,.035,-.018);
|
|
785
|
+
spool(finder,.046,.39,m.darkBrass,0,0,0);
|
|
786
|
+
ball(finder,.041,.018,.041,lensMat,0,.197,0);
|
|
787
|
+
block(yoke,.25,.087,.165,.022,m.brass,0,-.11,0);
|
|
788
|
+
sign(scope,'测 星',.32,.13,0,.27,.153);
|
|
789
|
+
|
|
790
|
+
const skyStar=V(5.0,10.0,-7.0);
|
|
791
|
+
const scopePoint=V();
|
|
792
|
+
const aim=new T.Quaternion();
|
|
793
|
+
const inverseYoke=new T.Quaternion();
|
|
794
|
+
const direction=V();
|
|
795
|
+
let scopeLocked=false;
|
|
796
|
+
let scopeScan=0;
|
|
797
|
+
|
|
798
|
+
/* 修表廊:开放式钟壳下段可以看见摆锤;上段有可见发条鼓和擒纵轮。 */
|
|
799
|
+
const repair=group(gallery,-.53,galleryFloor,-.36);
|
|
800
|
+
ao(repair,0,.006,0,1.65,1.03,.9);
|
|
801
|
+
block(repair,1.32,.105,.62,.046,m.edge,0,.043,.014);
|
|
802
|
+
block(repair,1.17,.866,.415,.064,m.wood,0,.518,-.11);
|
|
803
|
+
block(repair,.95,.746,.062,.037,m.grotto,0,.512,.123);
|
|
804
|
+
for(const x of [-.532,.532]){
|
|
805
|
+
block(repair,.127,.831,.30,.043,m.darkBrass,x,.52,.145);
|
|
806
|
+
block(repair,.122,.110,.322,.035,m.trim,x,.165,.155);
|
|
807
|
+
}
|
|
808
|
+
block(repair,1.26,.105,.405,.045,m.edge,0,.908,.071);
|
|
809
|
+
disc(repair,.397,.181,m.wood,0,.963,.051);
|
|
810
|
+
disc(repair,.352,.122,m.darkBrass,0,.957,.167);
|
|
811
|
+
disc(repair,.303,.061,m.cream,0,.957,.244);
|
|
812
|
+
ring(repair,.317,.027,m.brass,0,.957,.27);
|
|
813
|
+
const dial=canvasTexture(384,384,(c,w,h)=>{
|
|
814
|
+
c.clearRect(0,0,w,h);
|
|
815
|
+
c.translate(w/2,h/2);
|
|
816
|
+
c.beginPath();c.arc(0,0,185,0,TAU);c.fillStyle='#f3dfc0';c.fill();
|
|
817
|
+
c.strokeStyle='#b89871';c.lineWidth=2;c.beginPath();c.arc(0,0,167,0,TAU);c.stroke();
|
|
818
|
+
for(let i=0;i<60;i++){
|
|
819
|
+
const a=i*TAU/60;
|
|
820
|
+
c.beginPath();c.moveTo(158*sin(a),-158*Math.cos(a));
|
|
821
|
+
const r=i%5===0?143:151;
|
|
822
|
+
c.lineTo(r*sin(a),-r*Math.cos(a));c.strokeStyle='#6c5150';c.lineWidth=i%5===0?4:1.5;c.stroke();
|
|
823
|
+
}
|
|
824
|
+
c.fillStyle='#493d48';c.textAlign='center';c.textBaseline='middle';
|
|
825
|
+
c.font='35px Georgia';
|
|
826
|
+
for(let i=1;i<=12;i++){const a=i*TAU/12;c.fillText(String(i),119*sin(a),-119*Math.cos(a));}
|
|
827
|
+
c.font='18px serif';c.fillText('发 条',0,69);
|
|
828
|
+
});
|
|
829
|
+
const dialFace=mesh(repair,new T.CircleGeometry(.293,56),new T.MeshBasicMaterial({map:dial}),0,.957,.278,false);
|
|
830
|
+
function hand(p,l,w,mat,z){
|
|
831
|
+
const a=group(p,0,.957,z);
|
|
832
|
+
block(a,w,l,.018,.007,mat,0,l*.40,0);
|
|
833
|
+
ball(a,w*.57,w*.87,.017,mat,0,l*.875,0);
|
|
834
|
+
return a;
|
|
835
|
+
}
|
|
836
|
+
const hourHand=hand(repair,.148,.037,m.ink,.288);
|
|
837
|
+
const minuteHand=hand(repair,.215,.023,m.ink,.308);
|
|
838
|
+
const secondsHand=hand(repair,.238,.015,m.rose,.326);
|
|
839
|
+
disc(repair,.036,.031,m.brass,0,.957,.348);
|
|
840
|
+
|
|
841
|
+
function gear(p,r,teeth,depth,mat){
|
|
842
|
+
const a=group(p);
|
|
843
|
+
disc(a,r*.83,depth,mat);
|
|
844
|
+
for(let i=0;i<teeth;i++){
|
|
845
|
+
const t=i*TAU/teeth;
|
|
846
|
+
block(a,r*.26,r*.27,depth,.008,mat,sin(t)*r*.88,Math.cos(t)*r*.88,0).rotation.z=-t;
|
|
847
|
+
}
|
|
848
|
+
ring(a,r*.67,r*.074,m.darkBrass,0,0,depth*.53);
|
|
849
|
+
disc(a,r*.25,depth*1.65,m.steel);
|
|
850
|
+
return a;
|
|
851
|
+
}
|
|
852
|
+
const escape=gear(repair,.109,13,.038,m.brass);
|
|
853
|
+
escape.position.set(.319,.637,.189);
|
|
854
|
+
const springDrum=gear(repair,.138,15,.038,m.darkBrass);
|
|
855
|
+
springDrum.position.set(-.313,.584,.184);
|
|
856
|
+
const coil=[];
|
|
857
|
+
for(let i=0;i<=66;i++){
|
|
858
|
+
const a=i/66*TAU*3.22, r=.019+i/66*.080;
|
|
859
|
+
coil.push([r*Math.cos(a),r*sin(a),.028]);
|
|
860
|
+
}
|
|
861
|
+
tube(springDrum,coil,.006,m.brass,67);
|
|
862
|
+
const pallet=group(repair,.295,.769,.211);
|
|
863
|
+
tube(pallet,[[-.074,-.087,0],[-.048,-.035,0],[0,0,0],[.066,-.032,0],[.08,-.078,0]],.012,m.steel,20);
|
|
864
|
+
disc(pallet,.025,.021,m.brass);
|
|
865
|
+
const pendulum=group(repair,0,.684,.194);
|
|
866
|
+
between(pendulum,V(),V(0,-.443,0),.020,m.darkBrass);
|
|
867
|
+
disc(pendulum,.128,.057,m.brass,0,-.421,.021);
|
|
868
|
+
ring(pendulum,.095,.011,m.darkBrass,0,-.421,.055);
|
|
869
|
+
disc(pendulum,.058,.014,m.darkBrass,0,-.421,.056);
|
|
870
|
+
const clockFeet=[[-.45,.05,.22],[.45,.05,.22],[-.43,.05,-.22],[.43,.05,-.22]];
|
|
871
|
+
clockFeet.forEach(([x,y,z])=>ball(repair,.078,.048,.068,m.brass,x,y,z));
|
|
872
|
+
sign(gallery,'钟表修理廊',1.16,.182,-.69,1.29,.04).rotation.z=-.033;
|
|
873
|
+
|
|
874
|
+
// 修理台上的零件与桌脚共用局部坐标。
|
|
875
|
+
const work=group(gallery,.93,galleryFloor,-.51);
|
|
876
|
+
ao(work,0,.008,0,1.11,.88);
|
|
877
|
+
for(const x of [-.40,.40])for(const z of [-.22,.22])block(work,.083,.43,.091,.025,m.edge,x,.211,z);
|
|
878
|
+
block(work,1.02,.105,.65,.038,m.trim,0,.46,0);
|
|
879
|
+
block(work,.84,.14,.063,.018,m.wood,0,.367,.283);
|
|
880
|
+
for(const x of [-.28,0,.28])disc(work,.028,.024,m.brass,x,.363,.327);
|
|
881
|
+
const tray=group(work,.15,.524,.065);tray.rotation.y=.12;
|
|
882
|
+
block(tray,.54,.053,.33,.022,m.grotto,0,.019,0);
|
|
883
|
+
for(const x of [-.254,.254])block(tray,.037,.065,.32,.015,m.trim,x,.047,0);
|
|
884
|
+
for(const z of [-.152,.152])block(tray,.53,.065,.037,.015,m.trim,0,.047,z);
|
|
885
|
+
for(let i=0;i<7;i++){
|
|
886
|
+
const x=range(-.21,.21),z=range(-.109,.108);
|
|
887
|
+
if(i<3){
|
|
888
|
+
const o=gear(tray,.039,8,.016,m.brass);
|
|
889
|
+
o.position.set(x,.054,z);o.rotation.x=-Math.PI/2;o.rotation.z=range(0,TAU);
|
|
890
|
+
}else{
|
|
891
|
+
spool(tray,.022,.020,m.steel,x,.052,z);
|
|
892
|
+
block(tray,.024,.005,.008,.001,m.ink,x,.064,z).rotation.y=range(0,TAU);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
const screwdriver=group(work,-.27,.546,.117);
|
|
896
|
+
screwdriver.rotation.y=-.56;
|
|
897
|
+
between(screwdriver,V(-.14,.015,0),V(-.005,.015,0),.024,m.rose);
|
|
898
|
+
between(screwdriver,V(-.018,.015,0),V(.125,.015,0),.010,m.steel);
|
|
899
|
+
lantern(work,.385,.516,-.18,.66);
|
|
900
|
+
sign(work,'慢 一 拍',.39,.135,.28,.19,.312).rotation.z=.092;
|
|
901
|
+
|
|
902
|
+
/* 工具升降井:两导轨限定托篮,绳长随托篮更新,钟表没有引用任何井筒状态。 */
|
|
903
|
+
const shaft=group(root,1.65,2.24,2.30);
|
|
904
|
+
const lowStop=.17, highStop=1.64;
|
|
905
|
+
block(shaft,.83,.092,.61,.031,m.edge,0,.05,.09);
|
|
906
|
+
block(shaft,.98,.107,.68,.032,m.edge,.13,1.60,.048);
|
|
907
|
+
block(shaft,.60,.095,.91,.03,m.wood,.58,1.60,-.23);
|
|
908
|
+
beam(shaft,V(.80,1.60,.43),V(.55,1.13,-.19),.09,.102,m.edge);
|
|
909
|
+
for(const x of [-.253,.253]){
|
|
910
|
+
between(shaft,V(x,.074,.17),V(x,1.99,.17),.030,m.steel);
|
|
911
|
+
between(shaft,V(x,.07,-.056),V(x,2.10,-.056),.035,m.iron);
|
|
912
|
+
for(const y of [.22,.70,1.20,1.71]){
|
|
913
|
+
beam(shaft,V(x,y,.22),V(x,y,-.31),.064,.072,m.darkBrass);
|
|
914
|
+
ball(shaft,.045,.049,.043,m.brass,x,y,.191);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
block(shaft,.69,.093,.32,.027,m.iron,0,2.085,.046);
|
|
918
|
+
const axle=group(shaft,0,1.994,.089);
|
|
919
|
+
axle.rotation.z=-Math.PI/2;
|
|
920
|
+
spool(axle,.108,.39,m.darkBrass);
|
|
921
|
+
spool(axle,.124,.046,m.brass,0,-.197,0);
|
|
922
|
+
spool(axle,.124,.046,m.brass,0,.197,0);
|
|
923
|
+
for(let i=0;i<8;i++)ring(axle,.102,.010,m.rope,0,-.13+i*.037,0).rotation.x=Math.PI/2;
|
|
924
|
+
const crank=group(shaft,.345,1.994,.089);
|
|
925
|
+
between(crank,V(-.163,0,0),V(.07,0,0),.035,m.steel);
|
|
926
|
+
beam(crank,V(.045,0,0),V(.045,.162,.065),.051,.057,m.darkBrass);
|
|
927
|
+
between(crank,V(.044,.162,.065),V(.165,.162,.065),.035,m.wood);
|
|
928
|
+
ball(crank,.033,.036,.036,m.brass,.17,.162,.065);
|
|
929
|
+
const crankHit=ball(shaft,.25,.25,.20,new T.MeshBasicMaterial({visible:false}),.35,2.01,.09,false);
|
|
930
|
+
|
|
931
|
+
const basket=group(shaft,0,lowStop,.162);
|
|
932
|
+
block(basket,.415,.071,.36,.025,m.darkBrass,0,.00,0);
|
|
933
|
+
block(basket,.354,.044,.304,.020,m.wood,0,.041,0);
|
|
934
|
+
for(const x of [-.197,.197]){
|
|
935
|
+
block(basket,.051,.174,.342,.018,m.wood,x,.10,0);
|
|
936
|
+
block(basket,.058,.095,.11,.016,m.steel,x*1.24,.094,0);
|
|
937
|
+
}
|
|
938
|
+
for(const z of [-.158,.158])block(basket,.39,.142,.050,.018,m.wood,0,.092,z);
|
|
939
|
+
for(const x of [-.145,.145]){
|
|
940
|
+
between(basket,V(x,.17,.016),V(0,.366,-.017),.015,m.rope);
|
|
941
|
+
disc(basket,.022,.012,m.brass,x,.103,.188);
|
|
942
|
+
}
|
|
943
|
+
const parcel=block(basket,.181,.097,.149,.024,m.cream,-.052,.088,-.023);
|
|
944
|
+
parcel.rotation.y=.21;
|
|
945
|
+
block(parcel,.033,.101,.150,.006,m.rose,0,.002,0);
|
|
946
|
+
between(basket,V(.06,.074,-.068),V(.136,.084,.101),.021,m.steel);
|
|
947
|
+
const liftLine=mesh(shaft,ballGeo,m.rope,0,1,.145,false);
|
|
948
|
+
function updateLine(y){
|
|
949
|
+
const top=1.970,bottom=y+.361;
|
|
950
|
+
liftLine.position.y=(top+bottom)*.5;
|
|
951
|
+
liftLine.scale.set(.013,Math.max(.008,(top-bottom)*.5+.012),.013);
|
|
952
|
+
}
|
|
953
|
+
updateLine(lowStop);
|
|
954
|
+
sign(shaft,'器材',.39,.16,0,2.151,.265).rotation.z=.033;
|
|
955
|
+
const lift={x:lowStop,v:0,target:lowStop,previous:lowStop,angle:0,moving:false};
|
|
956
|
+
|
|
957
|
+
/* 观云台:湿度表、手写纸页和一只来记读数的雪貂。 */
|
|
958
|
+
const bench=group(terrace,-.28,.061,-.50);
|
|
959
|
+
ao(bench,0,.012,0,1.51,.87,.83);
|
|
960
|
+
for(const x of [-.49,.49])for(const z of [-.208,.208])
|
|
961
|
+
block(bench,.082,.39,.086,.021,m.darkBrass,x,.19,z);
|
|
962
|
+
block(bench,1.20,.10,.63,.038,m.wood,0,.416,0);
|
|
963
|
+
block(bench,1.12,.075,.10,.022,m.trim,0,.389,.273);
|
|
964
|
+
const gauge=group(bench,.327,.545,-.079);
|
|
965
|
+
gauge.rotation.x=-.155;gauge.rotation.y=-.24;
|
|
966
|
+
block(gauge,.42,.175,.22,.033,m.wood,0,-.027,-.022);
|
|
967
|
+
disc(gauge,.209,.090,m.darkBrass,0,.138,0);
|
|
968
|
+
disc(gauge,.176,.043,m.cream,0,.138,.056);
|
|
969
|
+
ring(gauge,.185,.017,m.brass,0,.138,.076);
|
|
970
|
+
const humidFace=canvasTexture(256,256,(c,w,h)=>{
|
|
971
|
+
c.fillStyle='#efe1c8';c.fillRect(0,0,w,h);
|
|
972
|
+
c.translate(w/2,h*.52);
|
|
973
|
+
for(let i=0;i<=20;i++){
|
|
974
|
+
const a=lerp(-2.25,2.25,i/20);
|
|
975
|
+
const r=i%5===0?73:85;
|
|
976
|
+
c.beginPath();c.moveTo(sin(a)*98,-Math.cos(a)*98);
|
|
977
|
+
c.lineTo(sin(a)*r,-Math.cos(a)*r);
|
|
978
|
+
c.strokeStyle=i>=14?'#688c8c':'#805b59';c.lineWidth=i%5===0?5:2;c.stroke();
|
|
979
|
+
}
|
|
980
|
+
c.fillStyle='#584657';c.font='37px serif';c.textAlign='center';c.fillText('% RH',0,68);
|
|
981
|
+
});
|
|
982
|
+
mesh(gauge,new T.CircleGeometry(.168,40),new T.MeshBasicMaterial({map:humidFace}),0,.138,.081,false);
|
|
983
|
+
const needle=group(gauge,0,.138,.087);
|
|
984
|
+
block(needle,.020,.145,.014,.004,m.rose,0,.049,0);
|
|
985
|
+
disc(gauge,.025,.021,m.brass,0,.138,.101);
|
|
986
|
+
|
|
987
|
+
function sheetMap(title,lines,damp=false){
|
|
988
|
+
return canvasTexture(384,248,(c,w,h)=>{
|
|
989
|
+
c.fillStyle='#f0e0c2';c.fillRect(0,0,w,h);
|
|
990
|
+
if(damp){
|
|
991
|
+
const g=c.createRadialGradient(359,217,3,359,217,156);
|
|
992
|
+
g.addColorStop(0,'#6d9d9e9c');g.addColorStop(.47,'#91aaa38a');g.addColorStop(1,'#91aaa300');
|
|
993
|
+
c.fillStyle=g;c.fillRect(0,0,w,h);
|
|
994
|
+
}
|
|
995
|
+
c.strokeStyle='#a792854b';c.lineWidth=2;
|
|
996
|
+
for(let y=92;y<h;y+=34){c.beginPath();c.moveTo(26,y);c.lineTo(w-26,y);c.stroke();}
|
|
997
|
+
c.fillStyle='#4a5063';c.font='45px serif';c.fillText(title,28,65);
|
|
998
|
+
c.font='29px serif';
|
|
999
|
+
lines.forEach((s,i)=>{
|
|
1000
|
+
c.save();c.translate(31+i*4,118+i*34);c.rotate(i%2?.016:-.023);c.fillText(s,0,0);c.restore();
|
|
1001
|
+
});
|
|
1002
|
+
c.fillStyle='#776083';c.globalAlpha=.39;c.beginPath();c.ellipse(w-39,h-35,5,9,.4,0,TAU);c.fill();
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
const log=group(bench,-.206,.475,.022);
|
|
1006
|
+
log.rotation.y=-.21;
|
|
1007
|
+
block(log,.51,.036,.36,.016,m.wine);
|
|
1008
|
+
block(log,.476,.024,.33,.011,m.paper,0,.022,0);
|
|
1009
|
+
const logFace=mesh(log,planeGeo,new T.MeshBasicMaterial({map:sheetMap('夜班簿',['云底渐低','RH 87%'])}),0,.035,0,false);
|
|
1010
|
+
logFace.rotation.x=-Math.PI/2;logFace.scale.set(.456,.314,1);
|
|
1011
|
+
const pencil=group(log,-.18,.055,.083);pencil.rotation.y=.52;
|
|
1012
|
+
between(pencil,V(-.14,0,0),V(.126,0,0),.014,m.rose);
|
|
1013
|
+
turn(pencil,[[0,-.031],[.007,-.026],[.016,.025],[.014,.033]],m.trim,.157,0,0,20).rotation.z=Math.PI/2;
|
|
1014
|
+
ball(pencil,.012,.010,.010,m.ink,.187,0,0);
|
|
1015
|
+
|
|
1016
|
+
function cup(p,x,y,z,mat){
|
|
1017
|
+
const a=group(p,x,y,z);
|
|
1018
|
+
turn(a,[[0,-.069],[.050,-.069],[.072,-.055],[.087,.032],[.084,.070],[.073,.071],[.069,.055],[.059,-.037],[0,-.046]],mat,0,.070,0,30);
|
|
1019
|
+
spool(a,.067,.012,standard('#9c786b',{roughness:.6}),0,.099,0);
|
|
1020
|
+
ring(a,.047,.012,mat,.094,.078,0);
|
|
1021
|
+
return a;
|
|
1022
|
+
}
|
|
1023
|
+
cup(bench,-.476,.469,-.169,m.pool).rotation.y=-.19;
|
|
1024
|
+
cup(work,-.35,.519,-.165,m.lilac).rotation.y=.68;
|
|
1025
|
+
|
|
1026
|
+
// 纸页上角探进甘露轮廓,外侧是潮痕,不另加悬空夹子。
|
|
1027
|
+
const wetNote=group(root,1.02,4.32,.21);
|
|
1028
|
+
wetNote.rotation.set(-.11,-.57,-.39);
|
|
1029
|
+
const wetCanvas=sheetMap('云 台',['RH 87%','露珠夹一下'],true);
|
|
1030
|
+
const paperG=new T.PlaneGeometry(.565,.364,20,12);
|
|
1031
|
+
const paperA=paperG.attributes.position;
|
|
1032
|
+
const paperRest=[];
|
|
1033
|
+
for(let i=0;i<paperA.count;i++){
|
|
1034
|
+
const x=paperA.getX(i),y=paperA.getY(i);
|
|
1035
|
+
const curl=.106*Math.pow((x+.2825)/.565,2)+.018*sin(y*16+x*11);
|
|
1036
|
+
paperA.setZ(i,curl);
|
|
1037
|
+
paperRest.push(curl);
|
|
1038
|
+
}
|
|
1039
|
+
paperG.computeVertexNormals();
|
|
1040
|
+
mesh(wetNote,paperG,new T.MeshStandardMaterial({
|
|
1041
|
+
map:wetCanvas,side:T.DoubleSide,roughness:.78
|
|
1042
|
+
}),0,0,0,false);
|
|
1043
|
+
ball(wetNote,.032,.016,.029,dropGlass,-.225,.146,.028,false);
|
|
1044
|
+
|
|
1045
|
+
/* 角色的根节点落在接触面,呼吸发生在其子节点,脚不会随呼吸升空。 */
|
|
1046
|
+
const actors=[];
|
|
1047
|
+
function eye(p,x,y,z,s=.037){
|
|
1048
|
+
ball(p,s,s*1.20,s*.57,m.ink,x,y,z);
|
|
1049
|
+
ball(p,s*.32,s*.32,s*.26,m.milk,x-.009,y+.013,z+s*.49,false);
|
|
1050
|
+
}
|
|
1051
|
+
function cheeks(p,x,y,z,s=.053){
|
|
1052
|
+
ball(p,s,s*.55,s*.27,m.pink,x,y,z,false);
|
|
1053
|
+
}
|
|
1054
|
+
function actor(p,x,y,z,yaw,phase,size=1){
|
|
1055
|
+
const a=group(p,x,y-.012,z);
|
|
1056
|
+
a.rotation.y=yaw;
|
|
1057
|
+
a.scale.setScalar(size);
|
|
1058
|
+
ao(a,0,.015,.029,.98,.63,.82);
|
|
1059
|
+
const body=group(a);
|
|
1060
|
+
actors.push({body,phase});
|
|
1061
|
+
return [a,body];
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
const [rabbit,rb]=actor(crown,.49,.085,.76,-.74,0,.86);
|
|
1065
|
+
for(const x of [-.149,.149])ball(rabbit,.121,.088,.175,m.milk,x,.066,.122);
|
|
1066
|
+
ball(rb,.247,.286,.216,m.milk,0,.277,0);
|
|
1067
|
+
ball(rb,.163,.188,.079,m.cream,0,.236,.176);
|
|
1068
|
+
ball(rb,.113,.112,.110,m.cream,.033,.197,-.216);
|
|
1069
|
+
const rHead=group(rb,0,.565,.033);
|
|
1070
|
+
ball(rHead,.276,.224,.218,m.milk);
|
|
1071
|
+
for(const x of [-.102,.102])eye(rHead,x,.026,.197,.036);
|
|
1072
|
+
for(const x of [-.162,.162])cheeks(rHead,x,-.051,.177);
|
|
1073
|
+
ball(rHead,.040,.026,.026,m.rose,0,-.035,.220);
|
|
1074
|
+
tube(rHead,[[-.063,-.080,.207],[-.029,-.093,.216],[0,-.066,.225],[.028,-.093,.216],[.058,-.079,.207]],.007,m.wine,17);
|
|
1075
|
+
const ears=[];
|
|
1076
|
+
for(const s of [-1,1]){
|
|
1077
|
+
const a=group(rHead,s*.148,.155,-.032);
|
|
1078
|
+
ball(a,.088,.243,.083,m.milk,0,.185,0);
|
|
1079
|
+
ball(a,.049,.171,.035,m.pink,0,.197,.061);
|
|
1080
|
+
ears.push(a);
|
|
1081
|
+
}
|
|
1082
|
+
ball(rb,.101,.119,.080,m.milk,-.189,.32,.154).rotation.z=-.42;
|
|
1083
|
+
ball(rb,.105,.115,.081,m.milk,.175,.36,.173).rotation.z=.50;
|
|
1084
|
+
turn(rb,[[.168,-.048],[.216,-.035],[.226,.005],[.208,.043],[.183,.047]],m.lilac,0,.426,.014);
|
|
1085
|
+
block(rb,.101,.191,.036,.012,m.lilac,.152,.328,.199).rotation.z=.21;
|
|
1086
|
+
|
|
1087
|
+
const [puffin,pb]=actor(gallery,.235,galleryFloor,.394,-.86,2.4,.76);
|
|
1088
|
+
for(const x of [-.141,.141]){
|
|
1089
|
+
ball(puffin,.111,.062,.153,m.rose,x,.052,.13);
|
|
1090
|
+
for(let i=0;i<3;i++)ball(puffin,.039,.034,.057,m.dimAmber,x+(i-1)*.047,.045,.23,false);
|
|
1091
|
+
}
|
|
1092
|
+
ball(pb,.268,.320,.233,m.ink,0,.298,0);
|
|
1093
|
+
ball(pb,.195,.239,.105,m.milk,0,.275,.166);
|
|
1094
|
+
const puffHead=group(pb,0,.588,.034);
|
|
1095
|
+
ball(puffHead,.261,.225,.217,m.ink);
|
|
1096
|
+
for(const x of [-.109,.109]){
|
|
1097
|
+
const a=ball(puffHead,.115,.156,.093,m.cream,x,-.033,.143);
|
|
1098
|
+
a.rotation.z=x*.9;
|
|
1099
|
+
eye(puffHead,x,.021,.226,.027);
|
|
1100
|
+
}
|
|
1101
|
+
const beak=group(puffHead,0,-.052,.218);
|
|
1102
|
+
ball(beak,.104,.073,.111,m.rose,0,0,.051);
|
|
1103
|
+
ball(beak,.084,.047,.110,m.dimAmber,0,.025,.047);
|
|
1104
|
+
ball(beak,.035,.045,.060,m.lilac,0,.004,.003);
|
|
1105
|
+
const folded=ball(pb,.094,.182,.106,m.blue,.213,.293,-.03);
|
|
1106
|
+
folded.rotation.z=.24;
|
|
1107
|
+
const wipe=group(pb,-.187,.351,.066);
|
|
1108
|
+
ball(wipe,.097,.165,.090,m.ink,-.022,.020,.057).rotation.z=-.43;
|
|
1109
|
+
block(wipe,.205,.173,.054,.022,m.canvas,-.079,.159,.137).rotation.z=-.31;
|
|
1110
|
+
for(let j=0;j<4;j++)block(wipe,.014,.095,.014,.004,m.paper,-.14+j*.040,.167,.170).rotation.z=-.31;
|
|
1111
|
+
|
|
1112
|
+
const [ferret,fb]=actor(terrace,-.25,.071,.456,2.99,4.2,.86);
|
|
1113
|
+
const fur=glaze('#bc9479');
|
|
1114
|
+
const furDark=glaze('#7a5867');
|
|
1115
|
+
for(const x of [-.122,.122])ball(ferret,.089,.058,.115,furDark,x,.048,.096);
|
|
1116
|
+
ball(fb,.195,.330,.170,fur,0,.278,0).rotation.x=-.12;
|
|
1117
|
+
ball(fb,.141,.239,.096,m.cream,0,.273,.083);
|
|
1118
|
+
const fHead=group(fb,.012,.593,.055);
|
|
1119
|
+
ball(fHead,.214,.167,.178,fur,0,0,0);
|
|
1120
|
+
for(const s of [-1,1]){
|
|
1121
|
+
ball(fHead,.076,.085,.059,furDark,s*.153,.11,-.047);
|
|
1122
|
+
ball(fHead,.047,.054,.023,m.pink,s*.153,.11,.002);
|
|
1123
|
+
const mask=ball(fHead,.094,.054,.055,furDark,s*.083,.002,.144);
|
|
1124
|
+
mask.rotation.z=s*.22;
|
|
1125
|
+
eye(fHead,s*.086,.015,.189,.027);
|
|
1126
|
+
cheeks(fHead,s*.125,-.050,.167,.037);
|
|
1127
|
+
}
|
|
1128
|
+
ball(fHead,.105,.079,.078,m.cream,0,-.055,.139);
|
|
1129
|
+
ball(fHead,.038,.025,.026,furDark,0,-.029,.210);
|
|
1130
|
+
const tail=group(ferret,0,.104,-.10);
|
|
1131
|
+
tube(tail,[[0,0,0],[.095,-.017,-.15],[.31,-.021,-.231],[.46,.015,-.17],[.48,.03,-.098]],.059,fur,31);
|
|
1132
|
+
ball(tail,.059,.057,.070,furDark,.484,.026,-.108);
|
|
1133
|
+
const writes=group(fb,-.115,.311,.098);
|
|
1134
|
+
ball(writes,.073,.131,.072,fur,-.018,.056,.103).rotation.z=-.24;
|
|
1135
|
+
ball(fb,.076,.109,.071,fur,.127,.355,.152).rotation.z=.31;
|
|
1136
|
+
between(writes,V(-.079,.147,.146),V(-.129,.350,.185),.015,m.rose);
|
|
1137
|
+
|
|
1138
|
+
/* 吸湿植物、标记钉和碎石只在实面上生长。 */
|
|
1139
|
+
const sway=[];
|
|
1140
|
+
function sprig(p,x,y,z,s){
|
|
1141
|
+
const a=group(p,x,y-.014,z);
|
|
1142
|
+
a.scale.setScalar(s);
|
|
1143
|
+
const stems=2+Math.floor(rand()*3);
|
|
1144
|
+
ao(a,0,.016,0,.42,.36,.46);
|
|
1145
|
+
for(let j=0;j<stems;j++){
|
|
1146
|
+
const q=j*TAU/stems+range(-.45,.45);
|
|
1147
|
+
const h=range(.14,.32), u=sin(q)*.11,v=Math.cos(q)*.11;
|
|
1148
|
+
tube(a,[[0,0,0],[u*.22,h*.24,v*.28],[u*.73,h*.68,v*.73],[u,h,v]],.011,m.moss,13);
|
|
1149
|
+
const leaf=ball(a,.036,.083,.022,j%2?m.mint:m.mossLight,u,h,v);
|
|
1150
|
+
leaf.rotation.set(v*3.7,0,-u*4.2);
|
|
1151
|
+
if(j===1)ball(a,.035,.031,.034,pick([m.rose,m.lilac,m.cream]),u,h+.057,v);
|
|
1152
|
+
}
|
|
1153
|
+
sway.push([a,range(-.8,.8)+x*.73+z*.35]);
|
|
1154
|
+
}
|
|
1155
|
+
for(const [x,z] of [[-4.04,1.01],[-3.41,2.62],[-2.97,2.68],[-2.34,-2.64],[2.24,-2.71],[3.48,-2.26],[3.91,-1.42],[3.97,2.69]])sprig(base,x,.618,z,range(.69,1.2));
|
|
1156
|
+
for(const [p,x,y,z,s] of [[crown,1.37,.067,-.86,.74],[crown,-1.52,.068,-.78,.63],[terrace,1.02,.072,.77,.92],[terrace,1.03,.073,-.66,.61]])sprig(p,x,y,z,s);
|
|
1157
|
+
for(const [x,y,z] of [[-3.54,1.47,1.61],[-3.43,1.58,1.69],[2.82,1.78,2.57],[2.65,1.79,2.59],[3.53,3.51,-.37]]){
|
|
1158
|
+
const a=group(root,x,y,z);
|
|
1159
|
+
a.rotation.z=range(-.32,.32);
|
|
1160
|
+
spool(a,.026,.13,m.cream,0,.057,0);
|
|
1161
|
+
ball(a,.087,.047,.073,m.lilac,0,.126,0);
|
|
1162
|
+
for(let j=0;j<3;j++)ball(a,.012,.007,.012,m.cream,range(-.049,.049),.164,range(-.04,.04),false);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
const cloudMat=standard('#afb6d0',{roughness:1});
|
|
1166
|
+
const cloudShade=standard('#9a9ebd',{roughness:.96});
|
|
1167
|
+
const clouds=[];
|
|
1168
|
+
function cloud(x,y,z,s){
|
|
1169
|
+
const a=group(scene,x,y,z);
|
|
1170
|
+
a.scale.setScalar(s);
|
|
1171
|
+
const shapes=[
|
|
1172
|
+
[-.69,-.047,0,.55,.215,.35],[-.29,.091,-.041,.55,.306,.39],
|
|
1173
|
+
[.12,.154,-.065,.51,.346,.42],[.47,.028,.006,.53,.25,.37],
|
|
1174
|
+
[.88,-.085,.034,.45,.17,.29],[.03,-.100,.21,.74,.18,.32]
|
|
1175
|
+
];
|
|
1176
|
+
shapes.forEach(([x,y,z,sx,sy,sz],i)=>ball(a,sx,sy,sz,i<4?cloudMat:cloudShade,x,y,z,false));
|
|
1177
|
+
clouds.push({a,x,y,z,s,phase:range(0,TAU)});
|
|
1178
|
+
}
|
|
1179
|
+
cloud(5.42,4.18,-1.9,.74);
|
|
1180
|
+
cloud(5.65,3.27,-.35,.47);
|
|
1181
|
+
cloud(-5.27,4.78,-2.1,.57);
|
|
1182
|
+
cloud(-3.7,7.85,-4.65,.55);
|
|
1183
|
+
cloud(3.59,6.0,-4.9,.36);
|
|
1184
|
+
|
|
1185
|
+
function points(p,coords,colors,mat){
|
|
1186
|
+
const g=new T.BufferGeometry();
|
|
1187
|
+
g.setAttribute('position',new T.Float32BufferAttribute(coords,3));
|
|
1188
|
+
g.setAttribute('color',new T.Float32BufferAttribute(colors,3));
|
|
1189
|
+
const a=new T.Points(g,mat);p.add(a);return a;
|
|
1190
|
+
}
|
|
1191
|
+
const skyMat=new T.PointsMaterial({
|
|
1192
|
+
size:.123,map:starMap,transparent:true,depthWrite:false,vertexColors:true,
|
|
1193
|
+
blending:T.AdditiveBlending,opacity:.73,fog:false
|
|
1194
|
+
});
|
|
1195
|
+
const st=[],stc=[];
|
|
1196
|
+
for(let i=0;i<510;i++){
|
|
1197
|
+
const r=range(26,43), a=range(0,TAU), y=range(1.0,27);
|
|
1198
|
+
st.push(Math.cos(a)*r,y,sin(a)*r);
|
|
1199
|
+
const c=new T.Color(pick(['#abc0dc','#f1cfa7','#cbbae2','#7787ad'])).multiplyScalar(range(.5,1));
|
|
1200
|
+
stc.push(c.r,c.g,c.b);
|
|
1201
|
+
}
|
|
1202
|
+
points(scene,st,stc,skyMat);
|
|
1203
|
+
function sprite(p,color,size,x,y,z,opacity){
|
|
1204
|
+
const a=new T.Sprite(new T.SpriteMaterial({
|
|
1205
|
+
map:starMap,color,transparent:true,opacity,depthWrite:false,fog:false,
|
|
1206
|
+
blending:T.AdditiveBlending
|
|
1207
|
+
}));
|
|
1208
|
+
a.position.set(x,y,z);a.scale.set(size,size,1);p.add(a);return a;
|
|
1209
|
+
}
|
|
1210
|
+
const targetStar=sprite(scene,'#ffdfa8',.36,...skyStar.toArray(),.96);
|
|
1211
|
+
for(const [x,y,z,s] of [
|
|
1212
|
+
[-7.9,7.4,-9,.23],[-7.2,8.04,-9,.27],[-6.1,7.82,-9,.20],[-5.5,8.36,-9,.22],
|
|
1213
|
+
[3.8,8.96,-8.2,.16],[4.3,9.45,-7.9,.17],[7.7,9.6,-8.6,.24]
|
|
1214
|
+
])sprite(scene,'#e4d8ff',s,x,y,z,.77);
|
|
1215
|
+
const flies=[];
|
|
1216
|
+
for(let i=0;i<31;i++){
|
|
1217
|
+
const a=range(0,TAU),r=range(3.3,5.2),y=range(.8,5.5);
|
|
1218
|
+
const o=sprite(scene,i%4===0?'#ffdca2':'#9cdada',range(.052,.138),Math.cos(a)*r,y,sin(a)*r,.48);
|
|
1219
|
+
flies.push({o,a,r,y,phase:range(0,TAU),speed:range(.12,.38)});
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/* 手写长焦轨道。画面上下的浅失焦在渲染目标上完成,不用任何后处理插件。 */
|
|
1223
|
+
const camera=new T.PerspectiveCamera(31,1,.15,125);
|
|
1224
|
+
camera.filmOffset=.19;
|
|
1225
|
+
const subject=new T.Box3().setFromObject(root);
|
|
1226
|
+
const center=subject.getCenter(V());
|
|
1227
|
+
center.y+=.18;
|
|
1228
|
+
const size=subject.getSize(V());
|
|
1229
|
+
const defaultPose={theta:.39,phi:1.134};
|
|
1230
|
+
const orbit={theta:defaultPose.theta,phi:defaultPose.phi,dist:26};
|
|
1231
|
+
const want={...orbit};
|
|
1232
|
+
let baseDistance=26;
|
|
1233
|
+
let zoomFactor=1;
|
|
1234
|
+
let userMoved=false;
|
|
1235
|
+
const reduced=matchMedia('(prefers-reduced-motion: reduce)');
|
|
1236
|
+
const canvas=renderer.domElement;
|
|
1237
|
+
const pixel=V();
|
|
1238
|
+
const pointer=new T.Vector2();
|
|
1239
|
+
const ray=new T.Raycaster();
|
|
1240
|
+
const pointers=new Map();
|
|
1241
|
+
let tap=null;
|
|
1242
|
+
let pinch=0;
|
|
1243
|
+
|
|
1244
|
+
const useFocus=renderer.capabilities.isWebGL2 && renderer.extensions.has('EXT_color_buffer_float');
|
|
1245
|
+
let targetRT,post,postCamera,postMat;
|
|
1246
|
+
if(useFocus){
|
|
1247
|
+
targetRT=new T.WebGLRenderTarget(1,1,{
|
|
1248
|
+
type:T.HalfFloatType,minFilter:T.LinearFilter,magFilter:T.LinearFilter,depthBuffer:true,samples:2
|
|
1249
|
+
});
|
|
1250
|
+
targetRT.depthTexture=new T.DepthTexture(1,1,T.UnsignedIntType);
|
|
1251
|
+
post=new T.Scene();
|
|
1252
|
+
postCamera=new T.OrthographicCamera(-1,1,1,-1,0,1);
|
|
1253
|
+
postMat=new T.ShaderMaterial({
|
|
1254
|
+
uniforms:{
|
|
1255
|
+
img:{value:targetRT.texture},dep:{value:targetRT.depthTexture},
|
|
1256
|
+
px:{value:new T.Vector2()},nearF:{value:camera.near},farF:{value:camera.far},focus:{value:25}
|
|
1257
|
+
},
|
|
1258
|
+
depthTest:false,depthWrite:false,
|
|
1259
|
+
toneMapped:true,
|
|
1260
|
+
vertexShader:`
|
|
1261
|
+
varying vec2 vUv;
|
|
1262
|
+
void main(){vUv=uv;gl_Position=vec4(position.xy*2.,0.,1.);}
|
|
1263
|
+
`,
|
|
1264
|
+
fragmentShader:`
|
|
1265
|
+
uniform sampler2D img,dep;
|
|
1266
|
+
uniform vec2 px;
|
|
1267
|
+
uniform float nearF,farF,focus;
|
|
1268
|
+
varying vec2 vUv;
|
|
1269
|
+
void main(){
|
|
1270
|
+
float d=texture2D(dep,vUv).r;
|
|
1271
|
+
float z=(nearF*farF)/(farF-d*(farF-nearF));
|
|
1272
|
+
float line=abs(vUv.y-.51+.104*(vUv.x-.5));
|
|
1273
|
+
float edge=smoothstep(.22,.48,line);
|
|
1274
|
+
float depthFactor=smoothstep(1.5,8.0,abs(z-focus));
|
|
1275
|
+
vec2 o=px*(.18+edge*(1.38+1.75*depthFactor));
|
|
1276
|
+
vec3 c=texture2D(img,vUv).rgb*.39;
|
|
1277
|
+
c+=(texture2D(img,vUv+vec2(o.x,0.)).rgb+texture2D(img,vUv-vec2(o.x,0.)).rgb)*.125;
|
|
1278
|
+
c+=(texture2D(img,vUv+vec2(0.,o.y)).rgb+texture2D(img,vUv-vec2(0.,o.y)).rgb)*.125;
|
|
1279
|
+
c+=(texture2D(img,vUv+o*.71).rgb+texture2D(img,vUv-o*.71).rgb)*.055;
|
|
1280
|
+
float vignette=smoothstep(.26,.71,length((vUv-.5)*vec2(.89,1.)));
|
|
1281
|
+
gl_FragColor=vec4(c*(1.-vignette*.22),1.);
|
|
1282
|
+
#include <tonemapping_fragment>
|
|
1283
|
+
#include <colorspace_fragment>
|
|
1284
|
+
}
|
|
1285
|
+
`
|
|
1286
|
+
});
|
|
1287
|
+
const plane=new T.Mesh(planeGeo,postMat);
|
|
1288
|
+
plane.frustumCulled=false;post.add(plane);
|
|
1289
|
+
}
|
|
1290
|
+
function fitDistance(){
|
|
1291
|
+
const vertical=Math.tan(camera.fov*Math.PI/360);
|
|
1292
|
+
const horizontal=vertical*camera.aspect;
|
|
1293
|
+
const view=V(
|
|
1294
|
+
sin(defaultPose.theta)*sin(defaultPose.phi),Math.cos(defaultPose.phi),
|
|
1295
|
+
Math.cos(defaultPose.theta)*sin(defaultPose.phi)
|
|
1296
|
+
);
|
|
1297
|
+
const right=V().crossVectors(up,view).normalize();
|
|
1298
|
+
const viewUp=V().crossVectors(view,right).normalize();
|
|
1299
|
+
let distance=0;
|
|
1300
|
+
for(const x of [subject.min.x,subject.max.x])for(const y of [subject.min.y,subject.max.y])
|
|
1301
|
+
for(const z of [subject.min.z,subject.max.z]){
|
|
1302
|
+
const v=V(x,y,z).sub(center);
|
|
1303
|
+
const h=Math.abs(v.dot(right))/(horizontal*.93);
|
|
1304
|
+
const w=Math.abs(v.dot(viewUp))/(vertical*.92);
|
|
1305
|
+
distance=Math.max(distance,Math.max(h,w)+v.dot(view));
|
|
1306
|
+
}
|
|
1307
|
+
return Math.max(17,distance*.99);
|
|
1308
|
+
}
|
|
1309
|
+
function resize(){
|
|
1310
|
+
const w=window.innerWidth,h=window.innerHeight;
|
|
1311
|
+
renderer.setPixelRatio(Math.min(devicePixelRatio,w<750?1.45:1.8));
|
|
1312
|
+
renderer.setSize(w,h);
|
|
1313
|
+
camera.aspect=w/h;
|
|
1314
|
+
camera.updateProjectionMatrix();
|
|
1315
|
+
baseDistance=fitDistance();
|
|
1316
|
+
want.dist=baseDistance*zoomFactor;
|
|
1317
|
+
if(!userMoved)orbit.dist=want.dist;
|
|
1318
|
+
if(useFocus){
|
|
1319
|
+
const p=renderer.getDrawingBufferSize(new T.Vector2());
|
|
1320
|
+
targetRT.setSize(p.x,p.y);
|
|
1321
|
+
postMat.uniforms.px.value.set(1/p.x,1/p.y);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
function setCamera(){
|
|
1325
|
+
const {theta,phi,dist}=orbit;
|
|
1326
|
+
camera.position.set(
|
|
1327
|
+
center.x+dist*sin(theta)*sin(phi),
|
|
1328
|
+
center.y+dist*Math.cos(phi),
|
|
1329
|
+
center.z+dist*Math.cos(theta)*sin(phi)
|
|
1330
|
+
);
|
|
1331
|
+
camera.lookAt(center);
|
|
1332
|
+
camera.updateMatrixWorld();
|
|
1333
|
+
}
|
|
1334
|
+
function zoom(by){
|
|
1335
|
+
userMoved=true;
|
|
1336
|
+
zoomFactor=clamp(zoomFactor*by,.57,1.72);
|
|
1337
|
+
want.dist=baseDistance*zoomFactor;
|
|
1338
|
+
}
|
|
1339
|
+
function reset(){
|
|
1340
|
+
userMoved=false;
|
|
1341
|
+
zoomFactor=1;
|
|
1342
|
+
Object.assign(want,defaultPose,{dist:baseDistance});
|
|
1343
|
+
}
|
|
1344
|
+
function hit(x,y){
|
|
1345
|
+
const r=canvas.getBoundingClientRect();
|
|
1346
|
+
pointer.set((x-r.left)/r.width*2-1,-(y-r.top)/r.height*2+1);
|
|
1347
|
+
ray.setFromCamera(pointer,camera);
|
|
1348
|
+
const found=ray.intersectObjects([scope,crank,crankHit,basket],true);
|
|
1349
|
+
if(!found.length)return null;
|
|
1350
|
+
let o=found[0].object;
|
|
1351
|
+
while(o){
|
|
1352
|
+
if(o===scope)return 'scope';
|
|
1353
|
+
if(o===crank||o===crankHit||o===basket)return 'lift';
|
|
1354
|
+
o=o.parent;
|
|
1355
|
+
}
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
let msgTimer;
|
|
1360
|
+
function tell(text){
|
|
1361
|
+
const a=document.getElementById('message');
|
|
1362
|
+
a.textContent=text;a.classList.add('show');
|
|
1363
|
+
clearTimeout(msgTimer);
|
|
1364
|
+
msgTimer=setTimeout(()=>a.classList.remove('show'),4300);
|
|
1365
|
+
}
|
|
1366
|
+
function operateLift(){
|
|
1367
|
+
lift.target=lift.target===highStop?lowStop:highStop;
|
|
1368
|
+
lift.moving=true;
|
|
1369
|
+
tell(lift.target===highStop?'绞盘正把工具提往上层交接台。':'工具托篮正降往下层交接台。');
|
|
1370
|
+
}
|
|
1371
|
+
function toggleScope(){
|
|
1372
|
+
scopeLocked=!scopeLocked;
|
|
1373
|
+
if(!scopeLocked){
|
|
1374
|
+
tell('望远镜回到巡星位置。');
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
optic.getWorldPosition(scopePoint);
|
|
1378
|
+
pixel.copy(skyStar).sub(scopePoint).normalize();
|
|
1379
|
+
const az=(Math.atan2(pixel.x,-pixel.z)*180/Math.PI+360)%360;
|
|
1380
|
+
const alt=Math.asin(pixel.y)*180/Math.PI;
|
|
1381
|
+
tell(`镜筒锁定琥珀星 · 方位 ${az.toFixed(1)}°,仰角 ${alt.toFixed(1)}°(沙盘星场)`);
|
|
1382
|
+
}
|
|
1383
|
+
function perform(a){
|
|
1384
|
+
if(a==='scope')toggleScope();
|
|
1385
|
+
if(a==='lift')operateLift();
|
|
1386
|
+
}
|
|
1387
|
+
canvas.addEventListener('contextmenu',e=>e.preventDefault());
|
|
1388
|
+
canvas.addEventListener('pointerdown',e=>{
|
|
1389
|
+
if(e.pointerType==='mouse' && e.button!==0)return;
|
|
1390
|
+
canvas.setPointerCapture(e.pointerId);
|
|
1391
|
+
pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});
|
|
1392
|
+
canvas.classList.add('drag');
|
|
1393
|
+
if(pointers.size===1)tap={id:e.pointerId,x:e.clientX,y:e.clientY,moved:false};
|
|
1394
|
+
else{
|
|
1395
|
+
if(tap)tap.moved=true;
|
|
1396
|
+
const [a,b]=pointers.values();
|
|
1397
|
+
pinch=Math.hypot(a.x-b.x,a.y-b.y);
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
canvas.addEventListener('pointermove',e=>{
|
|
1401
|
+
const previous=pointers.get(e.pointerId);
|
|
1402
|
+
if(!previous){
|
|
1403
|
+
if(e.pointerType==='mouse')canvas.classList.toggle('hot',!!hit(e.clientX,e.clientY));
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
const dx=e.clientX-previous.x,dy=e.clientY-previous.y;
|
|
1407
|
+
pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});
|
|
1408
|
+
if(pointers.size>1){
|
|
1409
|
+
const [a,b]=pointers.values();
|
|
1410
|
+
const next=Math.hypot(a.x-b.x,a.y-b.y);
|
|
1411
|
+
if(pinch>3&&next>3)zoom(pinch/next);
|
|
1412
|
+
pinch=next;
|
|
1413
|
+
}else{
|
|
1414
|
+
if(tap&&Math.hypot(e.clientX-tap.x,e.clientY-tap.y)>5)tap.moved=true;
|
|
1415
|
+
if(!tap||tap.moved){
|
|
1416
|
+
userMoved=true;
|
|
1417
|
+
want.theta-=dx*.0061;
|
|
1418
|
+
want.phi=clamp(want.phi-dy*.0057,.41,1.46);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
function endPointer(e){
|
|
1423
|
+
if(!pointers.has(e.pointerId))return;
|
|
1424
|
+
if(e.type==='pointerup' && tap?.id===e.pointerId && !tap.moved && pointers.size===1)
|
|
1425
|
+
perform(hit(e.clientX,e.clientY));
|
|
1426
|
+
pointers.delete(e.pointerId);
|
|
1427
|
+
if(!pointers.size){tap=null;canvas.classList.remove('drag');}
|
|
1428
|
+
}
|
|
1429
|
+
canvas.addEventListener('pointerup',endPointer);
|
|
1430
|
+
canvas.addEventListener('pointercancel',endPointer);
|
|
1431
|
+
canvas.addEventListener('lostpointercapture',endPointer);
|
|
1432
|
+
canvas.addEventListener('wheel',e=>{
|
|
1433
|
+
e.preventDefault();
|
|
1434
|
+
const unit=e.deltaMode===1?16:e.deltaMode===2?window.innerHeight:1;
|
|
1435
|
+
zoom(Math.exp(clamp(e.deltaY*unit,-240,240)*.0014));
|
|
1436
|
+
},{passive:false});
|
|
1437
|
+
document.getElementById('home').addEventListener('click',reset);
|
|
1438
|
+
document.getElementById('hoist').addEventListener('click',operateLift);
|
|
1439
|
+
window.addEventListener('keydown',e=>{
|
|
1440
|
+
if(e.altKey||e.ctrlKey||e.metaKey||e.repeat)return;
|
|
1441
|
+
const k=e.key.toLowerCase();
|
|
1442
|
+
if(k==='h')reset();
|
|
1443
|
+
if(k==='l')operateLift();
|
|
1444
|
+
if(k==='t')toggleScope();
|
|
1445
|
+
});
|
|
1446
|
+
window.addEventListener('resize',resize,{passive:true});
|
|
1447
|
+
resize();
|
|
1448
|
+
setCamera();
|
|
1449
|
+
|
|
1450
|
+
const initial=new Date();
|
|
1451
|
+
const startReading=initial.getHours()*3600+initial.getMinutes()*60+initial.getSeconds();
|
|
1452
|
+
let started=performance.now(),last=started,t=0;
|
|
1453
|
+
function animate(now){
|
|
1454
|
+
const dt=Math.min(.044,Math.max(0,(now-last)/1000));
|
|
1455
|
+
last=now;
|
|
1456
|
+
const restrained=reduced.matches;
|
|
1457
|
+
t+=dt*(restrained?.13:1);
|
|
1458
|
+
const alpha=restrained?1:1-Math.pow(.929,dt*60);
|
|
1459
|
+
orbit.theta=lerp(orbit.theta,want.theta,alpha);
|
|
1460
|
+
orbit.phi=lerp(orbit.phi,want.phi,alpha);
|
|
1461
|
+
orbit.dist=lerp(orbit.dist,want.dist,alpha);
|
|
1462
|
+
setCamera();
|
|
1463
|
+
|
|
1464
|
+
// 发条缓慢放卷,摆每半周期推进一次擒纵,表针只读取这套时基。
|
|
1465
|
+
const clockAge=(now-started)*.001;
|
|
1466
|
+
const beat=Math.floor(clockAge);
|
|
1467
|
+
const f=clockAge-beat;
|
|
1468
|
+
const advance=smooth(0,.16,f);
|
|
1469
|
+
const reading=startReading+beat+advance;
|
|
1470
|
+
hourHand.rotation.z=-TAU*reading/43200;
|
|
1471
|
+
minuteHand.rotation.z=-TAU*reading/3600;
|
|
1472
|
+
secondsHand.rotation.z=-TAU*reading/60;
|
|
1473
|
+
const swing=restrained?.048:.197;
|
|
1474
|
+
pendulum.rotation.z=sin(Math.PI*clockAge)*swing;
|
|
1475
|
+
pallet.rotation.z=-.53*pendulum.rotation.z;
|
|
1476
|
+
escape.rotation.z=-(beat+advance)*TAU/13;
|
|
1477
|
+
springDrum.rotation.z=-clockAge*.011;
|
|
1478
|
+
|
|
1479
|
+
// 半隐式弹簧阻尼;导向约束使托篮的 x / z 始终不变,不允许越过交接层。
|
|
1480
|
+
if(lift.moving){
|
|
1481
|
+
const previous=lift.x;
|
|
1482
|
+
lift.v+=(22*(lift.target-lift.x)-9.7*lift.v)*dt;
|
|
1483
|
+
lift.x=clamp(lift.x+lift.v*dt,lowStop,highStop);
|
|
1484
|
+
if(Math.abs(lift.target-lift.x)<.0014&&Math.abs(lift.v)<.014){
|
|
1485
|
+
lift.x=lift.target;lift.v=0;lift.moving=false;
|
|
1486
|
+
}
|
|
1487
|
+
lift.angle-=(lift.x-previous)/.101;
|
|
1488
|
+
basket.position.y=lift.x;
|
|
1489
|
+
crank.rotation.x=lift.angle;
|
|
1490
|
+
axle.rotation.y=lift.angle;
|
|
1491
|
+
updateLine(lift.x);
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// 镜筒的光轴是局部 +Y;眼端、镜片与星点在同一测量模型中。
|
|
1495
|
+
const scanTarget=scopeLocked?0:sin(t*.55)*.16+.28;
|
|
1496
|
+
scopeScan=lerp(scopeScan,scanTarget,1-Math.exp(-dt*2.4));
|
|
1497
|
+
optic.getWorldPosition(scopePoint);
|
|
1498
|
+
yoke.getWorldQuaternion(inverseYoke).invert();
|
|
1499
|
+
direction.copy(skyStar).sub(scopePoint).normalize();
|
|
1500
|
+
if(!scopeLocked)direction.applyAxisAngle(up,scopeScan);
|
|
1501
|
+
direction.applyQuaternion(inverseYoke);
|
|
1502
|
+
aim.setFromUnitVectors(up,direction);
|
|
1503
|
+
optic.quaternion.slerp(aim,1-Math.exp(-dt*5.4));
|
|
1504
|
+
targetStar.material.opacity=scopeLocked?.98:.69;
|
|
1505
|
+
|
|
1506
|
+
for(const a of actors){
|
|
1507
|
+
const y=1+.024*sin(t*2.25+a.phase);
|
|
1508
|
+
const x=1/Math.sqrt(y);
|
|
1509
|
+
a.body.scale.set(x,y,x); // x²·y = 1,严格保持体积
|
|
1510
|
+
}
|
|
1511
|
+
rHead.rotation.z=.083+.039*sin(t*1.19);
|
|
1512
|
+
rHead.rotation.y=.065*sin(t*.93+scopeScan*6);
|
|
1513
|
+
for(let i=0;i<ears.length;i++){
|
|
1514
|
+
ears[i].rotation.z=(i===0?.19:-.17)+.052*sin(t*1.8+i*1.7);
|
|
1515
|
+
ears[i].rotation.x=.082*sin(t*1.3+i);
|
|
1516
|
+
}
|
|
1517
|
+
wipe.rotation.z=.32+.19*sin(t*2.8)+.075*sin(t*5.6+.4);
|
|
1518
|
+
wipe.rotation.x=.40+.115*sin(t*2.8+1.3);
|
|
1519
|
+
puffHead.rotation.z=-.097+.031*sin(t*2.8-.63);
|
|
1520
|
+
fHead.rotation.x=.13+.067*sin(t*1.62+.4);
|
|
1521
|
+
writes.rotation.z=-.15+.12*sin(t*4.3);
|
|
1522
|
+
tail.rotation.y=.078*sin(t*1.8+3);
|
|
1523
|
+
needle.rotation.z=-1.31+.085*sin(t*.81);
|
|
1524
|
+
galleryLight.rotation.z=.033*sin(t*1.28+2);
|
|
1525
|
+
|
|
1526
|
+
for(let i=0;i<paperA.count;i++){
|
|
1527
|
+
const edge=smooth(-.24,.28,paperA.getX(i));
|
|
1528
|
+
paperA.setZ(i,paperRest[i]+edge*edge*.017*sin(t*2.1+paperA.getY(i)*9));
|
|
1529
|
+
}
|
|
1530
|
+
paperA.needsUpdate=true;
|
|
1531
|
+
paperG.computeVertexNormals();
|
|
1532
|
+
for(const [a,phase] of sway){
|
|
1533
|
+
a.rotation.z=.066*sin(t*1.71+phase);
|
|
1534
|
+
a.rotation.x=.035*sin(t*1.43+phase+2);
|
|
1535
|
+
}
|
|
1536
|
+
for(const q of clouds){
|
|
1537
|
+
q.a.position.set(
|
|
1538
|
+
q.x+.51*sin(t*.182+q.phase),
|
|
1539
|
+
q.y+.11*sin(t*.263+q.phase),
|
|
1540
|
+
q.z+.22*sin(t*.143+q.phase+.83)
|
|
1541
|
+
);
|
|
1542
|
+
const y=1+.025*sin(t*.71+q.phase);
|
|
1543
|
+
q.a.scale.set(q.s/Math.sqrt(y),q.s*y,q.s/Math.sqrt(y));
|
|
1544
|
+
}
|
|
1545
|
+
for(const q of flies){
|
|
1546
|
+
const a=q.a+.085*sin(t*q.speed+q.phase);
|
|
1547
|
+
q.o.position.set(Math.cos(a)*q.r,q.y+.16*sin(t*.63+q.phase),sin(a)*q.r);
|
|
1548
|
+
q.o.material.opacity=.20+.42*Math.pow(.5+.5*sin(t*1.32+q.phase),2);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
if(useFocus){
|
|
1552
|
+
postMat.uniforms.focus.value=orbit.dist;
|
|
1553
|
+
renderer.setRenderTarget(targetRT);
|
|
1554
|
+
renderer.render(scene,camera);
|
|
1555
|
+
renderer.setRenderTarget(null);
|
|
1556
|
+
renderer.render(post,postCamera);
|
|
1557
|
+
}else renderer.render(scene,camera);
|
|
1558
|
+
requestAnimationFrame(animate);
|
|
1559
|
+
}
|
|
1560
|
+
requestAnimationFrame(animate);
|
|
1561
|
+
} catch(err) {
|
|
1562
|
+
const error=document.getElementById('error');
|
|
1563
|
+
error.hidden=false;
|
|
1564
|
+
error.textContent='沙盘未能启动。请确认浏览器支持 WebGL、已启用硬件加速,并可访问 cdnjs。';
|
|
1565
|
+
console.error(err);
|
|
1566
|
+
}
|
|
1567
|
+
</script>
|
|
1568
|
+
</body>
|
|
1569
|
+
</html>
|