All projectsKeep looking
3D / WebGL3d
Sketchbook
1 views 0 copiesFree
Sign in to take this project
Sign in to copy the source, prompt and SKILL.md.
DetailsPublished
- Version
- v1.0
- Motion
- Micro interaction
- Updated
- Nov 25, 2026
sketchbook.html
1<!doctype html>2<html lang="en">3<head><script>function __threeuiStorageImage(...args){const image=new Image(...args);const property=Object.getOwnPropertyDescriptor(HTMLImageElement.prototype,"src");Object.defineProperty(image,"src",{configurable:true,get(){return property.get.call(this)},set(value){try{const url=new URL(value,document.baseURI);if(this.crossOrigin===null&&(url.href.startsWith("https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/")||url.origin===new URL(document.baseURI).origin))this.crossOrigin="anonymous"}catch{}property.set.call(this,value)}});return image;}4</script>5<meta charset="utf-8">6<meta name="viewport" content="width=device-width, initial-scale=1">7<title>Meng To</title>8<meta name="description" content="designer, creator, AI educator — Singapore">9<style>10@font-face{font-family:'Instrument Serif';font-style:normal;font-weight:400;font-display:block;11src:url(https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/embedded/60c06664b5a95c7de6cc3e00d1f9034d78bd1e40b564016b241674449a067d4d.woff2) format('woff2')}12@font-face{font-family:'Instrument Serif';font-style:italic;font-weight:400;font-display:block;13src:url(https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/embedded/6ee678c33f388dd7ba59700ebea635deb98821baafd817b09891f7927177f702.woff2) format('woff2')}14@font-face{font-family:'Newsreader';font-style:normal;font-weight:200 600;font-display:swap;15src:url(https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/dcec2e68141a33903e3b6cc1/newsreader.woff2) format('woff2')}1617:root{18--paper:#ece7dc;19--ink:#2b2721;20--ink-soft:rgba(43,39,33,.58);21--ink-faint:rgba(43,39,33,.36);22--hairline:rgba(43,39,33,.14);23--earth:#9a6a3e;24--display:'Instrument Serif',"New York",Georgia,'Times New Roman',serif;25--font:'Newsreader',"New York",Georgia,'Times New Roman',serif;26--track-caps:.24em;27--track-nav:.06em;28}29*{box-sizing:border-box}30html,body{margin:0;padding:0}31html{-webkit-text-size-adjust:100%}32body{33font-family:var(--font);font-weight:400;background:var(--paper);color:var(--ink);34-webkit-font-smoothing:antialiased;overflow-x:hidden;35}36a{color:inherit;text-decoration:none}37button{font:inherit}38::selection{background:rgba(43,39,33,.85);color:var(--paper)}3940/* the painted ground the whole page sits on */41.wash{42position:fixed;inset:0;z-index:-2;pointer-events:none;43background:url(https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/339abd2c649a11f725af9114/bg-wash.jpg) center top / cover no-repeat;44opacity:.85;45}46.wash:after{47content:"";position:absolute;inset:0;48background:linear-gradient(180deg,rgba(236,231,220,.25) 0%,rgba(236,231,220,.72) 58%,var(--paper) 88%);49}5051/* ---------------- top bar ---------------- */52.top{53position:fixed;top:0;left:0;right:0;z-index:500;54display:flex;flex-direction:column;align-items:center;gap:11px;55padding-inline:clamp(16px,4vw,48px);padding-block:18px 64px;pointer-events:none;text-align:center;56}57.top>*{pointer-events:auto}58.top:before{59content:"";position:absolute;inset:0;z-index:-1;60background:linear-gradient(180deg,rgba(240,236,226,.94),rgba(240,236,226,.7) 48%,rgba(240,236,226,0));61-webkit-backdrop-filter:blur(14px) saturate(.95);backdrop-filter:blur(14px) saturate(.95);62-webkit-mask-image:linear-gradient(180deg,#000 46%,transparent);63mask-image:linear-gradient(180deg,#000 46%,transparent);64}65.top .name{66font-family:var(--display);font-size:clamp(24px,2.4vw,30px);letter-spacing:.01em;67white-space:nowrap;line-height:1;68}69.top nav{70display:flex;gap:clamp(14px,2vw,26px);font-size:15px;align-items:center;71letter-spacing:var(--track-nav);font-weight:300;72}73.top nav a{color:var(--ink-soft);transition:color .2s}74.top nav a:hover,.top nav a[aria-current]{color:var(--ink)}75.top nav .top-socials{76display:flex;align-items:center;gap:13px;margin-left:2px;padding-left:clamp(12px,1.6vw,20px);77border-left:1px solid var(--hairline);78}79.icon-btn{display:inline-flex;align-items:center;justify-content:center;padding:4px;color:var(--ink-soft);transition:color .2s}80.icon-btn:hover{color:var(--ink)}81.top .icon-btn svg{width:16px;height:16px;display:block}82@media (max-width:640px){83.top{padding-inline:12px;padding-block:13px 50px;gap:8px}84.top .name{font-size:20px}85.top nav{gap:11px;font-size:13px}86.top nav .top-socials{gap:9px;padding-left:10px}87.top .icon-btn{padding:2px}88.top .icon-btn svg{width:14px;height:14px}89}9091/* ---------------- hero ---------------- */92.hero{93position:relative;display:grid;justify-items:center;align-content:center;94min-height:100svh;overflow-anchor:none;95padding:clamp(112px,13svh,152px) 0 clamp(72px,10svh,120px);96}97.botany{98position:absolute;bottom:0;width:clamp(120px,15vw,250px);opacity:.5;99pointer-events:none;user-select:none;z-index:0;100}101.botany.l{left:clamp(-40px,-1vw,0px);bottom:2%}102.botany.r{right:clamp(-30px,0vw,10px);bottom:-2%;width:clamp(100px,12vw,200px)}103@media (max-width:900px){.botany{display:none}}104105.hero-kicker{106font-size:12px;font-weight:400;letter-spacing:var(--track-caps);text-align:center;107color:var(--ink-soft);margin:0 0 clamp(22px,3.4vh,40px);text-transform:uppercase;108}109.hero-down{110position:absolute;bottom:30px;left:50%;transform:translateX(-50%);border:0;background:transparent;111padding:10px 14px;color:var(--ink);cursor:pointer;-webkit-tap-highlight-color:transparent;112animation:cue-breathe 2.6s ease-in-out infinite;z-index:3;113}114.hero-down:hover{animation:none;opacity:1}115@keyframes cue-breathe{0%,100%{opacity:.15}50%{opacity:.7}}116@media (prefers-reduced-motion:reduce){.hero-down{animation:none;opacity:.5}}117118/* ---------------- sketchbook ---------------- */119.hero,.hero *{-webkit-user-select:none;-moz-user-select:none;user-select:none}120.hero img{-webkit-user-drag:none;user-drag:none}121.sb-wrap{display:grid;justify-items:center;gap:20px;width:100%;position:relative;z-index:2}122.sb-stage{123display:flex;align-items:center;justify-content:center;width:100%;124position:relative;125touch-action:pan-y;126}127.sb-arrow{128flex:none;display:inline-flex;align-items:center;justify-content:center;padding:6px 2px;129border:0;background:transparent;color:var(--ink-faint);cursor:pointer;transition:color .2s;130-webkit-tap-highlight-color:transparent;z-index:8;131}132.sb-arrow:hover{color:var(--ink)}133134/* The box is the book's own untransformed frame: the loupe lives here, on135the desk, while only .sb-tilt leans and scales underneath it. */136.sb-3d{137position:relative;flex:1 1;min-width:0;max-width:900px;138perspective:1750px;perspective-origin:50% 46%;139}140.sb-tilt{141position:relative;142transform-style:preserve-3d;143transform:rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)) scale(var(--zoom,1));144will-change:transform;145}146.sb-book{position:relative;width:100%;aspect-ratio:1760/1240;transform-style:preserve-3d;z-index:1}147148/* The book sits on a surface, so its shadow is a soft pool underneath —149no box, no filter on the artwork, nothing with an edge of its own.150Both blobs fade to zero well inside their own bounds, and both ease151off while a leaf is in the air. */152.sb-cast{position:absolute;pointer-events:none;z-index:0}153.sb-cast.ambient{154left:5%;right:5%;top:27%;bottom:2%;155background:radial-gradient(50% 50% at 50% 58%,156rgba(58,44,26,.34) 0%,rgba(58,44,26,.19) 40%,rgba(58,44,26,0) 74%);157filter:blur(26px);158opacity:calc(1 - var(--shade,0) * .42);159}160.sb-cast.contact{161left:9%;right:9%;top:62%;bottom:10%;162background:radial-gradient(50% 44% at 50% 42%,163rgba(44,32,14,.40) 0%,rgba(44,32,14,.17) 48%,rgba(44,32,14,0) 78%);164filter:blur(11px);165opacity:calc(1 - var(--shade,0) * .5);166}167.sb-cast.hair{168left:12%;right:12%;top:70%;bottom:17%;169background:radial-gradient(50% 52% at 50% 40%,170rgba(40,28,10,.34) 0%,rgba(40,28,10,0) 76%);171filter:blur(4px);172opacity:calc(1 - var(--shade,0) * .62);173}174.sb-full{position:absolute;inset:0}175.sb-full img{width:100%;height:auto;display:block}176.sb-half{position:absolute;top:0;bottom:0;width:50%;overflow-x:clip;overflow-y:visible}177.sb-half.left{left:0}178.sb-half.right{left:50%}179.sb-half-img{width:200%;max-width:none;height:auto;display:block}180.sb-half-img.right{margin-left:-100%}181/* the shadow the lifting leaf throws onto the page beneath it */182.gutter-shade{183position:absolute;top:var(--pg,21.8%);bottom:var(--pg,21.8%);width:46%;184pointer-events:none;opacity:calc(var(--shade,0) * .62);185-webkit-mask-image:linear-gradient(180deg,transparent 0,#000 5.2%,#000 94.8%,transparent 100%);186mask-image:linear-gradient(180deg,transparent 0,#000 5.2%,#000 94.8%,transparent 100%);187}188.gutter-shade.left{right:0;background:linear-gradient(270deg,rgba(52,38,20,.30),rgba(52,38,20,0) 82%)}189.gutter-shade.right{left:0;background:linear-gradient(90deg,rgba(52,38,20,.24),rgba(52,38,20,0) 82%)}190191/* ---- the turning leaf: nested strips forming a curved surface ---- */192.curl{193position:absolute;top:0;height:100%;194width:calc(var(--bw,0px) * var(--span));195transform-style:preserve-3d;z-index:6;196}197.curl.next{left:50%;transform-origin:left center;transform:rotateY(calc(-1 * var(--tt,0deg)))}198.curl.prev{right:50%;transform-origin:right center;transform:rotateY(var(--tt,0deg))}199.strip{200position:absolute;top:0;height:100%;201width:calc(var(--bw,0px) * var(--span) / var(--n));202transform-style:preserve-3d;203}204.curl.next .strip{transform-origin:left center}205.curl.prev .strip{transform-origin:right center}206.curl.next>.strip{left:0}207.curl.prev>.strip{right:0;left:auto}208.curl.next .strip .strip{left:100%;transform:rotateY(var(--td,0deg))}209.curl.prev .strip .strip{right:100%;transform:rotateY(calc(-1 * var(--td,0deg)))}210.face{211position:absolute;top:0;bottom:0;left:0;right:-1.1px;212backface-visibility:hidden;-webkit-backface-visibility:hidden;213background-repeat:no-repeat;background-size:var(--bw,0px) auto;214}215.face.back{transform:rotateY(180deg)}216.face .sh,.face .gl{217-webkit-mask-image:linear-gradient(180deg,transparent 0,#000 5.2%,#000 94.8%,transparent 100%);218mask-image:linear-gradient(180deg,transparent 0,#000 5.2%,#000 94.8%,transparent 100%);219}220.strip.edge .face .sh,.strip.edge .face .gl{221-webkit-mask-image:linear-gradient(180deg,transparent 0,#000 9%,#000 91%,transparent 100%),var(--hf);222mask-image:linear-gradient(180deg,transparent 0,#000 9%,#000 91%,transparent 100%),var(--hf);223-webkit-mask-composite:source-in;mask-composite:intersect;224}225.curl.next .strip.edge .face.front,.curl.prev .strip.edge .face.back{226--hf:linear-gradient(90deg,#000 0 22%,transparent 96%);227}228.curl.next .strip.edge .face.back,.curl.prev .strip.edge .face.front{229--hf:linear-gradient(270deg,#000 0 22%,transparent 96%);230}231.face .sh{position:absolute;left:0;right:0;top:var(--pg,21.8%);bottom:var(--pg,21.8%);pointer-events:none}232.curl.next .face.front .sh,.curl.prev .face.back .sh{233background:linear-gradient(90deg,rgba(58,43,20,var(--a1,0)),rgba(58,43,20,var(--a2,0)));234}235.curl.next .face.back .sh,.curl.prev .face.front .sh{236background:linear-gradient(90deg,rgba(58,43,20,var(--a2,0)),rgba(58,43,20,var(--a1,0)));237}238.face .gl{239position:absolute;left:0;right:0;top:var(--pg,21.8%);bottom:var(--pg,21.8%);240pointer-events:none;background:#fffaf0;241opacity:calc(var(--shade,0) * var(--lit,1) * var(--lit,1) * .20);242}243244/* ---- the loupe: a real magnifier lying on the page. Pick it up and245drag it across the book; it stays where you put it. ---- */246.loupe{247position:absolute;left:0;top:0;248width:var(--lr,270px);height:var(--lr,270px);249pointer-events:none;z-index:80;opacity:0;250transition:opacity .25s ease;251will-change:transform;252}253.loupe.on{opacity:1}254.loupe.held .ring{cursor:grabbing}255.loupe .ring{256position:absolute;inset:0;border-radius:50%;257pointer-events:auto;cursor:grab;258padding:calc(var(--lr,270px) * .058);259box-shadow:2600 1px 2px rgba(58,44,26,.30),2610 10px 18px rgba(58,44,26,.24),2620 26px 40px rgba(58,44,26,.20),2630 48px 66px rgba(58,44,26,.13);264}265/* the bezel is an annulus, so the glass really is see-through */266.loupe .ring:before{267content:"";position:absolute;inset:0;border-radius:50%;pointer-events:none;268background:linear-gradient(146deg,269#fdf7e9 0%,#e6d7b4 14%,#b69d70 32%,#7d6740 50%,270#cdbb92 66%,#f4ead3 80%,#9b8459 100%);271box-shadow:272inset 0 1px 1px rgba(255,255,255,.8),273inset 0 -2px 3px rgba(70,52,26,.5);274-webkit-mask-image:radial-gradient(circle closest-side at 50% 50%,transparent 0 88.2%,#000 89.8% 100%);275mask-image:radial-gradient(circle closest-side at 50% 50%,transparent 0 88.2%,#000 89.8% 100%);276}277/* the handle, drawn before the bezel so the ring covers its inner end */278.loupe .grip{279position:absolute;left:50%;top:50%;280width:calc(var(--lr,270px) * .74);height:calc(var(--lr,270px) * .125);281transform-origin:0 50%;282transform:rotate(40deg) translate(calc(var(--lr,270px) * .33),-50%);283border-radius:calc(var(--lr,270px) * .06);284pointer-events:auto;cursor:grab;285background:286linear-gradient(180deg,rgba(255,255,255,.46) 0 13%,rgba(255,255,255,0) 44%,287rgba(0,0,0,.26) 100%),288linear-gradient(90deg,#d9bd82 0 14%,#a9884e 14% 20%,#6d4c2b 20% 62%,289#5a3d22 62% 92%,#7a563180 92% 100%);290box-shadow:0 8px 15px rgba(58,44,26,.26),0 18px 26px rgba(58,44,26,.14);291}292.lens{293position:relative;display:block;width:100%;height:100%;border-radius:50%;294background-repeat:no-repeat;overflow:hidden;295box-shadow:296inset 0 0 0 1px rgba(52,40,22,.55),297inset 0 4px 12px rgba(40,30,14,.28),298inset 0 -7px 16px rgba(255,250,240,.14);299}300.lens .mag{display:none}301/* A second copy of the book, sitting beside the glass outside the tilt, and302scaled about whichever page point the glass is currently over. */303.zoomwrap{304position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:2;305opacity:0;306}307.zoominner{position:absolute;inset:0;transform-origin:0 0}308.lens:before,.lens:after{content:"";position:absolute;inset:0;border-radius:50%;pointer-events:none}309.lens:before{z-index:1}310.lens:after{z-index:2}311/* the glass bends and darkens toward its rim, with a faint colour fringe */312.lens:before{313background:radial-gradient(circle at 50% 50%,314rgba(0,0,0,0) 54%,rgba(58,44,26,.10) 76%,rgba(46,34,16,.34) 100%);315box-shadow:316inset 0 0 0 2px rgba(130,162,196,.26),317inset 0 0 0 4px rgba(206,158,112,.15);318}319/* the dome: one broad specular and a tight crescent opposite it */320.lens:after{321background:322radial-gradient(36% 26% at 29% 19%,rgba(255,255,255,.30),rgba(255,255,255,0) 76%),323radial-gradient(24% 16% at 74% 86%,rgba(255,255,255,.12),rgba(255,255,255,0) 80%),324linear-gradient(150deg,rgba(255,255,255,.06) 0 18%,rgba(255,255,255,0) 42%);325}326327/* ---- controls ---- */328.sb-tools{329display:flex;align-items:center;gap:6px;330border:1px solid var(--hairline);border-radius:999px;331padding:5px 7px;background:rgba(250,246,238,.62);332-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);333}334.tool{335width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;336border:0;border-radius:50%;background:transparent;color:var(--ink-soft);337cursor:pointer;transition:background-color .18s ease,color .18s ease;338}339.tool:hover{background:rgba(255,252,244,.9);color:var(--ink)}340.tool[aria-pressed="true"]{background:rgba(154,106,62,.16);color:var(--earth)}341.tool:disabled{opacity:.32;cursor:default;background:transparent}342.tool svg{width:15px;height:15px;display:block}343.tool-sep{width:1px;height:17px;background:var(--hairline);margin:0 2px}344.zoom-read{345font-size:11px;letter-spacing:.1em;color:var(--ink-faint);346min-width:40px;text-align:center;font-variant-numeric:tabular-nums;347}348@media (pointer:coarse){.loupe{display:none}}349350.sb-zone{position:absolute;top:0;bottom:0;border:0;background:transparent;cursor:grab;z-index:60;-webkit-tap-highlight-color:transparent}351.sb-zone:active{cursor:grabbing}352.sb-prev{left:0;width:50%}353.sb-next{right:0;width:50%}354355.sb-captions{display:grid;justify-items:center}356.sb-captions>*{grid-area:1/1;margin:0}357.sb-caption{font-size:13px;letter-spacing:var(--track-caps);text-transform:uppercase;color:var(--ink-soft);358animation:sb-cap-in .5s ease both}359.sb-caption.live{animation:none}360@keyframes sb-cap-in{0%{opacity:0}}361@keyframes sb-cap-out{to{opacity:0}}362.sb-hint{363margin:0;font-size:11px;letter-spacing:.14em;text-transform:uppercase;color:var(--ink-faint);364transition:opacity .4s ease;365}366.sb-hint.gone{opacity:0}367.sb-wrap.intro .sb-full img,.sb-wrap.intro .sb-half-img{filter:url(#sb-mblur-1)}368.sb-wrap.intro.b2 .sb-full img,.sb-wrap.intro.b2 .sb-half-img{filter:url(#sb-mblur-2)}369.sb-wrap.intro .sb-caption{animation:none}370.sb-wrap.intro .sb-caption.cap-out{display:none}371@media (max-width:640px){372.hero-kicker{font-size:10.5px;letter-spacing:.16em}373.sb-wrap{width:100vw;margin-inline:calc(50% - 50vw)}374.sb-arrow{position:absolute;top:50%;transform:translateY(-50%);z-index:70;padding:12px 6px}375.sb-arrow.left{left:2px}376.sb-arrow.right{right:2px}377.sb-3d{max-width:none}378.sb-hint{font-size:9.5px;letter-spacing:.1em;padding:0 16px;text-align:center}379}380381/* ---------------- painted rules + sections ---------------- */382.rule{383display:block;width:min(1080px,86vw);margin:clamp(30px,6vh,64px) auto;384height:clamp(26px,4vw,46px);385background:url(https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/339abd2c649a11f725af9114/divider.png) center / 100% auto no-repeat;386opacity:.5;387}388.rule.short{width:min(420px,52vw);opacity:.4}389.section-label{390font-size:11px;letter-spacing:var(--track-caps);text-transform:uppercase;391color:var(--ink-faint);margin:0 0 18px;392}393.about{394position:relative;max-width:1080px;margin:0 auto;395padding:0 clamp(20px,5vw,48px);396display:grid;grid-template-columns:minmax(0,1fr) auto;gap:clamp(24px,5vw,60px);align-items:start;397}398.bio{font-size:clamp(17px,1.7vw,20px);line-height:1.74;letter-spacing:.005em;margin:0;font-weight:300;max-width:56ch}399.bio-link{color:var(--ink);text-decoration:underline;text-decoration-color:rgba(43,39,33,.28);400text-underline-offset:4px;transition:text-decoration-color .2s}401.bio-link:hover{text-decoration-color:var(--ink)}402.bloom{width:clamp(150px,17vw,260px);opacity:.9;user-select:none;align-self:center}403@media (max-width:760px){404.about{grid-template-columns:1fr}405.bloom{width:170px;justify-self:center}406}407408.plates{max-width:1080px;margin:0 auto;padding:0 clamp(20px,5vw,48px)}409.plate-list{list-style:none;margin:0;padding:0;border-top:1px solid var(--hairline)}410.plate{411display:grid;grid-template-columns:3.4em minmax(0,1fr) auto;gap:18px;align-items:baseline;412width:100%;padding:15px 4px;border:0;border-bottom:1px solid var(--hairline);413background:transparent;text-align:left;cursor:pointer;color:inherit;414transition:background-color .22s ease,padding-left .22s ease;415}416.plate:hover,.plate[aria-current="true"]{background:rgba(255,252,244,.5);padding-left:12px}417.plate .n{font-size:12px;color:var(--ink-faint);letter-spacing:var(--track-nav)}418.plate .t{font-family:var(--display);font-size:clamp(19px,2.1vw,26px)}419.plate .p{font-size:12.5px;color:var(--ink-faint);letter-spacing:.08em;text-transform:uppercase;text-align:right}420.plate[aria-current="true"] .p{color:var(--earth)}421422.foot{font-size:11.5px;letter-spacing:var(--track-caps);text-transform:uppercase;423color:var(--ink-faint);text-align:center;padding-bottom:44px}424</style>425</head>426<body>427<div class="wash" aria-hidden="true"></div>428<main class="page home">429430<header class="top">431<a class="name" href="#">Meng To</a>432<nav>433<a href="#plates">Journal</a>434<a href="#about">About</a>435<a href="#contact">Contact</a>436<div class="top-socials">437<a href="#" class="icon-btn" aria-label="X"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17.7 2.6h3.3l-7.2 8.2 8.5 11.2h-6.7l-5.2-6.9-6 6.9H1.1l7.7-8.8L.7 2.6h6.9l4.7 6.3 5.4-6.3Zm-1.2 17.5h1.8L7.6 4.4H5.7l10.8 15.7Z"/></svg></a>438<a href="#" class="icon-btn" aria-label="LinkedIn"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4.9 3.5a2.1 2.1 0 1 1 0 4.2 2.1 2.1 0 0 1 0-4.2ZM3.1 9.3h3.6v11.6H3.1V9.3Zm6 0h3.4v1.6h.05c.48-.9 1.65-1.85 3.4-1.85 3.63 0 4.3 2.35 4.3 5.4v6.45h-3.6v-5.72c0-1.36-.02-3.12-1.92-3.12-1.92 0-2.22 1.48-2.22 3.02v5.82H9.1V9.3Z"/></svg></a>439<a href="#" class="icon-btn" aria-label="Instagram"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" aria-hidden="true"><rect x="2.6" y="2.6" width="18.8" height="18.8" rx="5.4"/><circle cx="12" cy="12" r="4.4"/><circle cx="17.6" cy="6.4" r="1.15" fill="currentColor" stroke="none"/></svg></a>440<a href="#contact" class="icon-btn" aria-label="Email"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" aria-hidden="true"><rect x="2.4" y="4.6" width="19.2" height="14.8" rx="2.4"/><path d="m3.2 6.4 8.8 6.6 8.8-6.6"/></svg></a>441</div>442</nav>443</header>444445<section id="sketchbook" class="hero">446<img crossorigin="anonymous" class="botany l" src="https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/339abd2c649a11f725af9114/botany-left.png" alt="" aria-hidden="true">447<img crossorigin="anonymous" class="botany r" src="https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/339abd2c649a11f725af9114/botany-right.png" alt="" aria-hidden="true">448449<p class="hero-kicker">Designer / Creator / AI Educator / Founder @ Singapore</p>450451<div class="sb-wrap" id="sbWrap">452<svg width="0" height="0" style="position:absolute" aria-hidden="true">453<filter id="sb-mblur-1"><feGaussianBlur stdDeviation="5 0"/></filter>454<filter id="sb-mblur-2"><feGaussianBlur stdDeviation="14 0"/></filter>455</svg>456<div class="sb-stage" id="sbStage">457<button class="sb-arrow left" id="sbLeft" aria-label="previous page">458<svg viewBox="0 0 14 44" width="14" height="44" fill="none" aria-hidden="true"><polyline points="11,3 3,22 11,41" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"/></svg>459</button>460<div class="sb-3d" id="sb3d">461<div class="sb-tilt" id="sbTilt">462<div class="sb-cast ambient" aria-hidden="true"></div>463<div class="sb-cast contact" aria-hidden="true"></div>464<div class="sb-cast hair" aria-hidden="true"></div>465<div class="sb-book" id="sbBook"></div>466</div>467<div class="zoomwrap" id="zoomWrap" aria-hidden="true"><div class="zoominner" id="zoomInner"></div></div>468<div class="loupe" id="loupe"><span class="grip"></span><span class="ring"><span class="lens" id="loupeLens"><span class="mag" id="loupeMag"></span></span></span></div>469</div>470<button class="sb-arrow right" id="sbRight" aria-label="next page">471<svg viewBox="0 0 14 44" width="14" height="44" fill="none" aria-hidden="true"><polyline points="3,3 11,22 3,41" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"/></svg>472</button>473</div>474<div class="sb-captions" id="sbCaptions"></div>475<div class="sb-tools" role="group" aria-label="view controls">476<button class="tool" id="zOut" aria-label="zoom out"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><circle cx="8.6" cy="8.6" r="5.6"/><path d="M12.8 12.8 17.4 17.4M6.2 8.6h4.8"/></svg></button>477<span class="zoom-read" id="zRead">100%</span>478<button class="tool" id="zIn" aria-label="zoom in"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><circle cx="8.6" cy="8.6" r="5.6"/><path d="M12.8 12.8 17.4 17.4M6.2 8.6h4.8M8.6 6.2v4.8"/></svg></button>479<span class="tool-sep" aria-hidden="true"></span>480<button class="tool" id="loupeBtn" aria-label="magnifier" aria-pressed="true"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><circle cx="8.8" cy="8.8" r="5.8"/><path d="M13 13l4.4 4.4"/><path d="M6.4 7.2a3.2 3.2 0 0 1 2.4-1.4" opacity=".55"/></svg></button>481</div>482<p class="sb-hint" id="sbHint">Drag the page to turn · Drag the glass across it</p>483</div>484485<button class="hero-down" id="heroDown" aria-label="scroll to about">486<svg viewBox="0 0 44 22" width="34" height="17" fill="none" aria-hidden="true">487<polyline points="3,3 22,11 41,3" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"/>488<polyline points="3,11 22,19 41,11" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"/>489</svg>490</button>491</section>492493<div class="rule" aria-hidden="true"></div>494495<section id="about" class="about">496<div>497<p class="section-label">About</p>498<p class="bio">Meng To is a designer, creator, and AI educator based in Singapore. He is the founder of <a class="bio-link" href="#">Design+Code</a>, where for over a decade he has taught designers and developers to build real apps — from Sketch and Xcode through SwiftUI, and now the AI tools that let one person ship what used to take a team. His work lives on the seam between craft and code: teaching designers to build, and builders to see. This sketchbook is the other half of that — the city looked at slowly, in <a class="bio-link" href="#">ink and a little colour</a>: shophouse shutters, hawker tents, the bay at dusk.</p>499</div>500<img crossorigin="anonymous" class="bloom" src="https://ublctyddhtbgaersvxxb.supabase.co/storage/v1/object/public/threeui-media/scene-images/339abd2c649a11f725af9114/bloom.png" alt="" aria-hidden="true">501</section>502503<div class="rule short" aria-hidden="true"></div>504505<section id="plates" class="plates">506<p class="section-label">Plates</p>507<ol class="plate-list" id="plateList"></ol>508</section>509510<div class="rule short" aria-hidden="true"></div>511<p class="foot" id="contact">Singapore · Sketchbook · <a href="#" class="bio-link">hello@mengto.com</a></p>512</main>513514<script>515/* =====================================================================516Meng To — sketchbook hero.517Spreads are transparent PNGs of an open sketchbook generated with518Higgsfield. The leaf that turns is a real curved surface: a chain of519nested strips whose tangent sweeps through an arc, so the page bends520the way paper bends instead of pivoting like a flat door.521===================================================================== */522const Q=new URLSearchParams(location.search);523const DIR='meng-to-sketchbook/';524const PAGES=[525{file:'marina-bay-sands.png', title:'Marina Bay Sands', place:'Bayfront'},526{file:'gardens-by-the-bay.png', title:'Gardens by the Bay', place:'Supertree Grove'},527{file:'merlion.png', title:'The Merlion', place:'Merlion Park'},528{file:'buddha-tooth.png', title:'Buddha Tooth Relic Temple', place:'Chinatown'},529{file:'joo-chiat.png', title:'Joo Chiat Shophouses', place:'Katong'},530{file:'lau-pa-sat.png', title:'Lau Pa Sat', place:'Raffles Quay'},531{file:'marina-bay-skyline.png', title:'Marina Bay Skyline', place:'The Bay'},532{file:'singapore-river.png', title:'Singapore River', place:'Boat Quay'},533{file:'botanic-gardens.png', title:'Botanic Gardens', place:'Tanglin'}534];535PAGES.forEach(p=>p.url=DIR+p.file);536const M=PAGES.length, LAND=6;537538const wrap=document.getElementById('sbWrap');539const stage=document.getElementById('sbStage');540const sb3d=document.getElementById('sb3d');541const book=document.getElementById('sbBook');542const capBox=document.getElementById('sbCaptions');543const hint=document.getElementById('sbHint');544const REDUCED=matchMedia('(prefers-reduced-motion: reduce)').matches;545546/* ------------------------------------------------ the turning leaf */547const N=18; /* strips — enough for a smooth curve */548const SPAN=0.449; /* gutter → outer page edge, as a fraction */549const BETA=0.60; /* peak curl of the arc, radians */550let idx=0, turn=null; /* turn = {dir, from, to, t} */551let strips=[]; /* the chain, kept for per-frame lighting */552553function el(t,c){const e=document.createElement(t);if(c)e.className=c;return e}554function imgEl(i,side){555const im=new __threeuiStorageImage();im.className='sb-half-img '+side;556im.draggable=false;im.alt='';im.src=PAGES[i].url;return im;557}558559function halfEl(pos,i){560const d=el('div','sb-half '+pos);561d.appendChild(imgEl(i,pos));562d.appendChild(el('div','gutter-shade '+pos));563return d;564}565/* build the strip chain once per turn; background offsets are pure566geometry, so they never need touching again while it animates */567function buildCurl(dir,from,to){568strips=[];569const c=el('div','curl '+dir);570c.style.setProperty('--n',N);571c.style.setProperty('--span',SPAN);572let host=c;573for(let i=0;i<N;i++){574const s=el('div','strip');575s.style.setProperty('--i',i);576const gut='calc(var(--bw) * 0.5)';577const sw='calc(var(--bw) * '+SPAN+' / '+N+')';578const A='calc(-1 * ('+gut+' + '+i+' * '+sw+'))'; /* faces the from-page */579const B='calc('+(i+1)+' * '+sw+' - '+gut+')'; /* faces the to-page */580const f=el('div','face front'), b=el('div','face back');581const dress=(e,url,px)=>{582e.style.backgroundImage='url('+url+')';583e.style.backgroundPositionX=px;584};585dress(f,PAGES[from].url, dir==='next'?A:B);586dress(b,PAGES[to].url, dir==='next'?B:A);587f.appendChild(el('div','sh'));f.appendChild(el('div','gl'));588b.appendChild(el('div','sh'));b.appendChild(el('div','gl'));589s.appendChild(f);s.appendChild(b);590if(i===N-1)s.classList.add('edge');591host.appendChild(s);host=s;592strips.push(s);593}594return c;595}596function applyTurn(t){597const th=Math.PI*t; /* how far the leaf has swung */598const beta=BETA*Math.sin(Math.PI*t); /* it is flat at both ends */599const D=180/Math.PI;600const tt=th+beta, td=2*beta/N;601sb3d.style.setProperty('--tt',(tt*D).toFixed(2)+'deg');602sb3d.style.setProperty('--td',(td*D).toFixed(3)+'deg');603sb3d.style.setProperty('--shade',Math.sin(Math.PI*t).toFixed(3));604fadeCaption(t);605for(let i=0;i<strips.length;i++){606const l1=Math.abs(Math.cos(tt-i*td)); /* facing at this strip's near edge */607const l2=Math.abs(Math.cos(tt-(i+1)*td)); /* ...and at its far edge */608const st=strips[i].style;609st.setProperty('--lit',l1.toFixed(3));610st.setProperty('--a1',((1-l1)*.62).toFixed(3));611st.setProperty('--a2',((1-l2)*.62).toFixed(3));612}613}614function paint(){615book.textContent='';616if(!turn){617const f=el('div','sb-full');618const im=new __threeuiStorageImage();im.src=PAGES[idx].url;im.alt=PAGES[idx].title;619im.draggable=false;620f.appendChild(im);book.appendChild(f);621sb3d.style.setProperty('--shade','0');622}else{623const next=turn.dir==='next';624book.appendChild(halfEl('left', next?turn.from:turn.to));625book.appendChild(halfEl('right',next?turn.to:turn.from));626book.appendChild(buildCurl(turn.dir,turn.from,turn.to));627applyTurn(turn.t);628}629const a=el('button','sb-zone sb-prev'),b=el('button','sb-zone sb-next');630a.setAttribute('aria-label','previous page');b.setAttribute('aria-label','next page');631book.appendChild(a);book.appendChild(b);632layout();633caption();634marks();635if(typeof syncZoomLayer==='function')syncZoomLayer();636if(typeof placeLoupe==='function')placeLoupe();637}638function caption(){639capBox.textContent='';640capOut=capIn=null;641if(turn){642capOut=el('p','sb-caption live');capOut.textContent=PAGES[turn.from].title;capBox.appendChild(capOut);643capIn=el('p','sb-caption live');capIn.textContent=PAGES[turn.to].title;capBox.appendChild(capIn);644fadeCaption(turn.t);645}else{646const p=el('p','sb-caption');p.textContent=PAGES[idx].title;capBox.appendChild(p);647}648}649let capOut=null,capIn=null;650function fadeCaption(t){651if(!capOut||!capIn)return;652/* the old title is gone before the new one arrives, so they never653sit on top of each other mid-drag */654const out=1-Math.max(0,Math.min(1,(t-0.10)/0.28));655const inn=Math.max(0,Math.min(1,(t-0.56)/0.30));656capOut.style.opacity=out.toFixed(3);657capIn.style.opacity=inn.toFixed(3);658}659function layout(){660sb3d.style.setProperty('--bw',book.clientWidth+'px');661}662addEventListener('resize',layout);663664/* ------------------------------------------------------ spring loop */665let spring=null;666function animateTo(target,onDone,stiff,damp){667spring={kind:'spring',v:0,target:target,done:onDone,k:stiff||150,c:damp||22};668kick();669}670/* the riffle wants a fixed tempo, not a spring settling time */671function tweenTo(target,dur,onDone){672spring={kind:'tween',from:turn?turn.t:0,target:target,dur:dur,e:0,done:onDone};673kick();674}675let raf=null,last=0;676function tick(now){677raf=null;678const dt=Math.min(0.032,(now-last)/1000||0.016);last=now;679if(spring&&turn){680const s=spring;681if(s.kind==='tween'){682s.e+=dt;683const k=Math.min(1,s.e/s.dur);684turn.t=s.from+(s.target-s.from)*k;685applyTurn(turn.t);686if(k>=1){spring=null;const d=s.done;d&&d();}687}else{688const x=turn.t-s.target;689s.v+= (-s.k*x - s.c*s.v)*dt;690turn.t+=s.v*dt;691if(Math.abs(turn.t-s.target)<0.002&&Math.abs(s.v)<0.02){692turn.t=s.target;spring=null;693applyTurn(turn.t);694const d=s.done;d&&d();695}else applyTurn(turn.t);696}697}698viewSpring();699const lmoved=loupeEase();700/* kick() may already have queued the next frame from a done-callback */701if((spring||viewActive||lmoved)&&raf===null) raf=requestAnimationFrame(tick);702}703function kick(){ if(raf===null){last=performance.now();raf=requestAnimationFrame(tick);} }704705/* ------------------------------------------- tilt + zoom of the book */706const TILT_X=4.5, TILT_Y=7; /* degrees — deliberately restrained */707const ZOOM_MIN=0.9, ZOOM_MAX=1.5;708const view={rx:0,ry:0,z:1, trx:0,try_:0,tz:1};709let viewActive=false;710let lastZ=1;711function applyView(){712sb3d.style.setProperty('--rx',view.rx.toFixed(2)+'deg');713sb3d.style.setProperty('--ry',view.ry.toFixed(2)+'deg');714sb3d.style.setProperty('--zoom',view.z.toFixed(3));715/* the glass stays put, but the page under it has moved */716if(view.z!==lastZ){lastZ=view.z;if(typeof placeLoupe==='function')placeLoupe();}717}718function viewSpring(){719const e=0.14;720let moved=false;721for(const [k,t] of [['rx','trx'],['ry','try_'],['z','tz']]){722const d=view[t]-view[k];723if(Math.abs(d)>0.0006){view[k]+=d*e;moved=true;}724else view[k]=view[t];725}726if(moved)applyView();727viewActive=moved;728return moved;729}730function setView(rx,ry,z){731view.trx=Math.max(-TILT_X,Math.min(TILT_X,rx));732view.try_=Math.max(-TILT_Y,Math.min(TILT_Y,ry));733view.tz=Math.max(ZOOM_MIN,Math.min(ZOOM_MAX,z));734viewActive=true;kick();735if(typeof syncZoom==='function')syncZoom();736}737/* the book leans toward the cursor — no dragging, and never far */738function tiltTo(cx,cy){739if(drag)return; /* hold still while a page is being turned */740const r=book.getBoundingClientRect();741if(!r.width)return;742const nx=Math.max(-1,Math.min(1,(cx-(r.left+r.width/2))/(r.width*0.62)));743const ny=Math.max(-1,Math.min(1,(cy-(r.top+r.height/2))/(r.height*0.9)));744setView(-ny*TILT_X, nx*TILT_Y, view.tz);745}746addEventListener('pointermove',e=>{747if(e.pointerType==='touch')return;748tiltTo(e.clientX,e.clientY);749},{passive:true});750addEventListener('pointerout',e=>{if(!e.relatedTarget)setView(0,0,view.tz)});751addEventListener('blur',()=>setView(0,0,view.tz));752/* the wheel belongs to the page — zoom is on the toolbar, or a double click753to come back to 100% */754stage.addEventListener('dblclick',()=>setView(view.trx,view.try_,1));755756/* ------------------------------------------------------- pointer work */757let drag=null;758function bookRect(){return book.getBoundingClientRect()}759function hideHint(){hint.classList.add('gone')}760761stage.addEventListener('pointerdown',e=>{762if(e.button!==0)return;763e.preventDefault(); /* no text selection, no image drag */764const onBook=e.target.closest('.sb-zone');765stage.setPointerCapture(e.pointerId);766hideHint();767if(!onBook||introOn)return;768const r=bookRect();769const dir=(e.clientX-r.left)/r.width>0.5?'next':'prev';770startTurn(dir,0);771drag={dir:dir,x0:e.clientX,w:r.width,moved:0,vel:0,tPrev:performance.now()};772});773stage.addEventListener('pointermove',e=>{774if(!drag)return;775const dx=e.clientX-drag.x0;776drag.moved=Math.max(drag.moved,Math.abs(dx));777const raw=(drag.dir==='next'? -dx : dx)/(drag.w*0.62);778const t=Math.max(0,Math.min(1,raw));779const now=performance.now();780drag.vel=(t-(turn?turn.t:0))/Math.max(0.001,(now-drag.tPrev)/1000);781drag.tPrev=now;782if(turn){turn.t=t;applyTurn(t);}783});784function endDrag(e){785if(!drag)return;786const d=drag;drag=null;787if(!turn)return;788if(d.moved<6){ /* a tap, not a drag */789commit();return;790}791const go = turn.t>0.42 || d.vel>1.1;792if(go)commit(); else cancel();793}794stage.addEventListener('dragstart',e=>e.preventDefault());795stage.addEventListener('selectstart',e=>e.preventDefault());796stage.addEventListener('pointerup',endDrag);797stage.addEventListener('pointercancel',endDrag);798799/* ------------------------------------------------------ turn control */800function startTurn(dir,t){801spring=null;802if(turn){idx=turn.to;turn=null;} /* settle anything still in flight */803if(typeof shoveLoupe==='function')shoveLoupe(dir);804const from=idx;805turn={dir:dir,from:from,to:dir==='next'?(from+1)%M:(from-1+M)%M,t:t||0};806paint();807}808function commit(){809if(!turn)return;810if(REDUCED){idx=turn.to;turn=null;paint();return;}811animateTo(1,()=>{idx=turn.to;turn=null;paint();},170,26);812kick();813}814function cancel(){815if(!turn)return;816animateTo(0,()=>{turn=null;paint();},150,24);817kick();818}819function step(dir){820if(introOn)endIntro();821if(turn){ /* finish whatever is in flight first */ idx=turn.to;turn=null; }822startTurn(dir,0);commit();823}824function goTo(i){825if(introOn)endIntro();826if(i===idx)return;827if(turn){idx=turn.to;turn=null;}828const fwd=(i-idx+M)%M, back=(idx-i+M)%M;829if(Math.min(fwd,back)===1){step(fwd===1?'next':'prev');return;}830idx=i;paint();831}832document.getElementById('sbLeft').onclick=()=>step('prev');833document.getElementById('sbRight').onclick=()=>step('next');834addEventListener('keydown',e=>{835if(e.key!=='ArrowLeft'&&e.key!=='ArrowRight')return;836if(e.metaKey||e.ctrlKey||e.altKey)return;837const t=e.target;838if(t&&(t.tagName==='INPUT'||t.tagName==='TEXTAREA'||t.isContentEditable))return;839e.preventDefault();hideHint();840step(e.key==='ArrowRight'?'next':'prev');841});842document.getElementById('heroDown').onclick=()=>{843document.getElementById('about').scrollIntoView({behavior:'smooth',block:'start'});844};845846/* --------------------------------------------------- loupe + controls */847const loupe=document.getElementById('loupe');848const lens=document.getElementById('loupeLens');849const mag=document.getElementById('loupeMag');850const zRead=document.getElementById('zRead');851const loupeBtn=document.getElementById('loupeBtn');852const zInBtn=document.getElementById('zIn'), zOutBtn=document.getElementById('zOut');853const MAG=2.3;854const DESK=getComputedStyle(document.documentElement).getPropertyValue('--paper').trim()||'#ece7dc';855let loupeOn=true, lx=null, ly=null, lgrab=null, lTarget=null;856857function loupeSize(){return Math.round(Math.max(165,Math.min(262,book.clientWidth*0.235)));}858/* the loupe's own coordinate space: stage pixels in live mode (it sits859outside the book's transform), book pixels otherwise */860function bookBox(){861return {x:0,y:0,w:book.clientWidth,h:book.clientHeight};862}863/* park it on the desk at the lower right, half off the book */864function restLoupe(){865const b=bookBox();866lx=b.x+b.w*0.88; ly=b.y+b.h*0.855;867placeLoupe();868}869/* The glass sits above the tilt, in the book's untransformed pixels, so the870lean of the page never nudges it. What the tilt does change is which part871of the paper is under the glass, and only the scale matters enough to872correct for: the book is drawn about its own centre. */873const zoomWrap=document.getElementById('zoomWrap');874const zoomInner=document.getElementById('zoomInner');875/* mirror whatever the book is currently showing into the magnified copy */876function syncZoomLayer(){877zoomInner.textContent='';878for(const c of book.children){879if(c.classList.contains('sb-zone'))continue; /* hit targets need no copy */880zoomInner.appendChild(c.cloneNode(true));881}882}883function placeLoupe(){884if(lx===null)return;885const B=bookBox(), bw=B.w, bh=B.h;886if(!bw)return;887const R=loupeSize()/2, bez=R*2*0.058;888loupe.style.setProperty('--lr',R*2+'px');889loupe.style.transform='translate3d('+(lx-R).toFixed(1)+'px,'+(ly-R).toFixed(1)+'px,0)';890if(loupeOn)loupe.classList.add('on');891892/* where the paper's edges actually land once the book is scaled */893const z=view.z, cx=bw/2, cy=bh/2;894const x0=cx+(bw*.051-cx)*z, x1=cx+(bw*.949-cx)*z;895const y0=cy+(bh*.218-cy)*z, y1=cy+(bh*.782-cy)*z;896/* How far the glass's own centre is inside the paper. The copy fades out897as it wanders off the sheet, so you are left looking through plain898glass rather than at a sliver of page on flat desk. */899const nx=Math.max(x0,Math.min(lx,x1));900const ny=Math.max(y0,Math.min(ly,y1));901const inside=(lx>x0&&lx<x1&&ly>y0&&ly<y1)902? Math.min(lx-x0, x1-lx, ly-y0, y1-ly)903: -Math.hypot(lx-nx,ly-ny);904const k=Math.max(0,Math.min(1,(inside+R*0.30)/(R*0.55)));905906zoomWrap.style.opacity=(loupeOn?k:0).toFixed(3);907if(k<=0.002)return;908const r=(R-bez).toFixed(1);909const mask='radial-gradient(circle '+r+'px at '+lx.toFixed(1)+'px '+ly.toFixed(1)+'px,'910+'#000 calc(100% - 1px),transparent 100%)';911zoomWrap.style.webkitMaskImage=mask;912zoomWrap.style.maskImage=mask;913/* the page point beneath the glass, magnified about that same spot so the914lens keeps showing MAG times whatever is on screen */915const px=cx+(lx-cx)/z, py=cy+(ly-cy)/z, s=MAG*z;916zoomInner.style.transform='translate('+(lx-px*s).toFixed(1)+'px,'+(ly-py*s).toFixed(1)+'px) '917+'scale('+s.toFixed(4)+')';918}919/* the leaf shoves the glass aside as it sweeps past */920function shoveLoupe(dir){921if(!loupeOn||lx===null||lgrab)return;922const b=bookBox();923/* which page point the glass covers, once the book's scale is undone */924const nx=(b.w/2+(lx-b.x-b.w/2)/view.z)/b.w, ny=(b.h/2+(ly-b.y-b.h/2)/view.z)/b.h;925if(nx<0.02||nx>0.98||ny<0.17||ny>0.83)return; /* already clear of the page */926lTarget={x:b.x+b.w*(dir==='next'?0.12:0.88), y:b.y+b.h*0.855};927kick();928}929function loupeEase(){930if(!lTarget)return false;931if(lgrab){lTarget=null;return false;}932const dx=lTarget.x-lx, dy=lTarget.y-ly;933if(Math.abs(dx)<0.5&&Math.abs(dy)<0.5){lx=lTarget.x;ly=lTarget.y;lTarget=null;placeLoupe();return false;}934lx+=dx*0.17;ly+=dy*0.17;placeLoupe();935return true;936}937loupe.addEventListener('pointerdown',e=>{938if(!loupeOn||e.button!==0)return;939e.preventDefault();e.stopPropagation(); /* never starts a page turn */940lTarget=null;941lgrab={cx:e.clientX,cy:e.clientY,lx0:lx,ly0:ly};942loupe.classList.add('held');943loupe.setPointerCapture(e.pointerId);944hideHint();945});946loupe.addEventListener('pointermove',e=>{947if(!lgrab)return;948const b=bookBox(), R=loupeSize()/2;949/* the glass carries none of the book's transform, so the cursor maps 1:1 */950lx=Math.max(b.x-R*0.7,Math.min(b.x+b.w+R*0.7, lgrab.lx0+(e.clientX-lgrab.cx)));951ly=Math.max(b.y-R*0.7,Math.min(b.y+b.h+R*1.0, lgrab.ly0+(e.clientY-lgrab.cy)));952placeLoupe();953});954function dropLoupe(){lgrab=null;loupe.classList.remove('held');}955loupe.addEventListener('pointerup',dropLoupe);956loupe.addEventListener('pointercancel',dropLoupe);957loupeBtn.onclick=()=>{958loupeOn=!loupeOn;959loupeBtn.setAttribute('aria-pressed',String(loupeOn));960loupe.classList.toggle('on',loupeOn);961if(loupeOn&&lx===null)restLoupe();962};963addEventListener('resize',()=>{lx=null;restLoupe();});964965function syncZoom(){966zRead.textContent=Math.round(view.tz*100)+'%';967zOutBtn.disabled=view.tz<=ZOOM_MIN+0.001;968zInBtn.disabled=view.tz>=ZOOM_MAX-0.001;969}970zInBtn.onclick=()=>{setView(view.trx,view.try_,view.tz*1.16);hideHint();};971zOutBtn.onclick=()=>{setView(view.trx,view.try_,view.tz/1.16);hideHint();};972973/* --------------------------------------------------------- the index */974const plateList=document.getElementById('plateList');975PAGES.forEach((p,i)=>{976const li=el('li');977const b=el('button','plate');978b.innerHTML='<span class="n">'+String(i+1).padStart(2,'0')+'</span>'+979'<span class="t"></span><span class="p"></span>';980b.querySelector('.t').textContent=p.title;981b.querySelector('.p').textContent=p.place;982b.onclick=()=>{goTo(i);document.getElementById('sketchbook').scrollIntoView({behavior:'smooth',block:'center'});};983li.appendChild(b);plateList.appendChild(li);984});985function marks(){986const cur=turn?turn.to:idx;987plateList.querySelectorAll('.plate').forEach((b,i)=>b.setAttribute('aria-current',i===cur?'true':'false'));988}989990/* ---------------------------------------------------------- the riffle */991let riffle=null,riffleAt=0,introOn=false;992function endIntro(){993introOn=false;wrap.classList.remove('intro','b2');994}995function riffleStep(){996const s=riffle[riffleAt];997wrap.classList.toggle('b2',s.bell>0.55);998startTurn('next',0);999tweenTo(1,s.dur,()=>{1000idx=turn.to;turn=null;1001riffleAt++;1002if(introOn&&riffleAt<riffle.length){paint();riffleStep();}1003else{endIntro();paint();}1004});1005}1006function startIntro(){1007const coarse=matchMedia('(max-width: 640px), (pointer: coarse)').matches;1008if(coarse||REDUCED||Q.has('nointro')){idx=LAND;paint();return;}1009const steps=M+LAND;1010riffle=[];1011for(let r=0;r<steps;r++){1012const bell=Math.sin(Math.PI*(r/(steps-1)));1013riffle.push({bell:bell,dur:0.26-0.19*bell});1014}1015riffleAt=0;introOn=true;wrap.classList.add('intro');1016riffleStep();1017}10181019/* ------------------------------------------------------------- boot */1020(async function boot(){1021idx=Q.has('shot')?(parseInt(Q.get('shot'),10)||0)%M:0;1022paint();applyView();1023await Promise.all(PAGES.map(p=>{1024const im=new __threeuiStorageImage();im.src=p.url;1025return im.decode?im.decode().catch(()=>{}):new Promise(r=>{im.onload=im.onerror=r});1026}));1027if(document.fonts&&document.fonts.ready)await document.fonts.ready.catch(()=>{});1028syncZoom();restLoupe();1029document.body.dataset.ready='1';1030if(Q.has('shot')){1031if(Q.has('t')){startTurn(Q.get('dir')||'next',parseFloat(Q.get('t')));}1032return;1033}1034setTimeout(startIntro,220);1035})();1036</script>1037</body>1038</html>


