wizards 0.1.9
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 +110 -0
- package/README.md +170 -0
- package/apps/runtime/dist/agents/architect.js +453 -0
- package/apps/runtime/dist/agents/project-assistant.js +354 -0
- package/apps/runtime/dist/agents/subscription.js +206 -0
- package/apps/runtime/dist/agents/thought.js +21 -0
- package/apps/runtime/dist/agents/website.js +197 -0
- package/apps/runtime/dist/app.js +153 -0
- package/apps/runtime/dist/auth/account.js +121 -0
- package/apps/runtime/dist/auth/index.js +329 -0
- package/apps/runtime/dist/auth/keys.js +55 -0
- package/apps/runtime/dist/auth/local-ticket.js +23 -0
- package/apps/runtime/dist/authoring/example.js +73 -0
- package/apps/runtime/dist/authoring/guide.js +259 -0
- package/apps/runtime/dist/authoring/ops.js +117 -0
- package/apps/runtime/dist/cli/autostart.js +134 -0
- package/apps/runtime/dist/cli/clients.js +44 -0
- package/apps/runtime/dist/cli/environment.js +81 -0
- package/apps/runtime/dist/cli/exec.js +45 -0
- package/apps/runtime/dist/cli/home.js +74 -0
- package/apps/runtime/dist/cli/machine.js +145 -0
- package/apps/runtime/dist/cli/main.js +125 -0
- package/apps/runtime/dist/cli/setup.js +273 -0
- package/apps/runtime/dist/cli/start.js +190 -0
- package/apps/runtime/dist/cli/status.js +120 -0
- package/apps/runtime/dist/cli/ui.js +12 -0
- package/apps/runtime/dist/cli/update.js +58 -0
- package/apps/runtime/dist/connectors/builtin.js +70 -0
- package/apps/runtime/dist/connectors/external.js +400 -0
- package/apps/runtime/dist/connectors/gmail.js +107 -0
- package/apps/runtime/dist/connectors/imap.js +217 -0
- package/apps/runtime/dist/connectors/index.js +266 -0
- package/apps/runtime/dist/connectors/mail.js +72 -0
- package/apps/runtime/dist/connectors/outlook.js +90 -0
- package/apps/runtime/dist/credits/credits.js +103 -0
- package/apps/runtime/dist/credits/estimate.js +132 -0
- package/apps/runtime/dist/db/adopt.js +149 -0
- package/apps/runtime/dist/db/client.js +146 -0
- package/apps/runtime/dist/db/control-schema.js +70 -0
- package/apps/runtime/dist/db/migrations/control/0000_last_absorbing_man.sql +47 -0
- package/apps/runtime/dist/db/migrations/control/0001_gorgeous_nicolaos.sql +41 -0
- package/apps/runtime/dist/db/migrations/control/0002_secret_penance.sql +1 -0
- package/apps/runtime/dist/db/migrations/control/0003_nasty_mordo.sql +3 -0
- package/apps/runtime/dist/db/migrations/control/0004_breezy_eddie_brock.sql +6 -0
- package/apps/runtime/dist/db/migrations/control/meta/0000_snapshot.json +311 -0
- package/apps/runtime/dist/db/migrations/control/meta/0001_snapshot.json +599 -0
- package/apps/runtime/dist/db/migrations/control/meta/0002_snapshot.json +607 -0
- package/apps/runtime/dist/db/migrations/control/meta/0003_snapshot.json +311 -0
- package/apps/runtime/dist/db/migrations/control/meta/0004_snapshot.json +350 -0
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +41 -0
- package/apps/runtime/dist/db/migrations/tenant/0000_eminent_freak.sql +188 -0
- package/apps/runtime/dist/db/migrations/tenant/0001_salty_master_chief.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0002_cloudy_firebird.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0003_brown_warbound.sql +52 -0
- package/apps/runtime/dist/db/migrations/tenant/0004_romantic_nocturne.sql +6 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0000_snapshot.json +1323 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0001_snapshot.json +1330 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0002_snapshot.json +1337 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0003_snapshot.json +1605 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0004_snapshot.json +1645 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +41 -0
- package/apps/runtime/dist/db/schema.js +278 -0
- package/apps/runtime/dist/documents/parse.js +230 -0
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +193 -0
- package/apps/runtime/dist/engenty/connections-external/errors.js +11 -0
- package/apps/runtime/dist/engenty/connections-external/import-service.js +270 -0
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +34 -0
- package/apps/runtime/dist/engenty/connections-external/importer/map-auth.js +185 -0
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-mcp.js +63 -0
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-openapi.js +130 -0
- package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +143 -0
- package/apps/runtime/dist/engenty/connections-external/invoke/mcp-client.js +143 -0
- package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +119 -0
- package/apps/runtime/dist/engenty/connections-external/oauth-dcr.js +88 -0
- package/apps/runtime/dist/engenty/connections-external/registry-client.js +336 -0
- package/apps/runtime/dist/engenty/connections-external/registry-source.js +82 -0
- package/apps/runtime/dist/engenty/connections-external/types.js +7 -0
- package/apps/runtime/dist/engenty/connections-github/connector.js +209 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/calendar.js +359 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/contacts.js +94 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +290 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +567 -0
- package/apps/runtime/dist/engenty/connections-google/definitions.js +11 -0
- package/apps/runtime/dist/engenty/connections-google/shared.js +73 -0
- package/apps/runtime/dist/engenty/connections-hubspot/connector.js +140 -0
- package/apps/runtime/dist/engenty/connections-microsoft/action.js +17 -0
- package/apps/runtime/dist/engenty/connections-microsoft/graph.js +114 -0
- package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +286 -0
- package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +464 -0
- package/apps/runtime/dist/engenty/connections-s3/s3.js +328 -0
- package/apps/runtime/dist/engenty/connections-sdk/files-capability.js +86 -0
- package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +150 -0
- package/apps/runtime/dist/engenty/connections-sdk/registry.js +89 -0
- package/apps/runtime/dist/engenty/connections-sdk/storage-capability.js +84 -0
- package/apps/runtime/dist/engenty/connections-sdk/types.js +30 -0
- package/apps/runtime/dist/engenty/connections-slack/connector.js +360 -0
- package/apps/runtime/dist/engenty/csv-import/csv-matrix.js +178 -0
- package/apps/runtime/dist/engenty/csv-import/import-sources.js +87 -0
- package/apps/runtime/dist/engenty/csv-import/parse-csv.js +129 -0
- package/apps/runtime/dist/engenty/csv-import/serialize-csv.js +20 -0
- package/apps/runtime/dist/engenty/csv-import/types.js +1 -0
- package/apps/runtime/dist/engenty/csv-import/xlsx-workbook.js +159 -0
- package/apps/runtime/dist/engenty/doc-converter/interface.js +9 -0
- package/apps/runtime/dist/engenty/doc-converter/page-break.js +92 -0
- package/apps/runtime/dist/engenty/doc-converter/providers/local/index.js +72 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/classifier.js +30 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/index.js +4 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/invoice.js +73 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/receipt.js +63 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/shared.js +40 -0
- package/apps/runtime/dist/engenty/search-index/chunks.js +164 -0
- package/apps/runtime/dist/engenty/search-index/contracts.js +9 -0
- package/apps/runtime/dist/engenty/shims/connections-sdk.js +39 -0
- package/apps/runtime/dist/engenty/shims/plugin-sdk.js +1 -0
- package/apps/runtime/dist/engenty/shims/web-ingest.js +3 -0
- package/apps/runtime/dist/engenty/web-ingest/ssrf.js +277 -0
- package/apps/runtime/dist/engine/asks.js +60 -0
- package/apps/runtime/dist/engine/events.js +46 -0
- package/apps/runtime/dist/engine/input.js +170 -0
- package/apps/runtime/dist/engine/prepare.js +51 -0
- package/apps/runtime/dist/engine/requirements.js +124 -0
- package/apps/runtime/dist/engine/resources.js +89 -0
- package/apps/runtime/dist/engine/runner.js +560 -0
- package/apps/runtime/dist/engine/steps.js +598 -0
- package/apps/runtime/dist/engine/template.js +183 -0
- package/apps/runtime/dist/engine/types.js +3 -0
- package/apps/runtime/dist/env.js +224 -0
- package/apps/runtime/dist/files/blobs.js +22 -0
- package/apps/runtime/dist/files/objects.js +86 -0
- package/apps/runtime/dist/files/storage.js +95 -0
- package/apps/runtime/dist/geocode.js +58 -0
- package/apps/runtime/dist/harness/claude.js +138 -0
- package/apps/runtime/dist/harness/codex.js +228 -0
- package/apps/runtime/dist/harness/cursor.js +93 -0
- package/apps/runtime/dist/harness/env.js +124 -0
- package/apps/runtime/dist/harness/gemini.js +126 -0
- package/apps/runtime/dist/harness/index.js +99 -0
- package/apps/runtime/dist/harness/model.js +267 -0
- package/apps/runtime/dist/harness/prompt.js +121 -0
- package/apps/runtime/dist/harness/terminal.js +193 -0
- package/apps/runtime/dist/harness/types.js +7 -0
- package/apps/runtime/dist/index.js +76 -0
- package/apps/runtime/dist/limits.js +57 -0
- package/apps/runtime/dist/link-preview.js +59 -0
- package/apps/runtime/dist/manage.js +151 -0
- package/apps/runtime/dist/mcp/auth.js +102 -0
- package/apps/runtime/dist/mcp/bridge.js +59 -0
- package/apps/runtime/dist/mcp/handler.js +42 -0
- package/apps/runtime/dist/mcp/scopes.js +5 -0
- package/apps/runtime/dist/mcp/tools.js +401 -0
- package/apps/runtime/dist/media/ffmpeg.js +121 -0
- package/apps/runtime/dist/media/generate.js +120 -0
- package/apps/runtime/dist/media/marking.js +121 -0
- package/apps/runtime/dist/media/transcribe.js +30 -0
- package/apps/runtime/dist/model-errors.js +3 -0
- package/apps/runtime/dist/models.js +489 -0
- package/apps/runtime/dist/plugin.js +61 -0
- package/apps/runtime/dist/render/chromium.js +85 -0
- package/apps/runtime/dist/render/convert.js +161 -0
- package/apps/runtime/dist/render/downloads.js +277 -0
- package/apps/runtime/dist/render/guard.js +25 -0
- package/apps/runtime/dist/routes/api.js +74 -0
- package/apps/runtime/dist/routes/delivery.js +52 -0
- package/apps/runtime/dist/routes/internal.js +49 -0
- package/apps/runtime/dist/routes/marketplace.js +36 -0
- package/apps/runtime/dist/routes/runs.js +805 -0
- package/apps/runtime/dist/routes/studio.js +702 -0
- package/apps/runtime/dist/routes/wizard-stream.js +30 -0
- package/apps/runtime/dist/running.js +39 -0
- package/apps/runtime/dist/sandbox/agentos.js +191 -0
- package/apps/runtime/dist/sandbox/docker.js +77 -0
- package/apps/runtime/dist/sandbox/index.js +30 -0
- package/apps/runtime/dist/sandbox/types.js +1 -0
- package/apps/runtime/dist/secrets/crypto.js +28 -0
- package/apps/runtime/dist/secrets/signing.js +34 -0
- package/apps/runtime/dist/secrets/vault.js +59 -0
- package/apps/runtime/dist/services/architect.js +92 -0
- package/apps/runtime/dist/services/brand.js +20 -0
- package/apps/runtime/dist/services/cloud.js +52 -0
- package/apps/runtime/dist/services/draft-events.js +27 -0
- package/apps/runtime/dist/services/errors.js +24 -0
- package/apps/runtime/dist/services/files.js +129 -0
- package/apps/runtime/dist/services/links.js +16 -0
- package/apps/runtime/dist/services/marketplace.js +292 -0
- package/apps/runtime/dist/services/package.js +202 -0
- package/apps/runtime/dist/services/profile.js +23 -0
- package/apps/runtime/dist/services/project-files.js +266 -0
- package/apps/runtime/dist/services/project-index.js +109 -0
- package/apps/runtime/dist/services/projects.js +181 -0
- package/apps/runtime/dist/services/runs.js +224 -0
- package/apps/runtime/dist/services/shares.js +129 -0
- package/apps/runtime/dist/services/widgets.js +34 -0
- package/apps/runtime/dist/services/wizards.js +342 -0
- package/apps/runtime/dist/settings.js +16 -0
- package/apps/runtime/dist/store/index.js +279 -0
- package/apps/runtime/dist/tenants/control.js +106 -0
- package/apps/runtime/dist/tenants/tenant.js +26 -0
- package/apps/runtime/dist/tools/browser.js +380 -0
- package/apps/runtime/dist/tools/connector.js +204 -0
- package/apps/runtime/dist/tools/index.js +234 -0
- package/apps/runtime/dist/tools/mail.js +104 -0
- package/apps/runtime/dist/tools/net-guard.js +59 -0
- package/apps/runtime/dist/tools/project.js +53 -0
- package/apps/runtime/dist/tools/shared.js +42 -0
- package/apps/runtime/dist/tools/store.js +238 -0
- package/apps/runtime/dist/update.js +118 -0
- package/apps/runtime/dist/widgets/bundle.js +99 -0
- package/apps/runtime/dist/widgets/render.js +312 -0
- package/apps/runtime/dist/widgets/runtime.js +84 -0
- package/apps/runtime/dist/widgets/script.js +30 -0
- package/apps/runtime/dist/widgets/step.js +192 -0
- package/apps/web/dist/ai-labels/ai-black.svg +20 -0
- package/apps/web/dist/ai-labels/ai-generated-black.svg +31 -0
- package/apps/web/dist/ai-labels/ai-generated-white.svg +32 -0
- package/apps/web/dist/ai-labels/ai-modified-black.svg +30 -0
- package/apps/web/dist/ai-labels/ai-modified-white.svg +31 -0
- package/apps/web/dist/ai-labels/ai-white.svg +21 -0
- package/apps/web/dist/assets/ChangelogDialog-O00vEnbm.js +1 -0
- package/apps/web/dist/assets/ChatPanel-CH9ry0Hp.js +1 -0
- package/apps/web/dist/assets/CreditsDialog-DRzecwUw.js +1 -0
- package/apps/web/dist/assets/EditorPage-BRnBf02Q.js +2 -0
- package/apps/web/dist/assets/FlowPreview-DDOj8IAH.js +1 -0
- package/apps/web/dist/assets/HomePage-CAGTTG3N.js +1 -0
- package/apps/web/dist/assets/ImportWizard-0RRrAnX3.js +1 -0
- package/apps/web/dist/assets/LocalRuntime-BrP-ENHg.css +1 -0
- package/apps/web/dist/assets/LocalRuntime-C-TBYrzs.js +16 -0
- package/apps/web/dist/assets/NewWizardPage-kI90h3_9.js +2 -0
- package/apps/web/dist/assets/PublicRunner-CKRDeIVd.js +1 -0
- package/apps/web/dist/assets/RunnerView-Rc4H8wYH.js +2 -0
- package/apps/web/dist/assets/SettingsPage-CESMuZxq.js +2 -0
- package/apps/web/dist/assets/SetupPage-D1rrYU14.js +1 -0
- package/apps/web/dist/assets/SharePage-COTAmOgh.js +1 -0
- package/apps/web/dist/assets/api-BY28cjGY.js +10 -0
- package/apps/web/dist/assets/arrow-left-UpjOBfQp.js +1 -0
- package/apps/web/dist/assets/arrow-right-CucQycEy.js +1 -0
- package/apps/web/dist/assets/changelog-p3wsaDDS.js +1 -0
- package/apps/web/dist/assets/check-Bjx41xbB.js +1 -0
- package/apps/web/dist/assets/createLucideIcon-DBu2Ovxj.js +1 -0
- package/apps/web/dist/assets/definition-cy7uvY5L.js +55 -0
- package/apps/web/dist/assets/engenty-CWIFpgKq.js +1 -0
- package/apps/web/dist/assets/esm-D1OEhjTK.js +7 -0
- package/apps/web/dist/assets/external-link-CRg6DVdO.js +1 -0
- package/apps/web/dist/assets/fluffy-engenty-CJ3wCQgT.js +456 -0
- package/apps/web/dist/assets/index-CQ_q9iMO.css +1 -0
- package/apps/web/dist/assets/index-D0gxh90t.js +10 -0
- package/apps/web/dist/assets/jsx-runtime-Dk72oS4N.js +1 -0
- package/apps/web/dist/assets/meta-BbSdtTUa.js +1 -0
- package/apps/web/dist/assets/mic-CeqQ89Dj.js +1 -0
- package/apps/web/dist/assets/oss-credits-cPuZUFHD.js +1 -0
- package/apps/web/dist/assets/outputs-D6pxH6ve.js +69 -0
- package/apps/web/dist/assets/plus-HA210wXA.js +1 -0
- package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +1 -0
- package/apps/web/dist/assets/qr-scanner-worker.min-CJaXo3yu.js +98 -0
- package/apps/web/dist/assets/qr-scanner.min-C_UI0gH-.js +1 -0
- package/apps/web/dist/assets/type-BzYgVWKL.js +1 -0
- package/apps/web/dist/assets/ui-Ddwl35A6.js +1 -0
- package/apps/web/dist/assets/upload-DsgLfQ3U.js +1 -0
- package/apps/web/dist/assets/video-Dk1fuTDl.js +1 -0
- package/apps/web/dist/assets/wand-sparkles-Bf97fs8T.js +1 -0
- package/apps/web/dist/embed.js +102 -0
- package/apps/web/dist/favicon.svg +1 -0
- package/apps/web/dist/icons/apple-touch-icon.png +0 -0
- package/apps/web/dist/icons/icon-192.png +0 -0
- package/apps/web/dist/icons/icon-512.png +0 -0
- package/apps/web/dist/icons/icon-maskable-512.png +0 -0
- package/apps/web/dist/index.html +46 -0
- package/apps/web/dist/install.sh +532 -0
- package/apps/web/dist/manifest.webmanifest +20 -0
- package/apps/web/dist/sw.js +15 -0
- package/bin/wizards.mjs +13 -0
- package/node_modules/@engenty-wizards/shared/dist/connectors.d.ts +77 -0
- package/node_modules/@engenty-wizards/shared/dist/connectors.js +2 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +1415 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.js +762 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.d.ts +5 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.js +132 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.d.ts +11 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.js +209 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.d.ts +532 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.js +216 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.d.ts +3 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.js +3 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.d.ts +14 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.js +166 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.d.ts +33 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.js +99 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.d.ts +35 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +86 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.d.ts +20 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +133 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +298 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace.js +211 -0
- package/node_modules/@engenty-wizards/shared/dist/merge.d.ts +7 -0
- package/node_modules/@engenty-wizards/shared/dist/merge.js +40 -0
- package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +74 -0
- package/node_modules/@engenty-wizards/shared/dist/projects.js +96 -0
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +219 -0
- package/node_modules/@engenty-wizards/shared/dist/run.js +1 -0
- package/node_modules/@engenty-wizards/shared/dist/store.d.ts +100 -0
- package/node_modules/@engenty-wizards/shared/dist/store.js +44 -0
- package/node_modules/@engenty-wizards/shared/dist/workspace.d.ts +16 -0
- package/node_modules/@engenty-wizards/shared/dist/workspace.js +51 -0
- package/node_modules/@engenty-wizards/shared/package.json +10 -0
- package/package.json +62 -0
- package/plugin/.claude-plugin/plugin.json +9 -0
- package/plugin/.mcp.json +8 -0
- package/plugin/commands/wizard.md +8 -0
- package/plugin/skills/build-wizard/SKILL.md +27 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import{i as e,n as t,t as n}from"./jsx-runtime-Dk72oS4N.js";import{a as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./engenty-CWIFpgKq.js";var f=e(t(),1),p=new Map,m=null,h=new WeakMap;function g(e){let t=p.get(e);if(t)return t;if(!m){let e=document.createElement(`canvas`);e.width=1,e.height=1,m=e.getContext(`2d`,{willReadFrequently:!0})}let n=[.5,.5,.5];if(m){m.clearRect(0,0,1,1),m.fillStyle=`#808080`,m.fillStyle=e,m.fillRect(0,0,1,1);let[t,r,i]=m.getImageData(0,0,1,1).data;n=[t/255,r/255,i/255]}return p.set(e,n),n}function _(e,t){let n=h.get(e);return n||(n=document.createElement(`span`),n.setAttribute(`aria-hidden`,`true`),n.style.cssText=`position:absolute;width:0;height:0;overflow:hidden;visibility:hidden`,e.appendChild(n),h.set(e,n)),n.style.color=``,n.style.color=t,g(getComputedStyle(n).color||`#808080`)}var v=(e,t,n)=>[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n];function ee(e,t){let n=_(e,a[d[t]]),r=Math.max(...n),i=[Math.min(1,n[0]+n[0]/(r||1)*.45),Math.min(1,n[1]+n[1]/(r||1)*.45),Math.min(1,n[2]+n[2]/(r||1)*.45)];return{body:v(n,[1,1,1],.12),deep:v(n,[.03,.02,.06],.62),tip:v(i,[1,1,1],.12)}}var y=`#version 300 es
|
|
2
|
+
precision highp float;
|
|
3
|
+
#define BLOBS ${c}
|
|
4
|
+
#define EXTRAS ${i}
|
|
5
|
+
#define VIEW ${152 .toFixed(1)}
|
|
6
|
+
#define ORIGIN ${(-16).toFixed(1)}
|
|
7
|
+
#define TAU 6.2831853
|
|
8
|
+
uniform vec2 uResolution;
|
|
9
|
+
uniform float uTime;
|
|
10
|
+
uniform vec4 uBlobs[BLOBS];
|
|
11
|
+
uniform float uFalloff;
|
|
12
|
+
uniform float uScale;
|
|
13
|
+
uniform float uFur;
|
|
14
|
+
uniform float uPeriod;
|
|
15
|
+
uniform float uInflate;
|
|
16
|
+
uniform float uDensity;
|
|
17
|
+
uniform float uThick;
|
|
18
|
+
uniform vec2 uLean;
|
|
19
|
+
uniform vec2 uTurn;
|
|
20
|
+
uniform float uGoggles;
|
|
21
|
+
uniform vec3 uLight;
|
|
22
|
+
uniform vec3 uBody;
|
|
23
|
+
uniform vec3 uDeep;
|
|
24
|
+
uniform vec3 uTip;
|
|
25
|
+
uniform vec3 uEye;
|
|
26
|
+
uniform float uWind;
|
|
27
|
+
uniform vec2 uGaze;
|
|
28
|
+
uniform vec4 uExtras[EXTRAS];
|
|
29
|
+
uniform vec4 uExtraMeta[EXTRAS];
|
|
30
|
+
uniform vec2 uWobble;
|
|
31
|
+
uniform float uClarity;
|
|
32
|
+
uniform float uSoftness;
|
|
33
|
+
uniform vec4 uPull;
|
|
34
|
+
#ifdef JELLY_COAT
|
|
35
|
+
|
|
36
|
+
vec3 deformJelly(vec3 p) {
|
|
37
|
+
vec3 q=p-vec3(60.0,60.0,0.0);
|
|
38
|
+
vec3 local=q/max(uScale,1.0);
|
|
39
|
+
float softness=clamp(uSoftness,0.0,1.5);
|
|
40
|
+
float phase=TAU*uTime/uPeriod;
|
|
41
|
+
vec2 lag=clamp(uWobble,vec2(-7.0),vec2(7.0));
|
|
42
|
+
float squash=softness*(sin(phase)*0.08+sin(phase*1.7)*0.012+lag.y*0.012);
|
|
43
|
+
q.xz*=inversesqrt(1.0+squash);
|
|
44
|
+
q.y*=1.0+squash;
|
|
45
|
+
float top=clamp(1.0-p.y/125.0,0.0,1.0);
|
|
46
|
+
q.x+=softness*(lag.x*1.15*top*top+sin(phase*0.8+local.y*2.5)*0.8);
|
|
47
|
+
float wave=sin(local.x*3.1+uTime*1.15)*sin(local.y*2.7-uTime*0.85)*sin(local.z*2.6+uTime*0.65);
|
|
48
|
+
vec3 d1=local-vec3(-0.42,-0.32,0.72);
|
|
49
|
+
vec3 d2=local-vec3(0.45,0.46,0.7);
|
|
50
|
+
float dents=-3.2*exp(-dot(d1,d1)*8.0)-2.1*exp(-dot(d2,d2)*9.0);
|
|
51
|
+
float face=1.0-0.8*exp(-dot(p.xy-uEye.xy,p.xy-uEye.xy)/(uEye.z*uEye.z*3.0));
|
|
52
|
+
q+=normalize(local+vec3(0.0,0.001,0.0))*softness*face*(wave*3.2+dents);
|
|
53
|
+
vec2 grab=(p.xy-uPull.xy)/max(uScale*0.65,1.0);
|
|
54
|
+
float influence=exp(-dot(grab,grab)*2.0)*smoothstep(-0.2,0.65,local.z);
|
|
55
|
+
q.xy+=uPull.zw*softness*influence;
|
|
56
|
+
q.z-=length(uPull.zw)*softness*influence*0.15;
|
|
57
|
+
return q+vec3(60.0,60.0,0.0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#endif
|
|
61
|
+
vec2 eyeCentre() { return uEye.xy; }
|
|
62
|
+
float bodyK(vec2 p) {
|
|
63
|
+
float sum=0.0;
|
|
64
|
+
for(int i=0;i<BLOBS;i++){
|
|
65
|
+
vec4 b=uBlobs[i];if(b.z<=0.0)continue;
|
|
66
|
+
vec2 q=(p-b.xy)/b.zw;sum+=exp(-uFalloff*dot(q,q));
|
|
67
|
+
}
|
|
68
|
+
return sqrt(max(0.0,-log(max(sum,1e-8))/uFalloff));
|
|
69
|
+
}
|
|
70
|
+
float sdBody(vec2 p){return (bodyK(p)-1.0)*uScale;}
|
|
71
|
+
vec3 rotateCoat(vec3 p) {
|
|
72
|
+
vec3 q=vec3(p.x,cos(uTurn.y)*p.y-sin(uTurn.y)*p.z,sin(uTurn.y)*p.y+cos(uTurn.y)*p.z);
|
|
73
|
+
return vec3(cos(uTurn.x)*q.x+sin(uTurn.x)*q.z,q.y,-sin(uTurn.x)*q.x+cos(uTurn.x)*q.z);
|
|
74
|
+
}
|
|
75
|
+
vec3 bodyStretch(){float s=sin(TAU*uTime/uPeriod)*0.018;return vec3(1.0+s,1.0-s,1.0/(1.0-s*s));}
|
|
76
|
+
vec3 poseCoat(vec3 p) {
|
|
77
|
+
float w=TAU*uTime/uPeriod;
|
|
78
|
+
#ifdef JELLY_COAT
|
|
79
|
+
p=deformJelly(p);
|
|
80
|
+
#endif
|
|
81
|
+
vec3 q=(p-vec3(60.0,60.0,0.0))*bodyStretch();
|
|
82
|
+
q.xy+=uLean*(1.15-p.y/120.0)*0.3;
|
|
83
|
+
|
|
84
|
+
q=rotateCoat(q);
|
|
85
|
+
q.xy+=vec2(60.0+sin(w)*1.5,60.0+cos(w*0.8)*1.1);
|
|
86
|
+
return q;
|
|
87
|
+
}
|
|
88
|
+
vec3 poseNormal(vec3 p,vec3 normal){
|
|
89
|
+
#ifdef JELLY_COAT
|
|
90
|
+
vec3 tangent=normalize(cross(normal,abs(normal.y)>0.9?vec3(1.0,0.0,0.0):vec3(0.0,1.0,0.0)));
|
|
91
|
+
vec3 bitangent=cross(normal,tangent);
|
|
92
|
+
vec3 t=poseCoat(p+tangent*0.12)-poseCoat(p-tangent*0.12);
|
|
93
|
+
vec3 b=poseCoat(p+bitangent*0.12)-poseCoat(p-bitangent*0.12);
|
|
94
|
+
return normalize(cross(t,b));
|
|
95
|
+
#else
|
|
96
|
+
return rotateCoat(normalize(normal/bodyStretch()));
|
|
97
|
+
#endif
|
|
98
|
+
}
|
|
99
|
+
float coatZoom(){
|
|
100
|
+
float extent=0.0;
|
|
101
|
+
for(int i=0;i<BLOBS;i++){
|
|
102
|
+
vec4 b=uBlobs[i];if(b.z<=0.0)continue;
|
|
103
|
+
extent=max(extent,max(max(abs(b.x-60.0)+b.z,abs(b.y-60.0)+b.w),b.z*uInflate/30.0));
|
|
104
|
+
}
|
|
105
|
+
return min(1.0,65.0/(extent+uFur*1.2+3.0));
|
|
106
|
+
}
|
|
107
|
+
vec4 projectCoat(vec3 p){
|
|
108
|
+
float zoom=coatZoom();
|
|
109
|
+
vec2 screen=(p.xy-60.0)*zoom+60.0;
|
|
110
|
+
return vec4((screen.x-ORIGIN)/VIEW*2.0-1.0,1.0-(screen.y-ORIGIN)/VIEW*2.0,-p.z*zoom/150.0,1.0);
|
|
111
|
+
}
|
|
112
|
+
float sdArc(vec2 q,float r,float span){float a=clamp(atan(q.x,-q.y),-span,span);return length(q-vec2(sin(a),-cos(a))*r);}
|
|
113
|
+
vec4 extrasOver(vec2 p,vec3 ink,vec3 bodyCol,float aa){
|
|
114
|
+
vec4 acc=vec4(0.0);
|
|
115
|
+
for(int i=0;i<EXTRAS;i++){
|
|
116
|
+
vec4 m=uExtraMeta[i],g=uExtras[i];int kind=int(m.x+0.5);
|
|
117
|
+
if(kind==0||kind==2||(kind==3&&m.w>0.5))continue;
|
|
118
|
+
vec2 q=p-g.xy;float distance=1000.0,hw=m.z*0.5;
|
|
119
|
+
if(kind==1){distance=length(q)-g.z;hw=0.0;}
|
|
120
|
+
else if(kind==3)distance=sdArc(q,g.z,g.w);
|
|
121
|
+
else if(kind==4)distance=length(vec2(q.x,max(abs(q.y)-g.z,0.0)));
|
|
122
|
+
else if(kind==5){float x=clamp(q.x,0.0,g.z);distance=length(q-vec2(x,-g.w*sin(TAU*x/g.z)));}
|
|
123
|
+
float a=(1.0-smoothstep(hw-aa,hw+aa,distance))*m.y;
|
|
124
|
+
vec3 color=mix(ink,bodyCol*0.45,0.2);
|
|
125
|
+
acc=vec4(color*a,a)+acc*(1.0-a);
|
|
126
|
+
}
|
|
127
|
+
return acc;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
vec4 gogglesOver(vec2 p, float aa, float front) {
|
|
131
|
+
if (uGoggles < 0.5) return vec4(0.0);
|
|
132
|
+
vec2 q = p - eyeCentre();
|
|
133
|
+
float er = uEye.z * 1.35;
|
|
134
|
+
float d = length(q);
|
|
135
|
+
float outer = er * 1.27;
|
|
136
|
+
float bandY = q.y + 1.7 * pow(q.x / max(uScale, 1.0), 2.0);
|
|
137
|
+
float band = 1.0 - smoothstep(uEye.z * 0.31 - aa, uEye.z * 0.31 + aa, abs(bandY));
|
|
138
|
+
// Taper into the surface; fine irregular coverage lets fur cover the strap ends.
|
|
139
|
+
float skin = -sdBody(p);
|
|
140
|
+
float grain = sin(p.x * 7.3 + sin(p.y * 4.1)) * 0.6;
|
|
141
|
+
float tuck = smoothstep(0.5, 6.0, skin + grain);
|
|
142
|
+
band *= tuck * mix(1.0, smoothstep(outer - aa, outer + aa, d), front);
|
|
143
|
+
float curve = clamp(skin / max(uScale, 1.0), 0.0, 1.0);
|
|
144
|
+
vec3 leather = mix(vec3(0.12, 0.055, 0.025), vec3(0.43, 0.24, 0.1), curve);
|
|
145
|
+
float seam = 1.0 - smoothstep(0.12, 0.35, abs(abs(bandY) - uEye.z * 0.22));
|
|
146
|
+
leather += vec3(0.11, 0.065, 0.025) * seam * step(0.4, fract(p.x * 0.65));
|
|
147
|
+
vec4 acc = vec4(leather * band, band);
|
|
148
|
+
return acc;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
`;function b(e){let t=[];for(let n=0;n<e.extraMeta.length/4;n++){let[r,,i,a]=e.extraMeta.slice(n*4,n*4+4);if(r!==2&&!(r===3&&a>.5))continue;let[o,s,c,l]=e.extras.slice(n*4,n*4+4),u=r===2?16:32,d=(e,t)=>{let a=e/u*(r===2?Math.PI:l*2)-(r===2?0:l),d=t/16*Math.PI*2,f=r===2?[Math.sin(a)*Math.cos(d),-Math.cos(a),Math.sin(a)*Math.sin(d)]:[Math.sin(a)*Math.cos(d),-Math.cos(a)*Math.cos(d),Math.sin(d)],p=r===2?[o,s,0]:[o+Math.sin(a)*c,s-Math.cos(a)*c,0],m=r===2?c:i*.5;return[...p.map((e,t)=>e+f[t]*m),...f,n]},f=(e,n,r)=>{let i=n.map((t,n)=>t-e[n]),a=r.map((t,n)=>t-e[n]),o=[i[1]*a[2]-i[2]*a[1],i[2]*a[0]-i[0]*a[2],i[0]*a[1]-i[1]*a[0]].reduce((t,n,r)=>t+n*e[r+3],0)<0?[e,r,n]:[e,n,r];for(let e of o)t.push(...e)};for(let e=0;e<u;e++)for(let t=0;t<16;t++){let n=d(e,t),r=d(e+1,t),i=d(e+1,t+1),a=d(e,t+1);f(n,r,i),f(n,i,a)}}return new Float32Array(t)}function x(e,t){let n=new Map,r=[[`aPosition`,3,0],[`aNormal`,3,12],[`aExtra`,1,24]];return{draw(i){let a=`${i.extras.join(`,`)}:${i.extraMeta.join(`,`)}`,o=n.get(a);if(!o){let t=e.createBuffer();if(!t)throw Error(`engenty: accessory allocation failed`);let r=b(i);if(e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW),o={buffer:t,count:r.length/7},n.set(a,o),n.size>24){let t=n.entries().next().value;t&&(e.deleteBuffer(t[1].buffer),n.delete(t[0]))}}e.bindBuffer(e.ARRAY_BUFFER,o.buffer);for(let[n,i,a]of r){let r=e.getAttribLocation(t,n);e.enableVertexAttribArray(r),e.vertexAttribPointer(r,i,e.FLOAT,!1,28,a)}e.drawArrays(e.TRIANGLES,0,o.count)},dispose(){for(let t of n.values())e.deleteBuffer(t.buffer);n.clear()}}}var S=`${y}
|
|
152
|
+
in vec3 aPosition;
|
|
153
|
+
in vec3 aNormal;
|
|
154
|
+
in float aExtra;
|
|
155
|
+
out vec3 vNormal;
|
|
156
|
+
out float vAlpha;
|
|
157
|
+
void main(){
|
|
158
|
+
int index=int(aExtra+0.5);
|
|
159
|
+
vec3 p=aPosition;
|
|
160
|
+
p.y+=sin(uTime*1.5+float(index)*1.7)*1.2;
|
|
161
|
+
p.x+=cos(uTime*1.1+float(index))*0.5;
|
|
162
|
+
vNormal=rotateCoat(aNormal);
|
|
163
|
+
vAlpha=mix(uExtraMeta[index].y,1.0,0.65);
|
|
164
|
+
gl_Position=projectCoat(poseCoat(p));
|
|
165
|
+
}
|
|
166
|
+
`,C=`${y}
|
|
167
|
+
in vec3 vNormal;
|
|
168
|
+
in float vAlpha;
|
|
169
|
+
out vec4 outColor;
|
|
170
|
+
void main(){
|
|
171
|
+
vec3 n=normalize(vNormal),light=normalize(uLight);
|
|
172
|
+
float diffuse=max(dot(n,light),0.0);
|
|
173
|
+
vec3 color=mix(uDeep,uBody,0.55+diffuse*0.45)*(0.7+diffuse*0.45);
|
|
174
|
+
vec3 halfLight=normalize(light+vec3(0.0,0.0,1.0));
|
|
175
|
+
color+=vec3(0.85)*pow(max(dot(n,halfLight),0.0),48.0);
|
|
176
|
+
color+=uTip*pow(1.0-abs(n.z),3.0)*0.2;
|
|
177
|
+
outColor=vec4(color*vAlpha,vAlpha);
|
|
178
|
+
}
|
|
179
|
+
`,w={inflate:27,softness:.05,clarity:.15},T=`uResolution.uTime.uBlobs.uFalloff.uScale.uFur.uPeriod.uInflate.uDensity.uThick.uLean.uLight.uBody.uDeep.uTip.uEye.uWind.uGaze.uTurn.uGoggles.uExtras.uExtraMeta.uWobble.uClarity.uSoftness.uPull`.split(`.`);function E(e,t,n){let r=e.createShader(t);if(!r)throw Error(`engenty fur: could not create shader`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`engenty fur: shader compile failed — ${t}`)}return r}function D(e,t,n){let r=e.getContext(`webgl2`,{alpha:!0,antialias:!0,depth:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,stencil:!1});if(!r)return null;let i=null;try{let e=E(r,r.VERTEX_SHADER,n.vertex),a=E(r,r.FRAGMENT_SHADER,t);if(i=r.createProgram(),!i)throw Error(`engenty fur: could not create program`);if(r.attachShader(i,e),r.attachShader(i,a),r.linkProgram(i),r.deleteShader(e),r.deleteShader(a),!r.getProgramParameter(i,r.LINK_STATUS))throw Error(`engenty fur: link failed — ${r.getProgramInfoLog(i)}`)}catch(e){return i&&r.deleteProgram(i),console.error(e),null}let a={};for(let e of T)a[e]=r.getUniformLocation(i,e);let o=r.createVertexArray();r.bindVertexArray(o);let s=n.geometry(r,i),c=r.useProgram.bind(r);r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA);let l=!1,u=1;return{dispose(){l||(l=!0,s.dispose(),r.deleteVertexArray(o),r.deleteProgram(i))},render(e){l||(c(i),r.bindVertexArray(o),r.uniform2f(a.uResolution,u,u),r.uniform1f(a.uTime,e.time),r.uniform4fv(a.uBlobs,e.blobs),r.uniform1f(a.uFalloff,e.falloff),r.uniform1f(a.uScale,e.scale),r.uniform1f(a.uFur,e.fur),r.uniform1f(a.uPeriod,e.period),r.uniform1f(a.uInflate,e.inflate),r.uniform1f(a.uDensity,e.density),r.uniform1f(a.uThick,e.thick),r.uniform1f(a.uClarity,e.clarity),r.uniform1f(a.uSoftness,e.softness??w.softness),r.uniform4fv(a.uPull,e.pull??[60,60,0,0]),r.uniform2fv(a.uLean,e.lean),r.uniform3fv(a.uLight,e.light),r.uniform3fv(a.uBody,e.body),r.uniform3fv(a.uDeep,e.deep),r.uniform3fv(a.uTip,e.tip),r.uniform3fv(a.uEye,e.eye),r.uniform1f(a.uWind,e.wind),r.uniform2fv(a.uGaze,e.gaze),r.uniform2fv(a.uTurn,e.turn??[0,0]),r.uniform1f(a.uGoggles,+!!e.goggles),r.uniform4fv(a.uExtras,e.extras),r.uniform4fv(a.uExtraMeta,e.extraMeta),r.uniform2fv(a.uWobble,e.wobble),r.enable(r.SCISSOR_TEST),r.scissor(0,0,u,u),r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL),r.depthMask(!0),r.frontFace(r.CW),n.doubleSided?r.disable(r.CULL_FACE):(r.enable(r.CULL_FACE),r.cullFace(r.BACK)),n.clear!==!1&&(r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),r.depthMask(n.depthWrite!==!1),s.draw(e))},viewport(e){l||(u=e,r.viewport(0,0,e,e))}}}var O=new Map,k=[[0,5,1,6],[0,1,2,6],[0,2,3,6],[0,3,7,6],[0,7,4,6],[0,4,5,6]];function A(e){return`${e.blobs.join(`,`)}:${e.falloff}:${e.inflate}`}function j(e,t){let n=0,r=[0,0,0];for(let i=0;i<t.blobs.length;i+=4){let a=t.blobs[i+2],o=t.blobs[i+3];if(a<=0||o<=0)continue;let s=a*t.inflate/30,c=e[0]-t.blobs[i],l=e[1]-t.blobs[i+1],u=e[2],d=Math.exp(-t.falloff*(c*c/(a*a)+l*l/(o*o)+u*u/(s*s)));n+=d,r[0]+=d*c/(a*a),r[1]+=d*l/(o*o),r[2]+=d*u/(s*s)}let i=Math.hypot(...r)||1;return{value:n,normal:[r[0]/i,r[1]/i,r[2]/i]}}function M(e){let t=A(e),n=O.get(t);if(n)return n;let r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let t=0;t<e.blobs.length;t+=4){if(e.blobs[t+2]<=0)continue;let n=[e.blobs[t],e.blobs[t+1],0],a=[e.blobs[t+2],e.blobs[t+3],e.blobs[t+2]*e.inflate/30];for(let e=0;e<3;e++)r[e]=Math.min(r[e],n[e]-a[e]*1.5),i[e]=Math.max(i[e],n[e]+a[e]*1.5)}let a=2.7,[o,s,c]=i.map((e,t)=>Math.ceil((e-r[t])/a)+1),l=[],u=[];for(let t=0;t<c;t++)for(let n=0;n<s;n++)for(let i=0;i<o;i++){let o=[r[0]+i*a,r[1]+n*a,r[2]+t*a];l.push(o),u.push(j(o,e).value)}let d=Math.exp(-e.falloff),f=[],p=0,m=(e,t)=>{let n=(d-u[e])/(u[t]-u[e]);return[0,1,2].map(r=>l[e][r]+(l[t][r]-l[e][r])*n)},h=(t,n,r)=>{let i=n.map((e,n)=>e-t[n]),a=r.map((e,n)=>e-t[n]),o=[i[1]*a[2]-i[2]*a[1],i[2]*a[0]-i[0]*a[2],i[0]*a[1]-i[1]*a[0]],s=Math.hypot(...o)*.5;if(s<1e-9)return;let c=j(t,e).normal,l=o.reduce((e,t,n)=>e+t*c[n],0)<0?[t,r,n]:[t,n,r];for(let t of l)f.push(...t,...j(t,e).normal);p+=s};for(let e=0;e<c-1;e++)for(let t=0;t<s-1;t++)for(let n=0;n<o-1;n++){let r=n+o*(t+s*e),i=o*s,a=[r,r+1,r+o+1,r+o,r+i,r+i+1,r+i+o+1,r+i+o];if(!(a.every(e=>u[e]<d)||a.every(e=>u[e]>=d)))for(let e of k){let t=e.map(e=>a[e]).filter(e=>u[e]>=d),n=e.map(e=>a[e]).filter(e=>u[e]<d);if(t.length===1)h(...n.map(e=>m(t[0],e)));else if(t.length===3)h(...t.map(e=>m(n[0],e)));else if(t.length===2){let e=m(t[0],n[0]),r=m(t[0],n[1]),i=m(t[1],n[0]),a=m(t[1],n[1]);h(e,r,i),h(r,a,i)}}}let g={vertices:new Float32Array(f),area:p};if(O.set(t,g),O.size>24){let e=O.keys().next().value;e&&O.delete(e)}return g}function te(e,t,n){let r=0,i=200;for(let a=0;a<24;a++){let a=(r+i)/2,o=0;for(let r=0;r<e.blobs.length;r+=4){let[i,s,c,l]=e.blobs.slice(r,r+4);c<=0||(o+=Math.exp(-e.falloff*(((t-i)/c)**2+((n-s)/l)**2+(a/(c*e.inflate/30))**2)))}o>Math.exp(-e.falloff)?r=a:i=a}return(r+i)/2}function ne(e){let t=[],[n,r,i]=e.eye,a=i*1.35,o=te(e,n,r),s=(e,n,r)=>{let i=n.map((t,n)=>t-e[n]),a=r.map((t,n)=>t-e[n]),o=[i[1]*a[2]-i[2]*a[1],i[2]*a[0]-i[0]*a[2],i[0]*a[1]-i[1]*a[0]];for(let i of o.reduce((t,n,r)=>t+n*e[r+3],0)<0?[e,r,n]:[e,n,r])t.push(...i)},c=(e,t,n)=>{for(let r=0;r<e;r++)for(let i=0;i<t;i++){let a=n(r/e,i/t),o=n((r+1)/e,i/t),c=n((r+1)/e,(i+1)/t),l=n(r/e,(i+1)/t);s(a,o,c),s(a,c,l)}},l=(e,t,i,a,s)=>c(96,16,(c,l)=>{let u=c*Math.PI*2,d=l*Math.PI*2,f=Math.cos(u)*Math.cos(d)/t,p=Math.sin(u)*Math.cos(d)/t,m=Math.sin(d)/a,h=Math.hypot(f,p,m);return[n+Math.cos(u)*(e+Math.cos(d)*t),r+Math.sin(u)*(e+Math.cos(d)*t),o+i+Math.sin(d)*a,f/h,p/h,m/h,s]});l(a*1.14,a*.2,.3,1.5,0),l(a*1.13,a*.14,2.1,1.8,1);for(let e=0;e<4;e++){let t=Math.PI/4+e*Math.PI/2,i=n+Math.cos(t)*a*1.13,s=r+Math.sin(t)*a*1.13;c(10,12,(e,t)=>{let n=e*Math.PI,r=t*Math.PI*2,a=[Math.sin(n)*Math.cos(r),Math.sin(n)*Math.sin(r),Math.cos(n)];return[i+a[0]*.65,s+a[1]*.65,o+3.9+a[2]*.4,...a,2]})}return c(18,96,(e,t)=>{let i=t*Math.PI*2,s=Math.cos(i)*e,c=Math.sin(i)*e,l=[s*.45,c*.45,1],u=Math.hypot(...l);return[n+s*a,r+c*a,o+2.4+2.3*(1-e*e),l[0]/u,l[1]/u,l[2]/u,3]}),new Float32Array(t)}function re(e,t){let n=new Map,r=[[`aPosition`,3,0],[`aNormal`,3,12],[`aMaterial`,1,24]];return{draw(i){if(!i.goggles)return;let a=`${A(i)}:${i.eye.join(`,`)}`,o=n.get(a);if(!o){let t=e.createBuffer();if(!t)throw Error(`engenty: goggle allocation failed`);let r=ne(i);if(e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW),o={buffer:t,count:r.length/7},n.set(a,o),n.size>24){let t=n.entries().next().value;t&&(e.deleteBuffer(t[1].buffer),n.delete(t[0]))}}e.bindBuffer(e.ARRAY_BUFFER,o.buffer);for(let[n,i,a]of r){let r=e.getAttribLocation(t,n);e.enableVertexAttribArray(r),e.vertexAttribPointer(r,i,e.FLOAT,!1,28,a)}e.drawArrays(e.TRIANGLES,0,o.count)},dispose(){for(let{buffer:t}of n.values())e.deleteBuffer(t);n.clear()}}}var N=`${y}
|
|
180
|
+
in vec3 aPosition;
|
|
181
|
+
in vec3 aNormal;
|
|
182
|
+
in float aMaterial;
|
|
183
|
+
out vec3 vNormal;
|
|
184
|
+
flat out int vMaterial;
|
|
185
|
+
void main(){
|
|
186
|
+
vNormal=poseNormal(aPosition,aNormal);
|
|
187
|
+
vMaterial=int(aMaterial+0.5);
|
|
188
|
+
gl_Position=projectCoat(poseCoat(aPosition));
|
|
189
|
+
}
|
|
190
|
+
`,ie=`${y}
|
|
191
|
+
in vec3 vNormal;
|
|
192
|
+
flat in int vMaterial;
|
|
193
|
+
out vec4 outColor;
|
|
194
|
+
void main(){
|
|
195
|
+
vec3 n=normalize(vNormal),light=normalize(uLight),view=vec3(0.0,0.0,1.0);
|
|
196
|
+
float diffuse=max(dot(n,light),0.0);
|
|
197
|
+
float spec=pow(max(dot(n,normalize(light+view)),0.0),48.0);
|
|
198
|
+
if(vMaterial==3){
|
|
199
|
+
float fres=0.025+0.975*pow(1.0-max(dot(n,view),0.0),5.0);
|
|
200
|
+
float shine=pow(max(dot(n,normalize(light+view)),0.0),100.0);
|
|
201
|
+
float alpha=0.045+fres*0.3+shine*0.38;
|
|
202
|
+
vec3 glass=mix(vec3(0.35,0.65,0.73),vec3(1.0),clamp(shine*3.0,0.0,1.0));
|
|
203
|
+
outColor=vec4(glass*alpha,alpha);return;
|
|
204
|
+
}
|
|
205
|
+
vec3 base=vMaterial==0?vec3(0.1,0.065,0.04):vMaterial==2?vec3(0.3,0.18,0.07):vec3(0.68,0.4,0.12);
|
|
206
|
+
vec3 reflected=mix(vec3(0.1,0.065,0.04),vec3(1.0,0.85,0.52),smoothstep(-0.7,0.8,-reflect(-view,n).y));
|
|
207
|
+
vec3 color=base*(0.4+diffuse*0.75)+reflected*(vMaterial==0?0.04:0.27)+vec3(1.0,0.9,0.65)*spec*(vMaterial==0?0.1:0.8);
|
|
208
|
+
outColor=vec4(color,1.0);
|
|
209
|
+
}
|
|
210
|
+
`,P=`${y}
|
|
211
|
+
in vec3 aPosition;
|
|
212
|
+
in vec3 aNormal;
|
|
213
|
+
out vec3 vLocal;
|
|
214
|
+
out vec3 vNormal;
|
|
215
|
+
void main(){
|
|
216
|
+
vLocal=aPosition;
|
|
217
|
+
vNormal=poseNormal(aPosition,aNormal);
|
|
218
|
+
gl_Position=projectCoat(poseCoat(aPosition));
|
|
219
|
+
}
|
|
220
|
+
`,F=`
|
|
221
|
+
in vec3 vLocal;
|
|
222
|
+
in vec3 vNormal;
|
|
223
|
+
out vec4 outColor;
|
|
224
|
+
`,ae=`${y}${F}
|
|
225
|
+
void main(){
|
|
226
|
+
vec2 p=vLocal.xy;
|
|
227
|
+
vec3 n=normalize(vNormal),light=normalize(uLight);
|
|
228
|
+
float aa=max(fwidth(p.x),fwidth(p.y))*0.7;
|
|
229
|
+
float lit=max(dot(n,light),0.0);
|
|
230
|
+
vec3 color=mix(uDeep,uBody,0.48)*(0.65+0.5*lit);
|
|
231
|
+
float front=smoothstep(0.0,2.0,vLocal.z);
|
|
232
|
+
vec2 ep=p-uEye.xy;
|
|
233
|
+
float er=uEye.z*1.35;
|
|
234
|
+
color*=mix(0.7,1.0,smoothstep(er*0.9,er*1.35,length(ep))*front+(1.0-front));
|
|
235
|
+
float phase=fract(uTime/5.4);
|
|
236
|
+
float blink=smoothstep(0.955,0.972,phase)-smoothstep(0.972,0.99,phase);
|
|
237
|
+
ep.y/=max(1.0-blink,0.035);
|
|
238
|
+
float lens=(1.0-smoothstep(er-aa,er+aa,length(ep)))*front;
|
|
239
|
+
vec3 eyeNormal=rotateCoat(vec3(ep/er,sqrt(max(0.0,1.0-dot(ep,ep)/(er*er)))));
|
|
240
|
+
vec3 eyeColor=mix(vec3(0.78,0.83,0.92),vec3(1.0),0.5+max(dot(eyeNormal,light),0.0)*0.5);
|
|
241
|
+
vec2 pupil=ep-uGaze/max(1.0,length(uGaze))*er*0.42;
|
|
242
|
+
float iris=1.0-smoothstep(er*0.43-aa,er*0.43+aa,length(pupil));
|
|
243
|
+
eyeColor=mix(eyeColor,vec3(0.075,0.06,0.13),iris);
|
|
244
|
+
float glint=1.0-smoothstep(er*0.1,er*0.16,length(pupil+vec2(er*0.14,er*0.17)));
|
|
245
|
+
eyeColor=mix(eyeColor,vec3(1.0),glint*iris);
|
|
246
|
+
// Directional contact shade from the irregular fur fringe, strongest above.
|
|
247
|
+
float angle=atan(ep.y,ep.x);
|
|
248
|
+
float edge=length(ep)/er+sin(angle*19.0)*0.025+sin(angle*37.0)*0.015;
|
|
249
|
+
float contact=smoothstep(0.72,1.02,edge)*(0.25+0.3*clamp(-ep.y/er,0.0,1.0));
|
|
250
|
+
eyeColor*=1.0-contact;
|
|
251
|
+
color=mix(color,eyeColor,lens);
|
|
252
|
+
vec4 extras=extrasOver(p,uDeep*0.55,uBody,aa)*front*(1.0-lens);
|
|
253
|
+
color=color*(1.0-extras.a)+extras.rgb;
|
|
254
|
+
vec4 goggles=gogglesOver(p,aa,front);
|
|
255
|
+
outColor=vec4(goggles.rgb+color*(1.0-goggles.a),1.0);
|
|
256
|
+
}
|
|
257
|
+
`,I=`${y}${F}
|
|
258
|
+
/** Luminance, for turning a reflection into coverage. */
|
|
259
|
+
float lum(vec3 c) { return dot(c, vec3(0.2126, 0.7152, 0.0722)); }
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Coverage of a soft rectangular window seen in direction \`r\`, sitting in
|
|
263
|
+
* the key direction \`w\`. \`soft\` is the blur of the lobe reflecting it.
|
|
264
|
+
*/
|
|
265
|
+
float windowLobe(vec3 r, vec3 w, float soft, bool panes) {
|
|
266
|
+
float facing = dot(r, w);
|
|
267
|
+
if (facing <= 0.0) { return 0.0; }
|
|
268
|
+
// Tangent frame around the window direction.
|
|
269
|
+
vec3 ax = normalize(cross(w, vec3(0.0, 0.0, 1.0)));
|
|
270
|
+
vec3 ay = cross(w, ax);
|
|
271
|
+
vec2 q = vec2(dot(r, ax), dot(r, ay)) / facing;
|
|
272
|
+
vec2 half_ = vec2(0.26, 0.42);
|
|
273
|
+
vec2 cov = smoothstep(half_ + soft, half_ - soft, abs(q));
|
|
274
|
+
float win = cov.x * cov.y;
|
|
275
|
+
if (panes) {
|
|
276
|
+
// Mullions: two columns, three rows. The grid is what makes a bright
|
|
277
|
+
// patch read as a window and the surface as glass.
|
|
278
|
+
float bar = 0.018;
|
|
279
|
+
float mx = 1.0 - smoothstep(bar, bar + soft, abs(q.x));
|
|
280
|
+
float my = 1.0 - smoothstep(bar, bar + soft, abs(abs(q.y) - 0.14));
|
|
281
|
+
win *= 1.0 - 0.85 * max(mx, my);
|
|
282
|
+
}
|
|
283
|
+
return win;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
void main(){
|
|
287
|
+
vec2 p=vLocal.xy;
|
|
288
|
+
vec3 n=normalize(vNormal);
|
|
289
|
+
float front=smoothstep(0.0,2.0,vLocal.z);
|
|
290
|
+
float aaPx=max(fwidth(p.x),fwidth(p.y))*0.75;
|
|
291
|
+
vec4 extras=extrasOver(p,uDeep*0.55,uBody,aaPx)*front;
|
|
292
|
+
vec3 light = normalize(uLight);
|
|
293
|
+
vec3 view = vec3(0.0, 0.0, 1.0);
|
|
294
|
+
// 1 at the thick centre, 0 at the rim.
|
|
295
|
+
float ndv = clamp(n.z, 0.0, 1.0);
|
|
296
|
+
|
|
297
|
+
// Wavelength-dependent absorption keeps thick gel saturated and its rim clear.
|
|
298
|
+
vec3 skin=mix(uBody,vec3(1.0),0.18);
|
|
299
|
+
vec3 sigma=-log(max(uBody,0.025)/max(skin,0.026));
|
|
300
|
+
float side=clamp(-dot(n.xy,light.xy),-1.0,1.0);
|
|
301
|
+
float chord=ndv*(1.3+0.4*side);
|
|
302
|
+
vec3 gel=skin*exp(-sigma*chord*1.6);
|
|
303
|
+
float wrap=clamp((dot(n,light)+0.6)/1.6,0.0,1.0);
|
|
304
|
+
vec3 col=mix(uDeep*0.5,gel,0.42+wrap*0.58)*(0.75+wrap*0.35);
|
|
305
|
+
// A soft transmitted lobe brightens the side opposite the key light.
|
|
306
|
+
float transmitted=pow(max(dot(n,normalize(vec3(-light.xy,0.45))),0.0),5.0);
|
|
307
|
+
col+=mix(uBody,uTip,0.4)*transmitted*(0.32+0.55*(1.0-ndv));
|
|
308
|
+
vec3 refracted=refract(-view,n,1.0/1.36);
|
|
309
|
+
float focus=pow(max(dot(normalize(vec3(-refracted.xy,ndv)),light),0.0),12.0);
|
|
310
|
+
col+=uBody*focus*0.28;
|
|
311
|
+
|
|
312
|
+
// Soft, restrained studio reflections follow the deformed surface normal.
|
|
313
|
+
float f0=0.023;
|
|
314
|
+
float fres=f0+(1.0-f0)*pow(1.0-ndv,5.0);
|
|
315
|
+
vec3 r=reflect(-view,n);
|
|
316
|
+
float windowHdr=5.0;
|
|
317
|
+
vec3 room=mix(vec3(0.075,0.07,0.1),vec3(0.65,0.68,0.73),smoothstep(-0.8,0.8,-r.y));
|
|
318
|
+
float key=windowLobe(r,light,0.11,false);
|
|
319
|
+
float fill=windowLobe(r,normalize(vec3(0.85,0.12,0.35)),0.14,false);
|
|
320
|
+
vec3 coat=vec3(1.0)*key*(0.12+fres*0.24);
|
|
321
|
+
vec3 reflection=room*fres*0.24+coat+vec3(0.65,0.84,1.0)*fill*(0.05+fres*0.12);
|
|
322
|
+
reflection+=uTip*pow(1.0-ndv,7.0)*0.06;
|
|
323
|
+
reflection=1.0-exp(-reflection*1.8);
|
|
324
|
+
col=col*(1.0-fres*0.45)+reflection;
|
|
325
|
+
// Approximate transmission into the host background; the shared canvas does
|
|
326
|
+
// not sample DOM pixels, so this deliberately avoids claiming scene refraction.
|
|
327
|
+
float clarity=mix(0.55,0.24,smoothstep(0.0,0.85,ndv))*uClarity;
|
|
328
|
+
float alpha=min(1.0,1.0-clarity+lum(reflection)*0.65);
|
|
329
|
+
vec4 acc=vec4(min(col,vec3(1.0))*alpha,alpha);
|
|
330
|
+
|
|
331
|
+
// ─── eye, in the gel ───────────────────────────────────────────────────────
|
|
332
|
+
float phase = fract(uTime / 5.4);
|
|
333
|
+
float blink = smoothstep(0.955, 0.972, phase) - smoothstep(0.972, 0.99, phase);
|
|
334
|
+
vec2 ep = p - eyeCentre();
|
|
335
|
+
ep.y /= max(1.0 - blink, 0.06);
|
|
336
|
+
float er = uEye.z * 1.35;
|
|
337
|
+
float aa = er * 0.06;
|
|
338
|
+
// A soft dark socket under the lens, as if it sits a little inside the gel.
|
|
339
|
+
acc.rgb *= mix(1.0, mix(0.7, 1.0, smoothstep(er * 0.95, er * 1.4, length(ep))), front);
|
|
340
|
+
|
|
341
|
+
float lens = smoothstep(er + aa, er - aa, length(ep)) * front;
|
|
342
|
+
if (lens > 0.0) {
|
|
343
|
+
// ─── glass eye ─────────────────────────────────────────────────────────
|
|
344
|
+
// The lens is a dome set into the gel and the pupil a dark glass bead on
|
|
345
|
+
// it: each has its own hemisphere normal and is shaded like the body —
|
|
346
|
+
// window reflection, Fresnel rim, a little light leaking through the
|
|
347
|
+
// bead's far side — rather than painted flat.
|
|
348
|
+
vec2 el = ep / er;
|
|
349
|
+
float ez = sqrt(max(0.0, 1.0 - dot(el, el)));
|
|
350
|
+
vec3 en = rotateCoat(vec3(el, ez));
|
|
351
|
+
float ndlE = max(dot(en, light), 0.0);
|
|
352
|
+
// Sclera: milky glass, darker where the dome meets the socket.
|
|
353
|
+
vec3 eyeCol = vec3(0.93, 0.94, 0.97) * (0.62 + 0.38 * ndlE) * mix(0.55, 1.0, smoothstep(0.0, 0.5, ez));
|
|
354
|
+
|
|
355
|
+
vec2 pupilAt = uGaze * er * 0.45;
|
|
356
|
+
float pr = er * 0.42;
|
|
357
|
+
vec2 pl = (ep - pupilAt) / pr;
|
|
358
|
+
float pz = sqrt(max(0.0, 1.0 - dot(pl, pl)));
|
|
359
|
+
vec3 pn = vec3(pl, pz);
|
|
360
|
+
float pupil = smoothstep(pr + aa, pr - aa, length(ep - pupilAt));
|
|
361
|
+
if (pupil > 0.0) {
|
|
362
|
+
vec3 bead = mix(vec3(0.05, 0.04, 0.10), vec3(0.16, 0.13, 0.24), pow(1.0 - pz, 2.0));
|
|
363
|
+
// The bead is transparent too: light entering at the top leaves at the
|
|
364
|
+
// bottom edge, warmed by the iris.
|
|
365
|
+
float leak = pow(max(dot(pn, normalize(vec3(-light.xy, 0.2))), 0.0), 4.0) * (1.0 - pz);
|
|
366
|
+
bead += mix(uTip, vec3(1.0), 0.4) * leak * 0.55;
|
|
367
|
+
vec3 pr_ = reflect(-view, pn);
|
|
368
|
+
float pf = 0.03 + 0.97 * pow(1.0 - pz, 5.0);
|
|
369
|
+
// A bead this small would show the window as a speck; a flatter
|
|
370
|
+
// reflection normal spreads it to the broad soft patch a glass eye has.
|
|
371
|
+
vec3 prw = reflect(-view, normalize(vec3(pl * 0.4, pz)));
|
|
372
|
+
vec3 pref = (mix(vec3(0.12), vec3(0.6), smoothstep(-0.7, 0.9, -pr_.y)) * pf * 2.0)
|
|
373
|
+
+ vec3(1.0) * windowLobe(prw, light, 0.1, true) * windowHdr * (0.05 + pf * 0.5);
|
|
374
|
+
bead += 1.0 - exp(-pref);
|
|
375
|
+
eyeCol = mix(eyeCol, min(bead, vec3(1.0)), pupil);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Wet skin over the whole lens.
|
|
379
|
+
vec3 er_ = reflect(-view, en);
|
|
380
|
+
float ef = 0.022 + 0.978 * pow(1.0 - ez, 5.0);
|
|
381
|
+
vec3 lensRef = vec3(0.7, 0.72, 0.8) * ef * 1.6
|
|
382
|
+
+ vec3(1.0) * windowLobe(er_, light, 0.06, true) * windowHdr * (0.02 + ef * 0.3);
|
|
383
|
+
eyeCol += 1.0 - exp(-lensRef);
|
|
384
|
+
|
|
385
|
+
acc.rgb = acc.rgb * (1.0 - lens) + min(eyeCol, vec3(1.0)) * lens;
|
|
386
|
+
acc.a = acc.a * (1.0 - lens) + lens;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Decals sit in the gel: slightly softened by the coat's own alpha, and the
|
|
390
|
+
// wet skin's reflection lies over them.
|
|
391
|
+
float da = extras.a * 0.92;
|
|
392
|
+
acc.rgb = acc.rgb * (1.0 - da) + (extras.rgb + coat * extras.a * 0.5) * 0.92;
|
|
393
|
+
acc.a = acc.a * (1.0 - da) + da;
|
|
394
|
+
|
|
395
|
+
vec4 goggles = gogglesOver(p, aaPx, front);
|
|
396
|
+
outColor = goggles + acc * (1.0 - goggles.a);
|
|
397
|
+
}
|
|
398
|
+
`,L=8,R=256;function oe(e,t,n,r,i){let a=-Math.sin(n[0]),o=Math.cos(n[0])*Math.sin(n[1]),s=Math.cos(n[0])*Math.cos(n[1]),c=1/0,l=-1/0;for(let t=0;t<e.length;t+=L){let n=e[t]*a+e[t+1]*o+e[t+2]*s;c=Math.min(c,n),l=Math.max(l,n)}i.fill(0);let u=255/Math.max(l-c,.001);for(let t=0;t<r.length;t++){let n=t*L,l=e[n]*a+e[n+1]*o+e[n+2]*s,d=Math.min(255,Math.max(0,Math.floor((l-c)*u)));r[t]=d,i[d]++}let d=0;for(let e=0;e<R;e++){let t=i[e];i[e]=d,d+=t}for(let n=0;n<r.length;n++){let a=i[r[n]]++*L;for(let r=0;r<L;r++)t[a+r]=e[n*L+r]}}function se(e){return{roots:e,sorted:new Float32Array(e.length),buckets:new Uint16Array(e.length/L),counts:new Uint32Array(R),yaw:NaN,pitch:NaN}}function ce(e){let t=M(e),n=781,r=()=>(n=(n*1664525+1013904223)%4294967296,n/4294967296),i=[],a=Math.min(200,Math.max(10,e.density))**2/4e3,o=t.vertices;for(let e=0;e<o.length;e+=18){let t=[o[e+6]-o[e],o[e+7]-o[e+1],o[e+8]-o[e+2]],n=[o[e+12]-o[e],o[e+13]-o[e+1],o[e+14]-o[e+2]],s=Math.hypot(t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0])*.5*a,c=Math.floor(s)+ +(r()<s%1);for(let t=0;t<c;t++){let t=Math.sqrt(r()),n=r(),a=[1-t,t*(1-n),t*n],s=Array.from({length:6},(t,n)=>a.reduce((t,r,i)=>t+r*o[e+i*6+n],0)),c=Math.hypot(s[3],s[4],s[5]);i.push(s[0],s[1],s[2],s[3]/c,s[4]/c,s[5]/c,r(),r())}}return new Float32Array(i)}function z(e,t){let n=new Map,r=e.getAttribLocation(t,`aRoot`),i=e.getAttribLocation(t,`aNormal`),a=e.getAttribLocation(t,`aRandom`);return{draw(t){let o=`${A(t)}:${t.density}`,s=n.get(o);if(!s){let r=e.createBuffer();if(!r)throw Error(`engenty: strand allocation failed`);let i=ce(t);if(e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,i,e.DYNAMIC_DRAW),s={buffer:r,count:i.length/8,order:se(i)},n.set(o,s),n.size>24){let t=n.entries().next().value;t&&(e.deleteBuffer(t[1].buffer),n.delete(t[0]))}}e.bindBuffer(e.ARRAY_BUFFER,s.buffer);let c=t.turn??[0,0],l=s.order;(l.yaw!==c[0]||l.pitch!==c[1])&&(oe(l.roots,l.sorted,c,l.buckets,l.counts),e.bufferSubData(e.ARRAY_BUFFER,0,l.sorted),l.yaw=c[0],l.pitch=c[1]);for(let[t,n,o]of[[r,3,0],[i,3,12],[a,2,24]])e.enableVertexAttribArray(t),e.vertexAttribPointer(t,n,e.FLOAT,!1,32,o),e.vertexAttribDivisor(t,1);e.drawArraysInstanced(e.TRIANGLE_STRIP,0,18,s.count)},dispose(){for(let t of n.values())e.deleteBuffer(t.buffer);n.clear()}}}var B=`${y}
|
|
399
|
+
in vec3 aRoot;
|
|
400
|
+
in vec3 aNormal;
|
|
401
|
+
in vec2 aRandom;
|
|
402
|
+
out vec3 vColor;
|
|
403
|
+
out float vAcross;
|
|
404
|
+
out float vCoverage;
|
|
405
|
+
void main(){
|
|
406
|
+
float t=float(gl_VertexID/2)/8.0;
|
|
407
|
+
float side=float(gl_VertexID%2)*2.0-1.0;
|
|
408
|
+
float eyeDistance=length(aRoot.xy-uEye.xy);
|
|
409
|
+
float front=smoothstep(0.0,2.0,aRoot.z);
|
|
410
|
+
float eyeAngle=atan(aRoot.y-uEye.y,aRoot.x-uEye.x);
|
|
411
|
+
float rim=uEye.z*1.35;
|
|
412
|
+
float fringe=sin(eyeAngle*19.0)*0.025+sin(eyeAngle*37.0)*0.015;
|
|
413
|
+
float socket=mix(1.0,smoothstep(rim*(0.88+fringe),rim*(1.08+fringe),eyeDistance),front);
|
|
414
|
+
socket=mix(socket,mix(1.0,smoothstep(rim*1.22,rim*1.4,eyeDistance),front),uGoggles);
|
|
415
|
+
float bandY=aRoot.y-uEye.y+1.7*pow((aRoot.x-uEye.x)/max(uScale,1.0),2.0);
|
|
416
|
+
float strap=(1.0-smoothstep(uEye.z*0.3,uEye.z*0.5,abs(bandY)))*uGoggles*smoothstep(0.5,6.0,-sdBody(aRoot.xy));
|
|
417
|
+
// Compress the pile only on the facing surface; side tufts cover strap ends.
|
|
418
|
+
strap*=smoothstep(0.45,0.8,abs(aNormal.z));
|
|
419
|
+
float underfur=1.0-step(0.36,aRandom.x);
|
|
420
|
+
float len=uFur*mix(0.55+aRandom.x*0.55,0.3+aRandom.x*0.5,underfur)*socket*(1.0-strap*0.75);
|
|
421
|
+
vec3 tangent=normalize(cross(aNormal,abs(aNormal.y)>0.9?vec3(1.0,0.0,0.0):vec3(0.0,1.0,0.0)));
|
|
422
|
+
vec3 flow=aNormal*0.95+tangent*(aRandom.y-0.5)*0.5+vec3(0.04,0.12,0.0);
|
|
423
|
+
float nearEye=front*(1.0-smoothstep(rim, rim*1.5,eyeDistance));
|
|
424
|
+
flow.xy-=normalize(aRoot.xy-uEye.xy+vec2(0.001))*nearEye*0.7;
|
|
425
|
+
float wave=sin(uTime*1.8+aRoot.y*0.09+aRandom.x*TAU);
|
|
426
|
+
vec3 bend=vec3(wave*uWind*0.12,0.07+aRandom.y*0.12,0.0);
|
|
427
|
+
vec3 centre=poseCoat(aRoot+len*(flow*t+bend*t*t));
|
|
428
|
+
vec3 direction=rotateCoat(flow+2.0*bend*t);
|
|
429
|
+
vec2 across=normalize(vec2(-direction.y,direction.x)+vec2(0.00001));
|
|
430
|
+
float radius=uThick*(0.1+aRandom.y*0.09)*mix(1.0,1.8,underfur)*pow(1.0-t,0.8);
|
|
431
|
+
float pixel=VIEW/uResolution.x/coatZoom();
|
|
432
|
+
centre.xy+=across*side*max(radius,pixel*0.7);
|
|
433
|
+
gl_Position=projectCoat(centre);
|
|
434
|
+
vec3 n=normalize(rotateCoat(aNormal/bodyStretch()));
|
|
435
|
+
float lit=max(dot(n,normalize(uLight)),0.0);
|
|
436
|
+
vColor=mix(uDeep,uBody,0.52+t*0.48)*(0.6+lit*0.65);
|
|
437
|
+
vColor+=uTip*pow(1.0-abs(n.z),3.0)*(0.08+t*0.22);
|
|
438
|
+
vColor*=0.82+aRandom.y*0.32;
|
|
439
|
+
vColor+=vec3(0.08)*pow(lit,12.0)*t;
|
|
440
|
+
vAcross=side;
|
|
441
|
+
vCoverage=min(1.0,radius/(pixel*0.7))*socket*(1.0-strap*0.85);
|
|
442
|
+
}
|
|
443
|
+
`,V=`#version 300 es
|
|
444
|
+
precision highp float;
|
|
445
|
+
in vec3 vColor;
|
|
446
|
+
in float vAcross;
|
|
447
|
+
in float vCoverage;
|
|
448
|
+
out vec4 outColor;
|
|
449
|
+
void main(){
|
|
450
|
+
float alpha=(1.0-smoothstep(0.35,1.0,abs(vAcross)))*vCoverage;
|
|
451
|
+
if(alpha<0.025)discard;
|
|
452
|
+
outColor=vec4(vColor*alpha,alpha);
|
|
453
|
+
}
|
|
454
|
+
`;function H(e,t){let n=new Map,r=e.getAttribLocation(t,`aPosition`),i=e.getAttribLocation(t,`aNormal`);return{draw(t){let a=A(t),o=n.get(a);if(!o){let r=e.createBuffer();if(!r)throw Error(`engenty: body allocation failed`);let i=M(t);if(e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,i.vertices,e.STATIC_DRAW),o={buffer:r,count:i.vertices.length/6},n.set(a,o),n.size>24){let t=n.entries().next().value;t&&(e.deleteBuffer(t[1].buffer),n.delete(t[0]))}}e.bindBuffer(e.ARRAY_BUFFER,o.buffer);for(let[t,n]of[[r,0],[i,12]])e.enableVertexAttribArray(t),e.vertexAttribPointer(t,3,e.FLOAT,!1,24,n);e.drawArrays(e.TRIANGLES,0,o.count)},dispose(){for(let t of n.values())e.deleteBuffer(t.buffer);n.clear()}}}function U(e,t){let n=D(e,t===`fur`?ae:I,{vertex:t===`fur`?P:P.replace(`#version 300 es`,`#version 300 es
|
|
455
|
+
#define JELLY_COAT`),geometry:H});if(!n)return null;let r=[n];if(t===`fur`){let t=D(e,V,{vertex:B,geometry:z,clear:!1,doubleSided:!0,depthWrite:!1});if(!t)return n.dispose(),null;r.push(t)}let i=D(e,C,{vertex:S,geometry:x,clear:!1});if(!i){for(let e of r)e.dispose();return null}r.push(i);let a=D(e,ie,{vertex:t===`jelly`?N.replace(`#version 300 es`,`#version 300 es
|
|
456
|
+
#define JELLY_COAT`):N,geometry:re,clear:!1});if(!a){for(let e of r)e.dispose();return null}return r.push(a),{render(e){for(let t of r)t.render(e)},viewport(e){for(let t of r)t.viewport(e)},dispose(){for(let e of r)e.dispose()}}}var W=new Map,G=new Set;function le(e){if(G.has(e)||typeof document>`u`)return null;let t=document.createElement(`canvas`);t.width=1,t.height=1;let n=U(t,e);return n?(t.addEventListener(`webglcontextlost`,t=>{t.preventDefault(),W.delete(e)}),{canvas:t,refs:0,renderer:n,size:0}):(G.add(e),null)}function ue(e=`fur`){let t=W.get(e);if(!t){let n=le(e);if(!n)return null;W.set(e,n),t=n}let n=t;n.refs+=1;let r=!1;return{drawInto(t,i,a){if(r||W.get(e)!==n)return;let o=i;o>n.size&&(n.size=o,n.canvas.width=o,n.canvas.height=o),n.renderer.viewport(o),n.renderer.render(a),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(n.canvas,0,n.canvas.height-o,o,o,0,0,t.canvas.width,t.canvas.height)},release(){r||(r=!0,--n.refs,n.refs<=0&&W.get(e)===n&&(n.renderer.dispose(),W.delete(e)))}}}var K=Math.PI/18;function q(e,t){let n=K/Math.max(1,Math.hypot(e,t));return[e*n,t===0?0:-t*n]}function J(e,t,n){if(n<=0)return;let r=3.8,i=Math.sqrt(110-r*r),a=Math.exp(-3.8*n),o=Math.cos(i*n),s=Math.sin(i*n);for(let[n,c,l]of[[`x`,`vx`,t[0]],[`y`,`vy`,t[1]]]){let t=e[n]-l,u=e[c];e[n]=l+a*(t*o+(u+r*t)/i*s),e[c]=a*(u*o-(r*u+110*t)/i*s)}}function de(e,t){let n={x:0,y:0,vx:0,vy:0},r=[60,60],i=null,a=[0,0],o=!1,s=n=>{if(!t()||n.button!==0||i!==null)return;let s=e.getBoundingClientRect(),c=(n.clientX-s.left)/s.width*152+-16,l=(n.clientY-s.top)/s.height*152+-16;Math.hypot(c-60,l-60)>48||(r[0]=c,r[1]=l,a=[n.clientX,n.clientY],i=n.pointerId,o=!1,e.setPointerCapture(i))},c=r=>{if(r.pointerId!==i)return;if(!t()){l(r);return}let s=e.getBoundingClientRect(),c=(r.clientX-a[0])/s.width*152,u=(r.clientY-a[1])/s.height*152,d=Math.min(1,18/(Math.hypot(c,u)||1));n.x=c*d,n.y=u*d,n.vx=0,n.vy=0,o||=Math.hypot(r.clientX-a[0],r.clientY-a[1])>4},l=t=>{t.pointerId===i&&(i=null,e.hasPointerCapture(t.pointerId)&&e.releasePointerCapture(t.pointerId))},u=e=>{o&&=(e.preventDefault(),e.stopPropagation(),!1)};return e.addEventListener(`pointerdown`,s),e.addEventListener(`pointermove`,c),e.addEventListener(`pointerup`,l),e.addEventListener(`pointercancel`,l),e.addEventListener(`lostpointercapture`,l),e.addEventListener(`click`,u,!0),{step(e){return i===null&&J(n,[0,0],e),[r[0],r[1],n.x,n.y]},dispose(){i!==null&&e.hasPointerCapture(i)&&e.releasePointerCapture(i),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerup`,l),e.removeEventListener(`pointercancel`,l),e.removeEventListener(`lostpointercapture`,l),e.removeEventListener(`click`,u,!0)}}}var Y={x:0,y:0},X=new Set,Z=!1;function fe(e){Y.x=e.clientX,Y.y=e.clientY;for(let e of X)e()}function pe(){return Y}function me(e){return!Z&&typeof window<`u`&&(Z=!0,Y.x=window.innerWidth*.62,Y.y=window.innerHeight*.28,window.addEventListener(`pointermove`,fe,{passive:!0})),X.add(e),()=>{X.delete(e)}}var Q=n(),he={high:{density:68,dprCap:2,thick:1},low:{density:40,dprCap:1,thick:1.15},medium:{density:55,dprCap:1.5,thick:1.05}},ge=1.7,$=0,_e=2.399963,ve=[-.42,-.72,.75],ye=30,be=.5,xe=e=>(e- -16)/152*100;function Se({className:e,motion:t=`auto`,animationSpeed:n=1,turn:i,coat:a=`fur`,goggles:c=!1,interactive:d=!0,look:p=null,kind:m=`round`,overrides:h,quality:g=`high`,size:_=260}){let v=(0,f.useRef)(null),y=(0,f.useRef)(null),b=(0,f.useRef)(0);b.current===0&&($+=1,b.current=$*_e);let x=(0,f.useRef)(null),[S,C]=(0,f.useState)(!0),T=o[m],E=(0,f.useMemo)(()=>s(T),[T]),D=(0,f.useMemo)(()=>l(T),[T]),O=(0,f.useMemo)(()=>r(T),[T]),k=(0,f.useRef)({animationSpeed:n,motion:t,turn:i,goggles:c,blobs:E,extras:D,form:T,interactive:d,kind:m,look:p,overrides:h,quality:g,scale:O,size:_});return k.current={animationSpeed:n,motion:t,turn:i,goggles:c,blobs:E,extras:D,form:T,interactive:d,kind:m,look:p,overrides:h,quality:g,scale:O,size:_},(0,f.useEffect)(()=>{v.current?.()},[m,h,g,_,d,p,c,t,n,i]),(0,f.useEffect)(()=>{let e=y.current,t=x.current;if(!(e&&t))return;let n=e.getContext(`2d`),r=n?ue(a):null;if(!(n&&r)){C(!1);return}let i=b.current,o=window.matchMedia(`(prefers-reduced-motion: reduce)`),s={x:0,y:0},c={x:0,y:0},l={vx:0,vy:0,x:0,y:0},u=0,d=!0,f=0,p=0,m=a===`jelly`?de(t,()=>k.current.interactive&&k.current.motion!==`pause`&&(k.current.motion===`play`||!o.matches)):null,h=g=>{u=0;let _=k.current,v=he[_.quality],y=_.motion===`pause`||_.motion===`auto`&&o.matches,b=y?0:Math.min((g-(p||g))/1e3,.1);f+=b*Math.max(.1,Math.min(2,_.animationSpeed)),p=g;let x=Math.min(window.devicePixelRatio||1,v.dprCap),S=Math.max(1,Math.round(_.size*x));e.width!==S&&(e.width=S,e.height=S);let C=120*S/(ge*152),T=_.overrides?.fur??_.form.fur;if((_.interactive||_.look)&&!y){let e,n,r,i;if(_.look)e=_.look.x,n=_.look.y,r=Math.hypot(e,n)||1,i=Math.min(1,r);else{let a=t.getBoundingClientRect(),o=pe();e=o.x-(a.left+a.width*.5),n=o.y-(a.top+a.height*.48),r=Math.hypot(e,n)||1,i=.35+Math.min(1,r/(a.width*2.4||1))*.65}s.x+=(e/r*5.5*i-s.x)*.16,s.y+=(n/r*3.5*i-s.y)*.16,c.x+=(e/r*i-c.x)*.24,c.y+=(n/r*.9*i-c.y)*.24}J(l,[s.x,s.y],b*Math.max(.1,Math.min(2,_.animationSpeed)));let E=ee(t,_.kind);r.drawInto(n,S,{blobs:_.blobs,clarity:_.overrides?.clarity??w.clarity,softness:_.overrides?.softness??w.softness,pull:m?.step(b*Math.max(.1,Math.min(2,_.animationSpeed))),body:E.body,deep:E.deep,density:Math.min(_.overrides?.density??v.density,C),extraMeta:_.extras.meta,extras:_.extras.geometry,eye:[_.form.eye.x,_.form.eye.y,_.form.eye.r],gaze:[c.x,c.y],goggles:_.goggles,turn:_.turn?q(_.turn.yaw/K,_.turn.pitch/K):q(c.x,c.y),fur:T,inflate:_.overrides?.inflate??(a===`jelly`?w.inflate:ye),lean:[s.x,s.y],light:ve,period:_.form.period,scale:_.scale,falloff:_.form.falloff,thick:_.overrides?.thick??v.thick,time:f+i,tip:E.tip,wind:_.overrides?.wind??be,wobble:[l.x-s.x,l.y-s.y]}),d&&!y&&(u=requestAnimationFrame(h))},g=()=>{u||=(p=0,requestAnimationFrame(h))},_=new IntersectionObserver(([e])=>{d=e?.isIntersecting??!0,d?g():u&&=(cancelAnimationFrame(u),0)},{rootMargin:`120px`});_.observe(t),v.current=g;let S=me(g);return o.addEventListener(`change`,g),g(),()=>{v.current=null,_.disconnect(),m?.dispose(),S(),o.removeEventListener(`change`,g),u&&cancelAnimationFrame(u),r.release()}},[a]),S?(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:e,ref:x,style:{height:_,position:`relative`,width:_},children:[(0,Q.jsx)(`div`,{style:{background:`radial-gradient(closest-side, rgb(0 0 0 / 0.2), transparent)`,filter:`blur(4px)`,height:`${T.shadowRx*50/152}%`,left:`50%`,position:`absolute`,top:`${xe(110)}%`,transform:`translate(-50%, -50%)`,width:`${T.shadowRx*2.5*100/152}%`}}),(0,Q.jsx)(`canvas`,{ref:y,style:{display:`block`,height:_,width:_,touchAction:a===`jelly`&&d&&t!==`pause`?`none`:void 0,cursor:a===`jelly`&&d?`grab`:void 0}})]}):(0,Q.jsx)(u,{className:e,goggles:c,kind:m,size:_})}export{Se as FluffyEngenty};
|