webcake-storefront-mcp 1.36.2 → 1.38.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/README.md +19 -6
- package/README.vi.md +18 -6
- package/dist/auth/login.js +3 -2
- package/dist/builder/attributes.js +2 -2
- package/dist/builder/guide.js +3 -0
- package/dist/builder/native-first.js +168 -0
- package/dist/builder/page.js +69 -6
- package/dist/changelog.json +14 -14
- package/dist/guides.js +4 -1
- package/dist/index.js +1 -1
- package/dist/install.js +100 -52
- package/dist/server.js +2 -0
- package/dist/tools/builder.js +1 -1
- package/dist/tools/global-sources.js +41 -6
- package/dist/tools/images.js +4 -0
- package/dist/tools/pages.js +63 -24
- package/dist/tools/site-config.js +21 -1
- package/dist/web-guide-scene.js +611 -0
- package/dist/web-guide.js +13 -59
- package/package.json +1 -1
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Liquid-glass skin + the 3D "how MCP works" scene for the marketing page.
|
|
3
|
+
*
|
|
4
|
+
* - GLASS_CSS is appended to the page's <style>, so it wins over the base rules.
|
|
5
|
+
* - sceneHtml(lang) is plain, readable steps; without WebGL (or if the CDN fails) that
|
|
6
|
+
* list stays on its own and nothing is lost.
|
|
7
|
+
* - SCENE_JS loads three.js from jsDelivr only when the section nears the viewport, so
|
|
8
|
+
* the page itself stays one light HTML response. T (0..5) is the single timeline:
|
|
9
|
+
* every visual is a pure function of T, so clicking a step can jump either way.
|
|
10
|
+
*
|
|
11
|
+
* Kept identical in webcake-storefront-mcp and webcake-landing-mcp except COPY/ON_ACCENT.
|
|
12
|
+
* No backticks or dollar-brace inside SCENE_JS: it is pasted into a template literal.
|
|
13
|
+
*/
|
|
14
|
+
const THREE_URL = "https://cdn.jsdelivr.net/npm/three@0.186.1/build/three.module.min.js";
|
|
15
|
+
const ON_ACCENT = "#ffffff"; // text on the brand button
|
|
16
|
+
const TEXT_ACCENT = "#0a5f46"; // brand-coloured text on light glass, dark enough for 4.5:1
|
|
17
|
+
const COPY = {
|
|
18
|
+
"vi": {
|
|
19
|
+
"aria": "Cách MCP hoạt động, từng bước",
|
|
20
|
+
"pause": "Tạm dừng",
|
|
21
|
+
"resume": "Tiếp tục",
|
|
22
|
+
"replay": "Xem lại",
|
|
23
|
+
"tags": [
|
|
24
|
+
{
|
|
25
|
+
"t": "Bạn nói",
|
|
26
|
+
"s": "mô tả trang bạn muốn"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"t": "Trợ lý AI",
|
|
30
|
+
"s": "Claude · Cursor · Windsurf…"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"t": "WebCake MCP",
|
|
34
|
+
"s": "lưu & kiểm tra trang"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"t": "Cửa hàng của bạn",
|
|
38
|
+
"s": "trang web thật, live"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"steps": [
|
|
42
|
+
{
|
|
43
|
+
"t": "Bạn nói điều mình muốn",
|
|
44
|
+
"d": "Nhắn trong Claude, Cursor… như nhắn cho đồng nghiệp: “Tạo trang sản phẩm áo thun có nút mua ngay.”"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"t": "AI tìm đúng công cụ qua MCP",
|
|
48
|
+
"d": "MCP là cầu nối cho AI biết WebCake làm được những gì, như thêm sản phẩm hay tạo trang, và phải yêu cầu thế nào."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"t": "WebCake làm bằng tài khoản của bạn",
|
|
52
|
+
"d": "Bạn chỉ cần bấm Kết nối một lần. AI không cần biết mật khẩu của bạn."
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"t": "Trang được dựng lên từng phần",
|
|
56
|
+
"d": "Sản phẩm, nội dung, nút mua lần lượt được lưu vào cửa hàng. Đây là trang thật, bạn vẫn sửa được trong trình dựng."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"t": "AI gửi link cho bạn xem",
|
|
60
|
+
"d": "Chưa ưng chỗ nào thì nói tiếp, AI sửa đúng chỗ đó rồi gửi lại."
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"en": {
|
|
65
|
+
"aria": "How MCP works, step by step",
|
|
66
|
+
"pause": "Pause",
|
|
67
|
+
"resume": "Resume",
|
|
68
|
+
"replay": "Replay",
|
|
69
|
+
"tags": [
|
|
70
|
+
{
|
|
71
|
+
"t": "You describe",
|
|
72
|
+
"s": "what you want the page to be"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"t": "AI assistant",
|
|
76
|
+
"s": "Claude · Cursor · Windsurf…"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"t": "WebCake MCP",
|
|
80
|
+
"s": "saves & checks the page"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"t": "Your store",
|
|
84
|
+
"s": "a real, live page"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"steps": [
|
|
88
|
+
{
|
|
89
|
+
"t": "You say what you want",
|
|
90
|
+
"d": "Type in Claude, Cursor… like messaging a colleague: “Build a T-shirt product page with a buy button.”"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"t": "The AI finds the right tool through MCP",
|
|
94
|
+
"d": "MCP is the bridge that tells the AI what WebCake can do, like adding a product or creating a page, and how to ask for it."
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"t": "WebCake does the work on your account",
|
|
98
|
+
"d": "You only click Connect once. The AI never needs your password."
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"t": "The page goes up section by section",
|
|
102
|
+
"d": "Products, content and the buy button are saved to your store one by one. It is a real page you can keep editing yourself."
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"t": "The AI sends you the link",
|
|
106
|
+
"d": "Not quite right? Say so, and the AI changes just that part and sends it back."
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export function sceneHtml(lang) {
|
|
112
|
+
const c = COPY[lang];
|
|
113
|
+
return `<section class="sc" id="scene" aria-label="${c.aria}" data-pause="${c.pause}" data-resume="${c.resume}" data-replay="${c.replay}">
|
|
114
|
+
<div class="sc-stage" aria-hidden="true">
|
|
115
|
+
<canvas></canvas>
|
|
116
|
+
${c.tags.map((t) => `<span class="sc-tag"><b>${t.t}</b><small>${t.s}</small></span>`).join("")}
|
|
117
|
+
</div>
|
|
118
|
+
<div class="sc-panel glass">
|
|
119
|
+
<ol class="sc-steps">
|
|
120
|
+
${c.steps
|
|
121
|
+
.map((s, i) => `<li${i === 0 ? ' class="cur"' : ""}><button type="button" class="sc-step"><span class="sc-n">${i + 1}</span><span>${s.t}</span></button><div class="sc-dw"><p>${s.d}</p></div></li>`)
|
|
122
|
+
.join("\n ")}
|
|
123
|
+
</ol>
|
|
124
|
+
<button type="button" class="sc-ctl" hidden></button>
|
|
125
|
+
</div>
|
|
126
|
+
</section>`;
|
|
127
|
+
}
|
|
128
|
+
export const GLASS_CSS = `
|
|
129
|
+
/* ── Liquid glass ─────────────────────────────────────────────────────────
|
|
130
|
+
The page-builder grid and colour field sit behind everything, so the glass has
|
|
131
|
+
something to bend. Refraction itself is added by SCENE_JS on Chromium; other
|
|
132
|
+
browsers keep the blur + bright rim, which is still legible glass. */
|
|
133
|
+
:root{--on-g:${ON_ACCENT};--btn-a:color-mix(in srgb,var(--g) 94%,#000);--btn-b:color-mix(in srgb,var(--g) 84%,#000);--g7:${TEXT_ACCENT};--ic-fg:${TEXT_ACCENT};--ink:#0d1c15;--mut:#3b4942;--glass:rgba(255,255,255,.74);--glass-strong:rgba(255,255,255,.9);
|
|
134
|
+
--rim:rgba(255,255,255,.9);--rim-soft:rgba(255,255,255,.4);--glow:rgba(255,255,255,.55);--amber:#f5a524;
|
|
135
|
+
--drop:0 1px 1px rgba(16,40,30,.04),0 22px 44px -26px rgba(16,40,30,.38);--navbg:transparent}
|
|
136
|
+
@media(prefers-color-scheme:dark){:root:not([data-theme="light"]){--on-g:#04241a;--btn-a:var(--g);--btn-b:color-mix(in srgb,var(--g) 94%,#000);--mut:#bccbc3;--glass:rgba(17,25,21,.76);--glass-strong:rgba(14,21,18,.9);
|
|
137
|
+
--rim:rgba(255,255,255,.24);--rim-soft:rgba(255,255,255,.08);--glow:rgba(255,255,255,.1);
|
|
138
|
+
--drop:0 1px 1px rgba(0,0,0,.3),0 24px 48px -26px rgba(0,0,0,.85)}}
|
|
139
|
+
:root[data-theme="dark"]{--on-g:#04241a;--btn-a:var(--g);--btn-b:color-mix(in srgb,var(--g) 94%,#000);--mut:#bccbc3;--glass:rgba(17,25,21,.76);--glass-strong:rgba(14,21,18,.9);
|
|
140
|
+
--rim:rgba(255,255,255,.24);--rim-soft:rgba(255,255,255,.08);--glow:rgba(255,255,255,.1);
|
|
141
|
+
--drop:0 1px 1px rgba(0,0,0,.3),0 24px 48px -26px rgba(0,0,0,.85)}
|
|
142
|
+
body::after{content:"";position:fixed;inset:0;z-index:-2;pointer-events:none;
|
|
143
|
+
background-image:linear-gradient(var(--line) 1px,transparent 1px),linear-gradient(90deg,var(--line) 1px,transparent 1px);
|
|
144
|
+
background-size:46px 46px;-webkit-mask:none;mask:none;opacity:.45}
|
|
145
|
+
.blobs b{filter:blur(80px);opacity:.26}
|
|
146
|
+
.blobs b:nth-child(1){width:760px;height:760px;right:4%;top:-220px}
|
|
147
|
+
.blobs b:nth-child(2){width:680px;height:680px;left:6%;bottom:-200px}
|
|
148
|
+
.blobs b:nth-child(3){width:520px;height:520px;left:30%;top:30%;opacity:.16;
|
|
149
|
+
background:radial-gradient(circle,var(--amber),transparent 70%);animation:drift1 56s ease-in-out infinite}
|
|
150
|
+
.glass,.iconbtn,.langsw,.btn.ghost,.btn.ghost:hover,.nav{background-color:var(--glass);border:1px solid var(--rim-soft);
|
|
151
|
+
-webkit-backdrop-filter:blur(20px) saturate(175%);backdrop-filter:blur(20px) saturate(175%);
|
|
152
|
+
box-shadow:inset 0 1px 0 var(--rim),inset 0 -1px 0 var(--rim-soft),var(--drop)}
|
|
153
|
+
.glass{border-radius:22px;background-image:none}
|
|
154
|
+
.glass.card:hover,.uses li.glass:hover,.glass:hover{transform:none;border-color:var(--rim-soft);
|
|
155
|
+
box-shadow:inset 0 1px 0 var(--rim),inset 0 -1px 0 var(--rim-soft),var(--drop)}
|
|
156
|
+
/* The highlight follows the pointer (--mx/--my from SCENE_JS): light moving on a surface. */
|
|
157
|
+
@media(hover:hover){.glass:hover{background-image:radial-gradient(280px circle at var(--mx,50%) var(--my,0%),var(--glow),transparent 72%)}}
|
|
158
|
+
.tip{background:var(--glass);border-color:var(--rim-soft);border-radius:16px}
|
|
159
|
+
/* A long command scrolls inside its own box instead of stretching the steps past the phone screen. */
|
|
160
|
+
.steps{grid-template-columns:minmax(0,1fr)}
|
|
161
|
+
.btn{color:var(--on-g);border-radius:999px;border:0;background:linear-gradient(180deg,var(--btn-a),var(--btn-b));
|
|
162
|
+
box-shadow:inset 0 1px 0 rgba(255,255,255,.45),inset 0 -8px 12px -8px rgba(0,0,0,.28),0 12px 24px -14px var(--g)}
|
|
163
|
+
.btn:hover{transform:none;filter:brightness(1.07);background:linear-gradient(180deg,var(--btn-a),var(--btn-b))}
|
|
164
|
+
.btn:active{transform:scale(.97)}
|
|
165
|
+
.btn.ghost,.btn.ghost:hover{background-image:none;color:var(--ink);filter:none}
|
|
166
|
+
.btn:focus-visible,.langsw:focus-visible,.iconbtn:focus-visible,.nav a:focus-visible{outline:2px solid var(--g);outline-offset:2px}
|
|
167
|
+
.iconbtn{border-radius:50%}
|
|
168
|
+
.new{color:var(--on-g);background:var(--btn-a);animation:none}
|
|
169
|
+
.nav{position:sticky;top:10px;margin:18px 0 6px;padding:6px;border-radius:999px}
|
|
170
|
+
/* ── The scene: wider than the text column, panel floats over the canvas ── */
|
|
171
|
+
.sc{position:relative;width:min(1180px,calc(100vw - 32px));margin-left:calc(50% - min(590px,calc(50vw - 16px)))}
|
|
172
|
+
.sc-stage{display:none;position:relative;overflow:hidden;height:clamp(440px,46vw,600px)}
|
|
173
|
+
.js .sc.on .sc-stage{display:block}
|
|
174
|
+
.sc-stage canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
|
|
175
|
+
.sc-tag{position:absolute;left:0;top:0;padding:5px 13px 6px;border-radius:14px;text-align:center;white-space:nowrap;line-height:1.25;
|
|
176
|
+
color:var(--ink);background:var(--glass-strong);box-shadow:inset 0 1px 0 var(--rim),0 8px 18px -12px rgba(0,0,0,.5);
|
|
177
|
+
-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);pointer-events:none;will-change:transform;transition:color .25s ease}
|
|
178
|
+
.sc-tag b{display:block;font-size:.84rem}
|
|
179
|
+
.sc-tag small{display:block;font-size:.72rem;font-weight:500;color:var(--mut)}
|
|
180
|
+
.sc-tag.on b{color:var(--g7)}
|
|
181
|
+
.sc-panel{padding:12px;margin-top:12px}
|
|
182
|
+
@media(min-width:1040px){.js .sc.on .sc-panel{position:absolute;left:0;top:26px;width:372px;margin:0;z-index:2}}
|
|
183
|
+
@media(max-width:1039px){.sc{width:100%;margin-left:0}}
|
|
184
|
+
.sc-steps{list-style:none;margin:0;padding:0;display:grid;gap:2px}
|
|
185
|
+
.sc-step{display:flex;gap:11px;align-items:center;width:100%;padding:8px;border:0;border-radius:13px;background:none;color:inherit;
|
|
186
|
+
font:inherit;font-weight:700;font-size:.95rem;line-height:1.3;text-align:left;cursor:pointer;transition:background .15s ease,color .15s ease}
|
|
187
|
+
.sc-step:hover{background:rgba(127,160,140,.14)}
|
|
188
|
+
.sc-step:focus-visible,.sc-ctl:focus-visible{outline:2px solid var(--g);outline-offset:1px}
|
|
189
|
+
html:not(.js) .sc-step,.sc.off .sc-step{pointer-events:none}
|
|
190
|
+
.sc-n{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:grid;place-items:center;font-size:.84rem;font-weight:800;
|
|
191
|
+
color:var(--ic-fg);background:rgba(127,160,140,.18);transition:background .2s ease,color .2s ease}
|
|
192
|
+
.js .sc.on .cur .sc-step{color:var(--g7)}
|
|
193
|
+
.js .sc.on .cur .sc-n{background:var(--btn-a);color:var(--on-g)}
|
|
194
|
+
.sc-dw{display:grid;grid-template-rows:1fr;transition:grid-template-rows .3s cubic-bezier(.2,.7,.2,1)}
|
|
195
|
+
.js .sc.on li:not(.cur) .sc-dw{grid-template-rows:0fr}
|
|
196
|
+
.sc-dw p{overflow:hidden;min-height:0;margin:0;padding-left:47px;padding-right:8px;font-size:.9rem;color:var(--mut)}
|
|
197
|
+
.sc-dw p::after{content:"";display:block;height:8px}
|
|
198
|
+
.sc-ctl{display:block;margin:4px 8px 2px auto;padding:5px 10px;border:0;border-radius:999px;background:none;cursor:pointer;
|
|
199
|
+
color:var(--g7);font:inherit;font-size:.84rem;font-weight:700}
|
|
200
|
+
.sc-ctl:hover{background:rgba(127,160,140,.14)}
|
|
201
|
+
.sc-ctl[hidden]{display:none}
|
|
202
|
+
@media(max-width:639px){.sc-stage{height:520px}.sc-tag small{font-size:.68rem}.nav{margin-left:0;margin-right:0}}
|
|
203
|
+
@media(prefers-reduced-motion:reduce){.sc-dw,.sc-step,.sc-n,.sc-tag{transition:none}}
|
|
204
|
+
@media(prefers-reduced-transparency:reduce){
|
|
205
|
+
.glass,.iconbtn,.langsw,.btn.ghost,.btn.ghost:hover,.nav,.tip,.sc-tag{background-color:var(--card);background-image:none;
|
|
206
|
+
-webkit-backdrop-filter:none;backdrop-filter:none}
|
|
207
|
+
}
|
|
208
|
+
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
|
|
209
|
+
.glass,.iconbtn,.langsw,.btn.ghost,.btn.ghost:hover,.nav,.tip,.sc-tag{background-color:var(--card)}
|
|
210
|
+
}
|
|
211
|
+
`;
|
|
212
|
+
export const SCENE_JS = String.raw `
|
|
213
|
+
(function(){
|
|
214
|
+
var html=document.documentElement;
|
|
215
|
+
function mq(q){return !!(window.matchMedia&&matchMedia(q).matches);}
|
|
216
|
+
|
|
217
|
+
// ── Glass light: the highlight follows the pointer ──
|
|
218
|
+
document.addEventListener('pointermove',function(e){
|
|
219
|
+
var g=e.target&&e.target.closest&&e.target.closest('.glass');
|
|
220
|
+
if(!g)return;
|
|
221
|
+
var r=g.getBoundingClientRect();
|
|
222
|
+
g.style.setProperty('--mx',(e.clientX-r.left)+'px');
|
|
223
|
+
g.style.setProperty('--my',(e.clientY-r.top)+'px');
|
|
224
|
+
},{passive:true});
|
|
225
|
+
|
|
226
|
+
// ── Glass refraction: an edge-lens displacement map per element ──
|
|
227
|
+
// Only Chromium applies an SVG filter inside backdrop-filter; userAgentData is Chromium-only.
|
|
228
|
+
var chromium=!!(navigator.userAgentData&&navigator.userAgentData.brands&&navigator.userAgentData.brands.some(function(b){return /Chromium/.test(b.brand);}));
|
|
229
|
+
function lens(el,n){
|
|
230
|
+
var NS='http://www.w3.org/2000/svg',id='lg-lens-'+n;
|
|
231
|
+
var svg=document.createElementNS(NS,'svg');
|
|
232
|
+
svg.setAttribute('aria-hidden','true');svg.style.cssText='position:absolute;width:0;height:0';
|
|
233
|
+
var f=document.createElementNS(NS,'filter');
|
|
234
|
+
f.setAttribute('id',id);f.setAttribute('filterUnits','userSpaceOnUse');f.setAttribute('color-interpolation-filters','sRGB');
|
|
235
|
+
f.setAttribute('x','0');f.setAttribute('y','0');
|
|
236
|
+
var im=document.createElementNS(NS,'feImage');im.setAttribute('x','0');im.setAttribute('y','0');im.setAttribute('preserveAspectRatio','none');im.setAttribute('result','map');
|
|
237
|
+
var d=document.createElementNS(NS,'feDisplacementMap');d.setAttribute('in','SourceGraphic');d.setAttribute('in2','map');
|
|
238
|
+
d.setAttribute('xChannelSelector','R');d.setAttribute('yChannelSelector','G');d.setAttribute('scale','46');
|
|
239
|
+
f.appendChild(im);f.appendChild(d);svg.appendChild(f);document.body.appendChild(svg);
|
|
240
|
+
var pw=0,ph=0;
|
|
241
|
+
function draw(){
|
|
242
|
+
var w=el.offsetWidth,h=el.offsetHeight;
|
|
243
|
+
if(!w||!h||(w===pw&&h===ph))return;
|
|
244
|
+
pw=w;ph=h;
|
|
245
|
+
var cw=Math.ceil(w/2),ch=Math.ceil(h/2),cv=document.createElement('canvas');cv.width=cw;cv.height=ch;
|
|
246
|
+
var c=cv.getContext('2d'),img=c.createImageData(cw,ch),D=img.data;
|
|
247
|
+
var r=Math.min(parseFloat(getComputedStyle(el).borderTopLeftRadius)||0,h/2)/2,band=Math.min(16,ch/2);
|
|
248
|
+
for(var y=0;y<ch;y++)for(var x=0;x<cw;x++){
|
|
249
|
+
// Rounded-rect signed distance: strongest bend at the rim, none past the band.
|
|
250
|
+
var ax=x+.5-cw/2,ay=y+.5-ch/2,qx=Math.abs(ax)-cw/2+r,qy=Math.abs(ay)-ch/2+r;
|
|
251
|
+
var dist=Math.hypot(Math.max(qx,0),Math.max(qy,0))+Math.min(Math.max(qx,qy),0)-r;
|
|
252
|
+
var t=Math.max(0,Math.min(1,1+dist/band)),m=t*t,nx=0,ny=0;
|
|
253
|
+
if(qx>0&&qy>0){var l=Math.hypot(qx,qy)||1;nx=qx/l;ny=qy/l;}else if(qx>qy){nx=1;}else{ny=1;}
|
|
254
|
+
nx*=ax<0?-1:1;ny*=ay<0?-1:1;
|
|
255
|
+
var i=(y*cw+x)*4;
|
|
256
|
+
D[i]=128-nx*m*127;D[i+1]=128-ny*m*127;D[i+2]=128;D[i+3]=255;
|
|
257
|
+
}
|
|
258
|
+
c.putImageData(img,0,0);
|
|
259
|
+
f.setAttribute('width',w);f.setAttribute('height',h);
|
|
260
|
+
im.setAttribute('width',w);im.setAttribute('height',h);im.setAttribute('href',cv.toDataURL());
|
|
261
|
+
}
|
|
262
|
+
draw();
|
|
263
|
+
var bf='url(#'+id+') blur(14px) saturate(160%)';
|
|
264
|
+
el.style.backdropFilter=bf;
|
|
265
|
+
if(window.ResizeObserver)new ResizeObserver(draw).observe(el);
|
|
266
|
+
}
|
|
267
|
+
if(chromium&&!mq('(prefers-reduced-transparency: reduce)')){
|
|
268
|
+
var lensEls=document.querySelectorAll('.nav,.sc-panel');
|
|
269
|
+
for(var li=0;li<lensEls.length;li++)lens(lensEls[li],li);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ── The scene ──
|
|
273
|
+
var root=document.getElementById('scene');
|
|
274
|
+
if(!root||!window.IntersectionObserver)return;
|
|
275
|
+
function hasGL(){try{return !!document.createElement('canvas').getContext('webgl2');}catch(e){return false;}}
|
|
276
|
+
if(!hasGL()){root.classList.add('off');return;}
|
|
277
|
+
root.classList.add('on'); // reserved now so nothing jumps when three.js arrives
|
|
278
|
+
var stage=root.querySelector('.sc-stage'),canvas=root.querySelector('canvas'),ctl=root.querySelector('.sc-ctl');
|
|
279
|
+
var tags=[].slice.call(root.querySelectorAll('.sc-tag')),items=[].slice.call(root.querySelectorAll('.sc-steps li'));
|
|
280
|
+
var loader=new IntersectionObserver(function(es){
|
|
281
|
+
if(!es[0].isIntersecting)return;
|
|
282
|
+
loader.disconnect();
|
|
283
|
+
import('${THREE_URL}').then(start).catch(function(){root.classList.remove('on');root.classList.add('off');});
|
|
284
|
+
},{rootMargin:'320px'});
|
|
285
|
+
loader.observe(root);
|
|
286
|
+
|
|
287
|
+
function start(THREE){
|
|
288
|
+
var reduced=mq('(prefers-reduced-motion: reduce)');
|
|
289
|
+
var lite=(navigator.hardwareConcurrency||8)<=4||window.innerWidth<640;
|
|
290
|
+
var STEP=3.2,T=reduced?5:0,hold=5,playing=false,visible=false,touched=false,raf=0,last=0,curStep=-1;
|
|
291
|
+
var css=getComputedStyle(html),ACCENT=new THREE.Color((css.getPropertyValue('--g')||'#1DB954').trim()),AMBER=new THREE.Color(0xf5a524);
|
|
292
|
+
|
|
293
|
+
var renderer=new THREE.WebGLRenderer({canvas:canvas,antialias:true,alpha:true});
|
|
294
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,lite?1.5:2));
|
|
295
|
+
renderer.toneMapping=THREE.ACESFilmicToneMapping;
|
|
296
|
+
var scene=new THREE.Scene(),camera=new THREE.PerspectiveCamera(34,2,.1,60);
|
|
297
|
+
camera.position.set(0,0,11);
|
|
298
|
+
|
|
299
|
+
// Soft studio lighting, built here so there is no HDR file to download.
|
|
300
|
+
var envScene=new THREE.Scene();
|
|
301
|
+
function softbox(hex,power,w,h,p){
|
|
302
|
+
var c=new THREE.Color(hex).multiplyScalar(power);
|
|
303
|
+
var m=new THREE.Mesh(new THREE.PlaneGeometry(w,h),new THREE.MeshBasicMaterial({color:c,side:THREE.DoubleSide}));
|
|
304
|
+
m.position.set(p[0],p[1],p[2]);m.lookAt(0,0,0);envScene.add(m);
|
|
305
|
+
}
|
|
306
|
+
envScene.add(new THREE.Mesh(new THREE.SphereGeometry(30,16,12),new THREE.MeshBasicMaterial({color:0x26362f,side:THREE.BackSide})));
|
|
307
|
+
softbox(0xffffff,9,14,5,[0,12,6]);softbox(0xffffff,5,4,12,[-12,0,6]);softbox(0xffe2b0,5,4,10,[12,2,5]);softbox(ACCENT.getHex(),4,12,4,[0,-11,3]);
|
|
308
|
+
var pmrem=new THREE.PMREMGenerator(renderer);
|
|
309
|
+
scene.environment=pmrem.fromScene(envScene,.03).texture;pmrem.dispose();
|
|
310
|
+
var sun=new THREE.DirectionalLight(0xffffff,1.1);sun.position.set(3,6,8);scene.add(sun);
|
|
311
|
+
|
|
312
|
+
// Clear in the middle, bright at the edges, like real glass seen against a page. three's
|
|
313
|
+
// transmission can't see the page behind a transparent canvas (it turned grey), so edge
|
|
314
|
+
// opacity comes from a Fresnel term instead; also far cheaper on phones.
|
|
315
|
+
function glass(){
|
|
316
|
+
var m=new THREE.MeshPhysicalMaterial({color:ACCENT.clone().lerp(new THREE.Color(0xffffff),.72),transparent:true,opacity:.14,roughness:.06,clearcoat:1,clearcoatRoughness:.05,depthWrite:false,envMapIntensity:1.5});
|
|
317
|
+
m.onBeforeCompile=function(sh){
|
|
318
|
+
sh.fragmentShader=sh.fragmentShader.replace('#include <opaque_fragment>',
|
|
319
|
+
'diffuseColor.a=mix(diffuseColor.a,.8,pow(1.0-saturate(dot(normalize(vViewPosition),normal)),2.6));\n#include <opaque_fragment>');
|
|
320
|
+
};
|
|
321
|
+
return m;
|
|
322
|
+
}
|
|
323
|
+
function solid(color,rough){return new THREE.MeshStandardMaterial({color:color,emissive:color,emissiveIntensity:.12,roughness:rough==null?.32:rough});}
|
|
324
|
+
function rrShape(w,h,r,tail){
|
|
325
|
+
var s=new THREE.Shape(),x=-w/2,y=-h/2;
|
|
326
|
+
s.moveTo(x+r,y);
|
|
327
|
+
if(tail){s.lineTo(x+r+.02,y-.3);s.lineTo(x+r+.42,y);}
|
|
328
|
+
s.lineTo(x+w-r,y);s.quadraticCurveTo(x+w,y,x+w,y+r);s.lineTo(x+w,y+h-r);s.quadraticCurveTo(x+w,y+h,x+w-r,y+h);
|
|
329
|
+
s.lineTo(x+r,y+h);s.quadraticCurveTo(x,y+h,x,y+h-r);s.lineTo(x,y+r);s.quadraticCurveTo(x,y,x+r,y);return s;
|
|
330
|
+
}
|
|
331
|
+
function slab(w,h,r,d,tail){
|
|
332
|
+
var b=Math.min(.07,d*.5+.015);
|
|
333
|
+
return new THREE.ExtrudeGeometry(rrShape(w-2*b,h-2*b,Math.max(.01,r-b),tail),{depth:d,bevelEnabled:true,bevelSize:b,bevelThickness:b,bevelSegments:5,curveSegments:14}).center();
|
|
334
|
+
}
|
|
335
|
+
function mesh(g,m,p,parent){var o=new THREE.Mesh(g,m);if(p)o.position.set(p[0],p[1],p[2]);(parent||scene).add(o);return o;}
|
|
336
|
+
|
|
337
|
+
// The four stops are the ones the page has always named: you, the AI, MCP, Webcake.
|
|
338
|
+
// Stop 1: you, the idea. A glass light bulb that lights up.
|
|
339
|
+
var bulb=new THREE.Group();scene.add(bulb);
|
|
340
|
+
var bp=[new THREE.Vector2(.001,.84)];
|
|
341
|
+
for(var bi=1;bi<=18;bi++){var ba=Math.PI/2-bi/18*(Math.PI/2+.85);bp.push(new THREE.Vector2(.64*Math.cos(ba),.2+.64*Math.sin(ba)));}
|
|
342
|
+
bp.push(new THREE.Vector2(.3,-.5),new THREE.Vector2(.3,-.62));
|
|
343
|
+
mesh(new THREE.LatheGeometry(bp.reverse(),48),glass(),[0,0,0],bulb);
|
|
344
|
+
var capM=solid(0x9fb0a9,.45),fil=solid(AMBER,.2);
|
|
345
|
+
mesh(new THREE.CylinderGeometry(.29,.29,.1,32),capM,[0,-.68,0],bulb);
|
|
346
|
+
mesh(new THREE.CylinderGeometry(.25,.25,.1,32),capM,[0,-.8,0],bulb);
|
|
347
|
+
mesh(new THREE.CylinderGeometry(.13,.06,.1,24),capM,[0,-.91,0],bulb);
|
|
348
|
+
mesh(new THREE.CylinderGeometry(.025,.05,.7,12),capM,[0,-.2,0],bulb);
|
|
349
|
+
mesh(new THREE.SphereGeometry(.14,24,16),fil,[0,.2,0],bulb);
|
|
350
|
+
|
|
351
|
+
// Stop 2: the AI assistant, the brain icon drawn in tubes, inside a chat bubble.
|
|
352
|
+
var bubble=new THREE.Group();scene.add(bubble);
|
|
353
|
+
mesh(slab(1.95,1.5,.46,.3,true),glass(),[0,0,0],bubble);
|
|
354
|
+
var brainM=solid(ACCENT);
|
|
355
|
+
function iconTube(d,k,rad,mat,parent){
|
|
356
|
+
// The browser walks the SVG path, so arcs need no parser of ours.
|
|
357
|
+
var p=document.createElementNS('http://www.w3.org/2000/svg','path');p.setAttribute('d',d);
|
|
358
|
+
var L=p.getTotalLength(),pts=[];
|
|
359
|
+
for(var i=0;i<90;i++){var q=p.getPointAtLength(L*i/90);pts.push(new THREE.Vector3((q.x-12)*k,(12-q.y)*k,0));}
|
|
360
|
+
return mesh(new THREE.TubeGeometry(new THREE.CatmullRomCurve3(pts,true),240,rad,8,true),mat,[0,.14,.04],parent);
|
|
361
|
+
}
|
|
362
|
+
iconTube('M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z',.054,.034,brainM,bubble);
|
|
363
|
+
iconTube('M12 5a3 3 0 1 1 5.997.142 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z',.054,.034,brainM,bubble);
|
|
364
|
+
|
|
365
|
+
// Stop 3: Webcake MCP, the bridge: a ring of tools the AI can reach for, around the server icon.
|
|
366
|
+
var ringG=new THREE.Group();scene.add(ringG);
|
|
367
|
+
mesh(new THREE.TorusGeometry(.92,.14,32,96),glass(),[0,0,0],ringG);
|
|
368
|
+
var srvM=solid(ACCENT);
|
|
369
|
+
[.17,-.17].forEach(function(y){
|
|
370
|
+
mesh(slab(.92,.27,.08,.1),srvM,[0,y,0],ringG);
|
|
371
|
+
mesh(new THREE.SphereGeometry(.04,12,8),new THREE.MeshBasicMaterial({color:0xffffff,toneMapped:false}),[-.3,y,.11],ringG);
|
|
372
|
+
});
|
|
373
|
+
var toolM=solid(ACCENT.clone().lerp(new THREE.Color(0xffffff),.28)),pick=solid(AMBER);
|
|
374
|
+
var tools=[0,1,2,3,4,5].map(function(i){return mesh(slab(.24,.24,.07,.07),i===0?pick:toolM,[0,0,0],ringG);});
|
|
375
|
+
|
|
376
|
+
// Stop 4: Webcake and the real page. The page is built below; this is the logo in 3D on its
|
|
377
|
+
// corner: the official W and peach dot on a green tile inside clear glass.
|
|
378
|
+
var page=new THREE.Group();scene.add(page);page.rotation.y=-.22;
|
|
379
|
+
var W_PATH='M14.3011 11.3523C14.395 12.3191 14.4157 12.0816 15.0571 13.6768C15.0571 21.9423 13.5334 16.5399 12.2589 13.6732C11.4363 11.7505 10.7943 9.30526 8.74858 9.1988C7.57201 9.1623 6.51244 9.98392 6.47107 11.062C6.44377 11.4475 6.49804 11.8319 6.64075 12.191C7.2016 13.6024 8.65083 17.1402 8.92789 17.7945C9.36942 18.8396 9.77116 19.8691 10.1854 20.8761C10.6124 21.9109 11.0522 22.8274 12.5529 22.8274H12.8564C13.9412 22.8274 15.026 21.8587 15.4402 21.1763C16.0707 20.1346 15.8417 17.4106 16.1743 16.3166C16.2961 16.756 17.7389 20.1485 17.9731 20.6986C18.3873 21.6795 18.8071 22.8271 20.23 22.8271H20.686C21.8473 22.8271 22.8155 21.7767 22.8155 20.6483V20.5753C22.7647 19.951 20.713 15.1116 20.3587 14.2785C19.9081 13.2212 19.5137 12.2125 19.0666 11.1569C18.6251 10.1118 18.1725 9.17255 16.6572 9.17255H16.4281C15.2651 9.17255 14.3004 10.209 14.3004 11.3513L14.3011 11.3523Z';
|
|
380
|
+
function svgShape(d){
|
|
381
|
+
// Just the commands this path uses. y flips because SVG grows downward; the logo is 32 units wide.
|
|
382
|
+
var sh=new THREE.Shape(),m=d.match(/[MCHVLZ]|-?[0-9.]+/g),i=0,x=0,y=0;
|
|
383
|
+
function n(){return parseFloat(m[i++])-16;}
|
|
384
|
+
while(i<m.length){
|
|
385
|
+
var c=m[i++];
|
|
386
|
+
if(c==='M'){x=n();y=n();sh.moveTo(x,-y);}
|
|
387
|
+
else if(c==='L'){x=n();y=n();sh.lineTo(x,-y);}
|
|
388
|
+
else if(c==='H'){x=n();sh.lineTo(x,-y);}
|
|
389
|
+
else if(c==='V'){y=n();sh.lineTo(x,-y);}
|
|
390
|
+
else if(c==='C'){var a1=n(),b1=n(),a2=n(),b2=n();x=n();y=n();sh.bezierCurveTo(a1,-b1,a2,-b2,x,-y);}
|
|
391
|
+
}
|
|
392
|
+
return sh;
|
|
393
|
+
}
|
|
394
|
+
var logo=new THREE.Group();page.add(logo);logo.position.set(-.86,1.02,.34);logo.scale.setScalar(.62);
|
|
395
|
+
mesh(slab(1.98,1.98,.48,.3),glass(),[0,0,0],logo);
|
|
396
|
+
var tileG=slab(1.72,1.72,.4,.1),tileP=tileG.attributes.position,tileC=new Float32Array(tileP.count*3);
|
|
397
|
+
var topC=new THREE.Color(0x3FBB57),botC=new THREE.Color(0x108B67),mixC=new THREE.Color();
|
|
398
|
+
for(var ti=0;ti<tileP.count;ti++){mixC.copy(botC).lerp(topC,(tileP.getY(ti)+.86)/1.72);mixC.toArray(tileC,ti*3);}
|
|
399
|
+
tileG.setAttribute('color',new THREE.BufferAttribute(tileC,3));
|
|
400
|
+
var tileM=new THREE.MeshStandardMaterial({vertexColors:true,roughness:.28,emissive:0x108B67,emissiveIntensity:.12});
|
|
401
|
+
mesh(tileG,tileM,[0,0,0],logo);
|
|
402
|
+
var mark=new THREE.Group(),K=1.78/32;mark.scale.setScalar(K);mark.position.z=.15;logo.add(mark);
|
|
403
|
+
var wM=new THREE.MeshStandardMaterial({color:0xffffff,emissive:0xffffff,emissiveIntensity:.6,roughness:.22});
|
|
404
|
+
mesh(new THREE.ExtrudeGeometry(svgShape(W_PATH),{depth:1.3,bevelEnabled:true,bevelSize:.22,bevelThickness:.4,bevelSegments:5,curveSegments:16}),wM,[0,0,0],mark);
|
|
405
|
+
var dotP=solid(0xFFD591,.2),peach=mesh(new THREE.SphereGeometry(2.16,32,24),dotP,[23.4118-16,16-11.3277,1.1],mark);peach.scale.z=.62;
|
|
406
|
+
|
|
407
|
+
// The page itself, with sections that arrive one by one.
|
|
408
|
+
mesh(slab(1.9,2.3,.2,.1),glass(),[0,0,0],page);
|
|
409
|
+
mesh(slab(1.5,.09,.04,.015),solid(0x9fb0a9,.5),[0,.94,.1],page);
|
|
410
|
+
var soft=solid(ACCENT.clone().lerp(new THREE.Color(0xffffff),.45));
|
|
411
|
+
var built=[
|
|
412
|
+
{o:mesh(slab(1.5,.68,.1,.035),solid(ACCENT),[0,.43,.1],page),a:0,b:.38},
|
|
413
|
+
{o:mesh(slab(.45,.45,.08,.035),soft,[-.52,-.27,.1],page),a:.22,b:.54},
|
|
414
|
+
{o:mesh(slab(.45,.45,.08,.035),soft,[0,-.27,.1],page),a:.3,b:.62},
|
|
415
|
+
{o:mesh(slab(.45,.45,.08,.035),soft,[.52,-.27,.1],page),a:.38,b:.7},
|
|
416
|
+
{o:mesh(slab(.86,.22,.11,.035),solid(AMBER),[0,-.8,.1],page),a:.62,b:.95}
|
|
417
|
+
];
|
|
418
|
+
built.forEach(function(s){s.z=s.o.position.z;});
|
|
419
|
+
|
|
420
|
+
// The route the request travels, and the part of it already lit.
|
|
421
|
+
var wireBase=new THREE.MeshStandardMaterial({color:0x7f9a8c,transparent:true,opacity:.34,roughness:.3});
|
|
422
|
+
var wireLit=new THREE.MeshBasicMaterial({color:ACCENT,toneMapped:false}),wireRet=new THREE.MeshBasicMaterial({color:AMBER,toneMapped:false});
|
|
423
|
+
var base=mesh(new THREE.BufferGeometry(),wireBase),lit=mesh(new THREE.BufferGeometry(),wireLit),ret=mesh(new THREE.BufferGeometry(),wireRet);
|
|
424
|
+
var curve,lengths,stations=[bulb,bubble,ringG,page];
|
|
425
|
+
|
|
426
|
+
var sprite=(function(){
|
|
427
|
+
var c=document.createElement('canvas');c.width=c.height=64;
|
|
428
|
+
var g=c.getContext('2d'),r=g.createRadialGradient(32,32,0,32,32,32);
|
|
429
|
+
r.addColorStop(0,'rgba(255,255,255,1)');r.addColorStop(.25,'rgba(255,255,255,.55)');r.addColorStop(1,'rgba(255,255,255,0)');
|
|
430
|
+
g.fillStyle=r;g.fillRect(0,0,64,64);return new THREE.CanvasTexture(c);
|
|
431
|
+
})();
|
|
432
|
+
var haloM=new THREE.SpriteMaterial({map:sprite,color:ACCENT,transparent:true,depthWrite:false}),halo=new THREE.Sprite(haloM);halo.scale.setScalar(.62);scene.add(halo);
|
|
433
|
+
var bulbHaloM=new THREE.SpriteMaterial({map:sprite,color:AMBER,transparent:true,depthWrite:false,opacity:0}),bulbHalo=new THREE.Sprite(bulbHaloM);
|
|
434
|
+
bulbHalo.scale.setScalar(1.9);bulbHalo.position.y=.2;bulb.add(bulbHalo);
|
|
435
|
+
var headM=new THREE.MeshBasicMaterial({color:0xffffff,toneMapped:false}),head=mesh(new THREE.SphereGeometry(.085,24,16),headM);
|
|
436
|
+
var trailM=new THREE.MeshBasicMaterial({color:ACCENT,toneMapped:false,transparent:true,opacity:.6});
|
|
437
|
+
var trail=[1,2,3,4,5].map(function(k){return mesh(new THREE.SphereGeometry(.06-.008*k,12,8),trailM);});
|
|
438
|
+
|
|
439
|
+
var mode='',W=0,H=0,panelW=0,scaleS=1;
|
|
440
|
+
var LAYOUT={
|
|
441
|
+
wide:{z:11,p:[[-1,.95,0],[-.38,-1,.2],[.24,1.05,-.2],[1,-.55,0]]},
|
|
442
|
+
tall:{z:13.4,p:[[-1,2.95,0],[1.05,1.15,.2],[-1.05,-.65,-.2],[1,-2.3,0]]}
|
|
443
|
+
};
|
|
444
|
+
function layout(m){
|
|
445
|
+
mode=m;var L=LAYOUT[m],pts=[],at=[];
|
|
446
|
+
// World width left of the panel at the stage's depth: stations spread to fit it.
|
|
447
|
+
var vis=2*L.z*Math.tan(camera.fov*Math.PI/360)*(W/H),free=vis*(W-panelW)/W;
|
|
448
|
+
scaleS=m==='wide'?Math.min(1,free/9.4):.72;
|
|
449
|
+
var half=free/2-1.12*scaleS;
|
|
450
|
+
stations.forEach(function(g,i){
|
|
451
|
+
var x=m==='wide'?L.p[i][0]*half:L.p[i][0];
|
|
452
|
+
at.push(new THREE.Vector3(x,L.p[i][1],L.p[i][2]));
|
|
453
|
+
g.position.copy(at[i]);g.scale.setScalar(scaleS);
|
|
454
|
+
});
|
|
455
|
+
for(var i=0;i<4;i++){
|
|
456
|
+
// Behind the object, so the lit wire is seen through the glass.
|
|
457
|
+
var v=at[i].clone();v.z-=.5*scaleS;pts.push(v);
|
|
458
|
+
if(i<3)pts.push(v.clone().lerp(at[i+1],.5).add(new THREE.Vector3(0,0,-.45)));
|
|
459
|
+
}
|
|
460
|
+
curve=new THREE.CatmullRomCurve3(pts,false,'centripetal');
|
|
461
|
+
lengths=curve.getLengths(240);
|
|
462
|
+
[[base,.038],[lit,.03],[ret,.031]].forEach(function(e){
|
|
463
|
+
e[0].geometry.dispose();e[0].geometry=new THREE.TubeGeometry(curve,200,e[1],10,false);
|
|
464
|
+
});
|
|
465
|
+
camera.position.z=L.z;
|
|
466
|
+
}
|
|
467
|
+
function frac(t){return lengths[Math.round(t*240)]/lengths[240];}
|
|
468
|
+
function smooth(a,b,x){var t=Math.max(0,Math.min(1,(x-a)/(b-a)));return t*t*(3-2*t);}
|
|
469
|
+
function band(a,b){return smooth(a-.2,a+.08,T)*(1-smooth(b-.08,b+.2,T));}
|
|
470
|
+
|
|
471
|
+
function resize(){
|
|
472
|
+
W=stage.clientWidth;H=stage.clientHeight;
|
|
473
|
+
if(!W||!H)return;
|
|
474
|
+
renderer.setSize(W,H,false);
|
|
475
|
+
camera.aspect=W/H;
|
|
476
|
+
var panel=root.querySelector('.sc-panel');
|
|
477
|
+
panelW=getComputedStyle(panel).position==='absolute'?panel.offsetWidth:0;
|
|
478
|
+
layout(W<640?'tall':'wide');
|
|
479
|
+
if(panelW)camera.setViewOffset(W,H,-panelW/2,0,W,H);else camera.clearViewOffset();
|
|
480
|
+
camera.updateProjectionMatrix();
|
|
481
|
+
wake();
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
var par={x:0,y:0},parT={x:0,y:0},v3=new THREE.Vector3();
|
|
485
|
+
function draw(){
|
|
486
|
+
camera.position.x=par.x*.4;camera.position.y=-par.y*.3;camera.lookAt(0,0,0);
|
|
487
|
+
|
|
488
|
+
// Where the request is along the route (t), per step.
|
|
489
|
+
var t,idx=Math.min(4,Math.floor(T)),p=T-idx,e=p*p*(3-2*p);
|
|
490
|
+
if(idx===0)t=e/3;else if(idx===1)t=1/3+e/3;else if(idx===2)t=2/3+e/3;else if(idx===3)t=1;else t=1-e;
|
|
491
|
+
var f=frac(t),back=T>=4,on=T>.02&&T<4.98&&(T<2.98||back);
|
|
492
|
+
var count=lit.geometry.index.count,cut=Math.floor(count*f/6)*6;
|
|
493
|
+
lit.geometry.setDrawRange(0,back?count:cut);
|
|
494
|
+
ret.visible=back;ret.geometry.setDrawRange(cut,count-cut);
|
|
495
|
+
|
|
496
|
+
var pos=curve.getPoint(t);
|
|
497
|
+
head.visible=halo.visible=on;
|
|
498
|
+
head.position.copy(pos);halo.position.copy(pos);
|
|
499
|
+
var col=back?AMBER:ACCENT;haloM.color.copy(col);trailM.color.copy(col);
|
|
500
|
+
trail.forEach(function(s,k){
|
|
501
|
+
var tt=Math.max(0,Math.min(1,t+(back?1:-1)*(k+1)*.009));
|
|
502
|
+
s.visible=on;s.position.copy(curve.getPoint(tt));
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
// Each station wakes up in its own step.
|
|
506
|
+
var a0=Math.max(band(0,.7),smooth(4.7,4.95,T)),a1=Math.max(band(.7,1.3),band(4.4,4.7)),a2=band(1.7,2.3),a3=band(2.7,4.4);
|
|
507
|
+
fil.emissiveIntensity=.2+a0*1.6;bulbHaloM.opacity=a0*.75;bulbHalo.visible=a0>.01;
|
|
508
|
+
brainM.emissiveIntensity=.12+a1*.8;srvM.emissiveIntensity=.12+a2*.7;
|
|
509
|
+
tools.forEach(function(o,i){
|
|
510
|
+
var a=i/6*Math.PI*2+T*.9;
|
|
511
|
+
o.position.set(Math.cos(a)*.92,Math.sin(a)*.92,0);o.rotation.z=a;
|
|
512
|
+
o.scale.setScalar(i===0?1+a2*.55:1);
|
|
513
|
+
});
|
|
514
|
+
toolM.emissiveIntensity=.12+a2*.5;pick.emissiveIntensity=.2+a2;
|
|
515
|
+
ringG.rotation.y=Math.sin(T*.8)*.3;
|
|
516
|
+
tileM.emissiveIntensity=.12+a3*.22;wM.emissiveIntensity=.6+a3*.3;dotP.emissiveIntensity=.55+a3*.4;
|
|
517
|
+
// A full turn during its own step, so it reads as an object, resting slightly angled.
|
|
518
|
+
logo.rotation.y=.24+smooth(2,3,T)*Math.PI*2;logo.rotation.x=-.1;
|
|
519
|
+
built.forEach(function(s){
|
|
520
|
+
var k=smooth(s.a,s.b,T-3);
|
|
521
|
+
s.o.visible=k>.001;
|
|
522
|
+
s.o.scale.setScalar(.6+.4*k);
|
|
523
|
+
s.o.position.z=s.z+(1-k)*.9;
|
|
524
|
+
});
|
|
525
|
+
bubble.rotation.y=.22+Math.sin(T*.6)*.06;
|
|
526
|
+
[a0,a1,a2,a3].forEach(function(a,i){stations[i].scale.setScalar(scaleS*(1+a*.05));});
|
|
527
|
+
|
|
528
|
+
// Labels sit just under each station.
|
|
529
|
+
var drop=mode==='wide'?[1.36,1.32,1.46,1.56]:[1,.98,1.06,1.16];
|
|
530
|
+
stations.forEach(function(g,i){
|
|
531
|
+
v3.copy(g.position);v3.y-=drop[i]*(mode==='wide'?scaleS:1);v3.project(camera);
|
|
532
|
+
var x=(v3.x+1)/2*W,y=(1-v3.y)/2*H;
|
|
533
|
+
tags[i].style.transform='translate('+Math.round(x)+'px,'+Math.round(y)+'px) translate(-50%,-50%)';
|
|
534
|
+
tags[i].classList.toggle('on',[a0,a1,a2,a3][i]>.5);
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
var s=Math.max(0,Math.min(4,Math.ceil(T)-1));
|
|
538
|
+
if(s!==curStep){
|
|
539
|
+
curStep=s;
|
|
540
|
+
items.forEach(function(li,i){
|
|
541
|
+
li.classList.toggle('cur',i===s);
|
|
542
|
+
var b=li.querySelector('.sc-step');
|
|
543
|
+
if(i===s)b.setAttribute('aria-current','step');else b.removeAttribute('aria-current');
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
syncCtl();
|
|
547
|
+
renderer.render(scene,camera);
|
|
548
|
+
}
|
|
549
|
+
function syncCtl(){
|
|
550
|
+
if(reduced)return;
|
|
551
|
+
var label=playing?root.dataset.pause:(T>=5?root.dataset.replay:root.dataset.resume);
|
|
552
|
+
if(ctl.textContent!==label)ctl.textContent=label;
|
|
553
|
+
}
|
|
554
|
+
function frame(now){
|
|
555
|
+
raf=0;
|
|
556
|
+
var dt=Math.min((now-last)/1000,.05);last=now;
|
|
557
|
+
if(playing&&T<hold){T=Math.min(hold,T+dt/STEP);if(T>=hold)playing=false;}
|
|
558
|
+
par.x+=(parT.x-par.x)*.08;par.y+=(parT.y-par.y)*.08;
|
|
559
|
+
var settling=Math.abs(parT.x-par.x)>.002||Math.abs(parT.y-par.y)>.002;
|
|
560
|
+
draw();
|
|
561
|
+
if((playing||settling)&&visible)raf=requestAnimationFrame(frame);
|
|
562
|
+
}
|
|
563
|
+
function wake(){if(!raf&&visible&&W){last=performance.now();raf=requestAnimationFrame(frame);}}
|
|
564
|
+
|
|
565
|
+
items.forEach(function(li,i){
|
|
566
|
+
li.querySelector('.sc-step').addEventListener('click',function(){
|
|
567
|
+
touched=true;
|
|
568
|
+
if(reduced){T=i+1;hold=T;playing=false;}else{T=i;hold=i+1;playing=true;}
|
|
569
|
+
wake();
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
if(!reduced){
|
|
573
|
+
ctl.hidden=false;
|
|
574
|
+
ctl.addEventListener('click',function(){
|
|
575
|
+
touched=true;
|
|
576
|
+
if(playing)playing=false;
|
|
577
|
+
else{if(T>=5)T=0;hold=5;playing=true;}
|
|
578
|
+
syncCtl();wake();
|
|
579
|
+
});
|
|
580
|
+
stage.addEventListener('pointermove',function(e){
|
|
581
|
+
if(e.pointerType==='touch')return;
|
|
582
|
+
var r=stage.getBoundingClientRect();
|
|
583
|
+
parT.x=(e.clientX-r.left)/r.width-.5;parT.y=(e.clientY-r.top)/r.height-.5;wake();
|
|
584
|
+
},{passive:true});
|
|
585
|
+
stage.addEventListener('pointerleave',function(){parT.x=parT.y=0;wake();});
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function paintTheme(){
|
|
589
|
+
var dark=html.getAttribute('data-theme')==='dark'||(!html.getAttribute('data-theme')&&mq('(prefers-color-scheme: dark)'));
|
|
590
|
+
wireBase.color.set(dark?0x9fc4b2:0x4f7263);wireBase.opacity=dark?.3:.42;
|
|
591
|
+
scene.environmentIntensity=dark?.85:1.05;
|
|
592
|
+
wake();
|
|
593
|
+
}
|
|
594
|
+
new MutationObserver(paintTheme).observe(html,{attributes:true,attributeFilter:['data-theme']});
|
|
595
|
+
if(window.matchMedia)matchMedia('(prefers-color-scheme: dark)').addEventListener('change',paintTheme);
|
|
596
|
+
|
|
597
|
+
new IntersectionObserver(function(es){visible=es[0].isIntersecting;if(visible)wake();},{threshold:0}).observe(stage);
|
|
598
|
+
// Plays through once, the first time most of it is on screen; then it rests.
|
|
599
|
+
var starter=new IntersectionObserver(function(es){
|
|
600
|
+
if(!es[0].isIntersecting)return;
|
|
601
|
+
starter.disconnect();
|
|
602
|
+
if(!touched&&!reduced){playing=true;wake();}
|
|
603
|
+
},{threshold:.45});
|
|
604
|
+
starter.observe(stage);
|
|
605
|
+
|
|
606
|
+
if(window.ResizeObserver)new ResizeObserver(resize).observe(stage);else window.addEventListener('resize',resize);
|
|
607
|
+
resize();paintTheme();
|
|
608
|
+
visible=true;wake();
|
|
609
|
+
}
|
|
610
|
+
})();
|
|
611
|
+
`;
|