draken 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ACCEPTANCE.md +31 -0
- package/CHANGELOG.md +33 -0
- package/CONTRIBUTING.md +129 -0
- package/MEMORY.md +98 -0
- package/PERSONA.md +67 -0
- package/README.md +156 -78
- package/SETUP.md +111 -0
- package/SOURCES.md +75 -0
- package/TRAY.md +54 -0
- package/VOICE.md +118 -0
- package/dist/auth/middleware.d.ts +3 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +20 -15
- package/dist/auth/middleware.js.map +1 -1
- package/dist/cli.js +77 -58
- package/dist/cli.js.map +1 -1
- package/dist/db/agent-migration.d.ts +7 -0
- package/dist/db/agent-migration.d.ts.map +1 -0
- package/dist/db/agent-migration.js +36 -0
- package/dist/db/agent-migration.js.map +1 -0
- package/dist/db/evidence.d.ts +37 -0
- package/dist/db/evidence.d.ts.map +1 -0
- package/dist/db/evidence.js +110 -0
- package/dist/db/evidence.js.map +1 -0
- package/dist/db/pointer-migration.d.ts +7 -0
- package/dist/db/pointer-migration.d.ts.map +1 -0
- package/dist/db/pointer-migration.js +117 -0
- package/dist/db/pointer-migration.js.map +1 -0
- package/dist/db/retained-text.d.ts +8 -0
- package/dist/db/retained-text.d.ts.map +1 -0
- package/dist/db/retained-text.js +36 -0
- package/dist/db/retained-text.js.map +1 -0
- package/dist/db/schema.d.ts +1 -5
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +200 -55
- package/dist/db/schema.js.map +1 -1
- package/dist/db/snapshot-pointers.d.ts +5 -0
- package/dist/db/snapshot-pointers.d.ts.map +1 -0
- package/dist/db/snapshot-pointers.js +174 -0
- package/dist/db/snapshot-pointers.js.map +1 -0
- package/dist/memory/automatic.d.ts +38 -0
- package/dist/memory/automatic.d.ts.map +1 -0
- package/dist/memory/automatic.js +155 -0
- package/dist/memory/automatic.js.map +1 -0
- package/dist/memory/context.d.ts +12 -0
- package/dist/memory/context.d.ts.map +1 -0
- package/dist/memory/context.js +59 -0
- package/dist/memory/context.js.map +1 -0
- package/dist/memory/embedding-pool.d.ts +28 -0
- package/dist/memory/embedding-pool.d.ts.map +1 -0
- package/dist/memory/embedding-pool.js +135 -0
- package/dist/memory/embedding-pool.js.map +1 -0
- package/dist/memory/embedding-worker.d.ts +2 -0
- package/dist/memory/embedding-worker.d.ts.map +1 -0
- package/dist/memory/embedding-worker.js +32 -0
- package/dist/memory/embedding-worker.js.map +1 -0
- package/dist/memory/index.d.ts +26 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +283 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/model.d.ts +15 -0
- package/dist/memory/model.d.ts.map +1 -0
- package/dist/memory/model.js +152 -0
- package/dist/memory/model.js.map +1 -0
- package/dist/memory/service.d.ts +8 -0
- package/dist/memory/service.d.ts.map +1 -0
- package/dist/memory/service.js +217 -0
- package/dist/memory/service.js.map +1 -0
- package/dist/memory/sources.d.ts +15 -0
- package/dist/memory/sources.d.ts.map +1 -0
- package/dist/memory/sources.js +87 -0
- package/dist/memory/sources.js.map +1 -0
- package/dist/memory/stamps.d.ts +13 -0
- package/dist/memory/stamps.d.ts.map +1 -0
- package/dist/memory/stamps.js +101 -0
- package/dist/memory/stamps.js.map +1 -0
- package/dist/memory/storage.d.ts +5 -0
- package/dist/memory/storage.d.ts.map +1 -0
- package/dist/memory/storage.js +107 -0
- package/dist/memory/storage.js.map +1 -0
- package/dist/memory/types.d.ts +68 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +8 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/worker.d.ts +2 -0
- package/dist/memory/worker.d.ts.map +1 -0
- package/dist/memory/worker.js +82 -0
- package/dist/memory/worker.js.map +1 -0
- package/dist/npm-cli.d.ts +4 -0
- package/dist/npm-cli.d.ts.map +1 -0
- package/dist/npm-cli.js +36 -0
- package/dist/npm-cli.js.map +1 -0
- package/dist/pi/runtime.d.ts +34 -0
- package/dist/pi/runtime.d.ts.map +1 -0
- package/dist/pi/runtime.js +210 -0
- package/dist/pi/runtime.js.map +1 -0
- package/dist/pi/setup.d.ts +5 -0
- package/dist/pi/setup.d.ts.map +1 -0
- package/dist/pi/setup.js +147 -0
- package/dist/pi/setup.js.map +1 -0
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/auth.js +3 -1
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/live-voice.d.ts +3 -0
- package/dist/routes/live-voice.d.ts.map +1 -0
- package/dist/routes/live-voice.js +49 -0
- package/dist/routes/live-voice.js.map +1 -0
- package/dist/routes/{browse.d.ts → memory.d.ts} +1 -1
- package/dist/routes/memory.d.ts.map +1 -0
- package/dist/routes/memory.js +18 -0
- package/dist/routes/memory.js.map +1 -0
- package/dist/routes/{tasks.d.ts → sync.d.ts} +1 -1
- package/dist/routes/sync.d.ts.map +1 -0
- package/dist/routes/sync.js +127 -0
- package/dist/routes/sync.js.map +1 -0
- package/dist/routes/{projects.d.ts → voice.d.ts} +1 -1
- package/dist/routes/voice.d.ts.map +1 -0
- package/dist/routes/voice.js +35 -0
- package/dist/routes/voice.js.map +1 -0
- package/dist/server-state.d.ts +30 -0
- package/dist/server-state.d.ts.map +1 -0
- package/dist/server-state.js +113 -0
- package/dist/server-state.js.map +1 -0
- package/dist/server-status.d.ts +7 -0
- package/dist/server-status.d.ts.map +1 -0
- package/dist/server-status.js +34 -0
- package/dist/server-status.js.map +1 -0
- package/dist/server.d.ts +5 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +148 -46
- package/dist/server.js.map +1 -1
- package/dist/sources/adapters.d.ts +15 -0
- package/dist/sources/adapters.d.ts.map +1 -0
- package/dist/sources/adapters.js +159 -0
- package/dist/sources/adapters.js.map +1 -0
- package/dist/sources/registry.d.ts +17 -0
- package/dist/sources/registry.d.ts.map +1 -0
- package/dist/sources/registry.js +56 -0
- package/dist/sources/registry.js.map +1 -0
- package/dist/sync/collector.d.ts +3 -0
- package/dist/sync/collector.d.ts.map +1 -0
- package/dist/sync/collector.js +284 -0
- package/dist/sync/collector.js.map +1 -0
- package/dist/sync/cost.d.ts +7 -0
- package/dist/sync/cost.d.ts.map +1 -0
- package/dist/sync/cost.js +31 -0
- package/dist/sync/cost.js.map +1 -0
- package/dist/sync/jsonl.d.ts +34 -0
- package/dist/sync/jsonl.d.ts.map +1 -0
- package/dist/sync/jsonl.js +161 -0
- package/dist/sync/jsonl.js.map +1 -0
- package/dist/sync/manager.d.ts +12 -0
- package/dist/sync/manager.d.ts.map +1 -0
- package/dist/sync/manager.js +211 -0
- package/dist/sync/manager.js.map +1 -0
- package/dist/sync/normalize.d.ts +22 -0
- package/dist/sync/normalize.d.ts.map +1 -0
- package/dist/sync/normalize.js +107 -0
- package/dist/sync/normalize.js.map +1 -0
- package/dist/sync/pi-output.d.ts +33 -0
- package/dist/sync/pi-output.d.ts.map +1 -0
- package/dist/sync/pi-output.js +186 -0
- package/dist/sync/pi-output.js.map +1 -0
- package/dist/sync/pi.d.ts +15 -0
- package/dist/sync/pi.d.ts.map +1 -0
- package/dist/sync/pi.js +149 -0
- package/dist/sync/pi.js.map +1 -0
- package/dist/sync/recap.d.ts +25 -0
- package/dist/sync/recap.d.ts.map +1 -0
- package/dist/sync/recap.js +118 -0
- package/dist/sync/recap.js.map +1 -0
- package/dist/sync/references.d.ts +10 -0
- package/dist/sync/references.d.ts.map +1 -0
- package/dist/sync/references.js +50 -0
- package/dist/sync/references.js.map +1 -0
- package/dist/sync/source-files.d.ts +16 -0
- package/dist/sync/source-files.d.ts.map +1 -0
- package/dist/sync/source-files.js +56 -0
- package/dist/sync/source-files.js.map +1 -0
- package/dist/sync/store.d.ts +36 -0
- package/dist/sync/store.d.ts.map +1 -0
- package/dist/sync/store.js +359 -0
- package/dist/sync/store.js.map +1 -0
- package/dist/sync/summary-budget.d.ts +19 -0
- package/dist/sync/summary-budget.d.ts.map +1 -0
- package/dist/sync/summary-budget.js +39 -0
- package/dist/sync/summary-budget.js.map +1 -0
- package/dist/sync/tree.d.ts +69 -0
- package/dist/sync/tree.d.ts.map +1 -0
- package/dist/sync/tree.js +599 -0
- package/dist/sync/tree.js.map +1 -0
- package/dist/tray/controller.d.ts +51 -0
- package/dist/tray/controller.d.ts.map +1 -0
- package/dist/tray/controller.js +178 -0
- package/dist/tray/controller.js.map +1 -0
- package/dist/tray/launcher.d.ts +3 -0
- package/dist/tray/launcher.d.ts.map +1 -0
- package/dist/tray/launcher.js +47 -0
- package/dist/tray/launcher.js.map +1 -0
- package/dist/tray/native.d.ts +12 -0
- package/dist/tray/native.d.ts.map +1 -0
- package/dist/tray/native.js +93 -0
- package/dist/tray/native.js.map +1 -0
- package/dist/tray/processes.d.ts +5 -0
- package/dist/tray/processes.d.ts.map +1 -0
- package/dist/tray/processes.js +99 -0
- package/dist/tray/processes.js.map +1 -0
- package/dist/tray/worker.d.ts +4 -0
- package/dist/tray/worker.d.ts.map +1 -0
- package/dist/tray/worker.js +150 -0
- package/dist/tray/worker.js.map +1 -0
- package/dist/types.d.ts +212 -20
- package/dist/types.d.ts.map +1 -1
- package/dist/voice/continuation.d.ts +25 -0
- package/dist/voice/continuation.d.ts.map +1 -0
- package/dist/voice/continuation.js +94 -0
- package/dist/voice/continuation.js.map +1 -0
- package/dist/voice/legacy-history.d.ts +5 -0
- package/dist/voice/legacy-history.d.ts.map +1 -0
- package/dist/voice/legacy-history.js +34 -0
- package/dist/voice/legacy-history.js.map +1 -0
- package/dist/voice/live-context.d.ts +14 -0
- package/dist/voice/live-context.d.ts.map +1 -0
- package/dist/voice/live-context.js +137 -0
- package/dist/voice/live-context.js.map +1 -0
- package/dist/voice/live.d.ts +37 -0
- package/dist/voice/live.d.ts.map +1 -0
- package/dist/voice/live.js +448 -0
- package/dist/voice/live.js.map +1 -0
- package/package.json +49 -16
- package/public/assets/index-CYz_kpAp.js +126 -0
- package/public/assets/index-DmRid5xE.css +1 -0
- package/public/assets/index-Ymd62i3g.js +40 -0
- package/public/assets/persona-C_m1CVKe.css +1 -0
- package/public/assets/persona-XbLvCqRT.js +1 -0
- package/public/assets/scene-CBV2oPhA.js +3854 -0
- package/public/index.html +6 -8
- package/public/persona/THREE-LICENSE.txt +21 -0
- package/public/persona/call-poster.webp +0 -0
- package/public/persona/reference.jpg +0 -0
- package/public/persona/sample.wav +0 -0
- package/public/persona.html +7 -0
- package/runtime/pi/package-lock.json +1549 -0
- package/runtime/pi/package.json +12 -0
- package/tests/fixtures/voice-question.wav +0 -0
- package/tray/assets/error.ico +0 -0
- package/tray/assets/error.png +0 -0
- package/tray/assets/running.ico +0 -0
- package/tray/assets/running.png +0 -0
- package/tray/assets/starting.ico +0 -0
- package/tray/assets/starting.png +0 -0
- package/tray/assets/stopped.ico +0 -0
- package/tray/assets/stopped.png +0 -0
- package/tray/assets/stopping.ico +0 -0
- package/tray/assets/stopping.png +0 -0
- package/tray/macos.js +72 -0
- package/tray/windows.ps1 +104 -0
- package/voice/realtime/README.md +84 -0
- package/voice/realtime/backend.mjs +81 -0
- package/voice/realtime/native.mjs +210 -0
- package/voice/realtime/peer.d.mts +15 -0
- package/voice/realtime/peer.mjs +116 -0
- package/voice/realtime/probe-browser.mjs +81 -0
- package/voice/realtime/probe-server.mjs +86 -0
- package/voice/realtime/probe.html +11 -0
- package/voice/realtime/probe.mjs +42 -0
- package/voice/realtime/rpc.mjs +118 -0
- package/voice/realtime/setup.mjs +32 -0
- package/voice/tls.mjs +49 -0
- package/dist/db/queries.d.ts +0 -16
- package/dist/db/queries.d.ts.map +0 -1
- package/dist/db/queries.js +0 -91
- package/dist/db/queries.js.map +0 -1
- package/dist/docker/dockerfile.d.ts +0 -50
- package/dist/docker/dockerfile.d.ts.map +0 -1
- package/dist/docker/dockerfile.js +0 -160
- package/dist/docker/dockerfile.js.map +0 -1
- package/dist/docker/manager.d.ts +0 -42
- package/dist/docker/manager.d.ts.map +0 -1
- package/dist/docker/manager.js +0 -421
- package/dist/docker/manager.js.map +0 -1
- package/dist/git/status.d.ts +0 -76
- package/dist/git/status.d.ts.map +0 -1
- package/dist/git/status.js +0 -332
- package/dist/git/status.js.map +0 -1
- package/dist/routes/browse.d.ts.map +0 -1
- package/dist/routes/browse.js +0 -49
- package/dist/routes/browse.js.map +0 -1
- package/dist/routes/git.d.ts +0 -9
- package/dist/routes/git.d.ts.map +0 -1
- package/dist/routes/git.js +0 -338
- package/dist/routes/git.js.map +0 -1
- package/dist/routes/projects.d.ts.map +0 -1
- package/dist/routes/projects.js +0 -220
- package/dist/routes/projects.js.map +0 -1
- package/dist/routes/tasks.d.ts.map +0 -1
- package/dist/routes/tasks.js +0 -313
- package/dist/routes/tasks.js.map +0 -1
- package/draken.dockerfile.template +0 -18
- package/public/assets/index-3ngsG5kF.css +0 -1
- package/public/assets/index-B3YSD0ee.js +0 -252
|
@@ -0,0 +1,3854 @@
|
|
|
1
|
+
var Ya=Object.defineProperty;var Ja=(i,e,t)=>e in i?Ya(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var mt=(i,e,t)=>Ja(i,typeof e!="symbol"?e+"":e,t);/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2010-2025 Three.js Authors
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/const bt="srgb",Wn="srgb-linear",qi="linear",Qe="srgb";const cs="300 es";class Yn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const vt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let hs=1234567;const oi=Math.PI/180,ui=180/Math.PI;function yn(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(vt[i&255]+vt[i>>8&255]+vt[i>>16&255]+vt[i>>24&255]+"-"+vt[e&255]+vt[e>>8&255]+"-"+vt[e>>16&15|64]+vt[e>>24&255]+"-"+vt[t&63|128]+vt[t>>8&255]+"-"+vt[t>>16&255]+vt[t>>24&255]+vt[n&255]+vt[n>>8&255]+vt[n>>16&255]+vt[n>>24&255]).toLowerCase()}function He(i,e,t){return Math.max(e,Math.min(t,i))}function Wr(i,e){return(i%e+e)%e}function Za(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function Ka(i,e,t){return i!==e?(t-i)/(e-i):0}function li(i,e,t){return(1-t)*i+t*e}function $a(i,e,t,n){return li(i,e,1-Math.exp(-t*n))}function ja(i,e=1){return e-Math.abs(Wr(i,e*2)-e)}function Qa(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function eo(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function to(i,e){return i+Math.floor(Math.random()*(e-i+1))}function no(i,e){return i+Math.random()*(e-i)}function io(i){return i*(.5-Math.random())}function ro(i){i!==void 0&&(hs=i);let e=hs+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function so(i){return i*oi}function ao(i){return i*ui}function oo(i){return(i&i-1)===0&&i!==0}function lo(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function co(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function ho(i,e,t,n,r){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),h=a((e+n)/2),f=s((e-n)/2),d=a((e-n)/2),u=s((n-e)/2),g=a((n-e)/2);switch(r){case"XYX":i.set(o*h,c*f,c*d,o*l);break;case"YZY":i.set(c*d,o*h,c*f,o*l);break;case"ZXZ":i.set(c*f,c*d,o*h,o*l);break;case"XZX":i.set(o*h,c*g,c*u,o*l);break;case"YXY":i.set(c*u,o*h,c*g,o*l);break;case"ZYZ":i.set(c*g,c*u,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Vn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function yt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const us={DEG2RAD:oi,RAD2DEG:ui,generateUUID:yn,clamp:He,euclideanModulo:Wr,mapLinear:Za,inverseLerp:Ka,lerp:li,damp:$a,pingpong:ja,smoothstep:Qa,smootherstep:eo,randInt:to,randFloat:no,randFloatSpread:io,seededRandom:ro,degToRad:so,radToDeg:ao,isPowerOfTwo:oo,ceilPowerOfTwo:lo,floorPowerOfTwo:co,setQuaternionFromProperEuler:ho,normalize:yt,denormalize:Vn};class le{constructor(e=0,t=0){le.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class gi{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let c=n[r+0],l=n[r+1],h=n[r+2],f=n[r+3];const d=s[a+0],u=s[a+1],g=s[a+2],_=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=f;return}if(o===1){e[t+0]=d,e[t+1]=u,e[t+2]=g,e[t+3]=_;return}if(f!==_||c!==d||l!==u||h!==g){let m=1-o;const p=c*d+l*u+h*g+f*_,A=p>=0?1:-1,E=1-p*p;if(E>Number.EPSILON){const C=Math.sqrt(E),w=Math.atan2(C,p*A);m=Math.sin(m*w)/C,o=Math.sin(o*w)/C}const x=o*A;if(c=c*m+d*x,l=l*m+u*x,h=h*m+g*x,f=f*m+_*x,m===1-o){const C=1/Math.sqrt(c*c+l*l+h*h+f*f);c*=C,l*=C,h*=C,f*=C}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],c=n[r+1],l=n[r+2],h=n[r+3],f=s[a],d=s[a+1],u=s[a+2],g=s[a+3];return e[t]=o*g+h*f+c*u-l*d,e[t+1]=c*g+h*d+l*f-o*u,e[t+2]=l*g+h*u+o*d-c*f,e[t+3]=h*g-o*f-c*d-l*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(r/2),f=o(s/2),d=c(n/2),u=c(r/2),g=c(s/2);switch(a){case"XYZ":this._x=d*h*f+l*u*g,this._y=l*u*f-d*h*g,this._z=l*h*g+d*u*f,this._w=l*h*f-d*u*g;break;case"YXZ":this._x=d*h*f+l*u*g,this._y=l*u*f-d*h*g,this._z=l*h*g-d*u*f,this._w=l*h*f+d*u*g;break;case"ZXY":this._x=d*h*f-l*u*g,this._y=l*u*f+d*h*g,this._z=l*h*g+d*u*f,this._w=l*h*f-d*u*g;break;case"ZYX":this._x=d*h*f-l*u*g,this._y=l*u*f+d*h*g,this._z=l*h*g-d*u*f,this._w=l*h*f+d*u*g;break;case"YZX":this._x=d*h*f+l*u*g,this._y=l*u*f+d*h*g,this._z=l*h*g-d*u*f,this._w=l*h*f-d*u*g;break;case"XZY":this._x=d*h*f-l*u*g,this._y=l*u*f-d*h*g,this._z=l*h*g+d*u*f,this._w=l*h*f+d*u*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],f=t[10],d=n+o+f;if(d>0){const u=.5/Math.sqrt(d+1);this._w=.25/u,this._x=(h-c)*u,this._y=(s-l)*u,this._z=(a-r)*u}else if(n>o&&n>f){const u=2*Math.sqrt(1+n-o-f);this._w=(h-c)/u,this._x=.25*u,this._y=(r+a)/u,this._z=(s+l)/u}else if(o>f){const u=2*Math.sqrt(1+o-n-f);this._w=(s-l)/u,this._x=(r+a)/u,this._y=.25*u,this._z=(c+h)/u}else{const u=2*Math.sqrt(1+f-n-o);this._w=(a-r)/u,this._x=(s+l)/u,this._y=(c+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(He(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+r*l-s*c,this._y=r*h+a*c+s*o-n*l,this._z=s*h+a*l+n*c-r*o,this._w=a*h-n*o-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const u=1-t;return this._w=u*a+t*this._w,this._x=u*n+t*this._x,this._y=u*r+t*this._y,this._z=u*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),h=Math.atan2(l,o),f=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=a*f+this._w*d,this._x=n*f+this._x*d,this._y=r*f+this._y*d,this._z=s*f+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{constructor(e=0,t=0,n=0){P.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(fs.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fs.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*r-o*n),h=2*(o*t-s*r),f=2*(s*n-a*t);return this.x=t+c*l+a*f-o*h,this.y=n+c*h+o*l-s*f,this.z=r+c*f+s*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=r*c-s*o,this.y=s*a-n*c,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return nr.copy(this).projectOnVector(e),this.sub(nr)}reflect(e){return this.sub(nr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const nr=new P,fs=new gi;class Ge{constructor(e,t,n,r,s,a,o,c,l){Ge.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,c,l)}set(e,t,n,r,s,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],f=n[7],d=n[2],u=n[5],g=n[8],_=r[0],m=r[3],p=r[6],A=r[1],E=r[4],x=r[7],C=r[2],w=r[5],D=r[8];return s[0]=a*_+o*A+c*C,s[3]=a*m+o*E+c*w,s[6]=a*p+o*x+c*D,s[1]=l*_+h*A+f*C,s[4]=l*m+h*E+f*w,s[7]=l*p+h*x+f*D,s[2]=d*_+u*A+g*C,s[5]=d*m+u*E+g*w,s[8]=d*p+u*x+g*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*s*h+n*o*c+r*s*l-r*a*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],f=h*a-o*l,d=o*c-h*s,u=l*s-a*c,g=t*f+n*d+r*u;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=f*_,e[1]=(r*l-h*n)*_,e[2]=(o*n-r*a)*_,e[3]=d*_,e[4]=(h*t-r*c)*_,e[5]=(r*s-o*t)*_,e[6]=u*_,e[7]=(n*c-l*t)*_,e[8]=(a*t-n*s)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-r*l,r*c,-r*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ir.makeScale(e,t)),this}rotate(e){return this.premultiply(ir.makeRotation(-e)),this}translate(e,t){return this.premultiply(ir.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const ir=new Ge;function fa(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Yi(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function uo(){const i=Yi("canvas");return i.style.display="block",i}const ds={};function fi(i){i in ds||(ds[i]=!0,console.warn(i))}function fo(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const ps=new Ge().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ms=new Ge().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function po(){const i={enabled:!0,workingColorSpace:Wn,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Qe&&(r.r=tn(r.r),r.g=tn(r.g),r.b=tn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Qe&&(r.r=kn(r.r),r.g=kn(r.g),r.b=kn(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===""?qi:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return fi("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return fi("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Wn]:{primaries:e,whitePoint:n,transfer:qi,toXYZ:ps,fromXYZ:ms,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:bt},outputColorSpaceConfig:{drawingBufferColorSpace:bt}},[bt]:{primaries:e,whitePoint:n,transfer:Qe,toXYZ:ps,fromXYZ:ms,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:bt}}}),i}const Ze=po();function tn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function kn(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let bn;class mo{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{bn===void 0&&(bn=Yi("canvas")),bn.width=e.width,bn.height=e.height;const r=bn.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=bn}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Yi("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=tn(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(tn(t[n]/255)*255):t[n]=tn(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let go=0;class Xr{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:go++}),this.uuid=yn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(rr(r[a].image)):s.push(rr(r[a]))}else s=rr(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function rr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?mo.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let _o=0;const sr=new P;class Mt extends Yn{constructor(e=Mt.DEFAULT_IMAGE,t=Mt.DEFAULT_MAPPING,n=1001,r=1001,s=1006,a=1008,o=1023,c=1009,l=Mt.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:_o++}),this.uuid=yn(),this.name="",this.source=new Xr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new le(0,0),this.repeat=new le(1,1),this.center=new le(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ge,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(sr).x}get height(){return this.source.getSize(sr).y}get depth(){return this.source.getSize(sr).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Mt.DEFAULT_IMAGE=null;Mt.DEFAULT_MAPPING=300;Mt.DEFAULT_ANISOTROPY=1;class et{constructor(e=0,t=0,n=0,r=1){et.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const c=e.elements,l=c[0],h=c[4],f=c[8],d=c[1],u=c[5],g=c[9],_=c[2],m=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(f-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(f+_)<.1&&Math.abs(g+m)<.1&&Math.abs(l+u+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(l+1)/2,x=(u+1)/2,C=(p+1)/2,w=(h+d)/4,D=(f+_)/4,U=(g+m)/4;return E>x&&E>C?E<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(E),r=w/n,s=D/n):x>C?x<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(x),n=w/r,s=U/r):C<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(C),n=D/s,r=U/s),this.set(n,r,s,t),this}let A=Math.sqrt((m-g)*(m-g)+(f-_)*(f-_)+(d-h)*(d-h));return Math.abs(A)<.001&&(A=1),this.x=(m-g)/A,this.y=(f-_)/A,this.z=(d-h)/A,this.w=Math.acos((l+u+p-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this.w=He(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this.w=He(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class vo extends Yn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new et(0,0,e,t),this.scissorTest=!1,this.viewport=new et(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new Mt(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Xr(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class cn extends vo{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class da extends Mt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class xo extends Mt{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class En{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ot.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ot.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ot.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ot):Ot.fromBufferAttribute(s,a),Ot.applyMatrix4(e.matrixWorld),this.expandByPoint(Ot);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Si.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Si.copy(n.boundingBox)),Si.applyMatrix4(e.matrixWorld),this.union(Si)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ot),Ot.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter($n),yi.subVectors(this.max,$n),wn.subVectors(e.a,$n),Rn.subVectors(e.b,$n),Cn.subVectors(e.c,$n),nn.subVectors(Rn,wn),rn.subVectors(Cn,Rn),fn.subVectors(wn,Cn);let t=[0,-nn.z,nn.y,0,-rn.z,rn.y,0,-fn.z,fn.y,nn.z,0,-nn.x,rn.z,0,-rn.x,fn.z,0,-fn.x,-nn.y,nn.x,0,-rn.y,rn.x,0,-fn.y,fn.x,0];return!ar(t,wn,Rn,Cn,yi)||(t=[1,0,0,0,1,0,0,0,1],!ar(t,wn,Rn,Cn,yi))?!1:(Ei.crossVectors(nn,rn),t=[Ei.x,Ei.y,Ei.z],ar(t,wn,Rn,Cn,yi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ot).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ot).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Jt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jt),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Jt=[new P,new P,new P,new P,new P,new P,new P,new P],Ot=new P,Si=new En,wn=new P,Rn=new P,Cn=new P,nn=new P,rn=new P,fn=new P,$n=new P,yi=new P,Ei=new P,dn=new P;function ar(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){dn.fromArray(i,s);const o=r.x*Math.abs(dn.x)+r.y*Math.abs(dn.y)+r.z*Math.abs(dn.z),c=e.dot(dn),l=t.dot(dn),h=n.dot(dn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Mo=new En,jn=new P,or=new P;class _i{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Mo.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;jn.subVectors(e,this.center);const t=jn.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(jn,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(or.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(jn.copy(e.center).add(or)),this.expandByPoint(jn.copy(e.center).sub(or))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Zt=new P,lr=new P,Ti=new P,sn=new P,cr=new P,Ai=new P,hr=new P;class So{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Zt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Zt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Zt.copy(this.origin).addScaledVector(this.direction,t),Zt.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){lr.copy(e).add(t).multiplyScalar(.5),Ti.copy(t).sub(e).normalize(),sn.copy(this.origin).sub(lr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Ti),o=sn.dot(this.direction),c=-sn.dot(Ti),l=sn.lengthSq(),h=Math.abs(1-a*a);let f,d,u,g;if(h>0)if(f=a*c-o,d=a*o-c,g=s*h,f>=0)if(d>=-g)if(d<=g){const _=1/h;f*=_,d*=_,u=f*(f+a*d+2*o)+d*(a*f+d+2*c)+l}else d=s,f=Math.max(0,-(a*d+o)),u=-f*f+d*(d+2*c)+l;else d=-s,f=Math.max(0,-(a*d+o)),u=-f*f+d*(d+2*c)+l;else d<=-g?(f=Math.max(0,-(-a*s+o)),d=f>0?-s:Math.min(Math.max(-s,-c),s),u=-f*f+d*(d+2*c)+l):d<=g?(f=0,d=Math.min(Math.max(-s,-c),s),u=d*(d+2*c)+l):(f=Math.max(0,-(a*s+o)),d=f>0?s:Math.min(Math.max(-s,-c),s),u=-f*f+d*(d+2*c)+l);else d=a>0?-s:s,f=Math.max(0,-(a*d+o)),u=-f*f+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(lr).addScaledVector(Ti,d),u}intersectSphere(e,t){Zt.subVectors(e.center,this.origin);const n=Zt.dot(this.direction),r=Zt.dot(Zt)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),f>=0?(o=(e.min.z-d.z)*f,c=(e.max.z-d.z)*f):(o=(e.max.z-d.z)*f,c=(e.min.z-d.z)*f),n>c||o>r)||((o>n||n!==n)&&(n=o),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Zt)!==null}intersectTriangle(e,t,n,r,s){cr.subVectors(t,e),Ai.subVectors(n,e),hr.crossVectors(cr,Ai);let a=this.direction.dot(hr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;sn.subVectors(this.origin,e);const c=o*this.direction.dot(Ai.crossVectors(sn,Ai));if(c<0)return null;const l=o*this.direction.dot(cr.cross(sn));if(l<0||c+l>a)return null;const h=-o*sn.dot(hr);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class rt{constructor(e,t,n,r,s,a,o,c,l,h,f,d,u,g,_,m){rt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,c,l,h,f,d,u,g,_,m)}set(e,t,n,r,s,a,o,c,l,h,f,d,u,g,_,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=r,p[1]=s,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=f,p[14]=d,p[3]=u,p[7]=g,p[11]=_,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new rt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/Pn.setFromMatrixColumn(e,0).length(),s=1/Pn.setFromMatrixColumn(e,1).length(),a=1/Pn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(r),l=Math.sin(r),h=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const d=a*h,u=a*f,g=o*h,_=o*f;t[0]=c*h,t[4]=-c*f,t[8]=l,t[1]=u+g*l,t[5]=d-_*l,t[9]=-o*c,t[2]=_-d*l,t[6]=g+u*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,u=c*f,g=l*h,_=l*f;t[0]=d+_*o,t[4]=g*o-u,t[8]=a*l,t[1]=a*f,t[5]=a*h,t[9]=-o,t[2]=u*o-g,t[6]=_+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,u=c*f,g=l*h,_=l*f;t[0]=d-_*o,t[4]=-a*f,t[8]=g+u*o,t[1]=u+g*o,t[5]=a*h,t[9]=_-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,u=a*f,g=o*h,_=o*f;t[0]=c*h,t[4]=g*l-u,t[8]=d*l+_,t[1]=c*f,t[5]=_*l+d,t[9]=u*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,u=a*l,g=o*c,_=o*l;t[0]=c*h,t[4]=_-d*f,t[8]=g*f+u,t[1]=f,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=u*f+g,t[10]=d-_*f}else if(e.order==="XZY"){const d=a*c,u=a*l,g=o*c,_=o*l;t[0]=c*h,t[4]=-f,t[8]=l*h,t[1]=d*f+_,t[5]=a*h,t[9]=u*f-g,t[2]=g*f-u,t[6]=o*h,t[10]=_*f+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(yo,e,Eo)}lookAt(e,t,n){const r=this.elements;return Pt.subVectors(e,t),Pt.lengthSq()===0&&(Pt.z=1),Pt.normalize(),an.crossVectors(n,Pt),an.lengthSq()===0&&(Math.abs(n.z)===1?Pt.x+=1e-4:Pt.z+=1e-4,Pt.normalize(),an.crossVectors(n,Pt)),an.normalize(),bi.crossVectors(Pt,an),r[0]=an.x,r[4]=bi.x,r[8]=Pt.x,r[1]=an.y,r[5]=bi.y,r[9]=Pt.y,r[2]=an.z,r[6]=bi.z,r[10]=Pt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],f=n[5],d=n[9],u=n[13],g=n[2],_=n[6],m=n[10],p=n[14],A=n[3],E=n[7],x=n[11],C=n[15],w=r[0],D=r[4],U=r[8],y=r[12],M=r[1],R=r[5],O=r[9],G=r[13],W=r[2],q=r[6],k=r[10],te=r[14],H=r[3],ue=r[7],_e=r[11],Me=r[15];return s[0]=a*w+o*M+c*W+l*H,s[4]=a*D+o*R+c*q+l*ue,s[8]=a*U+o*O+c*k+l*_e,s[12]=a*y+o*G+c*te+l*Me,s[1]=h*w+f*M+d*W+u*H,s[5]=h*D+f*R+d*q+u*ue,s[9]=h*U+f*O+d*k+u*_e,s[13]=h*y+f*G+d*te+u*Me,s[2]=g*w+_*M+m*W+p*H,s[6]=g*D+_*R+m*q+p*ue,s[10]=g*U+_*O+m*k+p*_e,s[14]=g*y+_*G+m*te+p*Me,s[3]=A*w+E*M+x*W+C*H,s[7]=A*D+E*R+x*q+C*ue,s[11]=A*U+E*O+x*k+C*_e,s[15]=A*y+E*G+x*te+C*Me,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],f=e[6],d=e[10],u=e[14],g=e[3],_=e[7],m=e[11],p=e[15];return g*(+s*c*f-r*l*f-s*o*d+n*l*d+r*o*u-n*c*u)+_*(+t*c*u-t*l*d+s*a*d-r*a*u+r*l*h-s*c*h)+m*(+t*l*f-t*o*u-s*a*f+n*a*u+s*o*h-n*l*h)+p*(-r*o*h-t*c*f+t*o*d+r*a*f-n*a*d+n*c*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],f=e[9],d=e[10],u=e[11],g=e[12],_=e[13],m=e[14],p=e[15],A=f*m*l-_*d*l+_*c*u-o*m*u-f*c*p+o*d*p,E=g*d*l-h*m*l-g*c*u+a*m*u+h*c*p-a*d*p,x=h*_*l-g*f*l+g*o*u-a*_*u-h*o*p+a*f*p,C=g*f*c-h*_*c-g*o*d+a*_*d+h*o*m-a*f*m,w=t*A+n*E+r*x+s*C;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const D=1/w;return e[0]=A*D,e[1]=(_*d*s-f*m*s-_*r*u+n*m*u+f*r*p-n*d*p)*D,e[2]=(o*m*s-_*c*s+_*r*l-n*m*l-o*r*p+n*c*p)*D,e[3]=(f*c*s-o*d*s-f*r*l+n*d*l+o*r*u-n*c*u)*D,e[4]=E*D,e[5]=(h*m*s-g*d*s+g*r*u-t*m*u-h*r*p+t*d*p)*D,e[6]=(g*c*s-a*m*s-g*r*l+t*m*l+a*r*p-t*c*p)*D,e[7]=(a*d*s-h*c*s+h*r*l-t*d*l-a*r*u+t*c*u)*D,e[8]=x*D,e[9]=(g*f*s-h*_*s-g*n*u+t*_*u+h*n*p-t*f*p)*D,e[10]=(a*_*s-g*o*s+g*n*l-t*_*l-a*n*p+t*o*p)*D,e[11]=(h*o*s-a*f*s-h*n*l+t*f*l+a*n*u-t*o*u)*D,e[12]=C*D,e[13]=(h*_*r-g*f*r+g*n*d-t*_*d-h*n*m+t*f*m)*D,e[14]=(g*o*r-a*_*r-g*n*c+t*_*c+a*n*m-t*o*m)*D,e[15]=(a*f*r-h*o*r+h*n*c-t*f*c-a*n*d+t*o*d)*D,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,h=s*o;return this.set(l*a+n,l*o-r*c,l*c+r*o,0,l*o+r*c,h*o+n,h*c-r*a,0,l*c-r*o,h*c+r*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,h=a+a,f=o+o,d=s*l,u=s*h,g=s*f,_=a*h,m=a*f,p=o*f,A=c*l,E=c*h,x=c*f,C=n.x,w=n.y,D=n.z;return r[0]=(1-(_+p))*C,r[1]=(u+x)*C,r[2]=(g-E)*C,r[3]=0,r[4]=(u-x)*w,r[5]=(1-(d+p))*w,r[6]=(m+A)*w,r[7]=0,r[8]=(g+E)*D,r[9]=(m-A)*D,r[10]=(1-(d+_))*D,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=Pn.set(r[0],r[1],r[2]).length();const a=Pn.set(r[4],r[5],r[6]).length(),o=Pn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Bt.copy(this);const l=1/s,h=1/a,f=1/o;return Bt.elements[0]*=l,Bt.elements[1]*=l,Bt.elements[2]*=l,Bt.elements[4]*=h,Bt.elements[5]*=h,Bt.elements[6]*=h,Bt.elements[8]*=f,Bt.elements[9]*=f,Bt.elements[10]*=f,t.setFromRotationMatrix(Bt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=2e3,c=!1){const l=this.elements,h=2*s/(t-e),f=2*s/(n-r),d=(t+e)/(t-e),u=(n+r)/(n-r);let g,_;if(c)g=s/(a-s),_=a*s/(a-s);else if(o===2e3)g=-(a+s)/(a-s),_=-2*a*s/(a-s);else if(o===2001)g=-a/(a-s),_=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=f,l[9]=u,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=2e3,c=!1){const l=this.elements,h=2/(t-e),f=2/(n-r),d=-(t+e)/(t-e),u=-(n+r)/(n-r);let g,_;if(c)g=1/(a-s),_=a/(a-s);else if(o===2e3)g=-2/(a-s),_=-(a+s)/(a-s);else if(o===2001)g=-1/(a-s),_=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=f,l[9]=0,l[13]=u,l[2]=0,l[6]=0,l[10]=g,l[14]=_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Pn=new P,Bt=new rt,yo=new P(0,0,0),Eo=new P(1,1,1),an=new P,bi=new P,Pt=new P,gs=new rt,_s=new gi;class Ht{constructor(e=0,t=0,n=0,r=Ht.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],h=r[9],f=r[2],d=r[6],u=r[10];switch(t){case"XYZ":this._y=Math.asin(He(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-He(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,u),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(He(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-f,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-He(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(He(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,u));break;case"XZY":this._z=Math.asin(-He(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return gs.makeRotationFromQuaternion(e),this.setFromRotationMatrix(gs,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _s.setFromEuler(this),this.setFromQuaternion(_s,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ht.DEFAULT_ORDER="XYZ";class pa{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let To=0;const vs=new P,Dn=new gi,Kt=new rt,wi=new P,Qn=new P,Ao=new P,bo=new gi,xs=new P(1,0,0),Ms=new P(0,1,0),Ss=new P(0,0,1),ys={type:"added"},wo={type:"removed"},Ln={type:"childadded",child:null},ur={type:"childremoved",child:null};class _t extends Yn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:To++}),this.uuid=yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new P,t=new Ht,n=new gi,r=new P(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new rt},normalMatrix:{value:new Ge}}),this.matrix=new rt,this.matrixWorld=new rt,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Dn.setFromAxisAngle(e,t),this.quaternion.multiply(Dn),this}rotateOnWorldAxis(e,t){return Dn.setFromAxisAngle(e,t),this.quaternion.premultiply(Dn),this}rotateX(e){return this.rotateOnAxis(xs,e)}rotateY(e){return this.rotateOnAxis(Ms,e)}rotateZ(e){return this.rotateOnAxis(Ss,e)}translateOnAxis(e,t){return vs.copy(e).applyQuaternion(this.quaternion),this.position.add(vs.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xs,e)}translateY(e){return this.translateOnAxis(Ms,e)}translateZ(e){return this.translateOnAxis(Ss,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Kt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?wi.copy(e):wi.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Qn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Kt.lookAt(Qn,wi,this.up):Kt.lookAt(wi,Qn,this.up),this.quaternion.setFromRotationMatrix(Kt),r&&(Kt.extractRotation(r.matrixWorld),Dn.setFromRotationMatrix(Kt),this.quaternion.premultiply(Dn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(ys),Ln.child=e,this.dispatchEvent(Ln),Ln.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(wo),ur.child=e,this.dispatchEvent(ur),ur.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Kt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Kt.multiply(e.parent.matrixWorld)),e.applyMatrix4(Kt),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ys),Ln.child=e,this.dispatchEvent(Ln),Ln.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qn,e,Ao),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qn,bo,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const f=c[l];s(e.shapes,f)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];r.animations.push(s(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),f=a(e.shapes),d=a(e.skeletons),u=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),f.length>0&&(n.shapes=f),d.length>0&&(n.skeletons=d),u.length>0&&(n.animations=u),g.length>0&&(n.nodes=g)}return n.object=r,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}_t.DEFAULT_UP=new P(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zt=new P,$t=new P,fr=new P,jt=new P,Un=new P,In=new P,Es=new P,dr=new P,pr=new P,mr=new P,gr=new et,_r=new et,vr=new et;class Gt{constructor(e=new P,t=new P,n=new P){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),zt.subVectors(e,t),r.cross(zt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){zt.subVectors(r,t),$t.subVectors(n,t),fr.subVectors(e,t);const a=zt.dot(zt),o=zt.dot($t),c=zt.dot(fr),l=$t.dot($t),h=$t.dot(fr),f=a*l-o*o;if(f===0)return s.set(0,0,0),null;const d=1/f,u=(l*c-o*h)*d,g=(a*h-o*c)*d;return s.set(1-u-g,g,u)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,jt)===null?!1:jt.x>=0&&jt.y>=0&&jt.x+jt.y<=1}static getInterpolation(e,t,n,r,s,a,o,c){return this.getBarycoord(e,t,n,r,jt)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,jt.x),c.addScaledVector(a,jt.y),c.addScaledVector(o,jt.z),c)}static getInterpolatedAttribute(e,t,n,r,s,a){return gr.setScalar(0),_r.setScalar(0),vr.setScalar(0),gr.fromBufferAttribute(e,t),_r.fromBufferAttribute(e,n),vr.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(gr,s.x),a.addScaledVector(_r,s.y),a.addScaledVector(vr,s.z),a}static isFrontFacing(e,t,n,r){return zt.subVectors(n,t),$t.subVectors(e,t),zt.cross($t).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return zt.subVectors(this.c,this.b),$t.subVectors(this.a,this.b),zt.cross($t).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Gt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Gt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Gt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Gt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Gt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;Un.subVectors(r,n),In.subVectors(s,n),dr.subVectors(e,n);const c=Un.dot(dr),l=In.dot(dr);if(c<=0&&l<=0)return t.copy(n);pr.subVectors(e,r);const h=Un.dot(pr),f=In.dot(pr);if(h>=0&&f<=h)return t.copy(r);const d=c*f-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(Un,a);mr.subVectors(e,s);const u=Un.dot(mr),g=In.dot(mr);if(g>=0&&u<=g)return t.copy(s);const _=u*l-c*g;if(_<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(In,o);const m=h*g-u*f;if(m<=0&&f-h>=0&&u-g>=0)return Es.subVectors(s,r),o=(f-h)/(f-h+(u-g)),t.copy(r).addScaledVector(Es,o);const p=1/(m+_+d);return a=_*p,o=d*p,t.copy(n).addScaledVector(Un,a).addScaledVector(In,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ma={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},on={h:0,s:0,l:0},Ri={h:0,s:0,l:0};function xr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class ke{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=bt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ze.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Ze.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ze.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Ze.workingColorSpace){if(e=Wr(e,1),t=He(t,0,1),n=He(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=xr(a,s,e+1/3),this.g=xr(a,s,e),this.b=xr(a,s,e-1/3)}return Ze.colorSpaceToWorking(this,r),this}setStyle(e,t=bt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=bt){const n=ma[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=tn(e.r),this.g=tn(e.g),this.b=tn(e.b),this}copyLinearToSRGB(e){return this.r=kn(e.r),this.g=kn(e.g),this.b=kn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bt){return Ze.workingToColorSpace(xt.copy(this),e),Math.round(He(xt.r*255,0,255))*65536+Math.round(He(xt.g*255,0,255))*256+Math.round(He(xt.b*255,0,255))}getHexString(e=bt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ze.workingColorSpace){Ze.workingToColorSpace(xt.copy(this),t);const n=xt.r,r=xt.g,s=xt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const f=a-o;switch(l=h<=.5?f/(a+o):f/(2-a-o),a){case n:c=(r-s)/f+(r<s?6:0);break;case r:c=(s-n)/f+2;break;case s:c=(n-r)/f+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=Ze.workingColorSpace){return Ze.workingToColorSpace(xt.copy(this),t),e.r=xt.r,e.g=xt.g,e.b=xt.b,e}getStyle(e=bt){Ze.workingToColorSpace(xt.copy(this),e);const t=xt.r,n=xt.g,r=xt.b;return e!==bt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(on),this.setHSL(on.h+e,on.s+t,on.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(on),e.getHSL(Ri);const n=li(on.h,Ri.h,t),r=li(on.s,Ri.s,t),s=li(on.l,Ri.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xt=new ke;ke.NAMES=ma;let Ro=0;class Jn extends Yn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ro++}),this.uuid=yn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ke(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ga extends Jn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ht,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ut=new P,Ci=new le;let Co=0;class Vt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Co++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ci.fromBufferAttribute(this,t),Ci.applyMatrix3(e),this.setXY(t,Ci.x,Ci.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix3(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix4(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyNormalMatrix(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.transformDirection(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Vn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=yt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Vn(t,this.array)),t}setX(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Vn(t,this.array)),t}setY(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Vn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Vn(t,this.array)),t}setW(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array),r=yt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array),r=yt(r,this.array),s=yt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}}class _a extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class va extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class at extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Po=0;const Ft=new rt,Mr=new _t,Fn=new P,Dt=new En,ei=new En,gt=new P;class wt extends Yn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Po++}),this.uuid=yn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(fa(e)?va:_a)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Ge().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ft.makeRotationFromQuaternion(e),this.applyMatrix4(Ft),this}rotateX(e){return Ft.makeRotationX(e),this.applyMatrix4(Ft),this}rotateY(e){return Ft.makeRotationY(e),this.applyMatrix4(Ft),this}rotateZ(e){return Ft.makeRotationZ(e),this.applyMatrix4(Ft),this}translate(e,t,n){return Ft.makeTranslation(e,t,n),this.applyMatrix4(Ft),this}scale(e,t,n){return Ft.makeScale(e,t,n),this.applyMatrix4(Ft),this}lookAt(e){return Mr.lookAt(e),Mr.updateMatrix(),this.applyMatrix4(Mr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fn).negate(),this.translate(Fn.x,Fn.y,Fn.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new at(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new En);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Dt.setFromBufferAttribute(s),this.morphTargetsRelative?(gt.addVectors(this.boundingBox.min,Dt.min),this.boundingBox.expandByPoint(gt),gt.addVectors(this.boundingBox.max,Dt.max),this.boundingBox.expandByPoint(gt)):(this.boundingBox.expandByPoint(Dt.min),this.boundingBox.expandByPoint(Dt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _i);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const n=this.boundingSphere.center;if(Dt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];ei.setFromBufferAttribute(o),this.morphTargetsRelative?(gt.addVectors(Dt.min,ei.min),Dt.expandByPoint(gt),gt.addVectors(Dt.max,ei.max),Dt.expandByPoint(gt)):(Dt.expandByPoint(ei.min),Dt.expandByPoint(ei.max))}Dt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)gt.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(gt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)gt.fromBufferAttribute(o,l),c&&(Fn.fromBufferAttribute(e,l),gt.add(Fn)),r=Math.max(r,n.distanceToSquared(gt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Vt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let U=0;U<n.count;U++)o[U]=new P,c[U]=new P;const l=new P,h=new P,f=new P,d=new le,u=new le,g=new le,_=new P,m=new P;function p(U,y,M){l.fromBufferAttribute(n,U),h.fromBufferAttribute(n,y),f.fromBufferAttribute(n,M),d.fromBufferAttribute(s,U),u.fromBufferAttribute(s,y),g.fromBufferAttribute(s,M),h.sub(l),f.sub(l),u.sub(d),g.sub(d);const R=1/(u.x*g.y-g.x*u.y);isFinite(R)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(f,-u.y).multiplyScalar(R),m.copy(f).multiplyScalar(u.x).addScaledVector(h,-g.x).multiplyScalar(R),o[U].add(_),o[y].add(_),o[M].add(_),c[U].add(m),c[y].add(m),c[M].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let U=0,y=A.length;U<y;++U){const M=A[U],R=M.start,O=M.count;for(let G=R,W=R+O;G<W;G+=3)p(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const E=new P,x=new P,C=new P,w=new P;function D(U){C.fromBufferAttribute(r,U),w.copy(C);const y=o[U];E.copy(y),E.sub(C.multiplyScalar(C.dot(y))).normalize(),x.crossVectors(w,y);const R=x.dot(c[U])<0?-1:1;a.setXYZW(U,E.x,E.y,E.z,R)}for(let U=0,y=A.length;U<y;++U){const M=A[U],R=M.start,O=M.count;for(let G=R,W=R+O;G<W;G+=3)D(e.getX(G+0)),D(e.getX(G+1)),D(e.getX(G+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,u=n.count;d<u;d++)n.setXYZ(d,0,0,0);const r=new P,s=new P,a=new P,o=new P,c=new P,l=new P,h=new P,f=new P;if(e)for(let d=0,u=e.count;d<u;d+=3){const g=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,_),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,u=t.count;d<u;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)gt.fromBufferAttribute(e,t),gt.normalize(),e.setXYZ(t,gt.x,gt.y,gt.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,f=o.normalized,d=new l.constructor(c.length*h);let u=0,g=0;for(let _=0,m=c.length;_<m;_++){o.isInterleavedBufferAttribute?u=c[_]*o.data.stride+o.offset:u=c[_]*h;for(let p=0;p<h;p++)d[g++]=l[u++]}return new Vt(d,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new wt,n=this.index.array,r=this.attributes;for(const o in r){const c=r[o],l=e(c,n);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,f=l.length;h<f;h++){const d=l[h],u=e(d,n);c.push(u)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let f=0,d=l.length;f<d;f++){const u=l[f];h.push(u.toJSON(e.data))}h.length>0&&(r[c]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const l in r){const h=r[l];this.setAttribute(l,h.clone(t))}const s=e.morphAttributes;for(const l in s){const h=[],f=s[l];for(let d=0,u=f.length;d<u;d++)h.push(f[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const f=a[l];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ts=new rt,pn=new So,Pi=new _i,As=new P,Di=new P,Li=new P,Ui=new P,Sr=new P,Ii=new P,bs=new P,Fi=new P;class ft extends _t{constructor(e=new wt,t=new ga){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Ii.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],f=s[c];h!==0&&(Sr.fromBufferAttribute(f,e),a?Ii.addScaledVector(Sr,h):Ii.addScaledVector(Sr.sub(t),h))}t.add(Ii)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Pi.copy(n.boundingSphere),Pi.applyMatrix4(s),pn.copy(e.ray).recast(e.near),!(Pi.containsPoint(pn.origin)===!1&&(pn.intersectSphere(Pi,As)===null||pn.origin.distanceToSquared(As)>(e.far-e.near)**2))&&(Ts.copy(s).invert(),pn.copy(e.ray).applyMatrix4(Ts),!(n.boundingBox!==null&&pn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,pn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,d=s.groups,u=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],A=Math.max(m.start,u.start),E=Math.min(o.count,Math.min(m.start+m.count,u.start+u.count));for(let x=A,C=E;x<C;x+=3){const w=o.getX(x),D=o.getX(x+1),U=o.getX(x+2);r=Ni(this,p,e,n,l,h,f,w,D,U),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,u.start),_=Math.min(o.count,u.start+u.count);for(let m=g,p=_;m<p;m+=3){const A=o.getX(m),E=o.getX(m+1),x=o.getX(m+2);r=Ni(this,a,e,n,l,h,f,A,E,x),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],A=Math.max(m.start,u.start),E=Math.min(c.count,Math.min(m.start+m.count,u.start+u.count));for(let x=A,C=E;x<C;x+=3){const w=x,D=x+1,U=x+2;r=Ni(this,p,e,n,l,h,f,w,D,U),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,u.start),_=Math.min(c.count,u.start+u.count);for(let m=g,p=_;m<p;m+=3){const A=m,E=m+1,x=m+2;r=Ni(this,a,e,n,l,h,f,A,E,x),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function Do(i,e,t,n,r,s,a,o){let c;if(e.side===1?c=n.intersectTriangle(a,s,r,!0,o):c=n.intersectTriangle(r,s,a,e.side===0,o),c===null)return null;Fi.copy(o),Fi.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Fi);return l<t.near||l>t.far?null:{distance:l,point:Fi.clone(),object:i}}function Ni(i,e,t,n,r,s,a,o,c,l){i.getVertexPosition(o,Di),i.getVertexPosition(c,Li),i.getVertexPosition(l,Ui);const h=Do(i,e,t,n,Di,Li,Ui,bs);if(h){const f=new P;Gt.getBarycoord(bs,Di,Li,Ui,f),r&&(h.uv=Gt.getInterpolatedAttribute(r,o,c,l,f,new le)),s&&(h.uv1=Gt.getInterpolatedAttribute(s,o,c,l,f,new le)),a&&(h.normal=Gt.getInterpolatedAttribute(a,o,c,l,f,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new P,materialIndex:0};Gt.getNormal(Di,Li,Ui,d.normal),h.face=d,h.barycoord=f}return h}class Tn extends wt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],h=[],f=[];let d=0,u=0;g("z","y","x",-1,-1,n,t,e,a,s,0),g("z","y","x",1,-1,n,t,-e,a,s,1),g("x","z","y",1,1,e,n,t,r,a,2),g("x","z","y",1,-1,e,n,-t,r,a,3),g("x","y","z",1,-1,e,t,n,r,s,4),g("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new at(l,3)),this.setAttribute("normal",new at(h,3)),this.setAttribute("uv",new at(f,2));function g(_,m,p,A,E,x,C,w,D,U,y){const M=x/D,R=C/U,O=x/2,G=C/2,W=w/2,q=D+1,k=U+1;let te=0,H=0;const ue=new P;for(let _e=0;_e<k;_e++){const Me=_e*R-G;for(let Be=0;Be<q;Be++){const qe=Be*M-O;ue[_]=qe*A,ue[m]=Me*E,ue[p]=W,l.push(ue.x,ue.y,ue.z),ue[_]=0,ue[m]=0,ue[p]=w>0?1:-1,h.push(ue.x,ue.y,ue.z),f.push(Be/D),f.push(1-_e/U),te+=1}}for(let _e=0;_e<U;_e++)for(let Me=0;Me<D;Me++){const Be=d+Me+q*_e,qe=d+Me+q*(_e+1),$e=d+(Me+1)+q*(_e+1),Ye=d+(Me+1)+q*_e;c.push(Be,qe,Ye),c.push(qe,$e,Ye),H+=6}o.addGroup(u,H,y),u+=H,d+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Tn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Xn(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Et(i){const e={};for(let t=0;t<i.length;t++){const n=Xn(i[t]);for(const r in n)e[r]=n[r]}return e}function Lo(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function xa(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ze.workingColorSpace}const Uo={clone:Xn,merge:Et};var Io=`void main() {
|
|
6
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
7
|
+
}`,Fo=`void main() {
|
|
8
|
+
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
9
|
+
}`;class Xt extends Jn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Io,this.fragmentShader=Fo,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Xn(e.uniforms),this.uniformsGroups=Lo(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class qr extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new rt,this.projectionMatrix=new rt,this.projectionMatrixInverse=new rt,this.coordinateSystem=2e3,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const ln=new P,ws=new le,Rs=new le;class Lt extends qr{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ui*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(oi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ui*2*Math.atan(Math.tan(oi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ln.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ln.x,ln.y).multiplyScalar(-e/ln.z),ln.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ln.x,ln.y).multiplyScalar(-e/ln.z)}getViewSize(e,t){return this.getViewBounds(e,ws,Rs),t.subVectors(Rs,ws)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(oi*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/c,t-=a.offsetY*n/l,r*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Nn=-90,On=1;class No extends _t{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Lt(Nn,On,e,t);r.layers=this.layers,this.add(r);const s=new Lt(Nn,On,e,t);s.layers=this.layers,this.add(s);const a=new Lt(Nn,On,e,t);a.layers=this.layers,this.add(a);const o=new Lt(Nn,On,e,t);o.layers=this.layers,this.add(o);const c=new Lt(Nn,On,e,t);c.layers=this.layers,this.add(c);const l=new Lt(Nn,On,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,c]=t;for(const l of t)this.remove(l);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,h]=this.children,f=e.getRenderTarget(),d=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,c),e.setRenderTarget(n,4,r),e.render(t,l),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,r),e.render(t,h),e.setRenderTarget(f,d,u),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Ma extends Mt{constructor(e=[],t=301,n,r,s,a,o,c,l,h){super(e,t,n,r,s,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Oo extends cn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Ma(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
10
|
+
|
|
11
|
+
varying vec3 vWorldDirection;
|
|
12
|
+
|
|
13
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
14
|
+
|
|
15
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void main() {
|
|
20
|
+
|
|
21
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
22
|
+
|
|
23
|
+
#include <begin_vertex>
|
|
24
|
+
#include <project_vertex>
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
`,fragmentShader:`
|
|
28
|
+
|
|
29
|
+
uniform sampler2D tEquirect;
|
|
30
|
+
|
|
31
|
+
varying vec3 vWorldDirection;
|
|
32
|
+
|
|
33
|
+
#include <common>
|
|
34
|
+
|
|
35
|
+
void main() {
|
|
36
|
+
|
|
37
|
+
vec3 direction = normalize( vWorldDirection );
|
|
38
|
+
|
|
39
|
+
vec2 sampleUV = equirectUv( direction );
|
|
40
|
+
|
|
41
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
`},r=new Tn(5,5,5),s=new Xt({name:"CubemapFromEquirect",uniforms:Xn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});s.uniforms.tEquirect.value=t;const a=new ft(r,s),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=1006),new No(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class At extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Bo={type:"move"};class yr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new At,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new At,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new At,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,n),p=this._getHandJoint(l,_);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const h=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],d=h.position.distanceTo(f.position),u=.02,g=.005;l.inputState.pinching&&d>u+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=u-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Bo)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new At;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ji extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ht,this.environmentIntensity=1,this.environmentRotation=new Ht,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class zo extends Mt{constructor(e=null,t=1,n=1,r,s,a,o,c,l=1003,h=1003,f,d){super(null,a,o,c,l,h,r,s,f,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Cs extends Vt{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Bn=new rt,Ps=new rt,Oi=[],Ds=new En,Go=new rt,ti=new ft,ni=new _i;class Vo extends ft{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Cs(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,Go)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new En),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Bn),Ds.copy(e.boundingBox).applyMatrix4(Bn),this.boundingBox.union(Ds)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new _i),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Bn),ni.copy(e.boundingSphere).applyMatrix4(Bn),this.boundingSphere.union(ni)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=r[a+o]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(ti.geometry=this.geometry,ti.material=this.material,ti.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ni.copy(this.boundingSphere),ni.applyMatrix4(n),e.ray.intersectsSphere(ni)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Bn),Ps.multiplyMatrices(n,Bn),ti.matrixWorld=Ps,ti.raycast(e,Oi);for(let a=0,o=Oi.length;a<o;a++){const c=Oi[a];c.instanceId=s,c.object=this,t.push(c)}Oi.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Cs(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new zo(new Float32Array(r*this.count),r,this.count,1028,1015));const s=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=r*e;s[c]=o,s.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Er=new P,Ho=new P,ko=new Ge;class vn{constructor(e=new P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Er.subVectors(n,t).cross(Ho.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Er),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||ko.getNormalMatrix(e),r=this.coplanarPoint(Er).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const mn=new _i,Wo=new le(.5,.5),Bi=new P;class Yr{constructor(e=new vn,t=new vn,n=new vn,r=new vn,s=new vn,a=new vn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],c=s[2],l=s[3],h=s[4],f=s[5],d=s[6],u=s[7],g=s[8],_=s[9],m=s[10],p=s[11],A=s[12],E=s[13],x=s[14],C=s[15];if(r[0].setComponents(l-a,u-h,p-g,C-A).normalize(),r[1].setComponents(l+a,u+h,p+g,C+A).normalize(),r[2].setComponents(l+o,u+f,p+_,C+E).normalize(),r[3].setComponents(l-o,u-f,p-_,C-E).normalize(),n)r[4].setComponents(c,d,m,x).normalize(),r[5].setComponents(l-c,u-d,p-m,C-x).normalize();else if(r[4].setComponents(l-c,u-d,p-m,C-x).normalize(),t===2e3)r[5].setComponents(l+c,u+d,p+m,C+x).normalize();else if(t===2001)r[5].setComponents(c,d,m,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),mn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),mn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(mn)}intersectsSprite(e){mn.center.set(0,0,0);const t=Wo.distanceTo(e.center);return mn.radius=.7071067811865476+t,mn.applyMatrix4(e.matrixWorld),this.intersectsSphere(mn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Bi.x=r.normal.x>0?e.max.x:e.min.x,Bi.y=r.normal.y>0?e.max.y:e.min.y,Bi.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Bi)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Xo extends Mt{constructor(e,t,n,r,s,a,o,c,l){super(e,t,n,r,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Sa extends Mt{constructor(e,t,n=1014,r,s,a,o=1003,c=1003,l,h=1026,f=1){if(h!==1026&&h!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:f};super(d,r,s,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Xr(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class ya extends Mt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Qt extends wt{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:c};const l=this;r=Math.floor(r),s=Math.floor(s);const h=[],f=[],d=[],u=[];let g=0;const _=[],m=n/2;let p=0;A(),a===!1&&(e>0&&E(!0),t>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new at(f,3)),this.setAttribute("normal",new at(d,3)),this.setAttribute("uv",new at(u,2));function A(){const x=new P,C=new P;let w=0;const D=(t-e)/n;for(let U=0;U<=s;U++){const y=[],M=U/s,R=M*(t-e)+e;for(let O=0;O<=r;O++){const G=O/r,W=G*c+o,q=Math.sin(W),k=Math.cos(W);C.x=R*q,C.y=-M*n+m,C.z=R*k,f.push(C.x,C.y,C.z),x.set(q,D,k).normalize(),d.push(x.x,x.y,x.z),u.push(G,1-M),y.push(g++)}_.push(y)}for(let U=0;U<r;U++)for(let y=0;y<s;y++){const M=_[y][U],R=_[y+1][U],O=_[y+1][U+1],G=_[y][U+1];(e>0||y!==0)&&(h.push(M,R,G),w+=3),(t>0||y!==s-1)&&(h.push(R,O,G),w+=3)}l.addGroup(p,w,0),p+=w}function E(x){const C=g,w=new le,D=new P;let U=0;const y=x===!0?e:t,M=x===!0?1:-1;for(let O=1;O<=r;O++)f.push(0,m*M,0),d.push(0,M,0),u.push(.5,.5),g++;const R=g;for(let O=0;O<=r;O++){const W=O/r*c+o,q=Math.cos(W),k=Math.sin(W);D.x=y*k,D.y=m*M,D.z=y*q,f.push(D.x,D.y,D.z),d.push(0,M,0),w.x=q*.5+.5,w.y=k*.5*M+.5,u.push(w.x,w.y),g++}for(let O=0;O<r;O++){const G=C+O,W=R+O;x===!0?h.push(W,W+1,G):h.push(W+1,W,G),U+=3}l.addGroup(p,U,x===!0?1:2),p+=U}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qt(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Jr extends Qt{constructor(e=1,t=1,n=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Jr(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class qt{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(r=Math.floor(o+(c-o)/2),l=n[r]-a,l<0)o=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===a)return r/(s-1);const h=n[r],d=n[r+1]-h,u=(a-h)/d;return(r+u)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),c=t||(a.isVector2?new le:new P);return c.copy(o).sub(a).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new P,r=[],s=[],a=[],o=new P,c=new rt;for(let u=0;u<=e;u++){const g=u/e;r[u]=this.getTangentAt(g,new P)}s[0]=new P,a[0]=new P;let l=Number.MAX_VALUE;const h=Math.abs(r[0].x),f=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,n.set(1,0,0)),f<=l&&(l=f,n.set(0,1,0)),d<=l&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),a[u]=a[u-1].clone(),o.crossVectors(r[u-1],r[u]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(He(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(c.makeRotationAxis(o,g))}a[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(He(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(u=-u);for(let g=1;g<=e;g++)s[g].applyMatrix4(c.makeRotationAxis(r[g],u*g)),a[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Zr extends qt{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=c}getPoint(e,t=new le){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let c=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),f=Math.sin(this.aRotation),d=c-this.aX,u=l-this.aY;c=d*h-u*f+this.aX,l=d*f+u*h+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class qo extends Zr{constructor(e,t,n,r,s,a){super(e,t,n,n,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Kr(){let i=0,e=0,t=0,n=0;function r(s,a,o,c){i=s,e=o,t=-3*s+3*a-2*o-c,n=2*s-2*a+o+c}return{initCatmullRom:function(s,a,o,c,l){r(a,o,l*(o-s),l*(c-a))},initNonuniformCatmullRom:function(s,a,o,c,l,h,f){let d=(a-s)/l-(o-s)/(l+h)+(o-a)/h,u=(o-a)/h-(c-a)/(h+f)+(c-o)/f;d*=h,u*=h,r(a,o,d,u)},calc:function(s){const a=s*s,o=a*s;return i+e*s+t*a+n*o}}}const zi=new P,Tr=new Kr,Ar=new Kr,br=new Kr;class Or extends qt{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new P){const n=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),c=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:c===0&&o===s-1&&(o=s-2,c=1);let l,h;this.closed||o>0?l=r[(o-1)%s]:(zi.subVectors(r[0],r[1]).add(r[0]),l=zi);const f=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?h=r[(o+2)%s]:(zi.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=zi),this.curveType==="centripetal"||this.curveType==="chordal"){const u=this.curveType==="chordal"?.5:.25;let g=Math.pow(l.distanceToSquared(f),u),_=Math.pow(f.distanceToSquared(d),u),m=Math.pow(d.distanceToSquared(h),u);_<1e-4&&(_=1),g<1e-4&&(g=_),m<1e-4&&(m=_),Tr.initNonuniformCatmullRom(l.x,f.x,d.x,h.x,g,_,m),Ar.initNonuniformCatmullRom(l.y,f.y,d.y,h.y,g,_,m),br.initNonuniformCatmullRom(l.z,f.z,d.z,h.z,g,_,m)}else this.curveType==="catmullrom"&&(Tr.initCatmullRom(l.x,f.x,d.x,h.x,this.tension),Ar.initCatmullRom(l.y,f.y,d.y,h.y,this.tension),br.initCatmullRom(l.z,f.z,d.z,h.z,this.tension));return n.set(Tr.calc(c),Ar.calc(c),br.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new P().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Ls(i,e,t,n,r){const s=(n-e)*.5,a=(r-t)*.5,o=i*i,c=i*o;return(2*t-2*n+s+a)*c+(-3*t+3*n-2*s-a)*o+s*i+t}function Yo(i,e){const t=1-i;return t*t*e}function Jo(i,e){return 2*(1-i)*i*e}function Zo(i,e){return i*i*e}function ci(i,e,t,n){return Yo(i,e)+Jo(i,t)+Zo(i,n)}function Ko(i,e){const t=1-i;return t*t*t*e}function $o(i,e){const t=1-i;return 3*t*t*i*e}function jo(i,e){return 3*(1-i)*i*i*e}function Qo(i,e){return i*i*i*e}function hi(i,e,t,n,r){return Ko(i,e)+$o(i,t)+jo(i,n)+Qo(i,r)}class Ea extends qt{constructor(e=new le,t=new le,n=new le,r=new le){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new le){const n=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(hi(e,r.x,s.x,a.x,o.x),hi(e,r.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class el extends qt{constructor(e=new P,t=new P,n=new P,r=new P){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new P){const n=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(hi(e,r.x,s.x,a.x,o.x),hi(e,r.y,s.y,a.y,o.y),hi(e,r.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Ta extends qt{constructor(e=new le,t=new le){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new le){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new le){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class tl extends qt{constructor(e=new P,t=new P){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new P){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new P){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Aa extends qt{constructor(e=new le,t=new le,n=new le){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new le){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(ci(e,r.x,s.x,a.x),ci(e,r.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ba extends qt{constructor(e=new P,t=new P,n=new P){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new P){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(ci(e,r.x,s.x,a.x),ci(e,r.y,s.y,a.y),ci(e,r.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class wa extends qt{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new le){const n=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,c=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],f=r[a>r.length-3?r.length-1:a+2];return n.set(Ls(o,c.x,l.x,h.x,f.x),Ls(o,c.y,l.y,h.y,f.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new le().fromArray(r))}return this}}var Zi=Object.freeze({__proto__:null,ArcCurve:qo,CatmullRomCurve3:Or,CubicBezierCurve:Ea,CubicBezierCurve3:el,EllipseCurve:Zr,LineCurve:Ta,LineCurve3:tl,QuadraticBezierCurve:Aa,QuadraticBezierCurve3:ba,SplineCurve:wa});class nl extends qt{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Zi[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const a=r[s]-n,o=this.curves[s],c=o.getLength(),l=c===0?0:1-a/c;return o.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,c=a.getPoints(o);for(let l=0;l<c.length;l++){const h=c[l];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(new Zi[r.type]().fromJSON(r))}return this}}class Us extends nl{constructor(e){super(),this.type="Path",this.currentPoint=new le,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Ta(this.currentPoint.clone(),new le(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const s=new Aa(this.currentPoint.clone(),new le(e,t),new le(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,s,a){const o=new Ea(this.currentPoint.clone(),new le(e,t),new le(n,r),new le(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new wa(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,s,a){const o=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+o,t+c,n,r,s,a),this}absarc(e,t,n,r,s,a){return this.absellipse(e,t,n,n,r,s,a),this}ellipse(e,t,n,r,s,a,o,c){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,n,r,s,a,o,c),this}absellipse(e,t,n,r,s,a,o,c){const l=new Zr(e,t,n,r,s,a,o,c);if(this.curves.length>0){const f=l.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(l);const h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Ki extends Us{constructor(e){super(e),this.uuid=yn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(new Us().fromJSON(r))}return this}}function il(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=Ra(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,c,l;if(n&&(s=ll(i,e,s,t)),i.length>80*t){o=1/0,c=1/0;let h=-1/0,f=-1/0;for(let d=t;d<r;d+=t){const u=i[d],g=i[d+1];u<o&&(o=u),g<c&&(c=g),u>h&&(h=u),g>f&&(f=g)}l=Math.max(h-o,f-c),l=l!==0?32767/l:0}return di(s,a,t,o,c,l,0),a}function Ra(i,e,t,n,r){let s;if(r===xl(i,e,t,n)>0)for(let a=e;a<t;a+=n)s=Is(a/n|0,i[a],i[a+1],s);else for(let a=t-n;a>=e;a-=n)s=Is(a/n|0,i[a],i[a+1],s);return s&&qn(s,s.next)&&(mi(s),s=s.next),s}function Sn(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(qn(t,t.next)||ct(t.prev,t,t.next)===0)){if(mi(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function di(i,e,t,n,r,s,a){if(!i)return;!a&&s&&dl(i,n,r,s);let o=i;for(;i.prev!==i.next;){const c=i.prev,l=i.next;if(s?sl(i,n,r,s):rl(i)){e.push(c.i,i.i,l.i),mi(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=al(Sn(i),e),di(i,e,t,n,r,s,2)):a===2&&ol(i,e,t,n,r,s):di(Sn(i),e,t,n,r,s,1);break}}}function rl(i){const e=i.prev,t=i,n=i.next;if(ct(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,o=e.y,c=t.y,l=n.y,h=Math.min(r,s,a),f=Math.min(o,c,l),d=Math.max(r,s,a),u=Math.max(o,c,l);let g=n.next;for(;g!==e;){if(g.x>=h&&g.x<=d&&g.y>=f&&g.y<=u&&si(r,o,s,c,a,l,g.x,g.y)&&ct(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function sl(i,e,t,n){const r=i.prev,s=i,a=i.next;if(ct(r,s,a)>=0)return!1;const o=r.x,c=s.x,l=a.x,h=r.y,f=s.y,d=a.y,u=Math.min(o,c,l),g=Math.min(h,f,d),_=Math.max(o,c,l),m=Math.max(h,f,d),p=Br(u,g,e,t,n),A=Br(_,m,e,t,n);let E=i.prevZ,x=i.nextZ;for(;E&&E.z>=p&&x&&x.z<=A;){if(E.x>=u&&E.x<=_&&E.y>=g&&E.y<=m&&E!==r&&E!==a&&si(o,h,c,f,l,d,E.x,E.y)&&ct(E.prev,E,E.next)>=0||(E=E.prevZ,x.x>=u&&x.x<=_&&x.y>=g&&x.y<=m&&x!==r&&x!==a&&si(o,h,c,f,l,d,x.x,x.y)&&ct(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;E&&E.z>=p;){if(E.x>=u&&E.x<=_&&E.y>=g&&E.y<=m&&E!==r&&E!==a&&si(o,h,c,f,l,d,E.x,E.y)&&ct(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;x&&x.z<=A;){if(x.x>=u&&x.x<=_&&x.y>=g&&x.y<=m&&x!==r&&x!==a&&si(o,h,c,f,l,d,x.x,x.y)&&ct(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function al(i,e){let t=i;do{const n=t.prev,r=t.next.next;!qn(n,r)&&Pa(n,t,t.next,r)&&pi(n,r)&&pi(r,n)&&(e.push(n.i,t.i,r.i),mi(t),mi(t.next),t=i=r),t=t.next}while(t!==i);return Sn(t)}function ol(i,e,t,n,r,s){let a=i;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&gl(a,o)){let c=Da(a,o);a=Sn(a,a.next),c=Sn(c,c.next),di(a,e,t,n,r,s,0),di(c,e,t,n,r,s,0);return}o=o.next}a=a.next}while(a!==i)}function ll(i,e,t,n){const r=[];for(let s=0,a=e.length;s<a;s++){const o=e[s]*n,c=s<a-1?e[s+1]*n:i.length,l=Ra(i,o,c,n,!1);l===l.next&&(l.steiner=!0),r.push(ml(l))}r.sort(cl);for(let s=0;s<r.length;s++)t=hl(r[s],t);return t}function cl(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function hl(i,e){const t=ul(i,e);if(!t)return e;const n=Da(t,i);return Sn(n,n.next),Sn(t,t.next)}function ul(i,e){let t=e;const n=i.x,r=i.y;let s=-1/0,a;if(qn(i,t))return t;do{if(qn(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>s&&(s=f,a=t.x<t.next.x?t:t.next,f===n))return a}t=t.next}while(t!==e);if(!a)return null;const o=a,c=a.x,l=a.y;let h=1/0;t=a;do{if(n>=t.x&&t.x>=c&&n!==t.x&&Ca(r<l?n:s,r,c,l,r<l?s:n,r,t.x,t.y)){const f=Math.abs(r-t.y)/(n-t.x);pi(t,i)&&(f<h||f===h&&(t.x>a.x||t.x===a.x&&fl(a,t)))&&(a=t,h=f)}t=t.next}while(t!==o);return a}function fl(i,e){return ct(i.prev,i,e.prev)<0&&ct(e.next,i,i.next)<0}function dl(i,e,t,n){let r=i;do r.z===0&&(r.z=Br(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,pl(r)}function pl(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,o=0;for(let l=0;l<t&&(o++,a=a.nextZ,!!a);l++);let c=t;for(;o>0||c>0&&a;)o!==0&&(c===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,o--):(r=a,a=a.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function Br(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function ml(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Ca(i,e,t,n,r,s,a,o){return(r-a)*(e-o)>=(i-a)*(s-o)&&(i-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(n-o)}function si(i,e,t,n,r,s,a,o){return!(i===a&&e===o)&&Ca(i,e,t,n,r,s,a,o)}function gl(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!_l(i,e)&&(pi(i,e)&&pi(e,i)&&vl(i,e)&&(ct(i.prev,i,e.prev)||ct(i,e.prev,e))||qn(i,e)&&ct(i.prev,i,i.next)>0&&ct(e.prev,e,e.next)>0)}function ct(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function qn(i,e){return i.x===e.x&&i.y===e.y}function Pa(i,e,t,n){const r=Vi(ct(i,e,t)),s=Vi(ct(i,e,n)),a=Vi(ct(t,n,i)),o=Vi(ct(t,n,e));return!!(r!==s&&a!==o||r===0&&Gi(i,t,e)||s===0&&Gi(i,n,e)||a===0&&Gi(t,i,n)||o===0&&Gi(t,e,n))}function Gi(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Vi(i){return i>0?1:i<0?-1:0}function _l(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Pa(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function pi(i,e){return ct(i.prev,i,i.next)<0?ct(i,e,i.next)>=0&&ct(i,i.prev,e)>=0:ct(i,e,i.prev)<0||ct(i,i.next,e)<0}function vl(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Da(i,e){const t=zr(i.i,i.x,i.y),n=zr(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Is(i,e,t,n){const r=zr(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function mi(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function zr(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xl(i,e,t,n){let r=0;for(let s=e,a=t-n;s<t;s+=n)r+=(i[a]-i[s])*(i[s+1]+i[a+1]),a=s;return r}class Ml{static triangulate(e,t,n=2){return il(e,t,n)}}class en{static area(e){const t=e.length;let n=0;for(let r=t-1,s=0;s<t;r=s++)n+=e[r].x*e[s].y-e[s].x*e[r].y;return n*.5}static isClockWise(e){return en.area(e)<0}static triangulateShape(e,t){const n=[],r=[],s=[];Fs(e),Ns(n,e);let a=e.length;t.forEach(Fs);for(let c=0;c<t.length;c++)r.push(a),a+=t[c].length,Ns(n,t[c]);const o=Ml.triangulate(n,r);for(let c=0;c<o.length;c+=3)s.push(o.slice(c,c+3));return s}}function Fs(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function Ns(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class $r extends wt{constructor(e=new Ki([new le(.5,.5),new le(-.5,.5),new le(-.5,-.5),new le(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],s=[];for(let o=0,c=e.length;o<c;o++){const l=e[o];a(l)}this.setAttribute("position",new at(r,3)),this.setAttribute("uv",new at(s,2)),this.computeVertexNormals();function a(o){const c=[],l=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,f=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,u=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:u-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,m=t.bevelSegments!==void 0?t.bevelSegments:3;const p=t.extrudePath,A=t.UVGenerator!==void 0?t.UVGenerator:Sl;let E,x=!1,C,w,D,U;p&&(E=p.getSpacedPoints(h),x=!0,d=!1,C=p.computeFrenetFrames(h,!1),w=new P,D=new P,U=new P),d||(m=0,u=0,g=0,_=0);const y=o.extractPoints(l);let M=y.shape;const R=y.holes;if(!en.isClockWise(M)){M=M.reverse();for(let Q=0,K=R.length;Q<K;Q++){const Z=R[Q];en.isClockWise(Z)&&(R[Q]=Z.reverse())}}function G(Q){const Z=10000000000000001e-36;let J=Q[0];for(let ce=1;ce<=Q.length;ce++){const ne=ce%Q.length,he=Q[ne],Ne=he.x-J.x,Fe=he.y-J.y,T=Ne*Ne+Fe*Fe,v=Math.max(Math.abs(he.x),Math.abs(he.y),Math.abs(J.x),Math.abs(J.y)),N=Z*v*v;if(T<=N){Q.splice(ne,1),ce--;continue}J=he}}G(M),R.forEach(G);const W=R.length,q=M;for(let Q=0;Q<W;Q++){const K=R[Q];M=M.concat(K)}function k(Q,K,Z){return K||console.error("THREE.ExtrudeGeometry: vec does not exist"),Q.clone().addScaledVector(K,Z)}const te=M.length;function H(Q,K,Z){let J,ce,ne;const he=Q.x-K.x,Ne=Q.y-K.y,Fe=Z.x-Q.x,T=Z.y-Q.y,v=he*he+Ne*Ne,N=he*T-Ne*Fe;if(Math.abs(N)>Number.EPSILON){const V=Math.sqrt(v),j=Math.sqrt(Fe*Fe+T*T),X=K.x-Ne/V,we=K.y+he/V,oe=Z.x-T/j,Te=Z.y+Fe/j,Ae=((oe-X)*T-(Te-we)*Fe)/(he*T-Ne*Fe);J=X+he*Ae-Q.x,ce=we+Ne*Ae-Q.y;const ie=J*J+ce*ce;if(ie<=2)return new le(J,ce);ne=Math.sqrt(ie/2)}else{let V=!1;he>Number.EPSILON?Fe>Number.EPSILON&&(V=!0):he<-Number.EPSILON?Fe<-Number.EPSILON&&(V=!0):Math.sign(Ne)===Math.sign(T)&&(V=!0),V?(J=-Ne,ce=he,ne=Math.sqrt(v)):(J=he,ce=Ne,ne=Math.sqrt(v/2))}return new le(J/ne,ce/ne)}const ue=[];for(let Q=0,K=q.length,Z=K-1,J=Q+1;Q<K;Q++,Z++,J++)Z===K&&(Z=0),J===K&&(J=0),ue[Q]=H(q[Q],q[Z],q[J]);const _e=[];let Me,Be=ue.concat();for(let Q=0,K=W;Q<K;Q++){const Z=R[Q];Me=[];for(let J=0,ce=Z.length,ne=ce-1,he=J+1;J<ce;J++,ne++,he++)ne===ce&&(ne=0),he===ce&&(he=0),Me[J]=H(Z[J],Z[ne],Z[he]);_e.push(Me),Be=Be.concat(Me)}let qe;if(m===0)qe=en.triangulateShape(q,R);else{const Q=[],K=[];for(let Z=0;Z<m;Z++){const J=Z/m,ce=u*Math.cos(J*Math.PI/2),ne=g*Math.sin(J*Math.PI/2)+_;for(let he=0,Ne=q.length;he<Ne;he++){const Fe=k(q[he],ue[he],ne);Ce(Fe.x,Fe.y,-ce),J===0&&Q.push(Fe)}for(let he=0,Ne=W;he<Ne;he++){const Fe=R[he];Me=_e[he];const T=[];for(let v=0,N=Fe.length;v<N;v++){const V=k(Fe[v],Me[v],ne);Ce(V.x,V.y,-ce),J===0&&T.push(V)}J===0&&K.push(T)}}qe=en.triangulateShape(Q,K)}const $e=qe.length,Ye=g+_;for(let Q=0;Q<te;Q++){const K=d?k(M[Q],Be[Q],Ye):M[Q];x?(D.copy(C.normals[0]).multiplyScalar(K.x),w.copy(C.binormals[0]).multiplyScalar(K.y),U.copy(E[0]).add(D).add(w),Ce(U.x,U.y,U.z)):Ce(K.x,K.y,0)}for(let Q=1;Q<=h;Q++)for(let K=0;K<te;K++){const Z=d?k(M[K],Be[K],Ye):M[K];x?(D.copy(C.normals[Q]).multiplyScalar(Z.x),w.copy(C.binormals[Q]).multiplyScalar(Z.y),U.copy(E[Q]).add(D).add(w),Ce(U.x,U.y,U.z)):Ce(Z.x,Z.y,f/h*Q)}for(let Q=m-1;Q>=0;Q--){const K=Q/m,Z=u*Math.cos(K*Math.PI/2),J=g*Math.sin(K*Math.PI/2)+_;for(let ce=0,ne=q.length;ce<ne;ce++){const he=k(q[ce],ue[ce],J);Ce(he.x,he.y,f+Z)}for(let ce=0,ne=R.length;ce<ne;ce++){const he=R[ce];Me=_e[ce];for(let Ne=0,Fe=he.length;Ne<Fe;Ne++){const T=k(he[Ne],Me[Ne],J);x?Ce(T.x,T.y+E[h-1].y,E[h-1].x+Z):Ce(T.x,T.y,f+Z)}}}Y(),ee();function Y(){const Q=r.length/3;if(d){let K=0,Z=te*K;for(let J=0;J<$e;J++){const ce=qe[J];Ee(ce[2]+Z,ce[1]+Z,ce[0]+Z)}K=h+m*2,Z=te*K;for(let J=0;J<$e;J++){const ce=qe[J];Ee(ce[0]+Z,ce[1]+Z,ce[2]+Z)}}else{for(let K=0;K<$e;K++){const Z=qe[K];Ee(Z[2],Z[1],Z[0])}for(let K=0;K<$e;K++){const Z=qe[K];Ee(Z[0]+te*h,Z[1]+te*h,Z[2]+te*h)}}n.addGroup(Q,r.length/3-Q,0)}function ee(){const Q=r.length/3;let K=0;xe(q,K),K+=q.length;for(let Z=0,J=R.length;Z<J;Z++){const ce=R[Z];xe(ce,K),K+=ce.length}n.addGroup(Q,r.length/3-Q,1)}function xe(Q,K){let Z=Q.length;for(;--Z>=0;){const J=Z;let ce=Z-1;ce<0&&(ce=Q.length-1);for(let ne=0,he=h+m*2;ne<he;ne++){const Ne=te*ne,Fe=te*(ne+1),T=K+J+Ne,v=K+ce+Ne,N=K+ce+Fe,V=K+J+Fe;We(T,v,N,V)}}}function Ce(Q,K,Z){c.push(Q),c.push(K),c.push(Z)}function Ee(Q,K,Z){nt(Q),nt(K),nt(Z);const J=r.length/3,ce=A.generateTopUV(n,r,J-3,J-2,J-1);b(ce[0]),b(ce[1]),b(ce[2])}function We(Q,K,Z,J){nt(Q),nt(K),nt(J),nt(K),nt(Z),nt(J);const ce=r.length/3,ne=A.generateSideWallUV(n,r,ce-6,ce-3,ce-2,ce-1);b(ne[0]),b(ne[1]),b(ne[3]),b(ne[1]),b(ne[2]),b(ne[3])}function nt(Q){r.push(c[Q*3+0]),r.push(c[Q*3+1]),r.push(c[Q*3+2])}function b(Q){s.push(Q.x),s.push(Q.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return yl(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Zi[r.type]().fromJSON(r)),new $r(n,e.options)}}const Sl={generateTopUV:function(i,e,t,n,r){const s=e[t*3],a=e[t*3+1],o=e[n*3],c=e[n*3+1],l=e[r*3],h=e[r*3+1];return[new le(s,a),new le(o,c),new le(l,h)]},generateSideWallUV:function(i,e,t,n,r,s){const a=e[t*3],o=e[t*3+1],c=e[t*3+2],l=e[n*3],h=e[n*3+1],f=e[n*3+2],d=e[r*3],u=e[r*3+1],g=e[r*3+2],_=e[s*3],m=e[s*3+1],p=e[s*3+2];return Math.abs(o-h)<Math.abs(a-l)?[new le(a,1-c),new le(l,1-f),new le(d,1-g),new le(_,1-p)]:[new le(o,1-c),new le(h,1-f),new le(u,1-g),new le(m,1-p)]}};function yl(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class vi extends wt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),c=Math.floor(r),l=o+1,h=c+1,f=e/o,d=t/c,u=[],g=[],_=[],m=[];for(let p=0;p<h;p++){const A=p*d-a;for(let E=0;E<l;E++){const x=E*f-s;g.push(x,-A,0),_.push(0,0,1),m.push(E/o),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let A=0;A<o;A++){const E=A+l*p,x=A+l*(p+1),C=A+1+l*(p+1),w=A+1+l*p;u.push(E,x,w),u.push(x,C,w)}this.setIndex(u),this.setAttribute("position",new at(g,3)),this.setAttribute("normal",new at(_,3)),this.setAttribute("uv",new at(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vi(e.width,e.height,e.widthSegments,e.heightSegments)}}class jr extends wt{constructor(e=new Ki([new le(0,.5),new le(-.5,-.5),new le(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],s=[],a=[];let o=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let h=0;h<e.length;h++)l(e[h]),this.addGroup(o,c,h),o+=c,c=0;this.setIndex(n),this.setAttribute("position",new at(r,3)),this.setAttribute("normal",new at(s,3)),this.setAttribute("uv",new at(a,2));function l(h){const f=r.length/3,d=h.extractPoints(t);let u=d.shape;const g=d.holes;en.isClockWise(u)===!1&&(u=u.reverse());for(let m=0,p=g.length;m<p;m++){const A=g[m];en.isClockWise(A)===!0&&(g[m]=A.reverse())}const _=en.triangulateShape(u,g);for(let m=0,p=g.length;m<p;m++){const A=g[m];u=u.concat(A)}for(let m=0,p=u.length;m<p;m++){const A=u[m];r.push(A.x,A.y,0),s.push(0,0,1),a.push(A.x,A.y)}for(let m=0,p=_.length;m<p;m++){const A=_[m],E=A[0]+f,x=A[1]+f,C=A[2]+f;n.push(E,x,C),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return El(t,e)}static fromJSON(e,t){const n=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];n.push(a)}return new jr(n,e.curveSegments)}}function El(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}class Qr extends wt{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],f=new P,d=new P,u=[],g=[],_=[],m=[];for(let p=0;p<=n;p++){const A=[],E=p/n;let x=0;p===0&&a===0?x=.5/t:p===n&&c===Math.PI&&(x=-.5/t);for(let C=0;C<=t;C++){const w=C/t;f.x=-e*Math.cos(r+w*s)*Math.sin(a+E*o),f.y=e*Math.cos(a+E*o),f.z=e*Math.sin(r+w*s)*Math.sin(a+E*o),g.push(f.x,f.y,f.z),d.copy(f).normalize(),_.push(d.x,d.y,d.z),m.push(w+x,1-E),A.push(l++)}h.push(A)}for(let p=0;p<n;p++)for(let A=0;A<t;A++){const E=h[p][A+1],x=h[p][A],C=h[p+1][A],w=h[p+1][A+1];(p!==0||a>0)&&u.push(E,x,w),(p!==n-1||c<Math.PI)&&u.push(x,C,w)}this.setIndex(u),this.setAttribute("position",new at(g,3)),this.setAttribute("normal",new at(_,3)),this.setAttribute("uv",new at(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qr(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class $i extends wt{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const a=[],o=[],c=[],l=[],h=new P,f=new P,d=new P;for(let u=0;u<=n;u++)for(let g=0;g<=r;g++){const _=g/r*s,m=u/n*Math.PI*2;f.x=(e+t*Math.cos(m))*Math.cos(_),f.y=(e+t*Math.cos(m))*Math.sin(_),f.z=t*Math.sin(m),o.push(f.x,f.y,f.z),h.x=e*Math.cos(_),h.y=e*Math.sin(_),d.subVectors(f,h).normalize(),c.push(d.x,d.y,d.z),l.push(g/r),l.push(u/n)}for(let u=1;u<=n;u++)for(let g=1;g<=r;g++){const _=(r+1)*u+g-1,m=(r+1)*(u-1)+g-1,p=(r+1)*(u-1)+g,A=(r+1)*u+g;a.push(_,m,A),a.push(m,p,A)}this.setIndex(a),this.setAttribute("position",new at(o,3)),this.setAttribute("normal",new at(c,3)),this.setAttribute("uv",new at(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $i(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class es extends wt{constructor(e=new ba(new P(-1,-1,0),new P(-1,1,0),new P(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new P,c=new P,l=new le;let h=new P;const f=[],d=[],u=[],g=[];_(),this.setIndex(g),this.setAttribute("position",new at(f,3)),this.setAttribute("normal",new at(d,3)),this.setAttribute("uv",new at(u,2));function _(){for(let E=0;E<t;E++)m(E);m(s===!1?t:0),A(),p()}function m(E){h=e.getPointAt(E/t,h);const x=a.normals[E],C=a.binormals[E];for(let w=0;w<=r;w++){const D=w/r*Math.PI*2,U=Math.sin(D),y=-Math.cos(D);c.x=y*x.x+U*C.x,c.y=y*x.y+U*C.y,c.z=y*x.z+U*C.z,c.normalize(),d.push(c.x,c.y,c.z),o.x=h.x+n*c.x,o.y=h.y+n*c.y,o.z=h.z+n*c.z,f.push(o.x,o.y,o.z)}}function p(){for(let E=1;E<=t;E++)for(let x=1;x<=r;x++){const C=(r+1)*(E-1)+(x-1),w=(r+1)*E+(x-1),D=(r+1)*E+x,U=(r+1)*(E-1)+x;g.push(C,w,U),g.push(w,D,U)}}function A(){for(let E=0;E<=t;E++)for(let x=0;x<=r;x++)l.x=E/t,l.y=x/r,u.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new es(new Zi[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Gr extends Jn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ke(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ht,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class La extends Gr{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new le(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return He(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ke(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ke(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ke(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Tl extends Jn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ht,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Al extends Jn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class bl extends Jn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class ji extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ke(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class wl extends ji{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ke(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const wr=new rt,Os=new P,Bs=new P;class Ua{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new le(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Yr,this._frameExtents=new le(1,1),this._viewportCount=1,this._viewports=[new et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Os.setFromMatrixPosition(e.matrixWorld),t.position.copy(Os),Bs.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Bs),t.updateMatrixWorld(),wr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(wr,t.coordinateSystem,t.reversedDepth),t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(wr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const zs=new rt,ii=new P,Rr=new P;class Rl extends Ua{constructor(){super(new Lt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new le(4,2),this._viewportCount=6,this._viewports=[new et(2,1,1,1),new et(0,1,1,1),new et(3,1,1,1),new et(1,1,1,1),new et(3,0,1,1),new et(1,0,1,1)],this._cubeDirections=[new P(1,0,0),new P(-1,0,0),new P(0,0,1),new P(0,0,-1),new P(0,1,0),new P(0,-1,0)],this._cubeUps=[new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,0,1),new P(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),ii.setFromMatrixPosition(e.matrixWorld),n.position.copy(ii),Rr.copy(n.position),Rr.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Rr),n.updateMatrixWorld(),r.makeTranslation(-ii.x,-ii.y,-ii.z),zs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zs,n.coordinateSystem,n.reversedDepth)}}class Ia extends ji{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Rl}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Fa extends qr{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Cl extends Ua{constructor(){super(new Fa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Cr extends ji{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new Cl}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Pl extends Lt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}function Gs(i,e,t,n){const r=Dl(n);switch(t){case 1021:return i*e;case 1028:return i*e/r.components*r.byteLength;case 1029:return i*e/r.components*r.byteLength;case 1030:return i*e*2/r.components*r.byteLength;case 1031:return i*e*2/r.components*r.byteLength;case 1022:return i*e*3/r.components*r.byteLength;case 1023:return i*e*4/r.components*r.byteLength;case 1033:return i*e*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case 33778:case 33779:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case 35841:case 35843:return Math.max(i,16)*Math.max(e,8)/4;case 35840:case 35842:return Math.max(i,8)*Math.max(e,8)/2;case 36196:case 37492:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case 37496:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case 37808:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case 37809:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case 37810:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case 37811:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case 37812:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case 37813:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case 37814:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case 37815:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case 37816:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case 37817:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case 37818:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case 37819:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case 37820:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case 37821:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(i/4)*Math.ceil(e/4)*16;case 36283:case 36284:return Math.ceil(i/4)*Math.ceil(e/4)*8;case 36285:case 36286:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Dl(i){switch(i){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"180"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="180");/**
|
|
45
|
+
* @license
|
|
46
|
+
* Copyright 2010-2025 Three.js Authors
|
|
47
|
+
* SPDX-License-Identifier: MIT
|
|
48
|
+
*/function Na(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function Ll(i){const e=new WeakMap;function t(o,c){const l=o.array,h=o.usage,f=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),o.onUploadCallback();let u;if(l instanceof Float32Array)u=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)u=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?u=i.HALF_FLOAT:u=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)u=i.SHORT;else if(l instanceof Uint32Array)u=i.UNSIGNED_INT;else if(l instanceof Int32Array)u=i.INT;else if(l instanceof Int8Array)u=i.BYTE;else if(l instanceof Uint8Array)u=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)u=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:u,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function n(o,c,l){const h=c.array,f=c.updateRanges;if(i.bindBuffer(l,o),f.length===0)i.bufferSubData(l,0,h);else{f.sort((u,g)=>u.start-g.start);let d=0;for(let u=1;u<f.length;u++){const g=f[d],_=f[u];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,f[d]=_)}f.length=d+1;for(let u=0,g=f.length;u<g;u++){const _=f[u];i.bufferSubData(l,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}var Ul=`#ifdef USE_ALPHAHASH
|
|
49
|
+
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
50
|
+
#endif`,Il=`#ifdef USE_ALPHAHASH
|
|
51
|
+
const float ALPHA_HASH_SCALE = 0.05;
|
|
52
|
+
float hash2D( vec2 value ) {
|
|
53
|
+
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
54
|
+
}
|
|
55
|
+
float hash3D( vec3 value ) {
|
|
56
|
+
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
57
|
+
}
|
|
58
|
+
float getAlphaHashThreshold( vec3 position ) {
|
|
59
|
+
float maxDeriv = max(
|
|
60
|
+
length( dFdx( position.xyz ) ),
|
|
61
|
+
length( dFdy( position.xyz ) )
|
|
62
|
+
);
|
|
63
|
+
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
64
|
+
vec2 pixScales = vec2(
|
|
65
|
+
exp2( floor( log2( pixScale ) ) ),
|
|
66
|
+
exp2( ceil( log2( pixScale ) ) )
|
|
67
|
+
);
|
|
68
|
+
vec2 alpha = vec2(
|
|
69
|
+
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
70
|
+
hash3D( floor( pixScales.y * position.xyz ) )
|
|
71
|
+
);
|
|
72
|
+
float lerpFactor = fract( log2( pixScale ) );
|
|
73
|
+
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
74
|
+
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
75
|
+
vec3 cases = vec3(
|
|
76
|
+
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
77
|
+
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
78
|
+
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
79
|
+
);
|
|
80
|
+
float threshold = ( x < ( 1.0 - a ) )
|
|
81
|
+
? ( ( x < a ) ? cases.x : cases.y )
|
|
82
|
+
: cases.z;
|
|
83
|
+
return clamp( threshold , 1.0e-6, 1.0 );
|
|
84
|
+
}
|
|
85
|
+
#endif`,Fl=`#ifdef USE_ALPHAMAP
|
|
86
|
+
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
87
|
+
#endif`,Nl=`#ifdef USE_ALPHAMAP
|
|
88
|
+
uniform sampler2D alphaMap;
|
|
89
|
+
#endif`,Ol=`#ifdef USE_ALPHATEST
|
|
90
|
+
#ifdef ALPHA_TO_COVERAGE
|
|
91
|
+
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
92
|
+
if ( diffuseColor.a == 0.0 ) discard;
|
|
93
|
+
#else
|
|
94
|
+
if ( diffuseColor.a < alphaTest ) discard;
|
|
95
|
+
#endif
|
|
96
|
+
#endif`,Bl=`#ifdef USE_ALPHATEST
|
|
97
|
+
uniform float alphaTest;
|
|
98
|
+
#endif`,zl=`#ifdef USE_AOMAP
|
|
99
|
+
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
100
|
+
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
101
|
+
#if defined( USE_CLEARCOAT )
|
|
102
|
+
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
103
|
+
#endif
|
|
104
|
+
#if defined( USE_SHEEN )
|
|
105
|
+
sheenSpecularIndirect *= ambientOcclusion;
|
|
106
|
+
#endif
|
|
107
|
+
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
108
|
+
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
109
|
+
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
110
|
+
#endif
|
|
111
|
+
#endif`,Gl=`#ifdef USE_AOMAP
|
|
112
|
+
uniform sampler2D aoMap;
|
|
113
|
+
uniform float aoMapIntensity;
|
|
114
|
+
#endif`,Vl=`#ifdef USE_BATCHING
|
|
115
|
+
#if ! defined( GL_ANGLE_multi_draw )
|
|
116
|
+
#define gl_DrawID _gl_DrawID
|
|
117
|
+
uniform int _gl_DrawID;
|
|
118
|
+
#endif
|
|
119
|
+
uniform highp sampler2D batchingTexture;
|
|
120
|
+
uniform highp usampler2D batchingIdTexture;
|
|
121
|
+
mat4 getBatchingMatrix( const in float i ) {
|
|
122
|
+
int size = textureSize( batchingTexture, 0 ).x;
|
|
123
|
+
int j = int( i ) * 4;
|
|
124
|
+
int x = j % size;
|
|
125
|
+
int y = j / size;
|
|
126
|
+
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
127
|
+
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
128
|
+
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
129
|
+
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
130
|
+
return mat4( v1, v2, v3, v4 );
|
|
131
|
+
}
|
|
132
|
+
float getIndirectIndex( const in int i ) {
|
|
133
|
+
int size = textureSize( batchingIdTexture, 0 ).x;
|
|
134
|
+
int x = i % size;
|
|
135
|
+
int y = i / size;
|
|
136
|
+
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
|
137
|
+
}
|
|
138
|
+
#endif
|
|
139
|
+
#ifdef USE_BATCHING_COLOR
|
|
140
|
+
uniform sampler2D batchingColorTexture;
|
|
141
|
+
vec3 getBatchingColor( const in float i ) {
|
|
142
|
+
int size = textureSize( batchingColorTexture, 0 ).x;
|
|
143
|
+
int j = int( i );
|
|
144
|
+
int x = j % size;
|
|
145
|
+
int y = j / size;
|
|
146
|
+
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
147
|
+
}
|
|
148
|
+
#endif`,Hl=`#ifdef USE_BATCHING
|
|
149
|
+
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
150
|
+
#endif`,kl=`vec3 transformed = vec3( position );
|
|
151
|
+
#ifdef USE_ALPHAHASH
|
|
152
|
+
vPosition = vec3( position );
|
|
153
|
+
#endif`,Wl=`vec3 objectNormal = vec3( normal );
|
|
154
|
+
#ifdef USE_TANGENT
|
|
155
|
+
vec3 objectTangent = vec3( tangent.xyz );
|
|
156
|
+
#endif`,Xl=`float G_BlinnPhong_Implicit( ) {
|
|
157
|
+
return 0.25;
|
|
158
|
+
}
|
|
159
|
+
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
160
|
+
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
161
|
+
}
|
|
162
|
+
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
163
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
164
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
165
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
166
|
+
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
167
|
+
float G = G_BlinnPhong_Implicit( );
|
|
168
|
+
float D = D_BlinnPhong( shininess, dotNH );
|
|
169
|
+
return F * ( G * D );
|
|
170
|
+
} // validated`,ql=`#ifdef USE_IRIDESCENCE
|
|
171
|
+
const mat3 XYZ_TO_REC709 = mat3(
|
|
172
|
+
3.2404542, -0.9692660, 0.0556434,
|
|
173
|
+
-1.5371385, 1.8760108, -0.2040259,
|
|
174
|
+
-0.4985314, 0.0415560, 1.0572252
|
|
175
|
+
);
|
|
176
|
+
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
177
|
+
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
178
|
+
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
179
|
+
}
|
|
180
|
+
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
181
|
+
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
182
|
+
}
|
|
183
|
+
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
184
|
+
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
185
|
+
}
|
|
186
|
+
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
187
|
+
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
188
|
+
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
189
|
+
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
190
|
+
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
191
|
+
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
192
|
+
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
193
|
+
xyz /= 1.0685e-7;
|
|
194
|
+
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
195
|
+
return rgb;
|
|
196
|
+
}
|
|
197
|
+
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
198
|
+
vec3 I;
|
|
199
|
+
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
200
|
+
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
201
|
+
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
202
|
+
if ( cosTheta2Sq < 0.0 ) {
|
|
203
|
+
return vec3( 1.0 );
|
|
204
|
+
}
|
|
205
|
+
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
206
|
+
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
207
|
+
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
208
|
+
float T121 = 1.0 - R12;
|
|
209
|
+
float phi12 = 0.0;
|
|
210
|
+
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
211
|
+
float phi21 = PI - phi12;
|
|
212
|
+
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
213
|
+
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
214
|
+
vec3 phi23 = vec3( 0.0 );
|
|
215
|
+
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
216
|
+
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
217
|
+
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
218
|
+
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
219
|
+
vec3 phi = vec3( phi21 ) + phi23;
|
|
220
|
+
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
221
|
+
vec3 r123 = sqrt( R123 );
|
|
222
|
+
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
223
|
+
vec3 C0 = R12 + Rs;
|
|
224
|
+
I = C0;
|
|
225
|
+
vec3 Cm = Rs - T121;
|
|
226
|
+
for ( int m = 1; m <= 2; ++ m ) {
|
|
227
|
+
Cm *= r123;
|
|
228
|
+
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
229
|
+
I += Cm * Sm;
|
|
230
|
+
}
|
|
231
|
+
return max( I, vec3( 0.0 ) );
|
|
232
|
+
}
|
|
233
|
+
#endif`,Yl=`#ifdef USE_BUMPMAP
|
|
234
|
+
uniform sampler2D bumpMap;
|
|
235
|
+
uniform float bumpScale;
|
|
236
|
+
vec2 dHdxy_fwd() {
|
|
237
|
+
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
238
|
+
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
239
|
+
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
240
|
+
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
241
|
+
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
242
|
+
return vec2( dBx, dBy );
|
|
243
|
+
}
|
|
244
|
+
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
245
|
+
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
246
|
+
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|
247
|
+
vec3 vN = surf_norm;
|
|
248
|
+
vec3 R1 = cross( vSigmaY, vN );
|
|
249
|
+
vec3 R2 = cross( vN, vSigmaX );
|
|
250
|
+
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
251
|
+
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
252
|
+
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
253
|
+
}
|
|
254
|
+
#endif`,Jl=`#if NUM_CLIPPING_PLANES > 0
|
|
255
|
+
vec4 plane;
|
|
256
|
+
#ifdef ALPHA_TO_COVERAGE
|
|
257
|
+
float distanceToPlane, distanceGradient;
|
|
258
|
+
float clipOpacity = 1.0;
|
|
259
|
+
#pragma unroll_loop_start
|
|
260
|
+
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
261
|
+
plane = clippingPlanes[ i ];
|
|
262
|
+
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
263
|
+
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
264
|
+
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
265
|
+
if ( clipOpacity == 0.0 ) discard;
|
|
266
|
+
}
|
|
267
|
+
#pragma unroll_loop_end
|
|
268
|
+
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
269
|
+
float unionClipOpacity = 1.0;
|
|
270
|
+
#pragma unroll_loop_start
|
|
271
|
+
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
272
|
+
plane = clippingPlanes[ i ];
|
|
273
|
+
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
274
|
+
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
275
|
+
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
276
|
+
}
|
|
277
|
+
#pragma unroll_loop_end
|
|
278
|
+
clipOpacity *= 1.0 - unionClipOpacity;
|
|
279
|
+
#endif
|
|
280
|
+
diffuseColor.a *= clipOpacity;
|
|
281
|
+
if ( diffuseColor.a == 0.0 ) discard;
|
|
282
|
+
#else
|
|
283
|
+
#pragma unroll_loop_start
|
|
284
|
+
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
285
|
+
plane = clippingPlanes[ i ];
|
|
286
|
+
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
287
|
+
}
|
|
288
|
+
#pragma unroll_loop_end
|
|
289
|
+
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
290
|
+
bool clipped = true;
|
|
291
|
+
#pragma unroll_loop_start
|
|
292
|
+
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
293
|
+
plane = clippingPlanes[ i ];
|
|
294
|
+
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
295
|
+
}
|
|
296
|
+
#pragma unroll_loop_end
|
|
297
|
+
if ( clipped ) discard;
|
|
298
|
+
#endif
|
|
299
|
+
#endif
|
|
300
|
+
#endif`,Zl=`#if NUM_CLIPPING_PLANES > 0
|
|
301
|
+
varying vec3 vClipPosition;
|
|
302
|
+
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
303
|
+
#endif`,Kl=`#if NUM_CLIPPING_PLANES > 0
|
|
304
|
+
varying vec3 vClipPosition;
|
|
305
|
+
#endif`,$l=`#if NUM_CLIPPING_PLANES > 0
|
|
306
|
+
vClipPosition = - mvPosition.xyz;
|
|
307
|
+
#endif`,jl=`#if defined( USE_COLOR_ALPHA )
|
|
308
|
+
diffuseColor *= vColor;
|
|
309
|
+
#elif defined( USE_COLOR )
|
|
310
|
+
diffuseColor.rgb *= vColor;
|
|
311
|
+
#endif`,Ql=`#if defined( USE_COLOR_ALPHA )
|
|
312
|
+
varying vec4 vColor;
|
|
313
|
+
#elif defined( USE_COLOR )
|
|
314
|
+
varying vec3 vColor;
|
|
315
|
+
#endif`,ec=`#if defined( USE_COLOR_ALPHA )
|
|
316
|
+
varying vec4 vColor;
|
|
317
|
+
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
318
|
+
varying vec3 vColor;
|
|
319
|
+
#endif`,tc=`#if defined( USE_COLOR_ALPHA )
|
|
320
|
+
vColor = vec4( 1.0 );
|
|
321
|
+
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
322
|
+
vColor = vec3( 1.0 );
|
|
323
|
+
#endif
|
|
324
|
+
#ifdef USE_COLOR
|
|
325
|
+
vColor *= color;
|
|
326
|
+
#endif
|
|
327
|
+
#ifdef USE_INSTANCING_COLOR
|
|
328
|
+
vColor.xyz *= instanceColor.xyz;
|
|
329
|
+
#endif
|
|
330
|
+
#ifdef USE_BATCHING_COLOR
|
|
331
|
+
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
332
|
+
vColor.xyz *= batchingColor.xyz;
|
|
333
|
+
#endif`,nc=`#define PI 3.141592653589793
|
|
334
|
+
#define PI2 6.283185307179586
|
|
335
|
+
#define PI_HALF 1.5707963267948966
|
|
336
|
+
#define RECIPROCAL_PI 0.3183098861837907
|
|
337
|
+
#define RECIPROCAL_PI2 0.15915494309189535
|
|
338
|
+
#define EPSILON 1e-6
|
|
339
|
+
#ifndef saturate
|
|
340
|
+
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
341
|
+
#endif
|
|
342
|
+
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
343
|
+
float pow2( const in float x ) { return x*x; }
|
|
344
|
+
vec3 pow2( const in vec3 x ) { return x*x; }
|
|
345
|
+
float pow3( const in float x ) { return x*x*x; }
|
|
346
|
+
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
347
|
+
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
348
|
+
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
349
|
+
highp float rand( const in vec2 uv ) {
|
|
350
|
+
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
351
|
+
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
352
|
+
return fract( sin( sn ) * c );
|
|
353
|
+
}
|
|
354
|
+
#ifdef HIGH_PRECISION
|
|
355
|
+
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
356
|
+
#else
|
|
357
|
+
float precisionSafeLength( vec3 v ) {
|
|
358
|
+
float maxComponent = max3( abs( v ) );
|
|
359
|
+
return length( v / maxComponent ) * maxComponent;
|
|
360
|
+
}
|
|
361
|
+
#endif
|
|
362
|
+
struct IncidentLight {
|
|
363
|
+
vec3 color;
|
|
364
|
+
vec3 direction;
|
|
365
|
+
bool visible;
|
|
366
|
+
};
|
|
367
|
+
struct ReflectedLight {
|
|
368
|
+
vec3 directDiffuse;
|
|
369
|
+
vec3 directSpecular;
|
|
370
|
+
vec3 indirectDiffuse;
|
|
371
|
+
vec3 indirectSpecular;
|
|
372
|
+
};
|
|
373
|
+
#ifdef USE_ALPHAHASH
|
|
374
|
+
varying vec3 vPosition;
|
|
375
|
+
#endif
|
|
376
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
377
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
378
|
+
}
|
|
379
|
+
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
380
|
+
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
381
|
+
}
|
|
382
|
+
mat3 transposeMat3( const in mat3 m ) {
|
|
383
|
+
mat3 tmp;
|
|
384
|
+
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|
385
|
+
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|
386
|
+
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|
387
|
+
return tmp;
|
|
388
|
+
}
|
|
389
|
+
bool isPerspectiveMatrix( mat4 m ) {
|
|
390
|
+
return m[ 2 ][ 3 ] == - 1.0;
|
|
391
|
+
}
|
|
392
|
+
vec2 equirectUv( in vec3 dir ) {
|
|
393
|
+
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|
394
|
+
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|
395
|
+
return vec2( u, v );
|
|
396
|
+
}
|
|
397
|
+
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
398
|
+
return RECIPROCAL_PI * diffuseColor;
|
|
399
|
+
}
|
|
400
|
+
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
401
|
+
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
402
|
+
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
403
|
+
}
|
|
404
|
+
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
405
|
+
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
406
|
+
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
407
|
+
} // validated`,ic=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
408
|
+
#define cubeUV_minMipLevel 4.0
|
|
409
|
+
#define cubeUV_minTileSize 16.0
|
|
410
|
+
float getFace( vec3 direction ) {
|
|
411
|
+
vec3 absDirection = abs( direction );
|
|
412
|
+
float face = - 1.0;
|
|
413
|
+
if ( absDirection.x > absDirection.z ) {
|
|
414
|
+
if ( absDirection.x > absDirection.y )
|
|
415
|
+
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
416
|
+
else
|
|
417
|
+
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
418
|
+
} else {
|
|
419
|
+
if ( absDirection.z > absDirection.y )
|
|
420
|
+
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
421
|
+
else
|
|
422
|
+
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
423
|
+
}
|
|
424
|
+
return face;
|
|
425
|
+
}
|
|
426
|
+
vec2 getUV( vec3 direction, float face ) {
|
|
427
|
+
vec2 uv;
|
|
428
|
+
if ( face == 0.0 ) {
|
|
429
|
+
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
430
|
+
} else if ( face == 1.0 ) {
|
|
431
|
+
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
432
|
+
} else if ( face == 2.0 ) {
|
|
433
|
+
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
434
|
+
} else if ( face == 3.0 ) {
|
|
435
|
+
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
436
|
+
} else if ( face == 4.0 ) {
|
|
437
|
+
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
438
|
+
} else {
|
|
439
|
+
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
440
|
+
}
|
|
441
|
+
return 0.5 * ( uv + 1.0 );
|
|
442
|
+
}
|
|
443
|
+
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
444
|
+
float face = getFace( direction );
|
|
445
|
+
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
446
|
+
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
447
|
+
float faceSize = exp2( mipInt );
|
|
448
|
+
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
449
|
+
if ( face > 2.0 ) {
|
|
450
|
+
uv.y += faceSize;
|
|
451
|
+
face -= 3.0;
|
|
452
|
+
}
|
|
453
|
+
uv.x += face * faceSize;
|
|
454
|
+
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
455
|
+
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
456
|
+
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
457
|
+
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
458
|
+
#ifdef texture2DGradEXT
|
|
459
|
+
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
460
|
+
#else
|
|
461
|
+
return texture2D( envMap, uv ).rgb;
|
|
462
|
+
#endif
|
|
463
|
+
}
|
|
464
|
+
#define cubeUV_r0 1.0
|
|
465
|
+
#define cubeUV_m0 - 2.0
|
|
466
|
+
#define cubeUV_r1 0.8
|
|
467
|
+
#define cubeUV_m1 - 1.0
|
|
468
|
+
#define cubeUV_r4 0.4
|
|
469
|
+
#define cubeUV_m4 2.0
|
|
470
|
+
#define cubeUV_r5 0.305
|
|
471
|
+
#define cubeUV_m5 3.0
|
|
472
|
+
#define cubeUV_r6 0.21
|
|
473
|
+
#define cubeUV_m6 4.0
|
|
474
|
+
float roughnessToMip( float roughness ) {
|
|
475
|
+
float mip = 0.0;
|
|
476
|
+
if ( roughness >= cubeUV_r1 ) {
|
|
477
|
+
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
478
|
+
} else if ( roughness >= cubeUV_r4 ) {
|
|
479
|
+
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
480
|
+
} else if ( roughness >= cubeUV_r5 ) {
|
|
481
|
+
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
482
|
+
} else if ( roughness >= cubeUV_r6 ) {
|
|
483
|
+
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
484
|
+
} else {
|
|
485
|
+
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
486
|
+
return mip;
|
|
487
|
+
}
|
|
488
|
+
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
489
|
+
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
490
|
+
float mipF = fract( mip );
|
|
491
|
+
float mipInt = floor( mip );
|
|
492
|
+
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
493
|
+
if ( mipF == 0.0 ) {
|
|
494
|
+
return vec4( color0, 1.0 );
|
|
495
|
+
} else {
|
|
496
|
+
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
497
|
+
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
#endif`,rc=`vec3 transformedNormal = objectNormal;
|
|
501
|
+
#ifdef USE_TANGENT
|
|
502
|
+
vec3 transformedTangent = objectTangent;
|
|
503
|
+
#endif
|
|
504
|
+
#ifdef USE_BATCHING
|
|
505
|
+
mat3 bm = mat3( batchingMatrix );
|
|
506
|
+
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
507
|
+
transformedNormal = bm * transformedNormal;
|
|
508
|
+
#ifdef USE_TANGENT
|
|
509
|
+
transformedTangent = bm * transformedTangent;
|
|
510
|
+
#endif
|
|
511
|
+
#endif
|
|
512
|
+
#ifdef USE_INSTANCING
|
|
513
|
+
mat3 im = mat3( instanceMatrix );
|
|
514
|
+
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
515
|
+
transformedNormal = im * transformedNormal;
|
|
516
|
+
#ifdef USE_TANGENT
|
|
517
|
+
transformedTangent = im * transformedTangent;
|
|
518
|
+
#endif
|
|
519
|
+
#endif
|
|
520
|
+
transformedNormal = normalMatrix * transformedNormal;
|
|
521
|
+
#ifdef FLIP_SIDED
|
|
522
|
+
transformedNormal = - transformedNormal;
|
|
523
|
+
#endif
|
|
524
|
+
#ifdef USE_TANGENT
|
|
525
|
+
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
526
|
+
#ifdef FLIP_SIDED
|
|
527
|
+
transformedTangent = - transformedTangent;
|
|
528
|
+
#endif
|
|
529
|
+
#endif`,sc=`#ifdef USE_DISPLACEMENTMAP
|
|
530
|
+
uniform sampler2D displacementMap;
|
|
531
|
+
uniform float displacementScale;
|
|
532
|
+
uniform float displacementBias;
|
|
533
|
+
#endif`,ac=`#ifdef USE_DISPLACEMENTMAP
|
|
534
|
+
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
535
|
+
#endif`,oc=`#ifdef USE_EMISSIVEMAP
|
|
536
|
+
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
537
|
+
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
538
|
+
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
539
|
+
#endif
|
|
540
|
+
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
541
|
+
#endif`,lc=`#ifdef USE_EMISSIVEMAP
|
|
542
|
+
uniform sampler2D emissiveMap;
|
|
543
|
+
#endif`,cc="gl_FragColor = linearToOutputTexel( gl_FragColor );",hc=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
544
|
+
return value;
|
|
545
|
+
}
|
|
546
|
+
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
547
|
+
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
|
|
548
|
+
}
|
|
549
|
+
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
550
|
+
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
551
|
+
}`,uc=`#ifdef USE_ENVMAP
|
|
552
|
+
#ifdef ENV_WORLDPOS
|
|
553
|
+
vec3 cameraToFrag;
|
|
554
|
+
if ( isOrthographic ) {
|
|
555
|
+
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
556
|
+
} else {
|
|
557
|
+
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
558
|
+
}
|
|
559
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
560
|
+
#ifdef ENVMAP_MODE_REFLECTION
|
|
561
|
+
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
562
|
+
#else
|
|
563
|
+
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
564
|
+
#endif
|
|
565
|
+
#else
|
|
566
|
+
vec3 reflectVec = vReflect;
|
|
567
|
+
#endif
|
|
568
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
569
|
+
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
570
|
+
#else
|
|
571
|
+
vec4 envColor = vec4( 0.0 );
|
|
572
|
+
#endif
|
|
573
|
+
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
574
|
+
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
575
|
+
#elif defined( ENVMAP_BLENDING_MIX )
|
|
576
|
+
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
577
|
+
#elif defined( ENVMAP_BLENDING_ADD )
|
|
578
|
+
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
579
|
+
#endif
|
|
580
|
+
#endif`,fc=`#ifdef USE_ENVMAP
|
|
581
|
+
uniform float envMapIntensity;
|
|
582
|
+
uniform float flipEnvMap;
|
|
583
|
+
uniform mat3 envMapRotation;
|
|
584
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
585
|
+
uniform samplerCube envMap;
|
|
586
|
+
#else
|
|
587
|
+
uniform sampler2D envMap;
|
|
588
|
+
#endif
|
|
589
|
+
|
|
590
|
+
#endif`,dc=`#ifdef USE_ENVMAP
|
|
591
|
+
uniform float reflectivity;
|
|
592
|
+
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
593
|
+
#define ENV_WORLDPOS
|
|
594
|
+
#endif
|
|
595
|
+
#ifdef ENV_WORLDPOS
|
|
596
|
+
varying vec3 vWorldPosition;
|
|
597
|
+
uniform float refractionRatio;
|
|
598
|
+
#else
|
|
599
|
+
varying vec3 vReflect;
|
|
600
|
+
#endif
|
|
601
|
+
#endif`,pc=`#ifdef USE_ENVMAP
|
|
602
|
+
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
603
|
+
#define ENV_WORLDPOS
|
|
604
|
+
#endif
|
|
605
|
+
#ifdef ENV_WORLDPOS
|
|
606
|
+
|
|
607
|
+
varying vec3 vWorldPosition;
|
|
608
|
+
#else
|
|
609
|
+
varying vec3 vReflect;
|
|
610
|
+
uniform float refractionRatio;
|
|
611
|
+
#endif
|
|
612
|
+
#endif`,mc=`#ifdef USE_ENVMAP
|
|
613
|
+
#ifdef ENV_WORLDPOS
|
|
614
|
+
vWorldPosition = worldPosition.xyz;
|
|
615
|
+
#else
|
|
616
|
+
vec3 cameraToVertex;
|
|
617
|
+
if ( isOrthographic ) {
|
|
618
|
+
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
619
|
+
} else {
|
|
620
|
+
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|
621
|
+
}
|
|
622
|
+
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
623
|
+
#ifdef ENVMAP_MODE_REFLECTION
|
|
624
|
+
vReflect = reflect( cameraToVertex, worldNormal );
|
|
625
|
+
#else
|
|
626
|
+
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
627
|
+
#endif
|
|
628
|
+
#endif
|
|
629
|
+
#endif`,gc=`#ifdef USE_FOG
|
|
630
|
+
vFogDepth = - mvPosition.z;
|
|
631
|
+
#endif`,_c=`#ifdef USE_FOG
|
|
632
|
+
varying float vFogDepth;
|
|
633
|
+
#endif`,vc=`#ifdef USE_FOG
|
|
634
|
+
#ifdef FOG_EXP2
|
|
635
|
+
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
636
|
+
#else
|
|
637
|
+
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
638
|
+
#endif
|
|
639
|
+
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
640
|
+
#endif`,xc=`#ifdef USE_FOG
|
|
641
|
+
uniform vec3 fogColor;
|
|
642
|
+
varying float vFogDepth;
|
|
643
|
+
#ifdef FOG_EXP2
|
|
644
|
+
uniform float fogDensity;
|
|
645
|
+
#else
|
|
646
|
+
uniform float fogNear;
|
|
647
|
+
uniform float fogFar;
|
|
648
|
+
#endif
|
|
649
|
+
#endif`,Mc=`#ifdef USE_GRADIENTMAP
|
|
650
|
+
uniform sampler2D gradientMap;
|
|
651
|
+
#endif
|
|
652
|
+
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
653
|
+
float dotNL = dot( normal, lightDirection );
|
|
654
|
+
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|
655
|
+
#ifdef USE_GRADIENTMAP
|
|
656
|
+
return vec3( texture2D( gradientMap, coord ).r );
|
|
657
|
+
#else
|
|
658
|
+
vec2 fw = fwidth( coord ) * 0.5;
|
|
659
|
+
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
660
|
+
#endif
|
|
661
|
+
}`,Sc=`#ifdef USE_LIGHTMAP
|
|
662
|
+
uniform sampler2D lightMap;
|
|
663
|
+
uniform float lightMapIntensity;
|
|
664
|
+
#endif`,yc=`LambertMaterial material;
|
|
665
|
+
material.diffuseColor = diffuseColor.rgb;
|
|
666
|
+
material.specularStrength = specularStrength;`,Ec=`varying vec3 vViewPosition;
|
|
667
|
+
struct LambertMaterial {
|
|
668
|
+
vec3 diffuseColor;
|
|
669
|
+
float specularStrength;
|
|
670
|
+
};
|
|
671
|
+
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
672
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
673
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
674
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
675
|
+
}
|
|
676
|
+
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
677
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
678
|
+
}
|
|
679
|
+
#define RE_Direct RE_Direct_Lambert
|
|
680
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Tc=`uniform bool receiveShadow;
|
|
681
|
+
uniform vec3 ambientLightColor;
|
|
682
|
+
#if defined( USE_LIGHT_PROBES )
|
|
683
|
+
uniform vec3 lightProbe[ 9 ];
|
|
684
|
+
#endif
|
|
685
|
+
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
686
|
+
float x = normal.x, y = normal.y, z = normal.z;
|
|
687
|
+
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
688
|
+
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
689
|
+
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
690
|
+
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
691
|
+
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
692
|
+
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
693
|
+
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
694
|
+
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
695
|
+
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
699
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
700
|
+
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
701
|
+
return irradiance;
|
|
702
|
+
}
|
|
703
|
+
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
704
|
+
vec3 irradiance = ambientLightColor;
|
|
705
|
+
return irradiance;
|
|
706
|
+
}
|
|
707
|
+
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
708
|
+
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
709
|
+
if ( cutoffDistance > 0.0 ) {
|
|
710
|
+
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
711
|
+
}
|
|
712
|
+
return distanceFalloff;
|
|
713
|
+
}
|
|
714
|
+
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
715
|
+
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
716
|
+
}
|
|
717
|
+
#if NUM_DIR_LIGHTS > 0
|
|
718
|
+
struct DirectionalLight {
|
|
719
|
+
vec3 direction;
|
|
720
|
+
vec3 color;
|
|
721
|
+
};
|
|
722
|
+
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
723
|
+
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|
724
|
+
light.color = directionalLight.color;
|
|
725
|
+
light.direction = directionalLight.direction;
|
|
726
|
+
light.visible = true;
|
|
727
|
+
}
|
|
728
|
+
#endif
|
|
729
|
+
#if NUM_POINT_LIGHTS > 0
|
|
730
|
+
struct PointLight {
|
|
731
|
+
vec3 position;
|
|
732
|
+
vec3 color;
|
|
733
|
+
float distance;
|
|
734
|
+
float decay;
|
|
735
|
+
};
|
|
736
|
+
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
737
|
+
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
738
|
+
vec3 lVector = pointLight.position - geometryPosition;
|
|
739
|
+
light.direction = normalize( lVector );
|
|
740
|
+
float lightDistance = length( lVector );
|
|
741
|
+
light.color = pointLight.color;
|
|
742
|
+
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
743
|
+
light.visible = ( light.color != vec3( 0.0 ) );
|
|
744
|
+
}
|
|
745
|
+
#endif
|
|
746
|
+
#if NUM_SPOT_LIGHTS > 0
|
|
747
|
+
struct SpotLight {
|
|
748
|
+
vec3 position;
|
|
749
|
+
vec3 direction;
|
|
750
|
+
vec3 color;
|
|
751
|
+
float distance;
|
|
752
|
+
float decay;
|
|
753
|
+
float coneCos;
|
|
754
|
+
float penumbraCos;
|
|
755
|
+
};
|
|
756
|
+
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
757
|
+
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
758
|
+
vec3 lVector = spotLight.position - geometryPosition;
|
|
759
|
+
light.direction = normalize( lVector );
|
|
760
|
+
float angleCos = dot( light.direction, spotLight.direction );
|
|
761
|
+
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
762
|
+
if ( spotAttenuation > 0.0 ) {
|
|
763
|
+
float lightDistance = length( lVector );
|
|
764
|
+
light.color = spotLight.color * spotAttenuation;
|
|
765
|
+
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
766
|
+
light.visible = ( light.color != vec3( 0.0 ) );
|
|
767
|
+
} else {
|
|
768
|
+
light.color = vec3( 0.0 );
|
|
769
|
+
light.visible = false;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
#endif
|
|
773
|
+
#if NUM_RECT_AREA_LIGHTS > 0
|
|
774
|
+
struct RectAreaLight {
|
|
775
|
+
vec3 color;
|
|
776
|
+
vec3 position;
|
|
777
|
+
vec3 halfWidth;
|
|
778
|
+
vec3 halfHeight;
|
|
779
|
+
};
|
|
780
|
+
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
781
|
+
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
782
|
+
#endif
|
|
783
|
+
#if NUM_HEMI_LIGHTS > 0
|
|
784
|
+
struct HemisphereLight {
|
|
785
|
+
vec3 direction;
|
|
786
|
+
vec3 skyColor;
|
|
787
|
+
vec3 groundColor;
|
|
788
|
+
};
|
|
789
|
+
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
790
|
+
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
791
|
+
float dotNL = dot( normal, hemiLight.direction );
|
|
792
|
+
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
793
|
+
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
794
|
+
return irradiance;
|
|
795
|
+
}
|
|
796
|
+
#endif`,Ac=`#ifdef USE_ENVMAP
|
|
797
|
+
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
798
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
799
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
800
|
+
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
|
801
|
+
return PI * envMapColor.rgb * envMapIntensity;
|
|
802
|
+
#else
|
|
803
|
+
return vec3( 0.0 );
|
|
804
|
+
#endif
|
|
805
|
+
}
|
|
806
|
+
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
807
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
808
|
+
vec3 reflectVec = reflect( - viewDir, normal );
|
|
809
|
+
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
|
810
|
+
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
811
|
+
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
|
812
|
+
return envMapColor.rgb * envMapIntensity;
|
|
813
|
+
#else
|
|
814
|
+
return vec3( 0.0 );
|
|
815
|
+
#endif
|
|
816
|
+
}
|
|
817
|
+
#ifdef USE_ANISOTROPY
|
|
818
|
+
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
819
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
820
|
+
vec3 bentNormal = cross( bitangent, viewDir );
|
|
821
|
+
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
822
|
+
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
823
|
+
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
824
|
+
#else
|
|
825
|
+
return vec3( 0.0 );
|
|
826
|
+
#endif
|
|
827
|
+
}
|
|
828
|
+
#endif
|
|
829
|
+
#endif`,bc=`ToonMaterial material;
|
|
830
|
+
material.diffuseColor = diffuseColor.rgb;`,wc=`varying vec3 vViewPosition;
|
|
831
|
+
struct ToonMaterial {
|
|
832
|
+
vec3 diffuseColor;
|
|
833
|
+
};
|
|
834
|
+
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
835
|
+
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
836
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
837
|
+
}
|
|
838
|
+
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
839
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
840
|
+
}
|
|
841
|
+
#define RE_Direct RE_Direct_Toon
|
|
842
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Rc=`BlinnPhongMaterial material;
|
|
843
|
+
material.diffuseColor = diffuseColor.rgb;
|
|
844
|
+
material.specularColor = specular;
|
|
845
|
+
material.specularShininess = shininess;
|
|
846
|
+
material.specularStrength = specularStrength;`,Cc=`varying vec3 vViewPosition;
|
|
847
|
+
struct BlinnPhongMaterial {
|
|
848
|
+
vec3 diffuseColor;
|
|
849
|
+
vec3 specularColor;
|
|
850
|
+
float specularShininess;
|
|
851
|
+
float specularStrength;
|
|
852
|
+
};
|
|
853
|
+
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
854
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
855
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
856
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
857
|
+
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
858
|
+
}
|
|
859
|
+
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
860
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
861
|
+
}
|
|
862
|
+
#define RE_Direct RE_Direct_BlinnPhong
|
|
863
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Pc=`PhysicalMaterial material;
|
|
864
|
+
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
865
|
+
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
866
|
+
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
867
|
+
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
868
|
+
material.roughness = min( material.roughness, 1.0 );
|
|
869
|
+
#ifdef IOR
|
|
870
|
+
material.ior = ior;
|
|
871
|
+
#ifdef USE_SPECULAR
|
|
872
|
+
float specularIntensityFactor = specularIntensity;
|
|
873
|
+
vec3 specularColorFactor = specularColor;
|
|
874
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
875
|
+
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
876
|
+
#endif
|
|
877
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
878
|
+
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
879
|
+
#endif
|
|
880
|
+
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
881
|
+
#else
|
|
882
|
+
float specularIntensityFactor = 1.0;
|
|
883
|
+
vec3 specularColorFactor = vec3( 1.0 );
|
|
884
|
+
material.specularF90 = 1.0;
|
|
885
|
+
#endif
|
|
886
|
+
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
887
|
+
#else
|
|
888
|
+
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
889
|
+
material.specularF90 = 1.0;
|
|
890
|
+
#endif
|
|
891
|
+
#ifdef USE_CLEARCOAT
|
|
892
|
+
material.clearcoat = clearcoat;
|
|
893
|
+
material.clearcoatRoughness = clearcoatRoughness;
|
|
894
|
+
material.clearcoatF0 = vec3( 0.04 );
|
|
895
|
+
material.clearcoatF90 = 1.0;
|
|
896
|
+
#ifdef USE_CLEARCOATMAP
|
|
897
|
+
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|
898
|
+
#endif
|
|
899
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
900
|
+
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
901
|
+
#endif
|
|
902
|
+
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
903
|
+
material.clearcoatRoughness += geometryRoughness;
|
|
904
|
+
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
905
|
+
#endif
|
|
906
|
+
#ifdef USE_DISPERSION
|
|
907
|
+
material.dispersion = dispersion;
|
|
908
|
+
#endif
|
|
909
|
+
#ifdef USE_IRIDESCENCE
|
|
910
|
+
material.iridescence = iridescence;
|
|
911
|
+
material.iridescenceIOR = iridescenceIOR;
|
|
912
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
913
|
+
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
914
|
+
#endif
|
|
915
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
916
|
+
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
917
|
+
#else
|
|
918
|
+
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
919
|
+
#endif
|
|
920
|
+
#endif
|
|
921
|
+
#ifdef USE_SHEEN
|
|
922
|
+
material.sheenColor = sheenColor;
|
|
923
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
924
|
+
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
925
|
+
#endif
|
|
926
|
+
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
927
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
928
|
+
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
929
|
+
#endif
|
|
930
|
+
#endif
|
|
931
|
+
#ifdef USE_ANISOTROPY
|
|
932
|
+
#ifdef USE_ANISOTROPYMAP
|
|
933
|
+
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
934
|
+
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
935
|
+
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
936
|
+
#else
|
|
937
|
+
vec2 anisotropyV = anisotropyVector;
|
|
938
|
+
#endif
|
|
939
|
+
material.anisotropy = length( anisotropyV );
|
|
940
|
+
if( material.anisotropy == 0.0 ) {
|
|
941
|
+
anisotropyV = vec2( 1.0, 0.0 );
|
|
942
|
+
} else {
|
|
943
|
+
anisotropyV /= material.anisotropy;
|
|
944
|
+
material.anisotropy = saturate( material.anisotropy );
|
|
945
|
+
}
|
|
946
|
+
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
947
|
+
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
948
|
+
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
949
|
+
#endif`,Dc=`struct PhysicalMaterial {
|
|
950
|
+
vec3 diffuseColor;
|
|
951
|
+
float roughness;
|
|
952
|
+
vec3 specularColor;
|
|
953
|
+
float specularF90;
|
|
954
|
+
float dispersion;
|
|
955
|
+
#ifdef USE_CLEARCOAT
|
|
956
|
+
float clearcoat;
|
|
957
|
+
float clearcoatRoughness;
|
|
958
|
+
vec3 clearcoatF0;
|
|
959
|
+
float clearcoatF90;
|
|
960
|
+
#endif
|
|
961
|
+
#ifdef USE_IRIDESCENCE
|
|
962
|
+
float iridescence;
|
|
963
|
+
float iridescenceIOR;
|
|
964
|
+
float iridescenceThickness;
|
|
965
|
+
vec3 iridescenceFresnel;
|
|
966
|
+
vec3 iridescenceF0;
|
|
967
|
+
#endif
|
|
968
|
+
#ifdef USE_SHEEN
|
|
969
|
+
vec3 sheenColor;
|
|
970
|
+
float sheenRoughness;
|
|
971
|
+
#endif
|
|
972
|
+
#ifdef IOR
|
|
973
|
+
float ior;
|
|
974
|
+
#endif
|
|
975
|
+
#ifdef USE_TRANSMISSION
|
|
976
|
+
float transmission;
|
|
977
|
+
float transmissionAlpha;
|
|
978
|
+
float thickness;
|
|
979
|
+
float attenuationDistance;
|
|
980
|
+
vec3 attenuationColor;
|
|
981
|
+
#endif
|
|
982
|
+
#ifdef USE_ANISOTROPY
|
|
983
|
+
float anisotropy;
|
|
984
|
+
float alphaT;
|
|
985
|
+
vec3 anisotropyT;
|
|
986
|
+
vec3 anisotropyB;
|
|
987
|
+
#endif
|
|
988
|
+
};
|
|
989
|
+
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
990
|
+
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
991
|
+
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
992
|
+
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
993
|
+
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
994
|
+
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
995
|
+
float x2 = x * x;
|
|
996
|
+
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
997
|
+
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
998
|
+
}
|
|
999
|
+
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
1000
|
+
float a2 = pow2( alpha );
|
|
1001
|
+
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
1002
|
+
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
1003
|
+
return 0.5 / max( gv + gl, EPSILON );
|
|
1004
|
+
}
|
|
1005
|
+
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
1006
|
+
float a2 = pow2( alpha );
|
|
1007
|
+
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
1008
|
+
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
1009
|
+
}
|
|
1010
|
+
#ifdef USE_ANISOTROPY
|
|
1011
|
+
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
|
1012
|
+
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
1013
|
+
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
1014
|
+
float v = 0.5 / ( gv + gl );
|
|
1015
|
+
return saturate(v);
|
|
1016
|
+
}
|
|
1017
|
+
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
1018
|
+
float a2 = alphaT * alphaB;
|
|
1019
|
+
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
1020
|
+
highp float v2 = dot( v, v );
|
|
1021
|
+
float w2 = a2 / v2;
|
|
1022
|
+
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
1023
|
+
}
|
|
1024
|
+
#endif
|
|
1025
|
+
#ifdef USE_CLEARCOAT
|
|
1026
|
+
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
1027
|
+
vec3 f0 = material.clearcoatF0;
|
|
1028
|
+
float f90 = material.clearcoatF90;
|
|
1029
|
+
float roughness = material.clearcoatRoughness;
|
|
1030
|
+
float alpha = pow2( roughness );
|
|
1031
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1032
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1033
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1034
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1035
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
1036
|
+
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
1037
|
+
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
1038
|
+
float D = D_GGX( alpha, dotNH );
|
|
1039
|
+
return F * ( V * D );
|
|
1040
|
+
}
|
|
1041
|
+
#endif
|
|
1042
|
+
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
1043
|
+
vec3 f0 = material.specularColor;
|
|
1044
|
+
float f90 = material.specularF90;
|
|
1045
|
+
float roughness = material.roughness;
|
|
1046
|
+
float alpha = pow2( roughness );
|
|
1047
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1048
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1049
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1050
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1051
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
1052
|
+
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
1053
|
+
#ifdef USE_IRIDESCENCE
|
|
1054
|
+
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
1055
|
+
#endif
|
|
1056
|
+
#ifdef USE_ANISOTROPY
|
|
1057
|
+
float dotTL = dot( material.anisotropyT, lightDir );
|
|
1058
|
+
float dotTV = dot( material.anisotropyT, viewDir );
|
|
1059
|
+
float dotTH = dot( material.anisotropyT, halfDir );
|
|
1060
|
+
float dotBL = dot( material.anisotropyB, lightDir );
|
|
1061
|
+
float dotBV = dot( material.anisotropyB, viewDir );
|
|
1062
|
+
float dotBH = dot( material.anisotropyB, halfDir );
|
|
1063
|
+
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
1064
|
+
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
1065
|
+
#else
|
|
1066
|
+
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
1067
|
+
float D = D_GGX( alpha, dotNH );
|
|
1068
|
+
#endif
|
|
1069
|
+
return F * ( V * D );
|
|
1070
|
+
}
|
|
1071
|
+
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
1072
|
+
const float LUT_SIZE = 64.0;
|
|
1073
|
+
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
1074
|
+
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
1075
|
+
float dotNV = saturate( dot( N, V ) );
|
|
1076
|
+
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
1077
|
+
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
1078
|
+
return uv;
|
|
1079
|
+
}
|
|
1080
|
+
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
1081
|
+
float l = length( f );
|
|
1082
|
+
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
1083
|
+
}
|
|
1084
|
+
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
1085
|
+
float x = dot( v1, v2 );
|
|
1086
|
+
float y = abs( x );
|
|
1087
|
+
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
1088
|
+
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
1089
|
+
float v = a / b;
|
|
1090
|
+
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
1091
|
+
return cross( v1, v2 ) * theta_sintheta;
|
|
1092
|
+
}
|
|
1093
|
+
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
1094
|
+
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
1095
|
+
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
1096
|
+
vec3 lightNormal = cross( v1, v2 );
|
|
1097
|
+
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
1098
|
+
vec3 T1, T2;
|
|
1099
|
+
T1 = normalize( V - N * dot( V, N ) );
|
|
1100
|
+
T2 = - cross( N, T1 );
|
|
1101
|
+
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
|
1102
|
+
vec3 coords[ 4 ];
|
|
1103
|
+
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
1104
|
+
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
1105
|
+
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
1106
|
+
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
1107
|
+
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
1108
|
+
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
1109
|
+
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
1110
|
+
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
1111
|
+
vec3 vectorFormFactor = vec3( 0.0 );
|
|
1112
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
1113
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
1114
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
1115
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
1116
|
+
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
1117
|
+
return vec3( result );
|
|
1118
|
+
}
|
|
1119
|
+
#if defined( USE_SHEEN )
|
|
1120
|
+
float D_Charlie( float roughness, float dotNH ) {
|
|
1121
|
+
float alpha = pow2( roughness );
|
|
1122
|
+
float invAlpha = 1.0 / alpha;
|
|
1123
|
+
float cos2h = dotNH * dotNH;
|
|
1124
|
+
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
1125
|
+
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
1126
|
+
}
|
|
1127
|
+
float V_Neubelt( float dotNV, float dotNL ) {
|
|
1128
|
+
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
1129
|
+
}
|
|
1130
|
+
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
1131
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1132
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1133
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1134
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1135
|
+
float D = D_Charlie( sheenRoughness, dotNH );
|
|
1136
|
+
float V = V_Neubelt( dotNV, dotNL );
|
|
1137
|
+
return sheenColor * ( D * V );
|
|
1138
|
+
}
|
|
1139
|
+
#endif
|
|
1140
|
+
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
1141
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1142
|
+
float r2 = roughness * roughness;
|
|
1143
|
+
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
1144
|
+
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
1145
|
+
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
1146
|
+
return saturate( DG * RECIPROCAL_PI );
|
|
1147
|
+
}
|
|
1148
|
+
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
1149
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1150
|
+
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
1151
|
+
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
1152
|
+
vec4 r = roughness * c0 + c1;
|
|
1153
|
+
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|
1154
|
+
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|
1155
|
+
return fab;
|
|
1156
|
+
}
|
|
1157
|
+
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
1158
|
+
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
1159
|
+
return specularColor * fab.x + specularF90 * fab.y;
|
|
1160
|
+
}
|
|
1161
|
+
#ifdef USE_IRIDESCENCE
|
|
1162
|
+
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
1163
|
+
#else
|
|
1164
|
+
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
1165
|
+
#endif
|
|
1166
|
+
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
1167
|
+
#ifdef USE_IRIDESCENCE
|
|
1168
|
+
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|
1169
|
+
#else
|
|
1170
|
+
vec3 Fr = specularColor;
|
|
1171
|
+
#endif
|
|
1172
|
+
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|
1173
|
+
float Ess = fab.x + fab.y;
|
|
1174
|
+
float Ems = 1.0 - Ess;
|
|
1175
|
+
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
1176
|
+
singleScatter += FssEss;
|
|
1177
|
+
multiScatter += Fms * Ems;
|
|
1178
|
+
}
|
|
1179
|
+
#if NUM_RECT_AREA_LIGHTS > 0
|
|
1180
|
+
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
1181
|
+
vec3 normal = geometryNormal;
|
|
1182
|
+
vec3 viewDir = geometryViewDir;
|
|
1183
|
+
vec3 position = geometryPosition;
|
|
1184
|
+
vec3 lightPos = rectAreaLight.position;
|
|
1185
|
+
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
1186
|
+
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
1187
|
+
vec3 lightColor = rectAreaLight.color;
|
|
1188
|
+
float roughness = material.roughness;
|
|
1189
|
+
vec3 rectCoords[ 4 ];
|
|
1190
|
+
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
1191
|
+
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
1192
|
+
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
1193
|
+
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
1194
|
+
vec4 t1 = texture2D( ltc_1, uv );
|
|
1195
|
+
vec4 t2 = texture2D( ltc_2, uv );
|
|
1196
|
+
mat3 mInv = mat3(
|
|
1197
|
+
vec3( t1.x, 0, t1.y ),
|
|
1198
|
+
vec3( 0, 1, 0 ),
|
|
1199
|
+
vec3( t1.z, 0, t1.w )
|
|
1200
|
+
);
|
|
1201
|
+
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
1202
|
+
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
1203
|
+
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
1204
|
+
}
|
|
1205
|
+
#endif
|
|
1206
|
+
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
1207
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
1208
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
1209
|
+
#ifdef USE_CLEARCOAT
|
|
1210
|
+
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
1211
|
+
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
1212
|
+
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
1213
|
+
#endif
|
|
1214
|
+
#ifdef USE_SHEEN
|
|
1215
|
+
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
1216
|
+
#endif
|
|
1217
|
+
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
1218
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1219
|
+
}
|
|
1220
|
+
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
1221
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1222
|
+
}
|
|
1223
|
+
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
1224
|
+
#ifdef USE_CLEARCOAT
|
|
1225
|
+
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
1226
|
+
#endif
|
|
1227
|
+
#ifdef USE_SHEEN
|
|
1228
|
+
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
1229
|
+
#endif
|
|
1230
|
+
vec3 singleScattering = vec3( 0.0 );
|
|
1231
|
+
vec3 multiScattering = vec3( 0.0 );
|
|
1232
|
+
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
1233
|
+
#ifdef USE_IRIDESCENCE
|
|
1234
|
+
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
1235
|
+
#else
|
|
1236
|
+
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
1237
|
+
#endif
|
|
1238
|
+
vec3 totalScattering = singleScattering + multiScattering;
|
|
1239
|
+
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
1240
|
+
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
1241
|
+
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
1242
|
+
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
1243
|
+
}
|
|
1244
|
+
#define RE_Direct RE_Direct_Physical
|
|
1245
|
+
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
1246
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
1247
|
+
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1248
|
+
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1249
|
+
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1250
|
+
}`,Lc=`
|
|
1251
|
+
vec3 geometryPosition = - vViewPosition;
|
|
1252
|
+
vec3 geometryNormal = normal;
|
|
1253
|
+
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
1254
|
+
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
1255
|
+
#ifdef USE_CLEARCOAT
|
|
1256
|
+
geometryClearcoatNormal = clearcoatNormal;
|
|
1257
|
+
#endif
|
|
1258
|
+
#ifdef USE_IRIDESCENCE
|
|
1259
|
+
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
1260
|
+
if ( material.iridescenceThickness == 0.0 ) {
|
|
1261
|
+
material.iridescence = 0.0;
|
|
1262
|
+
} else {
|
|
1263
|
+
material.iridescence = saturate( material.iridescence );
|
|
1264
|
+
}
|
|
1265
|
+
if ( material.iridescence > 0.0 ) {
|
|
1266
|
+
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
1267
|
+
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
1268
|
+
}
|
|
1269
|
+
#endif
|
|
1270
|
+
IncidentLight directLight;
|
|
1271
|
+
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1272
|
+
PointLight pointLight;
|
|
1273
|
+
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
1274
|
+
PointLightShadow pointLightShadow;
|
|
1275
|
+
#endif
|
|
1276
|
+
#pragma unroll_loop_start
|
|
1277
|
+
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
1278
|
+
pointLight = pointLights[ i ];
|
|
1279
|
+
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
1280
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
1281
|
+
pointLightShadow = pointLightShadows[ i ];
|
|
1282
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
1283
|
+
#endif
|
|
1284
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1285
|
+
}
|
|
1286
|
+
#pragma unroll_loop_end
|
|
1287
|
+
#endif
|
|
1288
|
+
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1289
|
+
SpotLight spotLight;
|
|
1290
|
+
vec4 spotColor;
|
|
1291
|
+
vec3 spotLightCoord;
|
|
1292
|
+
bool inSpotLightMap;
|
|
1293
|
+
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1294
|
+
SpotLightShadow spotLightShadow;
|
|
1295
|
+
#endif
|
|
1296
|
+
#pragma unroll_loop_start
|
|
1297
|
+
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
1298
|
+
spotLight = spotLights[ i ];
|
|
1299
|
+
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
1300
|
+
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
1301
|
+
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
1302
|
+
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1303
|
+
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
1304
|
+
#else
|
|
1305
|
+
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
1306
|
+
#endif
|
|
1307
|
+
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
1308
|
+
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
1309
|
+
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
1310
|
+
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
1311
|
+
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
1312
|
+
#endif
|
|
1313
|
+
#undef SPOT_LIGHT_MAP_INDEX
|
|
1314
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1315
|
+
spotLightShadow = spotLightShadows[ i ];
|
|
1316
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
1317
|
+
#endif
|
|
1318
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1319
|
+
}
|
|
1320
|
+
#pragma unroll_loop_end
|
|
1321
|
+
#endif
|
|
1322
|
+
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1323
|
+
DirectionalLight directionalLight;
|
|
1324
|
+
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
1325
|
+
DirectionalLightShadow directionalLightShadow;
|
|
1326
|
+
#endif
|
|
1327
|
+
#pragma unroll_loop_start
|
|
1328
|
+
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
1329
|
+
directionalLight = directionalLights[ i ];
|
|
1330
|
+
getDirectionalLightInfo( directionalLight, directLight );
|
|
1331
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
1332
|
+
directionalLightShadow = directionalLightShadows[ i ];
|
|
1333
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
1334
|
+
#endif
|
|
1335
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1336
|
+
}
|
|
1337
|
+
#pragma unroll_loop_end
|
|
1338
|
+
#endif
|
|
1339
|
+
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
1340
|
+
RectAreaLight rectAreaLight;
|
|
1341
|
+
#pragma unroll_loop_start
|
|
1342
|
+
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
1343
|
+
rectAreaLight = rectAreaLights[ i ];
|
|
1344
|
+
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1345
|
+
}
|
|
1346
|
+
#pragma unroll_loop_end
|
|
1347
|
+
#endif
|
|
1348
|
+
#if defined( RE_IndirectDiffuse )
|
|
1349
|
+
vec3 iblIrradiance = vec3( 0.0 );
|
|
1350
|
+
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
1351
|
+
#if defined( USE_LIGHT_PROBES )
|
|
1352
|
+
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
1353
|
+
#endif
|
|
1354
|
+
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
1355
|
+
#pragma unroll_loop_start
|
|
1356
|
+
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
1357
|
+
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
1358
|
+
}
|
|
1359
|
+
#pragma unroll_loop_end
|
|
1360
|
+
#endif
|
|
1361
|
+
#endif
|
|
1362
|
+
#if defined( RE_IndirectSpecular )
|
|
1363
|
+
vec3 radiance = vec3( 0.0 );
|
|
1364
|
+
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1365
|
+
#endif`,Uc=`#if defined( RE_IndirectDiffuse )
|
|
1366
|
+
#ifdef USE_LIGHTMAP
|
|
1367
|
+
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1368
|
+
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
1369
|
+
irradiance += lightMapIrradiance;
|
|
1370
|
+
#endif
|
|
1371
|
+
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
1372
|
+
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
1373
|
+
#endif
|
|
1374
|
+
#endif
|
|
1375
|
+
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
1376
|
+
#ifdef USE_ANISOTROPY
|
|
1377
|
+
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
1378
|
+
#else
|
|
1379
|
+
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
1380
|
+
#endif
|
|
1381
|
+
#ifdef USE_CLEARCOAT
|
|
1382
|
+
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1383
|
+
#endif
|
|
1384
|
+
#endif`,Ic=`#if defined( RE_IndirectDiffuse )
|
|
1385
|
+
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1386
|
+
#endif
|
|
1387
|
+
#if defined( RE_IndirectSpecular )
|
|
1388
|
+
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1389
|
+
#endif`,Fc=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1390
|
+
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1391
|
+
#endif`,Nc=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1392
|
+
uniform float logDepthBufFC;
|
|
1393
|
+
varying float vFragDepth;
|
|
1394
|
+
varying float vIsPerspective;
|
|
1395
|
+
#endif`,Oc=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1396
|
+
varying float vFragDepth;
|
|
1397
|
+
varying float vIsPerspective;
|
|
1398
|
+
#endif`,Bc=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1399
|
+
vFragDepth = 1.0 + gl_Position.w;
|
|
1400
|
+
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1401
|
+
#endif`,zc=`#ifdef USE_MAP
|
|
1402
|
+
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1403
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
1404
|
+
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1405
|
+
#endif
|
|
1406
|
+
diffuseColor *= sampledDiffuseColor;
|
|
1407
|
+
#endif`,Gc=`#ifdef USE_MAP
|
|
1408
|
+
uniform sampler2D map;
|
|
1409
|
+
#endif`,Vc=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1410
|
+
#if defined( USE_POINTS_UV )
|
|
1411
|
+
vec2 uv = vUv;
|
|
1412
|
+
#else
|
|
1413
|
+
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
1414
|
+
#endif
|
|
1415
|
+
#endif
|
|
1416
|
+
#ifdef USE_MAP
|
|
1417
|
+
diffuseColor *= texture2D( map, uv );
|
|
1418
|
+
#endif
|
|
1419
|
+
#ifdef USE_ALPHAMAP
|
|
1420
|
+
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1421
|
+
#endif`,Hc=`#if defined( USE_POINTS_UV )
|
|
1422
|
+
varying vec2 vUv;
|
|
1423
|
+
#else
|
|
1424
|
+
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1425
|
+
uniform mat3 uvTransform;
|
|
1426
|
+
#endif
|
|
1427
|
+
#endif
|
|
1428
|
+
#ifdef USE_MAP
|
|
1429
|
+
uniform sampler2D map;
|
|
1430
|
+
#endif
|
|
1431
|
+
#ifdef USE_ALPHAMAP
|
|
1432
|
+
uniform sampler2D alphaMap;
|
|
1433
|
+
#endif`,kc=`float metalnessFactor = metalness;
|
|
1434
|
+
#ifdef USE_METALNESSMAP
|
|
1435
|
+
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1436
|
+
metalnessFactor *= texelMetalness.b;
|
|
1437
|
+
#endif`,Wc=`#ifdef USE_METALNESSMAP
|
|
1438
|
+
uniform sampler2D metalnessMap;
|
|
1439
|
+
#endif`,Xc=`#ifdef USE_INSTANCING_MORPH
|
|
1440
|
+
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1441
|
+
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1442
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1443
|
+
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1444
|
+
}
|
|
1445
|
+
#endif`,qc=`#if defined( USE_MORPHCOLORS )
|
|
1446
|
+
vColor *= morphTargetBaseInfluence;
|
|
1447
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1448
|
+
#if defined( USE_COLOR_ALPHA )
|
|
1449
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
1450
|
+
#elif defined( USE_COLOR )
|
|
1451
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1452
|
+
#endif
|
|
1453
|
+
}
|
|
1454
|
+
#endif`,Yc=`#ifdef USE_MORPHNORMALS
|
|
1455
|
+
objectNormal *= morphTargetBaseInfluence;
|
|
1456
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1457
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1458
|
+
}
|
|
1459
|
+
#endif`,Jc=`#ifdef USE_MORPHTARGETS
|
|
1460
|
+
#ifndef USE_INSTANCING_MORPH
|
|
1461
|
+
uniform float morphTargetBaseInfluence;
|
|
1462
|
+
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1463
|
+
#endif
|
|
1464
|
+
uniform sampler2DArray morphTargetsTexture;
|
|
1465
|
+
uniform ivec2 morphTargetsTextureSize;
|
|
1466
|
+
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
1467
|
+
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
1468
|
+
int y = texelIndex / morphTargetsTextureSize.x;
|
|
1469
|
+
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
1470
|
+
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1471
|
+
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1472
|
+
}
|
|
1473
|
+
#endif`,Zc=`#ifdef USE_MORPHTARGETS
|
|
1474
|
+
transformed *= morphTargetBaseInfluence;
|
|
1475
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1476
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1477
|
+
}
|
|
1478
|
+
#endif`,Kc=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1479
|
+
#ifdef FLAT_SHADED
|
|
1480
|
+
vec3 fdx = dFdx( vViewPosition );
|
|
1481
|
+
vec3 fdy = dFdy( vViewPosition );
|
|
1482
|
+
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
1483
|
+
#else
|
|
1484
|
+
vec3 normal = normalize( vNormal );
|
|
1485
|
+
#ifdef DOUBLE_SIDED
|
|
1486
|
+
normal *= faceDirection;
|
|
1487
|
+
#endif
|
|
1488
|
+
#endif
|
|
1489
|
+
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
1490
|
+
#ifdef USE_TANGENT
|
|
1491
|
+
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
1492
|
+
#else
|
|
1493
|
+
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
1494
|
+
#if defined( USE_NORMALMAP )
|
|
1495
|
+
vNormalMapUv
|
|
1496
|
+
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
1497
|
+
vClearcoatNormalMapUv
|
|
1498
|
+
#else
|
|
1499
|
+
vUv
|
|
1500
|
+
#endif
|
|
1501
|
+
);
|
|
1502
|
+
#endif
|
|
1503
|
+
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
1504
|
+
tbn[0] *= faceDirection;
|
|
1505
|
+
tbn[1] *= faceDirection;
|
|
1506
|
+
#endif
|
|
1507
|
+
#endif
|
|
1508
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1509
|
+
#ifdef USE_TANGENT
|
|
1510
|
+
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
1511
|
+
#else
|
|
1512
|
+
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|
1513
|
+
#endif
|
|
1514
|
+
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
1515
|
+
tbn2[0] *= faceDirection;
|
|
1516
|
+
tbn2[1] *= faceDirection;
|
|
1517
|
+
#endif
|
|
1518
|
+
#endif
|
|
1519
|
+
vec3 nonPerturbedNormal = normal;`,$c=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1520
|
+
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1521
|
+
#ifdef FLIP_SIDED
|
|
1522
|
+
normal = - normal;
|
|
1523
|
+
#endif
|
|
1524
|
+
#ifdef DOUBLE_SIDED
|
|
1525
|
+
normal = normal * faceDirection;
|
|
1526
|
+
#endif
|
|
1527
|
+
normal = normalize( normalMatrix * normal );
|
|
1528
|
+
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
1529
|
+
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1530
|
+
mapN.xy *= normalScale;
|
|
1531
|
+
normal = normalize( tbn * mapN );
|
|
1532
|
+
#elif defined( USE_BUMPMAP )
|
|
1533
|
+
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1534
|
+
#endif`,jc=`#ifndef FLAT_SHADED
|
|
1535
|
+
varying vec3 vNormal;
|
|
1536
|
+
#ifdef USE_TANGENT
|
|
1537
|
+
varying vec3 vTangent;
|
|
1538
|
+
varying vec3 vBitangent;
|
|
1539
|
+
#endif
|
|
1540
|
+
#endif`,Qc=`#ifndef FLAT_SHADED
|
|
1541
|
+
varying vec3 vNormal;
|
|
1542
|
+
#ifdef USE_TANGENT
|
|
1543
|
+
varying vec3 vTangent;
|
|
1544
|
+
varying vec3 vBitangent;
|
|
1545
|
+
#endif
|
|
1546
|
+
#endif`,eh=`#ifndef FLAT_SHADED
|
|
1547
|
+
vNormal = normalize( transformedNormal );
|
|
1548
|
+
#ifdef USE_TANGENT
|
|
1549
|
+
vTangent = normalize( transformedTangent );
|
|
1550
|
+
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
1551
|
+
#endif
|
|
1552
|
+
#endif`,th=`#ifdef USE_NORMALMAP
|
|
1553
|
+
uniform sampler2D normalMap;
|
|
1554
|
+
uniform vec2 normalScale;
|
|
1555
|
+
#endif
|
|
1556
|
+
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1557
|
+
uniform mat3 normalMatrix;
|
|
1558
|
+
#endif
|
|
1559
|
+
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
1560
|
+
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|
1561
|
+
vec3 q0 = dFdx( eye_pos.xyz );
|
|
1562
|
+
vec3 q1 = dFdy( eye_pos.xyz );
|
|
1563
|
+
vec2 st0 = dFdx( uv.st );
|
|
1564
|
+
vec2 st1 = dFdy( uv.st );
|
|
1565
|
+
vec3 N = surf_norm;
|
|
1566
|
+
vec3 q1perp = cross( q1, N );
|
|
1567
|
+
vec3 q0perp = cross( N, q0 );
|
|
1568
|
+
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
1569
|
+
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
1570
|
+
float det = max( dot( T, T ), dot( B, B ) );
|
|
1571
|
+
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1572
|
+
return mat3( T * scale, B * scale, N );
|
|
1573
|
+
}
|
|
1574
|
+
#endif`,nh=`#ifdef USE_CLEARCOAT
|
|
1575
|
+
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1576
|
+
#endif`,ih=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1577
|
+
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1578
|
+
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1579
|
+
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1580
|
+
#endif`,rh=`#ifdef USE_CLEARCOATMAP
|
|
1581
|
+
uniform sampler2D clearcoatMap;
|
|
1582
|
+
#endif
|
|
1583
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1584
|
+
uniform sampler2D clearcoatNormalMap;
|
|
1585
|
+
uniform vec2 clearcoatNormalScale;
|
|
1586
|
+
#endif
|
|
1587
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1588
|
+
uniform sampler2D clearcoatRoughnessMap;
|
|
1589
|
+
#endif`,sh=`#ifdef USE_IRIDESCENCEMAP
|
|
1590
|
+
uniform sampler2D iridescenceMap;
|
|
1591
|
+
#endif
|
|
1592
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1593
|
+
uniform sampler2D iridescenceThicknessMap;
|
|
1594
|
+
#endif`,ah=`#ifdef OPAQUE
|
|
1595
|
+
diffuseColor.a = 1.0;
|
|
1596
|
+
#endif
|
|
1597
|
+
#ifdef USE_TRANSMISSION
|
|
1598
|
+
diffuseColor.a *= material.transmissionAlpha;
|
|
1599
|
+
#endif
|
|
1600
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,oh=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1601
|
+
return normalize( normal ) * 0.5 + 0.5;
|
|
1602
|
+
}
|
|
1603
|
+
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
1604
|
+
return 2.0 * rgb.xyz - 1.0;
|
|
1605
|
+
}
|
|
1606
|
+
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
|
|
1607
|
+
const float Inv255 = 1. / 255.;
|
|
1608
|
+
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
|
1609
|
+
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
|
1610
|
+
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
|
1611
|
+
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
|
1612
|
+
vec4 packDepthToRGBA( const in float v ) {
|
|
1613
|
+
if( v <= 0.0 )
|
|
1614
|
+
return vec4( 0., 0., 0., 0. );
|
|
1615
|
+
if( v >= 1.0 )
|
|
1616
|
+
return vec4( 1., 1., 1., 1. );
|
|
1617
|
+
float vuf;
|
|
1618
|
+
float af = modf( v * PackFactors.a, vuf );
|
|
1619
|
+
float bf = modf( vuf * ShiftRight8, vuf );
|
|
1620
|
+
float gf = modf( vuf * ShiftRight8, vuf );
|
|
1621
|
+
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
|
1622
|
+
}
|
|
1623
|
+
vec3 packDepthToRGB( const in float v ) {
|
|
1624
|
+
if( v <= 0.0 )
|
|
1625
|
+
return vec3( 0., 0., 0. );
|
|
1626
|
+
if( v >= 1.0 )
|
|
1627
|
+
return vec3( 1., 1., 1. );
|
|
1628
|
+
float vuf;
|
|
1629
|
+
float bf = modf( v * PackFactors.b, vuf );
|
|
1630
|
+
float gf = modf( vuf * ShiftRight8, vuf );
|
|
1631
|
+
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
|
1632
|
+
}
|
|
1633
|
+
vec2 packDepthToRG( const in float v ) {
|
|
1634
|
+
if( v <= 0.0 )
|
|
1635
|
+
return vec2( 0., 0. );
|
|
1636
|
+
if( v >= 1.0 )
|
|
1637
|
+
return vec2( 1., 1. );
|
|
1638
|
+
float vuf;
|
|
1639
|
+
float gf = modf( v * 256., vuf );
|
|
1640
|
+
return vec2( vuf * Inv255, gf );
|
|
1641
|
+
}
|
|
1642
|
+
float unpackRGBAToDepth( const in vec4 v ) {
|
|
1643
|
+
return dot( v, UnpackFactors4 );
|
|
1644
|
+
}
|
|
1645
|
+
float unpackRGBToDepth( const in vec3 v ) {
|
|
1646
|
+
return dot( v, UnpackFactors3 );
|
|
1647
|
+
}
|
|
1648
|
+
float unpackRGToDepth( const in vec2 v ) {
|
|
1649
|
+
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
|
1650
|
+
}
|
|
1651
|
+
vec4 pack2HalfToRGBA( const in vec2 v ) {
|
|
1652
|
+
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|
1653
|
+
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|
1654
|
+
}
|
|
1655
|
+
vec2 unpackRGBATo2Half( const in vec4 v ) {
|
|
1656
|
+
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|
1657
|
+
}
|
|
1658
|
+
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|
1659
|
+
return ( viewZ + near ) / ( near - far );
|
|
1660
|
+
}
|
|
1661
|
+
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1662
|
+
return depth * ( near - far ) - near;
|
|
1663
|
+
}
|
|
1664
|
+
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
1665
|
+
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
1666
|
+
}
|
|
1667
|
+
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1668
|
+
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1669
|
+
}`,lh=`#ifdef PREMULTIPLIED_ALPHA
|
|
1670
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1671
|
+
#endif`,ch=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1672
|
+
#ifdef USE_BATCHING
|
|
1673
|
+
mvPosition = batchingMatrix * mvPosition;
|
|
1674
|
+
#endif
|
|
1675
|
+
#ifdef USE_INSTANCING
|
|
1676
|
+
mvPosition = instanceMatrix * mvPosition;
|
|
1677
|
+
#endif
|
|
1678
|
+
mvPosition = modelViewMatrix * mvPosition;
|
|
1679
|
+
gl_Position = projectionMatrix * mvPosition;`,hh=`#ifdef DITHERING
|
|
1680
|
+
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1681
|
+
#endif`,uh=`#ifdef DITHERING
|
|
1682
|
+
vec3 dithering( vec3 color ) {
|
|
1683
|
+
float grid_position = rand( gl_FragCoord.xy );
|
|
1684
|
+
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1685
|
+
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1686
|
+
return color + dither_shift_RGB;
|
|
1687
|
+
}
|
|
1688
|
+
#endif`,fh=`float roughnessFactor = roughness;
|
|
1689
|
+
#ifdef USE_ROUGHNESSMAP
|
|
1690
|
+
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1691
|
+
roughnessFactor *= texelRoughness.g;
|
|
1692
|
+
#endif`,dh=`#ifdef USE_ROUGHNESSMAP
|
|
1693
|
+
uniform sampler2D roughnessMap;
|
|
1694
|
+
#endif`,ph=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1695
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1696
|
+
#endif
|
|
1697
|
+
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
1698
|
+
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
1699
|
+
#endif
|
|
1700
|
+
#ifdef USE_SHADOWMAP
|
|
1701
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1702
|
+
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1703
|
+
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1704
|
+
struct DirectionalLightShadow {
|
|
1705
|
+
float shadowIntensity;
|
|
1706
|
+
float shadowBias;
|
|
1707
|
+
float shadowNormalBias;
|
|
1708
|
+
float shadowRadius;
|
|
1709
|
+
vec2 shadowMapSize;
|
|
1710
|
+
};
|
|
1711
|
+
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1712
|
+
#endif
|
|
1713
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1714
|
+
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1715
|
+
struct SpotLightShadow {
|
|
1716
|
+
float shadowIntensity;
|
|
1717
|
+
float shadowBias;
|
|
1718
|
+
float shadowNormalBias;
|
|
1719
|
+
float shadowRadius;
|
|
1720
|
+
vec2 shadowMapSize;
|
|
1721
|
+
};
|
|
1722
|
+
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1723
|
+
#endif
|
|
1724
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1725
|
+
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1726
|
+
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1727
|
+
struct PointLightShadow {
|
|
1728
|
+
float shadowIntensity;
|
|
1729
|
+
float shadowBias;
|
|
1730
|
+
float shadowNormalBias;
|
|
1731
|
+
float shadowRadius;
|
|
1732
|
+
vec2 shadowMapSize;
|
|
1733
|
+
float shadowCameraNear;
|
|
1734
|
+
float shadowCameraFar;
|
|
1735
|
+
};
|
|
1736
|
+
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1737
|
+
#endif
|
|
1738
|
+
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
1739
|
+
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
|
|
1740
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
1741
|
+
return step( depth, compare );
|
|
1742
|
+
#else
|
|
1743
|
+
return step( compare, depth );
|
|
1744
|
+
#endif
|
|
1745
|
+
}
|
|
1746
|
+
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
1747
|
+
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
1748
|
+
}
|
|
1749
|
+
float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
|
|
1750
|
+
float occlusion = 1.0;
|
|
1751
|
+
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
1752
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
1753
|
+
float hard_shadow = step( distribution.x, compare );
|
|
1754
|
+
#else
|
|
1755
|
+
float hard_shadow = step( compare, distribution.x );
|
|
1756
|
+
#endif
|
|
1757
|
+
if ( hard_shadow != 1.0 ) {
|
|
1758
|
+
float distance = compare - distribution.x;
|
|
1759
|
+
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
1760
|
+
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
1761
|
+
}
|
|
1762
|
+
return occlusion;
|
|
1763
|
+
}
|
|
1764
|
+
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
1765
|
+
float shadow = 1.0;
|
|
1766
|
+
shadowCoord.xyz /= shadowCoord.w;
|
|
1767
|
+
shadowCoord.z += shadowBias;
|
|
1768
|
+
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
1769
|
+
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
1770
|
+
if ( frustumTest ) {
|
|
1771
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
1772
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
1773
|
+
float dx0 = - texelSize.x * shadowRadius;
|
|
1774
|
+
float dy0 = - texelSize.y * shadowRadius;
|
|
1775
|
+
float dx1 = + texelSize.x * shadowRadius;
|
|
1776
|
+
float dy1 = + texelSize.y * shadowRadius;
|
|
1777
|
+
float dx2 = dx0 / 2.0;
|
|
1778
|
+
float dy2 = dy0 / 2.0;
|
|
1779
|
+
float dx3 = dx1 / 2.0;
|
|
1780
|
+
float dy3 = dy1 / 2.0;
|
|
1781
|
+
shadow = (
|
|
1782
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
1783
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
1784
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
1785
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
1786
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
1787
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
1788
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
1789
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
1790
|
+
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
1791
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
1792
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
1793
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
1794
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
1795
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
1796
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
1797
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
1798
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
1799
|
+
) * ( 1.0 / 17.0 );
|
|
1800
|
+
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
1801
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
1802
|
+
float dx = texelSize.x;
|
|
1803
|
+
float dy = texelSize.y;
|
|
1804
|
+
vec2 uv = shadowCoord.xy;
|
|
1805
|
+
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
1806
|
+
uv -= f * texelSize;
|
|
1807
|
+
shadow = (
|
|
1808
|
+
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
1809
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
1810
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
1811
|
+
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
1812
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
1813
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
1814
|
+
f.x ) +
|
|
1815
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
1816
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
1817
|
+
f.x ) +
|
|
1818
|
+
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
1819
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
1820
|
+
f.y ) +
|
|
1821
|
+
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
1822
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
1823
|
+
f.y ) +
|
|
1824
|
+
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
1825
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
1826
|
+
f.x ),
|
|
1827
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
1828
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
1829
|
+
f.x ),
|
|
1830
|
+
f.y )
|
|
1831
|
+
) * ( 1.0 / 9.0 );
|
|
1832
|
+
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
1833
|
+
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
1834
|
+
#else
|
|
1835
|
+
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
1836
|
+
#endif
|
|
1837
|
+
}
|
|
1838
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
1839
|
+
}
|
|
1840
|
+
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
1841
|
+
vec3 absV = abs( v );
|
|
1842
|
+
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
1843
|
+
absV *= scaleToCube;
|
|
1844
|
+
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
1845
|
+
vec2 planar = v.xy;
|
|
1846
|
+
float almostATexel = 1.5 * texelSizeY;
|
|
1847
|
+
float almostOne = 1.0 - almostATexel;
|
|
1848
|
+
if ( absV.z >= almostOne ) {
|
|
1849
|
+
if ( v.z > 0.0 )
|
|
1850
|
+
planar.x = 4.0 - v.x;
|
|
1851
|
+
} else if ( absV.x >= almostOne ) {
|
|
1852
|
+
float signX = sign( v.x );
|
|
1853
|
+
planar.x = v.z * signX + 2.0 * signX;
|
|
1854
|
+
} else if ( absV.y >= almostOne ) {
|
|
1855
|
+
float signY = sign( v.y );
|
|
1856
|
+
planar.x = v.x + 2.0 * signY + 2.0;
|
|
1857
|
+
planar.y = v.z * signY - 2.0;
|
|
1858
|
+
}
|
|
1859
|
+
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
1860
|
+
}
|
|
1861
|
+
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
1862
|
+
float shadow = 1.0;
|
|
1863
|
+
vec3 lightToPosition = shadowCoord.xyz;
|
|
1864
|
+
|
|
1865
|
+
float lightToPositionLength = length( lightToPosition );
|
|
1866
|
+
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
1867
|
+
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
1868
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
1869
|
+
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
1870
|
+
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
1871
|
+
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
1872
|
+
shadow = (
|
|
1873
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
1874
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
1875
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
1876
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
1877
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
1878
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
1879
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
1880
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
1881
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
1882
|
+
) * ( 1.0 / 9.0 );
|
|
1883
|
+
#else
|
|
1884
|
+
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
1885
|
+
#endif
|
|
1886
|
+
}
|
|
1887
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
1888
|
+
}
|
|
1889
|
+
#endif`,mh=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1890
|
+
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
1891
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1892
|
+
#endif
|
|
1893
|
+
#ifdef USE_SHADOWMAP
|
|
1894
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1895
|
+
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1896
|
+
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1897
|
+
struct DirectionalLightShadow {
|
|
1898
|
+
float shadowIntensity;
|
|
1899
|
+
float shadowBias;
|
|
1900
|
+
float shadowNormalBias;
|
|
1901
|
+
float shadowRadius;
|
|
1902
|
+
vec2 shadowMapSize;
|
|
1903
|
+
};
|
|
1904
|
+
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1905
|
+
#endif
|
|
1906
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1907
|
+
struct SpotLightShadow {
|
|
1908
|
+
float shadowIntensity;
|
|
1909
|
+
float shadowBias;
|
|
1910
|
+
float shadowNormalBias;
|
|
1911
|
+
float shadowRadius;
|
|
1912
|
+
vec2 shadowMapSize;
|
|
1913
|
+
};
|
|
1914
|
+
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1915
|
+
#endif
|
|
1916
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1917
|
+
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1918
|
+
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1919
|
+
struct PointLightShadow {
|
|
1920
|
+
float shadowIntensity;
|
|
1921
|
+
float shadowBias;
|
|
1922
|
+
float shadowNormalBias;
|
|
1923
|
+
float shadowRadius;
|
|
1924
|
+
vec2 shadowMapSize;
|
|
1925
|
+
float shadowCameraNear;
|
|
1926
|
+
float shadowCameraFar;
|
|
1927
|
+
};
|
|
1928
|
+
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1929
|
+
#endif
|
|
1930
|
+
#endif`,gh=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
1931
|
+
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
1932
|
+
vec4 shadowWorldPosition;
|
|
1933
|
+
#endif
|
|
1934
|
+
#if defined( USE_SHADOWMAP )
|
|
1935
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1936
|
+
#pragma unroll_loop_start
|
|
1937
|
+
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
1938
|
+
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|
1939
|
+
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|
1940
|
+
}
|
|
1941
|
+
#pragma unroll_loop_end
|
|
1942
|
+
#endif
|
|
1943
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1944
|
+
#pragma unroll_loop_start
|
|
1945
|
+
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
1946
|
+
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|
1947
|
+
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|
1948
|
+
}
|
|
1949
|
+
#pragma unroll_loop_end
|
|
1950
|
+
#endif
|
|
1951
|
+
#endif
|
|
1952
|
+
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1953
|
+
#pragma unroll_loop_start
|
|
1954
|
+
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|
1955
|
+
shadowWorldPosition = worldPosition;
|
|
1956
|
+
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1957
|
+
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|
1958
|
+
#endif
|
|
1959
|
+
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
1960
|
+
}
|
|
1961
|
+
#pragma unroll_loop_end
|
|
1962
|
+
#endif`,_h=`float getShadowMask() {
|
|
1963
|
+
float shadow = 1.0;
|
|
1964
|
+
#ifdef USE_SHADOWMAP
|
|
1965
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1966
|
+
DirectionalLightShadow directionalLight;
|
|
1967
|
+
#pragma unroll_loop_start
|
|
1968
|
+
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
1969
|
+
directionalLight = directionalLightShadows[ i ];
|
|
1970
|
+
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
1971
|
+
}
|
|
1972
|
+
#pragma unroll_loop_end
|
|
1973
|
+
#endif
|
|
1974
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1975
|
+
SpotLightShadow spotLight;
|
|
1976
|
+
#pragma unroll_loop_start
|
|
1977
|
+
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
1978
|
+
spotLight = spotLightShadows[ i ];
|
|
1979
|
+
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
1980
|
+
}
|
|
1981
|
+
#pragma unroll_loop_end
|
|
1982
|
+
#endif
|
|
1983
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1984
|
+
PointLightShadow pointLight;
|
|
1985
|
+
#pragma unroll_loop_start
|
|
1986
|
+
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
1987
|
+
pointLight = pointLightShadows[ i ];
|
|
1988
|
+
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
1989
|
+
}
|
|
1990
|
+
#pragma unroll_loop_end
|
|
1991
|
+
#endif
|
|
1992
|
+
#endif
|
|
1993
|
+
return shadow;
|
|
1994
|
+
}`,vh=`#ifdef USE_SKINNING
|
|
1995
|
+
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
1996
|
+
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
1997
|
+
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
1998
|
+
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
1999
|
+
#endif`,xh=`#ifdef USE_SKINNING
|
|
2000
|
+
uniform mat4 bindMatrix;
|
|
2001
|
+
uniform mat4 bindMatrixInverse;
|
|
2002
|
+
uniform highp sampler2D boneTexture;
|
|
2003
|
+
mat4 getBoneMatrix( const in float i ) {
|
|
2004
|
+
int size = textureSize( boneTexture, 0 ).x;
|
|
2005
|
+
int j = int( i ) * 4;
|
|
2006
|
+
int x = j % size;
|
|
2007
|
+
int y = j / size;
|
|
2008
|
+
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
2009
|
+
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
2010
|
+
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
2011
|
+
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2012
|
+
return mat4( v1, v2, v3, v4 );
|
|
2013
|
+
}
|
|
2014
|
+
#endif`,Mh=`#ifdef USE_SKINNING
|
|
2015
|
+
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2016
|
+
vec4 skinned = vec4( 0.0 );
|
|
2017
|
+
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
2018
|
+
skinned += boneMatY * skinVertex * skinWeight.y;
|
|
2019
|
+
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2020
|
+
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2021
|
+
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2022
|
+
#endif`,Sh=`#ifdef USE_SKINNING
|
|
2023
|
+
mat4 skinMatrix = mat4( 0.0 );
|
|
2024
|
+
skinMatrix += skinWeight.x * boneMatX;
|
|
2025
|
+
skinMatrix += skinWeight.y * boneMatY;
|
|
2026
|
+
skinMatrix += skinWeight.z * boneMatZ;
|
|
2027
|
+
skinMatrix += skinWeight.w * boneMatW;
|
|
2028
|
+
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|
2029
|
+
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|
2030
|
+
#ifdef USE_TANGENT
|
|
2031
|
+
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2032
|
+
#endif
|
|
2033
|
+
#endif`,yh=`float specularStrength;
|
|
2034
|
+
#ifdef USE_SPECULARMAP
|
|
2035
|
+
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2036
|
+
specularStrength = texelSpecular.r;
|
|
2037
|
+
#else
|
|
2038
|
+
specularStrength = 1.0;
|
|
2039
|
+
#endif`,Eh=`#ifdef USE_SPECULARMAP
|
|
2040
|
+
uniform sampler2D specularMap;
|
|
2041
|
+
#endif`,Th=`#if defined( TONE_MAPPING )
|
|
2042
|
+
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2043
|
+
#endif`,Ah=`#ifndef saturate
|
|
2044
|
+
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2045
|
+
#endif
|
|
2046
|
+
uniform float toneMappingExposure;
|
|
2047
|
+
vec3 LinearToneMapping( vec3 color ) {
|
|
2048
|
+
return saturate( toneMappingExposure * color );
|
|
2049
|
+
}
|
|
2050
|
+
vec3 ReinhardToneMapping( vec3 color ) {
|
|
2051
|
+
color *= toneMappingExposure;
|
|
2052
|
+
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
2053
|
+
}
|
|
2054
|
+
vec3 CineonToneMapping( vec3 color ) {
|
|
2055
|
+
color *= toneMappingExposure;
|
|
2056
|
+
color = max( vec3( 0.0 ), color - 0.004 );
|
|
2057
|
+
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|
2058
|
+
}
|
|
2059
|
+
vec3 RRTAndODTFit( vec3 v ) {
|
|
2060
|
+
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|
2061
|
+
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|
2062
|
+
return a / b;
|
|
2063
|
+
}
|
|
2064
|
+
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
2065
|
+
const mat3 ACESInputMat = mat3(
|
|
2066
|
+
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|
2067
|
+
vec3( 0.04823, 0.01566, 0.83777 )
|
|
2068
|
+
);
|
|
2069
|
+
const mat3 ACESOutputMat = mat3(
|
|
2070
|
+
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|
2071
|
+
vec3( -0.07367, -0.00605, 1.07602 )
|
|
2072
|
+
);
|
|
2073
|
+
color *= toneMappingExposure / 0.6;
|
|
2074
|
+
color = ACESInputMat * color;
|
|
2075
|
+
color = RRTAndODTFit( color );
|
|
2076
|
+
color = ACESOutputMat * color;
|
|
2077
|
+
return saturate( color );
|
|
2078
|
+
}
|
|
2079
|
+
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
2080
|
+
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
2081
|
+
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
2082
|
+
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
2083
|
+
);
|
|
2084
|
+
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
2085
|
+
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
2086
|
+
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
2087
|
+
vec3( 0.0433, 0.0113, 0.8956 )
|
|
2088
|
+
);
|
|
2089
|
+
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
2090
|
+
vec3 x2 = x * x;
|
|
2091
|
+
vec3 x4 = x2 * x2;
|
|
2092
|
+
return + 15.5 * x4 * x2
|
|
2093
|
+
- 40.14 * x4 * x
|
|
2094
|
+
+ 31.96 * x4
|
|
2095
|
+
- 6.868 * x2 * x
|
|
2096
|
+
+ 0.4298 * x2
|
|
2097
|
+
+ 0.1191 * x
|
|
2098
|
+
- 0.00232;
|
|
2099
|
+
}
|
|
2100
|
+
vec3 AgXToneMapping( vec3 color ) {
|
|
2101
|
+
const mat3 AgXInsetMatrix = mat3(
|
|
2102
|
+
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
2103
|
+
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
2104
|
+
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
2105
|
+
);
|
|
2106
|
+
const mat3 AgXOutsetMatrix = mat3(
|
|
2107
|
+
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
2108
|
+
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
2109
|
+
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
2110
|
+
);
|
|
2111
|
+
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|
2112
|
+
color *= toneMappingExposure;
|
|
2113
|
+
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
2114
|
+
color = AgXInsetMatrix * color;
|
|
2115
|
+
color = max( color, 1e-10 ); color = log2( color );
|
|
2116
|
+
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
2117
|
+
color = clamp( color, 0.0, 1.0 );
|
|
2118
|
+
color = agxDefaultContrastApprox( color );
|
|
2119
|
+
color = AgXOutsetMatrix * color;
|
|
2120
|
+
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
2121
|
+
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
2122
|
+
color = clamp( color, 0.0, 1.0 );
|
|
2123
|
+
return color;
|
|
2124
|
+
}
|
|
2125
|
+
vec3 NeutralToneMapping( vec3 color ) {
|
|
2126
|
+
const float StartCompression = 0.8 - 0.04;
|
|
2127
|
+
const float Desaturation = 0.15;
|
|
2128
|
+
color *= toneMappingExposure;
|
|
2129
|
+
float x = min( color.r, min( color.g, color.b ) );
|
|
2130
|
+
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
2131
|
+
color -= offset;
|
|
2132
|
+
float peak = max( color.r, max( color.g, color.b ) );
|
|
2133
|
+
if ( peak < StartCompression ) return color;
|
|
2134
|
+
float d = 1. - StartCompression;
|
|
2135
|
+
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|
2136
|
+
color *= newPeak / peak;
|
|
2137
|
+
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2138
|
+
return mix( color, vec3( newPeak ), g );
|
|
2139
|
+
}
|
|
2140
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,bh=`#ifdef USE_TRANSMISSION
|
|
2141
|
+
material.transmission = transmission;
|
|
2142
|
+
material.transmissionAlpha = 1.0;
|
|
2143
|
+
material.thickness = thickness;
|
|
2144
|
+
material.attenuationDistance = attenuationDistance;
|
|
2145
|
+
material.attenuationColor = attenuationColor;
|
|
2146
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2147
|
+
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
2148
|
+
#endif
|
|
2149
|
+
#ifdef USE_THICKNESSMAP
|
|
2150
|
+
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
2151
|
+
#endif
|
|
2152
|
+
vec3 pos = vWorldPosition;
|
|
2153
|
+
vec3 v = normalize( cameraPosition - pos );
|
|
2154
|
+
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
2155
|
+
vec4 transmitted = getIBLVolumeRefraction(
|
|
2156
|
+
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
2157
|
+
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|
2158
|
+
material.attenuationColor, material.attenuationDistance );
|
|
2159
|
+
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2160
|
+
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2161
|
+
#endif`,wh=`#ifdef USE_TRANSMISSION
|
|
2162
|
+
uniform float transmission;
|
|
2163
|
+
uniform float thickness;
|
|
2164
|
+
uniform float attenuationDistance;
|
|
2165
|
+
uniform vec3 attenuationColor;
|
|
2166
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2167
|
+
uniform sampler2D transmissionMap;
|
|
2168
|
+
#endif
|
|
2169
|
+
#ifdef USE_THICKNESSMAP
|
|
2170
|
+
uniform sampler2D thicknessMap;
|
|
2171
|
+
#endif
|
|
2172
|
+
uniform vec2 transmissionSamplerSize;
|
|
2173
|
+
uniform sampler2D transmissionSamplerMap;
|
|
2174
|
+
uniform mat4 modelMatrix;
|
|
2175
|
+
uniform mat4 projectionMatrix;
|
|
2176
|
+
varying vec3 vWorldPosition;
|
|
2177
|
+
float w0( float a ) {
|
|
2178
|
+
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
2179
|
+
}
|
|
2180
|
+
float w1( float a ) {
|
|
2181
|
+
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|
2182
|
+
}
|
|
2183
|
+
float w2( float a ){
|
|
2184
|
+
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|
2185
|
+
}
|
|
2186
|
+
float w3( float a ) {
|
|
2187
|
+
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|
2188
|
+
}
|
|
2189
|
+
float g0( float a ) {
|
|
2190
|
+
return w0( a ) + w1( a );
|
|
2191
|
+
}
|
|
2192
|
+
float g1( float a ) {
|
|
2193
|
+
return w2( a ) + w3( a );
|
|
2194
|
+
}
|
|
2195
|
+
float h0( float a ) {
|
|
2196
|
+
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|
2197
|
+
}
|
|
2198
|
+
float h1( float a ) {
|
|
2199
|
+
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|
2200
|
+
}
|
|
2201
|
+
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|
2202
|
+
uv = uv * texelSize.zw + 0.5;
|
|
2203
|
+
vec2 iuv = floor( uv );
|
|
2204
|
+
vec2 fuv = fract( uv );
|
|
2205
|
+
float g0x = g0( fuv.x );
|
|
2206
|
+
float g1x = g1( fuv.x );
|
|
2207
|
+
float h0x = h0( fuv.x );
|
|
2208
|
+
float h1x = h1( fuv.x );
|
|
2209
|
+
float h0y = h0( fuv.y );
|
|
2210
|
+
float h1y = h1( fuv.y );
|
|
2211
|
+
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
2212
|
+
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
2213
|
+
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
2214
|
+
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
2215
|
+
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|
2216
|
+
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|
2217
|
+
}
|
|
2218
|
+
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|
2219
|
+
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|
2220
|
+
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|
2221
|
+
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|
2222
|
+
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|
2223
|
+
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
2224
|
+
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
2225
|
+
return mix( fSample, cSample, fract( lod ) );
|
|
2226
|
+
}
|
|
2227
|
+
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
2228
|
+
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
2229
|
+
vec3 modelScale;
|
|
2230
|
+
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
2231
|
+
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
2232
|
+
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
2233
|
+
return normalize( refractionVector ) * thickness * modelScale;
|
|
2234
|
+
}
|
|
2235
|
+
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
2236
|
+
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
2237
|
+
}
|
|
2238
|
+
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
2239
|
+
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
2240
|
+
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|
2241
|
+
}
|
|
2242
|
+
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
2243
|
+
if ( isinf( attenuationDistance ) ) {
|
|
2244
|
+
return vec3( 1.0 );
|
|
2245
|
+
} else {
|
|
2246
|
+
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
2247
|
+
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
2251
|
+
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
2252
|
+
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
|
|
2253
|
+
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
2254
|
+
vec4 transmittedLight;
|
|
2255
|
+
vec3 transmittance;
|
|
2256
|
+
#ifdef USE_DISPERSION
|
|
2257
|
+
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
|
2258
|
+
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
|
2259
|
+
for ( int i = 0; i < 3; i ++ ) {
|
|
2260
|
+
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
|
|
2261
|
+
vec3 refractedRayExit = position + transmissionRay;
|
|
2262
|
+
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
2263
|
+
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
2264
|
+
refractionCoords += 1.0;
|
|
2265
|
+
refractionCoords /= 2.0;
|
|
2266
|
+
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
|
2267
|
+
transmittedLight[ i ] = transmissionSample[ i ];
|
|
2268
|
+
transmittedLight.a += transmissionSample.a;
|
|
2269
|
+
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
|
2270
|
+
}
|
|
2271
|
+
transmittedLight.a /= 3.0;
|
|
2272
|
+
#else
|
|
2273
|
+
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
2274
|
+
vec3 refractedRayExit = position + transmissionRay;
|
|
2275
|
+
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
2276
|
+
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
2277
|
+
refractionCoords += 1.0;
|
|
2278
|
+
refractionCoords /= 2.0;
|
|
2279
|
+
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
2280
|
+
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
2281
|
+
#endif
|
|
2282
|
+
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
2283
|
+
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
2284
|
+
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2285
|
+
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2286
|
+
}
|
|
2287
|
+
#endif`,Rh=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2288
|
+
varying vec2 vUv;
|
|
2289
|
+
#endif
|
|
2290
|
+
#ifdef USE_MAP
|
|
2291
|
+
varying vec2 vMapUv;
|
|
2292
|
+
#endif
|
|
2293
|
+
#ifdef USE_ALPHAMAP
|
|
2294
|
+
varying vec2 vAlphaMapUv;
|
|
2295
|
+
#endif
|
|
2296
|
+
#ifdef USE_LIGHTMAP
|
|
2297
|
+
varying vec2 vLightMapUv;
|
|
2298
|
+
#endif
|
|
2299
|
+
#ifdef USE_AOMAP
|
|
2300
|
+
varying vec2 vAoMapUv;
|
|
2301
|
+
#endif
|
|
2302
|
+
#ifdef USE_BUMPMAP
|
|
2303
|
+
varying vec2 vBumpMapUv;
|
|
2304
|
+
#endif
|
|
2305
|
+
#ifdef USE_NORMALMAP
|
|
2306
|
+
varying vec2 vNormalMapUv;
|
|
2307
|
+
#endif
|
|
2308
|
+
#ifdef USE_EMISSIVEMAP
|
|
2309
|
+
varying vec2 vEmissiveMapUv;
|
|
2310
|
+
#endif
|
|
2311
|
+
#ifdef USE_METALNESSMAP
|
|
2312
|
+
varying vec2 vMetalnessMapUv;
|
|
2313
|
+
#endif
|
|
2314
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2315
|
+
varying vec2 vRoughnessMapUv;
|
|
2316
|
+
#endif
|
|
2317
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2318
|
+
varying vec2 vAnisotropyMapUv;
|
|
2319
|
+
#endif
|
|
2320
|
+
#ifdef USE_CLEARCOATMAP
|
|
2321
|
+
varying vec2 vClearcoatMapUv;
|
|
2322
|
+
#endif
|
|
2323
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2324
|
+
varying vec2 vClearcoatNormalMapUv;
|
|
2325
|
+
#endif
|
|
2326
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2327
|
+
varying vec2 vClearcoatRoughnessMapUv;
|
|
2328
|
+
#endif
|
|
2329
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2330
|
+
varying vec2 vIridescenceMapUv;
|
|
2331
|
+
#endif
|
|
2332
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2333
|
+
varying vec2 vIridescenceThicknessMapUv;
|
|
2334
|
+
#endif
|
|
2335
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2336
|
+
varying vec2 vSheenColorMapUv;
|
|
2337
|
+
#endif
|
|
2338
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2339
|
+
varying vec2 vSheenRoughnessMapUv;
|
|
2340
|
+
#endif
|
|
2341
|
+
#ifdef USE_SPECULARMAP
|
|
2342
|
+
varying vec2 vSpecularMapUv;
|
|
2343
|
+
#endif
|
|
2344
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2345
|
+
varying vec2 vSpecularColorMapUv;
|
|
2346
|
+
#endif
|
|
2347
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2348
|
+
varying vec2 vSpecularIntensityMapUv;
|
|
2349
|
+
#endif
|
|
2350
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2351
|
+
uniform mat3 transmissionMapTransform;
|
|
2352
|
+
varying vec2 vTransmissionMapUv;
|
|
2353
|
+
#endif
|
|
2354
|
+
#ifdef USE_THICKNESSMAP
|
|
2355
|
+
uniform mat3 thicknessMapTransform;
|
|
2356
|
+
varying vec2 vThicknessMapUv;
|
|
2357
|
+
#endif`,Ch=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2358
|
+
varying vec2 vUv;
|
|
2359
|
+
#endif
|
|
2360
|
+
#ifdef USE_MAP
|
|
2361
|
+
uniform mat3 mapTransform;
|
|
2362
|
+
varying vec2 vMapUv;
|
|
2363
|
+
#endif
|
|
2364
|
+
#ifdef USE_ALPHAMAP
|
|
2365
|
+
uniform mat3 alphaMapTransform;
|
|
2366
|
+
varying vec2 vAlphaMapUv;
|
|
2367
|
+
#endif
|
|
2368
|
+
#ifdef USE_LIGHTMAP
|
|
2369
|
+
uniform mat3 lightMapTransform;
|
|
2370
|
+
varying vec2 vLightMapUv;
|
|
2371
|
+
#endif
|
|
2372
|
+
#ifdef USE_AOMAP
|
|
2373
|
+
uniform mat3 aoMapTransform;
|
|
2374
|
+
varying vec2 vAoMapUv;
|
|
2375
|
+
#endif
|
|
2376
|
+
#ifdef USE_BUMPMAP
|
|
2377
|
+
uniform mat3 bumpMapTransform;
|
|
2378
|
+
varying vec2 vBumpMapUv;
|
|
2379
|
+
#endif
|
|
2380
|
+
#ifdef USE_NORMALMAP
|
|
2381
|
+
uniform mat3 normalMapTransform;
|
|
2382
|
+
varying vec2 vNormalMapUv;
|
|
2383
|
+
#endif
|
|
2384
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2385
|
+
uniform mat3 displacementMapTransform;
|
|
2386
|
+
varying vec2 vDisplacementMapUv;
|
|
2387
|
+
#endif
|
|
2388
|
+
#ifdef USE_EMISSIVEMAP
|
|
2389
|
+
uniform mat3 emissiveMapTransform;
|
|
2390
|
+
varying vec2 vEmissiveMapUv;
|
|
2391
|
+
#endif
|
|
2392
|
+
#ifdef USE_METALNESSMAP
|
|
2393
|
+
uniform mat3 metalnessMapTransform;
|
|
2394
|
+
varying vec2 vMetalnessMapUv;
|
|
2395
|
+
#endif
|
|
2396
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2397
|
+
uniform mat3 roughnessMapTransform;
|
|
2398
|
+
varying vec2 vRoughnessMapUv;
|
|
2399
|
+
#endif
|
|
2400
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2401
|
+
uniform mat3 anisotropyMapTransform;
|
|
2402
|
+
varying vec2 vAnisotropyMapUv;
|
|
2403
|
+
#endif
|
|
2404
|
+
#ifdef USE_CLEARCOATMAP
|
|
2405
|
+
uniform mat3 clearcoatMapTransform;
|
|
2406
|
+
varying vec2 vClearcoatMapUv;
|
|
2407
|
+
#endif
|
|
2408
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2409
|
+
uniform mat3 clearcoatNormalMapTransform;
|
|
2410
|
+
varying vec2 vClearcoatNormalMapUv;
|
|
2411
|
+
#endif
|
|
2412
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2413
|
+
uniform mat3 clearcoatRoughnessMapTransform;
|
|
2414
|
+
varying vec2 vClearcoatRoughnessMapUv;
|
|
2415
|
+
#endif
|
|
2416
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2417
|
+
uniform mat3 sheenColorMapTransform;
|
|
2418
|
+
varying vec2 vSheenColorMapUv;
|
|
2419
|
+
#endif
|
|
2420
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2421
|
+
uniform mat3 sheenRoughnessMapTransform;
|
|
2422
|
+
varying vec2 vSheenRoughnessMapUv;
|
|
2423
|
+
#endif
|
|
2424
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2425
|
+
uniform mat3 iridescenceMapTransform;
|
|
2426
|
+
varying vec2 vIridescenceMapUv;
|
|
2427
|
+
#endif
|
|
2428
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2429
|
+
uniform mat3 iridescenceThicknessMapTransform;
|
|
2430
|
+
varying vec2 vIridescenceThicknessMapUv;
|
|
2431
|
+
#endif
|
|
2432
|
+
#ifdef USE_SPECULARMAP
|
|
2433
|
+
uniform mat3 specularMapTransform;
|
|
2434
|
+
varying vec2 vSpecularMapUv;
|
|
2435
|
+
#endif
|
|
2436
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2437
|
+
uniform mat3 specularColorMapTransform;
|
|
2438
|
+
varying vec2 vSpecularColorMapUv;
|
|
2439
|
+
#endif
|
|
2440
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2441
|
+
uniform mat3 specularIntensityMapTransform;
|
|
2442
|
+
varying vec2 vSpecularIntensityMapUv;
|
|
2443
|
+
#endif
|
|
2444
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2445
|
+
uniform mat3 transmissionMapTransform;
|
|
2446
|
+
varying vec2 vTransmissionMapUv;
|
|
2447
|
+
#endif
|
|
2448
|
+
#ifdef USE_THICKNESSMAP
|
|
2449
|
+
uniform mat3 thicknessMapTransform;
|
|
2450
|
+
varying vec2 vThicknessMapUv;
|
|
2451
|
+
#endif`,Ph=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2452
|
+
vUv = vec3( uv, 1 ).xy;
|
|
2453
|
+
#endif
|
|
2454
|
+
#ifdef USE_MAP
|
|
2455
|
+
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|
2456
|
+
#endif
|
|
2457
|
+
#ifdef USE_ALPHAMAP
|
|
2458
|
+
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|
2459
|
+
#endif
|
|
2460
|
+
#ifdef USE_LIGHTMAP
|
|
2461
|
+
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|
2462
|
+
#endif
|
|
2463
|
+
#ifdef USE_AOMAP
|
|
2464
|
+
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|
2465
|
+
#endif
|
|
2466
|
+
#ifdef USE_BUMPMAP
|
|
2467
|
+
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|
2468
|
+
#endif
|
|
2469
|
+
#ifdef USE_NORMALMAP
|
|
2470
|
+
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|
2471
|
+
#endif
|
|
2472
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2473
|
+
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|
2474
|
+
#endif
|
|
2475
|
+
#ifdef USE_EMISSIVEMAP
|
|
2476
|
+
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|
2477
|
+
#endif
|
|
2478
|
+
#ifdef USE_METALNESSMAP
|
|
2479
|
+
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|
2480
|
+
#endif
|
|
2481
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2482
|
+
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2483
|
+
#endif
|
|
2484
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2485
|
+
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
2486
|
+
#endif
|
|
2487
|
+
#ifdef USE_CLEARCOATMAP
|
|
2488
|
+
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|
2489
|
+
#endif
|
|
2490
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2491
|
+
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|
2492
|
+
#endif
|
|
2493
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2494
|
+
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2495
|
+
#endif
|
|
2496
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2497
|
+
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|
2498
|
+
#endif
|
|
2499
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2500
|
+
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|
2501
|
+
#endif
|
|
2502
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2503
|
+
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|
2504
|
+
#endif
|
|
2505
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2506
|
+
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2507
|
+
#endif
|
|
2508
|
+
#ifdef USE_SPECULARMAP
|
|
2509
|
+
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|
2510
|
+
#endif
|
|
2511
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2512
|
+
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|
2513
|
+
#endif
|
|
2514
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2515
|
+
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|
2516
|
+
#endif
|
|
2517
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2518
|
+
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|
2519
|
+
#endif
|
|
2520
|
+
#ifdef USE_THICKNESSMAP
|
|
2521
|
+
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2522
|
+
#endif`,Dh=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2523
|
+
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2524
|
+
#ifdef USE_BATCHING
|
|
2525
|
+
worldPosition = batchingMatrix * worldPosition;
|
|
2526
|
+
#endif
|
|
2527
|
+
#ifdef USE_INSTANCING
|
|
2528
|
+
worldPosition = instanceMatrix * worldPosition;
|
|
2529
|
+
#endif
|
|
2530
|
+
worldPosition = modelMatrix * worldPosition;
|
|
2531
|
+
#endif`;const Lh=`varying vec2 vUv;
|
|
2532
|
+
uniform mat3 uvTransform;
|
|
2533
|
+
void main() {
|
|
2534
|
+
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2535
|
+
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2536
|
+
}`,Uh=`uniform sampler2D t2D;
|
|
2537
|
+
uniform float backgroundIntensity;
|
|
2538
|
+
varying vec2 vUv;
|
|
2539
|
+
void main() {
|
|
2540
|
+
vec4 texColor = texture2D( t2D, vUv );
|
|
2541
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
2542
|
+
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
|
2543
|
+
#endif
|
|
2544
|
+
texColor.rgb *= backgroundIntensity;
|
|
2545
|
+
gl_FragColor = texColor;
|
|
2546
|
+
#include <tonemapping_fragment>
|
|
2547
|
+
#include <colorspace_fragment>
|
|
2548
|
+
}`,Ih=`varying vec3 vWorldDirection;
|
|
2549
|
+
#include <common>
|
|
2550
|
+
void main() {
|
|
2551
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2552
|
+
#include <begin_vertex>
|
|
2553
|
+
#include <project_vertex>
|
|
2554
|
+
gl_Position.z = gl_Position.w;
|
|
2555
|
+
}`,Fh=`#ifdef ENVMAP_TYPE_CUBE
|
|
2556
|
+
uniform samplerCube envMap;
|
|
2557
|
+
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2558
|
+
uniform sampler2D envMap;
|
|
2559
|
+
#endif
|
|
2560
|
+
uniform float flipEnvMap;
|
|
2561
|
+
uniform float backgroundBlurriness;
|
|
2562
|
+
uniform float backgroundIntensity;
|
|
2563
|
+
uniform mat3 backgroundRotation;
|
|
2564
|
+
varying vec3 vWorldDirection;
|
|
2565
|
+
#include <cube_uv_reflection_fragment>
|
|
2566
|
+
void main() {
|
|
2567
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
2568
|
+
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
2569
|
+
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2570
|
+
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
2571
|
+
#else
|
|
2572
|
+
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
2573
|
+
#endif
|
|
2574
|
+
texColor.rgb *= backgroundIntensity;
|
|
2575
|
+
gl_FragColor = texColor;
|
|
2576
|
+
#include <tonemapping_fragment>
|
|
2577
|
+
#include <colorspace_fragment>
|
|
2578
|
+
}`,Nh=`varying vec3 vWorldDirection;
|
|
2579
|
+
#include <common>
|
|
2580
|
+
void main() {
|
|
2581
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2582
|
+
#include <begin_vertex>
|
|
2583
|
+
#include <project_vertex>
|
|
2584
|
+
gl_Position.z = gl_Position.w;
|
|
2585
|
+
}`,Oh=`uniform samplerCube tCube;
|
|
2586
|
+
uniform float tFlip;
|
|
2587
|
+
uniform float opacity;
|
|
2588
|
+
varying vec3 vWorldDirection;
|
|
2589
|
+
void main() {
|
|
2590
|
+
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|
2591
|
+
gl_FragColor = texColor;
|
|
2592
|
+
gl_FragColor.a *= opacity;
|
|
2593
|
+
#include <tonemapping_fragment>
|
|
2594
|
+
#include <colorspace_fragment>
|
|
2595
|
+
}`,Bh=`#include <common>
|
|
2596
|
+
#include <batching_pars_vertex>
|
|
2597
|
+
#include <uv_pars_vertex>
|
|
2598
|
+
#include <displacementmap_pars_vertex>
|
|
2599
|
+
#include <morphtarget_pars_vertex>
|
|
2600
|
+
#include <skinning_pars_vertex>
|
|
2601
|
+
#include <logdepthbuf_pars_vertex>
|
|
2602
|
+
#include <clipping_planes_pars_vertex>
|
|
2603
|
+
varying vec2 vHighPrecisionZW;
|
|
2604
|
+
void main() {
|
|
2605
|
+
#include <uv_vertex>
|
|
2606
|
+
#include <batching_vertex>
|
|
2607
|
+
#include <skinbase_vertex>
|
|
2608
|
+
#include <morphinstance_vertex>
|
|
2609
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2610
|
+
#include <beginnormal_vertex>
|
|
2611
|
+
#include <morphnormal_vertex>
|
|
2612
|
+
#include <skinnormal_vertex>
|
|
2613
|
+
#endif
|
|
2614
|
+
#include <begin_vertex>
|
|
2615
|
+
#include <morphtarget_vertex>
|
|
2616
|
+
#include <skinning_vertex>
|
|
2617
|
+
#include <displacementmap_vertex>
|
|
2618
|
+
#include <project_vertex>
|
|
2619
|
+
#include <logdepthbuf_vertex>
|
|
2620
|
+
#include <clipping_planes_vertex>
|
|
2621
|
+
vHighPrecisionZW = gl_Position.zw;
|
|
2622
|
+
}`,zh=`#if DEPTH_PACKING == 3200
|
|
2623
|
+
uniform float opacity;
|
|
2624
|
+
#endif
|
|
2625
|
+
#include <common>
|
|
2626
|
+
#include <packing>
|
|
2627
|
+
#include <uv_pars_fragment>
|
|
2628
|
+
#include <map_pars_fragment>
|
|
2629
|
+
#include <alphamap_pars_fragment>
|
|
2630
|
+
#include <alphatest_pars_fragment>
|
|
2631
|
+
#include <alphahash_pars_fragment>
|
|
2632
|
+
#include <logdepthbuf_pars_fragment>
|
|
2633
|
+
#include <clipping_planes_pars_fragment>
|
|
2634
|
+
varying vec2 vHighPrecisionZW;
|
|
2635
|
+
void main() {
|
|
2636
|
+
vec4 diffuseColor = vec4( 1.0 );
|
|
2637
|
+
#include <clipping_planes_fragment>
|
|
2638
|
+
#if DEPTH_PACKING == 3200
|
|
2639
|
+
diffuseColor.a = opacity;
|
|
2640
|
+
#endif
|
|
2641
|
+
#include <map_fragment>
|
|
2642
|
+
#include <alphamap_fragment>
|
|
2643
|
+
#include <alphatest_fragment>
|
|
2644
|
+
#include <alphahash_fragment>
|
|
2645
|
+
#include <logdepthbuf_fragment>
|
|
2646
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
2647
|
+
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
2648
|
+
#else
|
|
2649
|
+
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
2650
|
+
#endif
|
|
2651
|
+
#if DEPTH_PACKING == 3200
|
|
2652
|
+
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
2653
|
+
#elif DEPTH_PACKING == 3201
|
|
2654
|
+
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
2655
|
+
#elif DEPTH_PACKING == 3202
|
|
2656
|
+
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
2657
|
+
#elif DEPTH_PACKING == 3203
|
|
2658
|
+
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2659
|
+
#endif
|
|
2660
|
+
}`,Gh=`#define DISTANCE
|
|
2661
|
+
varying vec3 vWorldPosition;
|
|
2662
|
+
#include <common>
|
|
2663
|
+
#include <batching_pars_vertex>
|
|
2664
|
+
#include <uv_pars_vertex>
|
|
2665
|
+
#include <displacementmap_pars_vertex>
|
|
2666
|
+
#include <morphtarget_pars_vertex>
|
|
2667
|
+
#include <skinning_pars_vertex>
|
|
2668
|
+
#include <clipping_planes_pars_vertex>
|
|
2669
|
+
void main() {
|
|
2670
|
+
#include <uv_vertex>
|
|
2671
|
+
#include <batching_vertex>
|
|
2672
|
+
#include <skinbase_vertex>
|
|
2673
|
+
#include <morphinstance_vertex>
|
|
2674
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2675
|
+
#include <beginnormal_vertex>
|
|
2676
|
+
#include <morphnormal_vertex>
|
|
2677
|
+
#include <skinnormal_vertex>
|
|
2678
|
+
#endif
|
|
2679
|
+
#include <begin_vertex>
|
|
2680
|
+
#include <morphtarget_vertex>
|
|
2681
|
+
#include <skinning_vertex>
|
|
2682
|
+
#include <displacementmap_vertex>
|
|
2683
|
+
#include <project_vertex>
|
|
2684
|
+
#include <worldpos_vertex>
|
|
2685
|
+
#include <clipping_planes_vertex>
|
|
2686
|
+
vWorldPosition = worldPosition.xyz;
|
|
2687
|
+
}`,Vh=`#define DISTANCE
|
|
2688
|
+
uniform vec3 referencePosition;
|
|
2689
|
+
uniform float nearDistance;
|
|
2690
|
+
uniform float farDistance;
|
|
2691
|
+
varying vec3 vWorldPosition;
|
|
2692
|
+
#include <common>
|
|
2693
|
+
#include <packing>
|
|
2694
|
+
#include <uv_pars_fragment>
|
|
2695
|
+
#include <map_pars_fragment>
|
|
2696
|
+
#include <alphamap_pars_fragment>
|
|
2697
|
+
#include <alphatest_pars_fragment>
|
|
2698
|
+
#include <alphahash_pars_fragment>
|
|
2699
|
+
#include <clipping_planes_pars_fragment>
|
|
2700
|
+
void main () {
|
|
2701
|
+
vec4 diffuseColor = vec4( 1.0 );
|
|
2702
|
+
#include <clipping_planes_fragment>
|
|
2703
|
+
#include <map_fragment>
|
|
2704
|
+
#include <alphamap_fragment>
|
|
2705
|
+
#include <alphatest_fragment>
|
|
2706
|
+
#include <alphahash_fragment>
|
|
2707
|
+
float dist = length( vWorldPosition - referencePosition );
|
|
2708
|
+
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2709
|
+
dist = saturate( dist );
|
|
2710
|
+
gl_FragColor = packDepthToRGBA( dist );
|
|
2711
|
+
}`,Hh=`varying vec3 vWorldDirection;
|
|
2712
|
+
#include <common>
|
|
2713
|
+
void main() {
|
|
2714
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2715
|
+
#include <begin_vertex>
|
|
2716
|
+
#include <project_vertex>
|
|
2717
|
+
}`,kh=`uniform sampler2D tEquirect;
|
|
2718
|
+
varying vec3 vWorldDirection;
|
|
2719
|
+
#include <common>
|
|
2720
|
+
void main() {
|
|
2721
|
+
vec3 direction = normalize( vWorldDirection );
|
|
2722
|
+
vec2 sampleUV = equirectUv( direction );
|
|
2723
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2724
|
+
#include <tonemapping_fragment>
|
|
2725
|
+
#include <colorspace_fragment>
|
|
2726
|
+
}`,Wh=`uniform float scale;
|
|
2727
|
+
attribute float lineDistance;
|
|
2728
|
+
varying float vLineDistance;
|
|
2729
|
+
#include <common>
|
|
2730
|
+
#include <uv_pars_vertex>
|
|
2731
|
+
#include <color_pars_vertex>
|
|
2732
|
+
#include <fog_pars_vertex>
|
|
2733
|
+
#include <morphtarget_pars_vertex>
|
|
2734
|
+
#include <logdepthbuf_pars_vertex>
|
|
2735
|
+
#include <clipping_planes_pars_vertex>
|
|
2736
|
+
void main() {
|
|
2737
|
+
vLineDistance = scale * lineDistance;
|
|
2738
|
+
#include <uv_vertex>
|
|
2739
|
+
#include <color_vertex>
|
|
2740
|
+
#include <morphinstance_vertex>
|
|
2741
|
+
#include <morphcolor_vertex>
|
|
2742
|
+
#include <begin_vertex>
|
|
2743
|
+
#include <morphtarget_vertex>
|
|
2744
|
+
#include <project_vertex>
|
|
2745
|
+
#include <logdepthbuf_vertex>
|
|
2746
|
+
#include <clipping_planes_vertex>
|
|
2747
|
+
#include <fog_vertex>
|
|
2748
|
+
}`,Xh=`uniform vec3 diffuse;
|
|
2749
|
+
uniform float opacity;
|
|
2750
|
+
uniform float dashSize;
|
|
2751
|
+
uniform float totalSize;
|
|
2752
|
+
varying float vLineDistance;
|
|
2753
|
+
#include <common>
|
|
2754
|
+
#include <color_pars_fragment>
|
|
2755
|
+
#include <uv_pars_fragment>
|
|
2756
|
+
#include <map_pars_fragment>
|
|
2757
|
+
#include <fog_pars_fragment>
|
|
2758
|
+
#include <logdepthbuf_pars_fragment>
|
|
2759
|
+
#include <clipping_planes_pars_fragment>
|
|
2760
|
+
void main() {
|
|
2761
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2762
|
+
#include <clipping_planes_fragment>
|
|
2763
|
+
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
2764
|
+
discard;
|
|
2765
|
+
}
|
|
2766
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
2767
|
+
#include <logdepthbuf_fragment>
|
|
2768
|
+
#include <map_fragment>
|
|
2769
|
+
#include <color_fragment>
|
|
2770
|
+
outgoingLight = diffuseColor.rgb;
|
|
2771
|
+
#include <opaque_fragment>
|
|
2772
|
+
#include <tonemapping_fragment>
|
|
2773
|
+
#include <colorspace_fragment>
|
|
2774
|
+
#include <fog_fragment>
|
|
2775
|
+
#include <premultiplied_alpha_fragment>
|
|
2776
|
+
}`,qh=`#include <common>
|
|
2777
|
+
#include <batching_pars_vertex>
|
|
2778
|
+
#include <uv_pars_vertex>
|
|
2779
|
+
#include <envmap_pars_vertex>
|
|
2780
|
+
#include <color_pars_vertex>
|
|
2781
|
+
#include <fog_pars_vertex>
|
|
2782
|
+
#include <morphtarget_pars_vertex>
|
|
2783
|
+
#include <skinning_pars_vertex>
|
|
2784
|
+
#include <logdepthbuf_pars_vertex>
|
|
2785
|
+
#include <clipping_planes_pars_vertex>
|
|
2786
|
+
void main() {
|
|
2787
|
+
#include <uv_vertex>
|
|
2788
|
+
#include <color_vertex>
|
|
2789
|
+
#include <morphinstance_vertex>
|
|
2790
|
+
#include <morphcolor_vertex>
|
|
2791
|
+
#include <batching_vertex>
|
|
2792
|
+
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
2793
|
+
#include <beginnormal_vertex>
|
|
2794
|
+
#include <morphnormal_vertex>
|
|
2795
|
+
#include <skinbase_vertex>
|
|
2796
|
+
#include <skinnormal_vertex>
|
|
2797
|
+
#include <defaultnormal_vertex>
|
|
2798
|
+
#endif
|
|
2799
|
+
#include <begin_vertex>
|
|
2800
|
+
#include <morphtarget_vertex>
|
|
2801
|
+
#include <skinning_vertex>
|
|
2802
|
+
#include <project_vertex>
|
|
2803
|
+
#include <logdepthbuf_vertex>
|
|
2804
|
+
#include <clipping_planes_vertex>
|
|
2805
|
+
#include <worldpos_vertex>
|
|
2806
|
+
#include <envmap_vertex>
|
|
2807
|
+
#include <fog_vertex>
|
|
2808
|
+
}`,Yh=`uniform vec3 diffuse;
|
|
2809
|
+
uniform float opacity;
|
|
2810
|
+
#ifndef FLAT_SHADED
|
|
2811
|
+
varying vec3 vNormal;
|
|
2812
|
+
#endif
|
|
2813
|
+
#include <common>
|
|
2814
|
+
#include <dithering_pars_fragment>
|
|
2815
|
+
#include <color_pars_fragment>
|
|
2816
|
+
#include <uv_pars_fragment>
|
|
2817
|
+
#include <map_pars_fragment>
|
|
2818
|
+
#include <alphamap_pars_fragment>
|
|
2819
|
+
#include <alphatest_pars_fragment>
|
|
2820
|
+
#include <alphahash_pars_fragment>
|
|
2821
|
+
#include <aomap_pars_fragment>
|
|
2822
|
+
#include <lightmap_pars_fragment>
|
|
2823
|
+
#include <envmap_common_pars_fragment>
|
|
2824
|
+
#include <envmap_pars_fragment>
|
|
2825
|
+
#include <fog_pars_fragment>
|
|
2826
|
+
#include <specularmap_pars_fragment>
|
|
2827
|
+
#include <logdepthbuf_pars_fragment>
|
|
2828
|
+
#include <clipping_planes_pars_fragment>
|
|
2829
|
+
void main() {
|
|
2830
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2831
|
+
#include <clipping_planes_fragment>
|
|
2832
|
+
#include <logdepthbuf_fragment>
|
|
2833
|
+
#include <map_fragment>
|
|
2834
|
+
#include <color_fragment>
|
|
2835
|
+
#include <alphamap_fragment>
|
|
2836
|
+
#include <alphatest_fragment>
|
|
2837
|
+
#include <alphahash_fragment>
|
|
2838
|
+
#include <specularmap_fragment>
|
|
2839
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
2840
|
+
#ifdef USE_LIGHTMAP
|
|
2841
|
+
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
2842
|
+
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
2843
|
+
#else
|
|
2844
|
+
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
2845
|
+
#endif
|
|
2846
|
+
#include <aomap_fragment>
|
|
2847
|
+
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
2848
|
+
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
2849
|
+
#include <envmap_fragment>
|
|
2850
|
+
#include <opaque_fragment>
|
|
2851
|
+
#include <tonemapping_fragment>
|
|
2852
|
+
#include <colorspace_fragment>
|
|
2853
|
+
#include <fog_fragment>
|
|
2854
|
+
#include <premultiplied_alpha_fragment>
|
|
2855
|
+
#include <dithering_fragment>
|
|
2856
|
+
}`,Jh=`#define LAMBERT
|
|
2857
|
+
varying vec3 vViewPosition;
|
|
2858
|
+
#include <common>
|
|
2859
|
+
#include <batching_pars_vertex>
|
|
2860
|
+
#include <uv_pars_vertex>
|
|
2861
|
+
#include <displacementmap_pars_vertex>
|
|
2862
|
+
#include <envmap_pars_vertex>
|
|
2863
|
+
#include <color_pars_vertex>
|
|
2864
|
+
#include <fog_pars_vertex>
|
|
2865
|
+
#include <normal_pars_vertex>
|
|
2866
|
+
#include <morphtarget_pars_vertex>
|
|
2867
|
+
#include <skinning_pars_vertex>
|
|
2868
|
+
#include <shadowmap_pars_vertex>
|
|
2869
|
+
#include <logdepthbuf_pars_vertex>
|
|
2870
|
+
#include <clipping_planes_pars_vertex>
|
|
2871
|
+
void main() {
|
|
2872
|
+
#include <uv_vertex>
|
|
2873
|
+
#include <color_vertex>
|
|
2874
|
+
#include <morphinstance_vertex>
|
|
2875
|
+
#include <morphcolor_vertex>
|
|
2876
|
+
#include <batching_vertex>
|
|
2877
|
+
#include <beginnormal_vertex>
|
|
2878
|
+
#include <morphnormal_vertex>
|
|
2879
|
+
#include <skinbase_vertex>
|
|
2880
|
+
#include <skinnormal_vertex>
|
|
2881
|
+
#include <defaultnormal_vertex>
|
|
2882
|
+
#include <normal_vertex>
|
|
2883
|
+
#include <begin_vertex>
|
|
2884
|
+
#include <morphtarget_vertex>
|
|
2885
|
+
#include <skinning_vertex>
|
|
2886
|
+
#include <displacementmap_vertex>
|
|
2887
|
+
#include <project_vertex>
|
|
2888
|
+
#include <logdepthbuf_vertex>
|
|
2889
|
+
#include <clipping_planes_vertex>
|
|
2890
|
+
vViewPosition = - mvPosition.xyz;
|
|
2891
|
+
#include <worldpos_vertex>
|
|
2892
|
+
#include <envmap_vertex>
|
|
2893
|
+
#include <shadowmap_vertex>
|
|
2894
|
+
#include <fog_vertex>
|
|
2895
|
+
}`,Zh=`#define LAMBERT
|
|
2896
|
+
uniform vec3 diffuse;
|
|
2897
|
+
uniform vec3 emissive;
|
|
2898
|
+
uniform float opacity;
|
|
2899
|
+
#include <common>
|
|
2900
|
+
#include <packing>
|
|
2901
|
+
#include <dithering_pars_fragment>
|
|
2902
|
+
#include <color_pars_fragment>
|
|
2903
|
+
#include <uv_pars_fragment>
|
|
2904
|
+
#include <map_pars_fragment>
|
|
2905
|
+
#include <alphamap_pars_fragment>
|
|
2906
|
+
#include <alphatest_pars_fragment>
|
|
2907
|
+
#include <alphahash_pars_fragment>
|
|
2908
|
+
#include <aomap_pars_fragment>
|
|
2909
|
+
#include <lightmap_pars_fragment>
|
|
2910
|
+
#include <emissivemap_pars_fragment>
|
|
2911
|
+
#include <envmap_common_pars_fragment>
|
|
2912
|
+
#include <envmap_pars_fragment>
|
|
2913
|
+
#include <fog_pars_fragment>
|
|
2914
|
+
#include <bsdfs>
|
|
2915
|
+
#include <lights_pars_begin>
|
|
2916
|
+
#include <normal_pars_fragment>
|
|
2917
|
+
#include <lights_lambert_pars_fragment>
|
|
2918
|
+
#include <shadowmap_pars_fragment>
|
|
2919
|
+
#include <bumpmap_pars_fragment>
|
|
2920
|
+
#include <normalmap_pars_fragment>
|
|
2921
|
+
#include <specularmap_pars_fragment>
|
|
2922
|
+
#include <logdepthbuf_pars_fragment>
|
|
2923
|
+
#include <clipping_planes_pars_fragment>
|
|
2924
|
+
void main() {
|
|
2925
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2926
|
+
#include <clipping_planes_fragment>
|
|
2927
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
2928
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
2929
|
+
#include <logdepthbuf_fragment>
|
|
2930
|
+
#include <map_fragment>
|
|
2931
|
+
#include <color_fragment>
|
|
2932
|
+
#include <alphamap_fragment>
|
|
2933
|
+
#include <alphatest_fragment>
|
|
2934
|
+
#include <alphahash_fragment>
|
|
2935
|
+
#include <specularmap_fragment>
|
|
2936
|
+
#include <normal_fragment_begin>
|
|
2937
|
+
#include <normal_fragment_maps>
|
|
2938
|
+
#include <emissivemap_fragment>
|
|
2939
|
+
#include <lights_lambert_fragment>
|
|
2940
|
+
#include <lights_fragment_begin>
|
|
2941
|
+
#include <lights_fragment_maps>
|
|
2942
|
+
#include <lights_fragment_end>
|
|
2943
|
+
#include <aomap_fragment>
|
|
2944
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
2945
|
+
#include <envmap_fragment>
|
|
2946
|
+
#include <opaque_fragment>
|
|
2947
|
+
#include <tonemapping_fragment>
|
|
2948
|
+
#include <colorspace_fragment>
|
|
2949
|
+
#include <fog_fragment>
|
|
2950
|
+
#include <premultiplied_alpha_fragment>
|
|
2951
|
+
#include <dithering_fragment>
|
|
2952
|
+
}`,Kh=`#define MATCAP
|
|
2953
|
+
varying vec3 vViewPosition;
|
|
2954
|
+
#include <common>
|
|
2955
|
+
#include <batching_pars_vertex>
|
|
2956
|
+
#include <uv_pars_vertex>
|
|
2957
|
+
#include <color_pars_vertex>
|
|
2958
|
+
#include <displacementmap_pars_vertex>
|
|
2959
|
+
#include <fog_pars_vertex>
|
|
2960
|
+
#include <normal_pars_vertex>
|
|
2961
|
+
#include <morphtarget_pars_vertex>
|
|
2962
|
+
#include <skinning_pars_vertex>
|
|
2963
|
+
#include <logdepthbuf_pars_vertex>
|
|
2964
|
+
#include <clipping_planes_pars_vertex>
|
|
2965
|
+
void main() {
|
|
2966
|
+
#include <uv_vertex>
|
|
2967
|
+
#include <color_vertex>
|
|
2968
|
+
#include <morphinstance_vertex>
|
|
2969
|
+
#include <morphcolor_vertex>
|
|
2970
|
+
#include <batching_vertex>
|
|
2971
|
+
#include <beginnormal_vertex>
|
|
2972
|
+
#include <morphnormal_vertex>
|
|
2973
|
+
#include <skinbase_vertex>
|
|
2974
|
+
#include <skinnormal_vertex>
|
|
2975
|
+
#include <defaultnormal_vertex>
|
|
2976
|
+
#include <normal_vertex>
|
|
2977
|
+
#include <begin_vertex>
|
|
2978
|
+
#include <morphtarget_vertex>
|
|
2979
|
+
#include <skinning_vertex>
|
|
2980
|
+
#include <displacementmap_vertex>
|
|
2981
|
+
#include <project_vertex>
|
|
2982
|
+
#include <logdepthbuf_vertex>
|
|
2983
|
+
#include <clipping_planes_vertex>
|
|
2984
|
+
#include <fog_vertex>
|
|
2985
|
+
vViewPosition = - mvPosition.xyz;
|
|
2986
|
+
}`,$h=`#define MATCAP
|
|
2987
|
+
uniform vec3 diffuse;
|
|
2988
|
+
uniform float opacity;
|
|
2989
|
+
uniform sampler2D matcap;
|
|
2990
|
+
varying vec3 vViewPosition;
|
|
2991
|
+
#include <common>
|
|
2992
|
+
#include <dithering_pars_fragment>
|
|
2993
|
+
#include <color_pars_fragment>
|
|
2994
|
+
#include <uv_pars_fragment>
|
|
2995
|
+
#include <map_pars_fragment>
|
|
2996
|
+
#include <alphamap_pars_fragment>
|
|
2997
|
+
#include <alphatest_pars_fragment>
|
|
2998
|
+
#include <alphahash_pars_fragment>
|
|
2999
|
+
#include <fog_pars_fragment>
|
|
3000
|
+
#include <normal_pars_fragment>
|
|
3001
|
+
#include <bumpmap_pars_fragment>
|
|
3002
|
+
#include <normalmap_pars_fragment>
|
|
3003
|
+
#include <logdepthbuf_pars_fragment>
|
|
3004
|
+
#include <clipping_planes_pars_fragment>
|
|
3005
|
+
void main() {
|
|
3006
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3007
|
+
#include <clipping_planes_fragment>
|
|
3008
|
+
#include <logdepthbuf_fragment>
|
|
3009
|
+
#include <map_fragment>
|
|
3010
|
+
#include <color_fragment>
|
|
3011
|
+
#include <alphamap_fragment>
|
|
3012
|
+
#include <alphatest_fragment>
|
|
3013
|
+
#include <alphahash_fragment>
|
|
3014
|
+
#include <normal_fragment_begin>
|
|
3015
|
+
#include <normal_fragment_maps>
|
|
3016
|
+
vec3 viewDir = normalize( vViewPosition );
|
|
3017
|
+
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
3018
|
+
vec3 y = cross( viewDir, x );
|
|
3019
|
+
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
3020
|
+
#ifdef USE_MATCAP
|
|
3021
|
+
vec4 matcapColor = texture2D( matcap, uv );
|
|
3022
|
+
#else
|
|
3023
|
+
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
3024
|
+
#endif
|
|
3025
|
+
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
3026
|
+
#include <opaque_fragment>
|
|
3027
|
+
#include <tonemapping_fragment>
|
|
3028
|
+
#include <colorspace_fragment>
|
|
3029
|
+
#include <fog_fragment>
|
|
3030
|
+
#include <premultiplied_alpha_fragment>
|
|
3031
|
+
#include <dithering_fragment>
|
|
3032
|
+
}`,jh=`#define NORMAL
|
|
3033
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3034
|
+
varying vec3 vViewPosition;
|
|
3035
|
+
#endif
|
|
3036
|
+
#include <common>
|
|
3037
|
+
#include <batching_pars_vertex>
|
|
3038
|
+
#include <uv_pars_vertex>
|
|
3039
|
+
#include <displacementmap_pars_vertex>
|
|
3040
|
+
#include <normal_pars_vertex>
|
|
3041
|
+
#include <morphtarget_pars_vertex>
|
|
3042
|
+
#include <skinning_pars_vertex>
|
|
3043
|
+
#include <logdepthbuf_pars_vertex>
|
|
3044
|
+
#include <clipping_planes_pars_vertex>
|
|
3045
|
+
void main() {
|
|
3046
|
+
#include <uv_vertex>
|
|
3047
|
+
#include <batching_vertex>
|
|
3048
|
+
#include <beginnormal_vertex>
|
|
3049
|
+
#include <morphinstance_vertex>
|
|
3050
|
+
#include <morphnormal_vertex>
|
|
3051
|
+
#include <skinbase_vertex>
|
|
3052
|
+
#include <skinnormal_vertex>
|
|
3053
|
+
#include <defaultnormal_vertex>
|
|
3054
|
+
#include <normal_vertex>
|
|
3055
|
+
#include <begin_vertex>
|
|
3056
|
+
#include <morphtarget_vertex>
|
|
3057
|
+
#include <skinning_vertex>
|
|
3058
|
+
#include <displacementmap_vertex>
|
|
3059
|
+
#include <project_vertex>
|
|
3060
|
+
#include <logdepthbuf_vertex>
|
|
3061
|
+
#include <clipping_planes_vertex>
|
|
3062
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3063
|
+
vViewPosition = - mvPosition.xyz;
|
|
3064
|
+
#endif
|
|
3065
|
+
}`,Qh=`#define NORMAL
|
|
3066
|
+
uniform float opacity;
|
|
3067
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3068
|
+
varying vec3 vViewPosition;
|
|
3069
|
+
#endif
|
|
3070
|
+
#include <packing>
|
|
3071
|
+
#include <uv_pars_fragment>
|
|
3072
|
+
#include <normal_pars_fragment>
|
|
3073
|
+
#include <bumpmap_pars_fragment>
|
|
3074
|
+
#include <normalmap_pars_fragment>
|
|
3075
|
+
#include <logdepthbuf_pars_fragment>
|
|
3076
|
+
#include <clipping_planes_pars_fragment>
|
|
3077
|
+
void main() {
|
|
3078
|
+
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
3079
|
+
#include <clipping_planes_fragment>
|
|
3080
|
+
#include <logdepthbuf_fragment>
|
|
3081
|
+
#include <normal_fragment_begin>
|
|
3082
|
+
#include <normal_fragment_maps>
|
|
3083
|
+
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
|
3084
|
+
#ifdef OPAQUE
|
|
3085
|
+
gl_FragColor.a = 1.0;
|
|
3086
|
+
#endif
|
|
3087
|
+
}`,eu=`#define PHONG
|
|
3088
|
+
varying vec3 vViewPosition;
|
|
3089
|
+
#include <common>
|
|
3090
|
+
#include <batching_pars_vertex>
|
|
3091
|
+
#include <uv_pars_vertex>
|
|
3092
|
+
#include <displacementmap_pars_vertex>
|
|
3093
|
+
#include <envmap_pars_vertex>
|
|
3094
|
+
#include <color_pars_vertex>
|
|
3095
|
+
#include <fog_pars_vertex>
|
|
3096
|
+
#include <normal_pars_vertex>
|
|
3097
|
+
#include <morphtarget_pars_vertex>
|
|
3098
|
+
#include <skinning_pars_vertex>
|
|
3099
|
+
#include <shadowmap_pars_vertex>
|
|
3100
|
+
#include <logdepthbuf_pars_vertex>
|
|
3101
|
+
#include <clipping_planes_pars_vertex>
|
|
3102
|
+
void main() {
|
|
3103
|
+
#include <uv_vertex>
|
|
3104
|
+
#include <color_vertex>
|
|
3105
|
+
#include <morphcolor_vertex>
|
|
3106
|
+
#include <batching_vertex>
|
|
3107
|
+
#include <beginnormal_vertex>
|
|
3108
|
+
#include <morphinstance_vertex>
|
|
3109
|
+
#include <morphnormal_vertex>
|
|
3110
|
+
#include <skinbase_vertex>
|
|
3111
|
+
#include <skinnormal_vertex>
|
|
3112
|
+
#include <defaultnormal_vertex>
|
|
3113
|
+
#include <normal_vertex>
|
|
3114
|
+
#include <begin_vertex>
|
|
3115
|
+
#include <morphtarget_vertex>
|
|
3116
|
+
#include <skinning_vertex>
|
|
3117
|
+
#include <displacementmap_vertex>
|
|
3118
|
+
#include <project_vertex>
|
|
3119
|
+
#include <logdepthbuf_vertex>
|
|
3120
|
+
#include <clipping_planes_vertex>
|
|
3121
|
+
vViewPosition = - mvPosition.xyz;
|
|
3122
|
+
#include <worldpos_vertex>
|
|
3123
|
+
#include <envmap_vertex>
|
|
3124
|
+
#include <shadowmap_vertex>
|
|
3125
|
+
#include <fog_vertex>
|
|
3126
|
+
}`,tu=`#define PHONG
|
|
3127
|
+
uniform vec3 diffuse;
|
|
3128
|
+
uniform vec3 emissive;
|
|
3129
|
+
uniform vec3 specular;
|
|
3130
|
+
uniform float shininess;
|
|
3131
|
+
uniform float opacity;
|
|
3132
|
+
#include <common>
|
|
3133
|
+
#include <packing>
|
|
3134
|
+
#include <dithering_pars_fragment>
|
|
3135
|
+
#include <color_pars_fragment>
|
|
3136
|
+
#include <uv_pars_fragment>
|
|
3137
|
+
#include <map_pars_fragment>
|
|
3138
|
+
#include <alphamap_pars_fragment>
|
|
3139
|
+
#include <alphatest_pars_fragment>
|
|
3140
|
+
#include <alphahash_pars_fragment>
|
|
3141
|
+
#include <aomap_pars_fragment>
|
|
3142
|
+
#include <lightmap_pars_fragment>
|
|
3143
|
+
#include <emissivemap_pars_fragment>
|
|
3144
|
+
#include <envmap_common_pars_fragment>
|
|
3145
|
+
#include <envmap_pars_fragment>
|
|
3146
|
+
#include <fog_pars_fragment>
|
|
3147
|
+
#include <bsdfs>
|
|
3148
|
+
#include <lights_pars_begin>
|
|
3149
|
+
#include <normal_pars_fragment>
|
|
3150
|
+
#include <lights_phong_pars_fragment>
|
|
3151
|
+
#include <shadowmap_pars_fragment>
|
|
3152
|
+
#include <bumpmap_pars_fragment>
|
|
3153
|
+
#include <normalmap_pars_fragment>
|
|
3154
|
+
#include <specularmap_pars_fragment>
|
|
3155
|
+
#include <logdepthbuf_pars_fragment>
|
|
3156
|
+
#include <clipping_planes_pars_fragment>
|
|
3157
|
+
void main() {
|
|
3158
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3159
|
+
#include <clipping_planes_fragment>
|
|
3160
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3161
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3162
|
+
#include <logdepthbuf_fragment>
|
|
3163
|
+
#include <map_fragment>
|
|
3164
|
+
#include <color_fragment>
|
|
3165
|
+
#include <alphamap_fragment>
|
|
3166
|
+
#include <alphatest_fragment>
|
|
3167
|
+
#include <alphahash_fragment>
|
|
3168
|
+
#include <specularmap_fragment>
|
|
3169
|
+
#include <normal_fragment_begin>
|
|
3170
|
+
#include <normal_fragment_maps>
|
|
3171
|
+
#include <emissivemap_fragment>
|
|
3172
|
+
#include <lights_phong_fragment>
|
|
3173
|
+
#include <lights_fragment_begin>
|
|
3174
|
+
#include <lights_fragment_maps>
|
|
3175
|
+
#include <lights_fragment_end>
|
|
3176
|
+
#include <aomap_fragment>
|
|
3177
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
3178
|
+
#include <envmap_fragment>
|
|
3179
|
+
#include <opaque_fragment>
|
|
3180
|
+
#include <tonemapping_fragment>
|
|
3181
|
+
#include <colorspace_fragment>
|
|
3182
|
+
#include <fog_fragment>
|
|
3183
|
+
#include <premultiplied_alpha_fragment>
|
|
3184
|
+
#include <dithering_fragment>
|
|
3185
|
+
}`,nu=`#define STANDARD
|
|
3186
|
+
varying vec3 vViewPosition;
|
|
3187
|
+
#ifdef USE_TRANSMISSION
|
|
3188
|
+
varying vec3 vWorldPosition;
|
|
3189
|
+
#endif
|
|
3190
|
+
#include <common>
|
|
3191
|
+
#include <batching_pars_vertex>
|
|
3192
|
+
#include <uv_pars_vertex>
|
|
3193
|
+
#include <displacementmap_pars_vertex>
|
|
3194
|
+
#include <color_pars_vertex>
|
|
3195
|
+
#include <fog_pars_vertex>
|
|
3196
|
+
#include <normal_pars_vertex>
|
|
3197
|
+
#include <morphtarget_pars_vertex>
|
|
3198
|
+
#include <skinning_pars_vertex>
|
|
3199
|
+
#include <shadowmap_pars_vertex>
|
|
3200
|
+
#include <logdepthbuf_pars_vertex>
|
|
3201
|
+
#include <clipping_planes_pars_vertex>
|
|
3202
|
+
void main() {
|
|
3203
|
+
#include <uv_vertex>
|
|
3204
|
+
#include <color_vertex>
|
|
3205
|
+
#include <morphinstance_vertex>
|
|
3206
|
+
#include <morphcolor_vertex>
|
|
3207
|
+
#include <batching_vertex>
|
|
3208
|
+
#include <beginnormal_vertex>
|
|
3209
|
+
#include <morphnormal_vertex>
|
|
3210
|
+
#include <skinbase_vertex>
|
|
3211
|
+
#include <skinnormal_vertex>
|
|
3212
|
+
#include <defaultnormal_vertex>
|
|
3213
|
+
#include <normal_vertex>
|
|
3214
|
+
#include <begin_vertex>
|
|
3215
|
+
#include <morphtarget_vertex>
|
|
3216
|
+
#include <skinning_vertex>
|
|
3217
|
+
#include <displacementmap_vertex>
|
|
3218
|
+
#include <project_vertex>
|
|
3219
|
+
#include <logdepthbuf_vertex>
|
|
3220
|
+
#include <clipping_planes_vertex>
|
|
3221
|
+
vViewPosition = - mvPosition.xyz;
|
|
3222
|
+
#include <worldpos_vertex>
|
|
3223
|
+
#include <shadowmap_vertex>
|
|
3224
|
+
#include <fog_vertex>
|
|
3225
|
+
#ifdef USE_TRANSMISSION
|
|
3226
|
+
vWorldPosition = worldPosition.xyz;
|
|
3227
|
+
#endif
|
|
3228
|
+
}`,iu=`#define STANDARD
|
|
3229
|
+
#ifdef PHYSICAL
|
|
3230
|
+
#define IOR
|
|
3231
|
+
#define USE_SPECULAR
|
|
3232
|
+
#endif
|
|
3233
|
+
uniform vec3 diffuse;
|
|
3234
|
+
uniform vec3 emissive;
|
|
3235
|
+
uniform float roughness;
|
|
3236
|
+
uniform float metalness;
|
|
3237
|
+
uniform float opacity;
|
|
3238
|
+
#ifdef IOR
|
|
3239
|
+
uniform float ior;
|
|
3240
|
+
#endif
|
|
3241
|
+
#ifdef USE_SPECULAR
|
|
3242
|
+
uniform float specularIntensity;
|
|
3243
|
+
uniform vec3 specularColor;
|
|
3244
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
3245
|
+
uniform sampler2D specularColorMap;
|
|
3246
|
+
#endif
|
|
3247
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
3248
|
+
uniform sampler2D specularIntensityMap;
|
|
3249
|
+
#endif
|
|
3250
|
+
#endif
|
|
3251
|
+
#ifdef USE_CLEARCOAT
|
|
3252
|
+
uniform float clearcoat;
|
|
3253
|
+
uniform float clearcoatRoughness;
|
|
3254
|
+
#endif
|
|
3255
|
+
#ifdef USE_DISPERSION
|
|
3256
|
+
uniform float dispersion;
|
|
3257
|
+
#endif
|
|
3258
|
+
#ifdef USE_IRIDESCENCE
|
|
3259
|
+
uniform float iridescence;
|
|
3260
|
+
uniform float iridescenceIOR;
|
|
3261
|
+
uniform float iridescenceThicknessMinimum;
|
|
3262
|
+
uniform float iridescenceThicknessMaximum;
|
|
3263
|
+
#endif
|
|
3264
|
+
#ifdef USE_SHEEN
|
|
3265
|
+
uniform vec3 sheenColor;
|
|
3266
|
+
uniform float sheenRoughness;
|
|
3267
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
3268
|
+
uniform sampler2D sheenColorMap;
|
|
3269
|
+
#endif
|
|
3270
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
3271
|
+
uniform sampler2D sheenRoughnessMap;
|
|
3272
|
+
#endif
|
|
3273
|
+
#endif
|
|
3274
|
+
#ifdef USE_ANISOTROPY
|
|
3275
|
+
uniform vec2 anisotropyVector;
|
|
3276
|
+
#ifdef USE_ANISOTROPYMAP
|
|
3277
|
+
uniform sampler2D anisotropyMap;
|
|
3278
|
+
#endif
|
|
3279
|
+
#endif
|
|
3280
|
+
varying vec3 vViewPosition;
|
|
3281
|
+
#include <common>
|
|
3282
|
+
#include <packing>
|
|
3283
|
+
#include <dithering_pars_fragment>
|
|
3284
|
+
#include <color_pars_fragment>
|
|
3285
|
+
#include <uv_pars_fragment>
|
|
3286
|
+
#include <map_pars_fragment>
|
|
3287
|
+
#include <alphamap_pars_fragment>
|
|
3288
|
+
#include <alphatest_pars_fragment>
|
|
3289
|
+
#include <alphahash_pars_fragment>
|
|
3290
|
+
#include <aomap_pars_fragment>
|
|
3291
|
+
#include <lightmap_pars_fragment>
|
|
3292
|
+
#include <emissivemap_pars_fragment>
|
|
3293
|
+
#include <iridescence_fragment>
|
|
3294
|
+
#include <cube_uv_reflection_fragment>
|
|
3295
|
+
#include <envmap_common_pars_fragment>
|
|
3296
|
+
#include <envmap_physical_pars_fragment>
|
|
3297
|
+
#include <fog_pars_fragment>
|
|
3298
|
+
#include <lights_pars_begin>
|
|
3299
|
+
#include <normal_pars_fragment>
|
|
3300
|
+
#include <lights_physical_pars_fragment>
|
|
3301
|
+
#include <transmission_pars_fragment>
|
|
3302
|
+
#include <shadowmap_pars_fragment>
|
|
3303
|
+
#include <bumpmap_pars_fragment>
|
|
3304
|
+
#include <normalmap_pars_fragment>
|
|
3305
|
+
#include <clearcoat_pars_fragment>
|
|
3306
|
+
#include <iridescence_pars_fragment>
|
|
3307
|
+
#include <roughnessmap_pars_fragment>
|
|
3308
|
+
#include <metalnessmap_pars_fragment>
|
|
3309
|
+
#include <logdepthbuf_pars_fragment>
|
|
3310
|
+
#include <clipping_planes_pars_fragment>
|
|
3311
|
+
void main() {
|
|
3312
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3313
|
+
#include <clipping_planes_fragment>
|
|
3314
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3315
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3316
|
+
#include <logdepthbuf_fragment>
|
|
3317
|
+
#include <map_fragment>
|
|
3318
|
+
#include <color_fragment>
|
|
3319
|
+
#include <alphamap_fragment>
|
|
3320
|
+
#include <alphatest_fragment>
|
|
3321
|
+
#include <alphahash_fragment>
|
|
3322
|
+
#include <roughnessmap_fragment>
|
|
3323
|
+
#include <metalnessmap_fragment>
|
|
3324
|
+
#include <normal_fragment_begin>
|
|
3325
|
+
#include <normal_fragment_maps>
|
|
3326
|
+
#include <clearcoat_normal_fragment_begin>
|
|
3327
|
+
#include <clearcoat_normal_fragment_maps>
|
|
3328
|
+
#include <emissivemap_fragment>
|
|
3329
|
+
#include <lights_physical_fragment>
|
|
3330
|
+
#include <lights_fragment_begin>
|
|
3331
|
+
#include <lights_fragment_maps>
|
|
3332
|
+
#include <lights_fragment_end>
|
|
3333
|
+
#include <aomap_fragment>
|
|
3334
|
+
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
3335
|
+
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
3336
|
+
#include <transmission_fragment>
|
|
3337
|
+
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
3338
|
+
#ifdef USE_SHEEN
|
|
3339
|
+
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
3340
|
+
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
3341
|
+
#endif
|
|
3342
|
+
#ifdef USE_CLEARCOAT
|
|
3343
|
+
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
3344
|
+
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
3345
|
+
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
3346
|
+
#endif
|
|
3347
|
+
#include <opaque_fragment>
|
|
3348
|
+
#include <tonemapping_fragment>
|
|
3349
|
+
#include <colorspace_fragment>
|
|
3350
|
+
#include <fog_fragment>
|
|
3351
|
+
#include <premultiplied_alpha_fragment>
|
|
3352
|
+
#include <dithering_fragment>
|
|
3353
|
+
}`,ru=`#define TOON
|
|
3354
|
+
varying vec3 vViewPosition;
|
|
3355
|
+
#include <common>
|
|
3356
|
+
#include <batching_pars_vertex>
|
|
3357
|
+
#include <uv_pars_vertex>
|
|
3358
|
+
#include <displacementmap_pars_vertex>
|
|
3359
|
+
#include <color_pars_vertex>
|
|
3360
|
+
#include <fog_pars_vertex>
|
|
3361
|
+
#include <normal_pars_vertex>
|
|
3362
|
+
#include <morphtarget_pars_vertex>
|
|
3363
|
+
#include <skinning_pars_vertex>
|
|
3364
|
+
#include <shadowmap_pars_vertex>
|
|
3365
|
+
#include <logdepthbuf_pars_vertex>
|
|
3366
|
+
#include <clipping_planes_pars_vertex>
|
|
3367
|
+
void main() {
|
|
3368
|
+
#include <uv_vertex>
|
|
3369
|
+
#include <color_vertex>
|
|
3370
|
+
#include <morphinstance_vertex>
|
|
3371
|
+
#include <morphcolor_vertex>
|
|
3372
|
+
#include <batching_vertex>
|
|
3373
|
+
#include <beginnormal_vertex>
|
|
3374
|
+
#include <morphnormal_vertex>
|
|
3375
|
+
#include <skinbase_vertex>
|
|
3376
|
+
#include <skinnormal_vertex>
|
|
3377
|
+
#include <defaultnormal_vertex>
|
|
3378
|
+
#include <normal_vertex>
|
|
3379
|
+
#include <begin_vertex>
|
|
3380
|
+
#include <morphtarget_vertex>
|
|
3381
|
+
#include <skinning_vertex>
|
|
3382
|
+
#include <displacementmap_vertex>
|
|
3383
|
+
#include <project_vertex>
|
|
3384
|
+
#include <logdepthbuf_vertex>
|
|
3385
|
+
#include <clipping_planes_vertex>
|
|
3386
|
+
vViewPosition = - mvPosition.xyz;
|
|
3387
|
+
#include <worldpos_vertex>
|
|
3388
|
+
#include <shadowmap_vertex>
|
|
3389
|
+
#include <fog_vertex>
|
|
3390
|
+
}`,su=`#define TOON
|
|
3391
|
+
uniform vec3 diffuse;
|
|
3392
|
+
uniform vec3 emissive;
|
|
3393
|
+
uniform float opacity;
|
|
3394
|
+
#include <common>
|
|
3395
|
+
#include <packing>
|
|
3396
|
+
#include <dithering_pars_fragment>
|
|
3397
|
+
#include <color_pars_fragment>
|
|
3398
|
+
#include <uv_pars_fragment>
|
|
3399
|
+
#include <map_pars_fragment>
|
|
3400
|
+
#include <alphamap_pars_fragment>
|
|
3401
|
+
#include <alphatest_pars_fragment>
|
|
3402
|
+
#include <alphahash_pars_fragment>
|
|
3403
|
+
#include <aomap_pars_fragment>
|
|
3404
|
+
#include <lightmap_pars_fragment>
|
|
3405
|
+
#include <emissivemap_pars_fragment>
|
|
3406
|
+
#include <gradientmap_pars_fragment>
|
|
3407
|
+
#include <fog_pars_fragment>
|
|
3408
|
+
#include <bsdfs>
|
|
3409
|
+
#include <lights_pars_begin>
|
|
3410
|
+
#include <normal_pars_fragment>
|
|
3411
|
+
#include <lights_toon_pars_fragment>
|
|
3412
|
+
#include <shadowmap_pars_fragment>
|
|
3413
|
+
#include <bumpmap_pars_fragment>
|
|
3414
|
+
#include <normalmap_pars_fragment>
|
|
3415
|
+
#include <logdepthbuf_pars_fragment>
|
|
3416
|
+
#include <clipping_planes_pars_fragment>
|
|
3417
|
+
void main() {
|
|
3418
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3419
|
+
#include <clipping_planes_fragment>
|
|
3420
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3421
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3422
|
+
#include <logdepthbuf_fragment>
|
|
3423
|
+
#include <map_fragment>
|
|
3424
|
+
#include <color_fragment>
|
|
3425
|
+
#include <alphamap_fragment>
|
|
3426
|
+
#include <alphatest_fragment>
|
|
3427
|
+
#include <alphahash_fragment>
|
|
3428
|
+
#include <normal_fragment_begin>
|
|
3429
|
+
#include <normal_fragment_maps>
|
|
3430
|
+
#include <emissivemap_fragment>
|
|
3431
|
+
#include <lights_toon_fragment>
|
|
3432
|
+
#include <lights_fragment_begin>
|
|
3433
|
+
#include <lights_fragment_maps>
|
|
3434
|
+
#include <lights_fragment_end>
|
|
3435
|
+
#include <aomap_fragment>
|
|
3436
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
3437
|
+
#include <opaque_fragment>
|
|
3438
|
+
#include <tonemapping_fragment>
|
|
3439
|
+
#include <colorspace_fragment>
|
|
3440
|
+
#include <fog_fragment>
|
|
3441
|
+
#include <premultiplied_alpha_fragment>
|
|
3442
|
+
#include <dithering_fragment>
|
|
3443
|
+
}`,au=`uniform float size;
|
|
3444
|
+
uniform float scale;
|
|
3445
|
+
#include <common>
|
|
3446
|
+
#include <color_pars_vertex>
|
|
3447
|
+
#include <fog_pars_vertex>
|
|
3448
|
+
#include <morphtarget_pars_vertex>
|
|
3449
|
+
#include <logdepthbuf_pars_vertex>
|
|
3450
|
+
#include <clipping_planes_pars_vertex>
|
|
3451
|
+
#ifdef USE_POINTS_UV
|
|
3452
|
+
varying vec2 vUv;
|
|
3453
|
+
uniform mat3 uvTransform;
|
|
3454
|
+
#endif
|
|
3455
|
+
void main() {
|
|
3456
|
+
#ifdef USE_POINTS_UV
|
|
3457
|
+
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
3458
|
+
#endif
|
|
3459
|
+
#include <color_vertex>
|
|
3460
|
+
#include <morphinstance_vertex>
|
|
3461
|
+
#include <morphcolor_vertex>
|
|
3462
|
+
#include <begin_vertex>
|
|
3463
|
+
#include <morphtarget_vertex>
|
|
3464
|
+
#include <project_vertex>
|
|
3465
|
+
gl_PointSize = size;
|
|
3466
|
+
#ifdef USE_SIZEATTENUATION
|
|
3467
|
+
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
3468
|
+
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
3469
|
+
#endif
|
|
3470
|
+
#include <logdepthbuf_vertex>
|
|
3471
|
+
#include <clipping_planes_vertex>
|
|
3472
|
+
#include <worldpos_vertex>
|
|
3473
|
+
#include <fog_vertex>
|
|
3474
|
+
}`,ou=`uniform vec3 diffuse;
|
|
3475
|
+
uniform float opacity;
|
|
3476
|
+
#include <common>
|
|
3477
|
+
#include <color_pars_fragment>
|
|
3478
|
+
#include <map_particle_pars_fragment>
|
|
3479
|
+
#include <alphatest_pars_fragment>
|
|
3480
|
+
#include <alphahash_pars_fragment>
|
|
3481
|
+
#include <fog_pars_fragment>
|
|
3482
|
+
#include <logdepthbuf_pars_fragment>
|
|
3483
|
+
#include <clipping_planes_pars_fragment>
|
|
3484
|
+
void main() {
|
|
3485
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3486
|
+
#include <clipping_planes_fragment>
|
|
3487
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
3488
|
+
#include <logdepthbuf_fragment>
|
|
3489
|
+
#include <map_particle_fragment>
|
|
3490
|
+
#include <color_fragment>
|
|
3491
|
+
#include <alphatest_fragment>
|
|
3492
|
+
#include <alphahash_fragment>
|
|
3493
|
+
outgoingLight = diffuseColor.rgb;
|
|
3494
|
+
#include <opaque_fragment>
|
|
3495
|
+
#include <tonemapping_fragment>
|
|
3496
|
+
#include <colorspace_fragment>
|
|
3497
|
+
#include <fog_fragment>
|
|
3498
|
+
#include <premultiplied_alpha_fragment>
|
|
3499
|
+
}`,lu=`#include <common>
|
|
3500
|
+
#include <batching_pars_vertex>
|
|
3501
|
+
#include <fog_pars_vertex>
|
|
3502
|
+
#include <morphtarget_pars_vertex>
|
|
3503
|
+
#include <skinning_pars_vertex>
|
|
3504
|
+
#include <logdepthbuf_pars_vertex>
|
|
3505
|
+
#include <shadowmap_pars_vertex>
|
|
3506
|
+
void main() {
|
|
3507
|
+
#include <batching_vertex>
|
|
3508
|
+
#include <beginnormal_vertex>
|
|
3509
|
+
#include <morphinstance_vertex>
|
|
3510
|
+
#include <morphnormal_vertex>
|
|
3511
|
+
#include <skinbase_vertex>
|
|
3512
|
+
#include <skinnormal_vertex>
|
|
3513
|
+
#include <defaultnormal_vertex>
|
|
3514
|
+
#include <begin_vertex>
|
|
3515
|
+
#include <morphtarget_vertex>
|
|
3516
|
+
#include <skinning_vertex>
|
|
3517
|
+
#include <project_vertex>
|
|
3518
|
+
#include <logdepthbuf_vertex>
|
|
3519
|
+
#include <worldpos_vertex>
|
|
3520
|
+
#include <shadowmap_vertex>
|
|
3521
|
+
#include <fog_vertex>
|
|
3522
|
+
}`,cu=`uniform vec3 color;
|
|
3523
|
+
uniform float opacity;
|
|
3524
|
+
#include <common>
|
|
3525
|
+
#include <packing>
|
|
3526
|
+
#include <fog_pars_fragment>
|
|
3527
|
+
#include <bsdfs>
|
|
3528
|
+
#include <lights_pars_begin>
|
|
3529
|
+
#include <logdepthbuf_pars_fragment>
|
|
3530
|
+
#include <shadowmap_pars_fragment>
|
|
3531
|
+
#include <shadowmask_pars_fragment>
|
|
3532
|
+
void main() {
|
|
3533
|
+
#include <logdepthbuf_fragment>
|
|
3534
|
+
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
3535
|
+
#include <tonemapping_fragment>
|
|
3536
|
+
#include <colorspace_fragment>
|
|
3537
|
+
#include <fog_fragment>
|
|
3538
|
+
}`,hu=`uniform float rotation;
|
|
3539
|
+
uniform vec2 center;
|
|
3540
|
+
#include <common>
|
|
3541
|
+
#include <uv_pars_vertex>
|
|
3542
|
+
#include <fog_pars_vertex>
|
|
3543
|
+
#include <logdepthbuf_pars_vertex>
|
|
3544
|
+
#include <clipping_planes_pars_vertex>
|
|
3545
|
+
void main() {
|
|
3546
|
+
#include <uv_vertex>
|
|
3547
|
+
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|
3548
|
+
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
3549
|
+
#ifndef USE_SIZEATTENUATION
|
|
3550
|
+
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
3551
|
+
if ( isPerspective ) scale *= - mvPosition.z;
|
|
3552
|
+
#endif
|
|
3553
|
+
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
3554
|
+
vec2 rotatedPosition;
|
|
3555
|
+
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
3556
|
+
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
3557
|
+
mvPosition.xy += rotatedPosition;
|
|
3558
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
3559
|
+
#include <logdepthbuf_vertex>
|
|
3560
|
+
#include <clipping_planes_vertex>
|
|
3561
|
+
#include <fog_vertex>
|
|
3562
|
+
}`,uu=`uniform vec3 diffuse;
|
|
3563
|
+
uniform float opacity;
|
|
3564
|
+
#include <common>
|
|
3565
|
+
#include <uv_pars_fragment>
|
|
3566
|
+
#include <map_pars_fragment>
|
|
3567
|
+
#include <alphamap_pars_fragment>
|
|
3568
|
+
#include <alphatest_pars_fragment>
|
|
3569
|
+
#include <alphahash_pars_fragment>
|
|
3570
|
+
#include <fog_pars_fragment>
|
|
3571
|
+
#include <logdepthbuf_pars_fragment>
|
|
3572
|
+
#include <clipping_planes_pars_fragment>
|
|
3573
|
+
void main() {
|
|
3574
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3575
|
+
#include <clipping_planes_fragment>
|
|
3576
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
3577
|
+
#include <logdepthbuf_fragment>
|
|
3578
|
+
#include <map_fragment>
|
|
3579
|
+
#include <alphamap_fragment>
|
|
3580
|
+
#include <alphatest_fragment>
|
|
3581
|
+
#include <alphahash_fragment>
|
|
3582
|
+
outgoingLight = diffuseColor.rgb;
|
|
3583
|
+
#include <opaque_fragment>
|
|
3584
|
+
#include <tonemapping_fragment>
|
|
3585
|
+
#include <colorspace_fragment>
|
|
3586
|
+
#include <fog_fragment>
|
|
3587
|
+
}`,Ve={alphahash_fragment:Ul,alphahash_pars_fragment:Il,alphamap_fragment:Fl,alphamap_pars_fragment:Nl,alphatest_fragment:Ol,alphatest_pars_fragment:Bl,aomap_fragment:zl,aomap_pars_fragment:Gl,batching_pars_vertex:Vl,batching_vertex:Hl,begin_vertex:kl,beginnormal_vertex:Wl,bsdfs:Xl,iridescence_fragment:ql,bumpmap_pars_fragment:Yl,clipping_planes_fragment:Jl,clipping_planes_pars_fragment:Zl,clipping_planes_pars_vertex:Kl,clipping_planes_vertex:$l,color_fragment:jl,color_pars_fragment:Ql,color_pars_vertex:ec,color_vertex:tc,common:nc,cube_uv_reflection_fragment:ic,defaultnormal_vertex:rc,displacementmap_pars_vertex:sc,displacementmap_vertex:ac,emissivemap_fragment:oc,emissivemap_pars_fragment:lc,colorspace_fragment:cc,colorspace_pars_fragment:hc,envmap_fragment:uc,envmap_common_pars_fragment:fc,envmap_pars_fragment:dc,envmap_pars_vertex:pc,envmap_physical_pars_fragment:Ac,envmap_vertex:mc,fog_vertex:gc,fog_pars_vertex:_c,fog_fragment:vc,fog_pars_fragment:xc,gradientmap_pars_fragment:Mc,lightmap_pars_fragment:Sc,lights_lambert_fragment:yc,lights_lambert_pars_fragment:Ec,lights_pars_begin:Tc,lights_toon_fragment:bc,lights_toon_pars_fragment:wc,lights_phong_fragment:Rc,lights_phong_pars_fragment:Cc,lights_physical_fragment:Pc,lights_physical_pars_fragment:Dc,lights_fragment_begin:Lc,lights_fragment_maps:Uc,lights_fragment_end:Ic,logdepthbuf_fragment:Fc,logdepthbuf_pars_fragment:Nc,logdepthbuf_pars_vertex:Oc,logdepthbuf_vertex:Bc,map_fragment:zc,map_pars_fragment:Gc,map_particle_fragment:Vc,map_particle_pars_fragment:Hc,metalnessmap_fragment:kc,metalnessmap_pars_fragment:Wc,morphinstance_vertex:Xc,morphcolor_vertex:qc,morphnormal_vertex:Yc,morphtarget_pars_vertex:Jc,morphtarget_vertex:Zc,normal_fragment_begin:Kc,normal_fragment_maps:$c,normal_pars_fragment:jc,normal_pars_vertex:Qc,normal_vertex:eh,normalmap_pars_fragment:th,clearcoat_normal_fragment_begin:nh,clearcoat_normal_fragment_maps:ih,clearcoat_pars_fragment:rh,iridescence_pars_fragment:sh,opaque_fragment:ah,packing:oh,premultiplied_alpha_fragment:lh,project_vertex:ch,dithering_fragment:hh,dithering_pars_fragment:uh,roughnessmap_fragment:fh,roughnessmap_pars_fragment:dh,shadowmap_pars_fragment:ph,shadowmap_pars_vertex:mh,shadowmap_vertex:gh,shadowmask_pars_fragment:_h,skinbase_vertex:vh,skinning_pars_vertex:xh,skinning_vertex:Mh,skinnormal_vertex:Sh,specularmap_fragment:yh,specularmap_pars_fragment:Eh,tonemapping_fragment:Th,tonemapping_pars_fragment:Ah,transmission_fragment:bh,transmission_pars_fragment:wh,uv_pars_fragment:Rh,uv_pars_vertex:Ch,uv_vertex:Ph,worldpos_vertex:Dh,background_vert:Lh,background_frag:Uh,backgroundCube_vert:Ih,backgroundCube_frag:Fh,cube_vert:Nh,cube_frag:Oh,depth_vert:Bh,depth_frag:zh,distanceRGBA_vert:Gh,distanceRGBA_frag:Vh,equirect_vert:Hh,equirect_frag:kh,linedashed_vert:Wh,linedashed_frag:Xh,meshbasic_vert:qh,meshbasic_frag:Yh,meshlambert_vert:Jh,meshlambert_frag:Zh,meshmatcap_vert:Kh,meshmatcap_frag:$h,meshnormal_vert:jh,meshnormal_frag:Qh,meshphong_vert:eu,meshphong_frag:tu,meshphysical_vert:nu,meshphysical_frag:iu,meshtoon_vert:ru,meshtoon_frag:su,points_vert:au,points_frag:ou,shadow_vert:lu,shadow_frag:cu,sprite_vert:hu,sprite_frag:uu},de={common:{diffuse:{value:new ke(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ge}},envmap:{envMap:{value:null},envMapRotation:{value:new Ge},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ge}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ge}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ge},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ge},normalScale:{value:new le(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ge},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ge}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ge}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ge}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ke(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ke(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0},uvTransform:{value:new Ge}},sprite:{diffuse:{value:new ke(16777215)},opacity:{value:1},center:{value:new le(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}}},Wt={basic:{uniforms:Et([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Et([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new ke(0)}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:Et([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new ke(0)},specular:{value:new ke(1118481)},shininess:{value:30}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:Et([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new ke(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:Et([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new ke(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:Et([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Et([de.points,de.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Et([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Et([de.common,de.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Et([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Et([de.sprite,de.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new Ge},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ge}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distanceRGBA:{uniforms:Et([de.common,de.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ve.distanceRGBA_vert,fragmentShader:Ve.distanceRGBA_frag},shadow:{uniforms:Et([de.lights,de.fog,{color:{value:new ke(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};Wt.physical={uniforms:Et([Wt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ge},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ge},clearcoatNormalScale:{value:new le(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ge},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ge},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ge},sheen:{value:0},sheenColor:{value:new ke(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ge},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ge},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ge},transmissionSamplerSize:{value:new le},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ge},attenuationDistance:{value:0},attenuationColor:{value:new ke(0)},specularColor:{value:new ke(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ge},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ge},anisotropyVector:{value:new le},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ge}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};const Hi={r:0,b:0,g:0},gn=new Ht,fu=new rt;function du(i,e,t,n,r,s,a){const o=new ke(0);let c=s===!0?0:1,l,h,f=null,d=0,u=null;function g(E){let x=E.isScene===!0?E.background:null;return x&&x.isTexture&&(x=(E.backgroundBlurriness>0?t:e).get(x)),x}function _(E){let x=!1;const C=g(E);C===null?p(o,c):C&&C.isColor&&(p(C,1),x=!0);const w=i.xr.getEnvironmentBlendMode();w==="additive"?n.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(E,x){const C=g(x);C&&(C.isCubeTexture||C.mapping===306)?(h===void 0&&(h=new ft(new Tn(1,1,1),new Xt({name:"BackgroundCubeMaterial",uniforms:Xn(Wt.backgroundCube.uniforms),vertexShader:Wt.backgroundCube.vertexShader,fragmentShader:Wt.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,D,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),gn.copy(x.backgroundRotation),gn.x*=-1,gn.y*=-1,gn.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(gn.y*=-1,gn.z*=-1),h.material.uniforms.envMap.value=C,h.material.uniforms.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(fu.makeRotationFromEuler(gn)),h.material.toneMapped=Ze.getTransfer(C.colorSpace)!==Qe,(f!==C||d!==C.version||u!==i.toneMapping)&&(h.material.needsUpdate=!0,f=C,d=C.version,u=i.toneMapping),h.layers.enableAll(),E.unshift(h,h.geometry,h.material,0,0,null)):C&&C.isTexture&&(l===void 0&&(l=new ft(new vi(2,2),new Xt({name:"BackgroundMaterial",uniforms:Xn(Wt.background.uniforms),vertexShader:Wt.background.vertexShader,fragmentShader:Wt.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=C,l.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,l.material.toneMapped=Ze.getTransfer(C.colorSpace)!==Qe,C.matrixAutoUpdate===!0&&C.updateMatrix(),l.material.uniforms.uvTransform.value.copy(C.matrix),(f!==C||d!==C.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,f=C,d=C.version,u=i.toneMapping),l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null))}function p(E,x){E.getRGB(Hi,xa(i)),n.buffers.color.setClear(Hi.r,Hi.g,Hi.b,x,a)}function A(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(E,x=1){o.set(E),c=x,p(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(E){c=E,p(o,c)},render:_,addToRenderList:m,dispose:A}}function pu(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null);let s=r,a=!1;function o(M,R,O,G,W){let q=!1;const k=f(G,O,R);s!==k&&(s=k,l(s.object)),q=u(M,G,O,W),q&&g(M,G,O,W),W!==null&&e.update(W,i.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,x(M,R,O,G),W!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(W).buffer))}function c(){return i.createVertexArray()}function l(M){return i.bindVertexArray(M)}function h(M){return i.deleteVertexArray(M)}function f(M,R,O){const G=O.wireframe===!0;let W=n[M.id];W===void 0&&(W={},n[M.id]=W);let q=W[R.id];q===void 0&&(q={},W[R.id]=q);let k=q[G];return k===void 0&&(k=d(c()),q[G]=k),k}function d(M){const R=[],O=[],G=[];for(let W=0;W<t;W++)R[W]=0,O[W]=0,G[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:O,attributeDivisors:G,object:M,attributes:{},index:null}}function u(M,R,O,G){const W=s.attributes,q=R.attributes;let k=0;const te=O.getAttributes();for(const H in te)if(te[H].location>=0){const _e=W[H];let Me=q[H];if(Me===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(Me=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(Me=M.instanceColor)),_e===void 0||_e.attribute!==Me||Me&&_e.data!==Me.data)return!0;k++}return s.attributesNum!==k||s.index!==G}function g(M,R,O,G){const W={},q=R.attributes;let k=0;const te=O.getAttributes();for(const H in te)if(te[H].location>=0){let _e=q[H];_e===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(_e=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(_e=M.instanceColor));const Me={};Me.attribute=_e,_e&&_e.data&&(Me.data=_e.data),W[H]=Me,k++}s.attributes=W,s.attributesNum=k,s.index=G}function _(){const M=s.newAttributes;for(let R=0,O=M.length;R<O;R++)M[R]=0}function m(M){p(M,0)}function p(M,R){const O=s.newAttributes,G=s.enabledAttributes,W=s.attributeDivisors;O[M]=1,G[M]===0&&(i.enableVertexAttribArray(M),G[M]=1),W[M]!==R&&(i.vertexAttribDivisor(M,R),W[M]=R)}function A(){const M=s.newAttributes,R=s.enabledAttributes;for(let O=0,G=R.length;O<G;O++)R[O]!==M[O]&&(i.disableVertexAttribArray(O),R[O]=0)}function E(M,R,O,G,W,q,k){k===!0?i.vertexAttribIPointer(M,R,O,W,q):i.vertexAttribPointer(M,R,O,G,W,q)}function x(M,R,O,G){_();const W=G.attributes,q=O.getAttributes(),k=R.defaultAttributeValues;for(const te in q){const H=q[te];if(H.location>=0){let ue=W[te];if(ue===void 0&&(te==="instanceMatrix"&&M.instanceMatrix&&(ue=M.instanceMatrix),te==="instanceColor"&&M.instanceColor&&(ue=M.instanceColor)),ue!==void 0){const _e=ue.normalized,Me=ue.itemSize,Be=e.get(ue);if(Be===void 0)continue;const qe=Be.buffer,$e=Be.type,Ye=Be.bytesPerElement,Y=$e===i.INT||$e===i.UNSIGNED_INT||ue.gpuType===1013;if(ue.isInterleavedBufferAttribute){const ee=ue.data,xe=ee.stride,Ce=ue.offset;if(ee.isInstancedInterleavedBuffer){for(let Ee=0;Ee<H.locationSize;Ee++)p(H.location+Ee,ee.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let Ee=0;Ee<H.locationSize;Ee++)m(H.location+Ee);i.bindBuffer(i.ARRAY_BUFFER,qe);for(let Ee=0;Ee<H.locationSize;Ee++)E(H.location+Ee,Me/H.locationSize,$e,_e,xe*Ye,(Ce+Me/H.locationSize*Ee)*Ye,Y)}else{if(ue.isInstancedBufferAttribute){for(let ee=0;ee<H.locationSize;ee++)p(H.location+ee,ue.meshPerAttribute);M.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let ee=0;ee<H.locationSize;ee++)m(H.location+ee);i.bindBuffer(i.ARRAY_BUFFER,qe);for(let ee=0;ee<H.locationSize;ee++)E(H.location+ee,Me/H.locationSize,$e,_e,Me*Ye,Me/H.locationSize*ee*Ye,Y)}}else if(k!==void 0){const _e=k[te];if(_e!==void 0)switch(_e.length){case 2:i.vertexAttrib2fv(H.location,_e);break;case 3:i.vertexAttrib3fv(H.location,_e);break;case 4:i.vertexAttrib4fv(H.location,_e);break;default:i.vertexAttrib1fv(H.location,_e)}}}}A()}function C(){U();for(const M in n){const R=n[M];for(const O in R){const G=R[O];for(const W in G)h(G[W].object),delete G[W];delete R[O]}delete n[M]}}function w(M){if(n[M.id]===void 0)return;const R=n[M.id];for(const O in R){const G=R[O];for(const W in G)h(G[W].object),delete G[W];delete R[O]}delete n[M.id]}function D(M){for(const R in n){const O=n[R];if(O[M.id]===void 0)continue;const G=O[M.id];for(const W in G)h(G[W].object),delete G[W];delete O[M.id]}}function U(){y(),a=!0,s!==r&&(s=r,l(s.object))}function y(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:U,resetDefaultState:y,dispose:C,releaseStatesOfGeometry:w,releaseStatesOfProgram:D,initAttributes:_,enableAttribute:m,disableUnusedAttributes:A}}function mu(i,e,t){let n;function r(l){n=l}function s(l,h){i.drawArrays(n,l,h),t.update(h,n,1)}function a(l,h,f){f!==0&&(i.drawArraysInstanced(n,l,h,f),t.update(h,n,f))}function o(l,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,h,0,f);let u=0;for(let g=0;g<f;g++)u+=h[g];t.update(u,n,1)}function c(l,h,f,d){if(f===0)return;const u=e.get("WEBGL_multi_draw");if(u===null)for(let g=0;g<l.length;g++)a(l[g],h[g],d[g]);else{u.multiDrawArraysInstancedWEBGL(n,l,0,h,0,d,0,f);let g=0;for(let _=0;_<f;_++)g+=h[_]*d[_];t.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function gu(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const D=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(D){return!(D!==1023&&n.convert(D)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(D){const U=D===1016&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(D!==1009&&n.convert(D)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&D!==1015&&!U)}function c(D){if(D==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";D="mediump"}return D==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const f=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),u=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),x=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),C=g>0,w=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:d,maxTextures:u,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:A,maxVaryings:E,maxFragmentUniforms:x,vertexTextures:C,maxSamples:w}}function _u(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new vn,o=new Ge,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,d){const u=f.length!==0||d||n!==0||r;return r=d,n=f.length,u},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,d){t=h(f,d,0)},this.setState=function(f,d,u){const g=f.clippingPlanes,_=f.clipIntersection,m=f.clipShadows,p=i.get(f);if(!r||g===null||g.length===0||s&&!m)s?h(null):l();else{const A=s?0:n,E=A*4;let x=p.clippingState||null;c.value=x,x=h(g,d,E,u);for(let C=0;C!==E;++C)x[C]=t[C];p.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(f,d,u,g){const _=f!==null?f.length:0;let m=null;if(_!==0){if(m=c.value,g!==!0||m===null){const p=u+_*4,A=d.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<p)&&(m=new Float32Array(p));for(let E=0,x=u;E!==_;++E,x+=4)a.copy(f[E]).applyMatrix4(A,o),a.normal.toArray(m,x),m[x+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}function vu(i){let e=new WeakMap;function t(a,o){return o===303?a.mapping=301:o===304&&(a.mapping=302),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===303||o===304)if(e.has(a)){const c=e.get(a).texture;return t(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const l=new Oo(c.height);return l.fromEquirectangularTexture(i,a),e.set(a,l),a.addEventListener("dispose",r),t(l.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const Hn=4,Vs=[.125,.215,.35,.446,.526,.582],Mn=20,Pr=new Fa,Hs=new ke;let Dr=null,Lr=0,Ur=0,Ir=!1;const xn=(1+Math.sqrt(5))/2,zn=1/xn,ks=[new P(-xn,zn,0),new P(xn,zn,0),new P(-zn,0,xn),new P(zn,0,xn),new P(0,xn,-zn),new P(0,xn,zn),new P(-1,1,-1),new P(1,1,-1),new P(-1,1,1),new P(1,1,1)],xu=new P;class Vr{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100,s={}){const{size:a=256,position:o=xu}=s;Dr=this._renderer.getRenderTarget(),Lr=this._renderer.getActiveCubeFace(),Ur=this._renderer.getActiveMipmapLevel(),Ir=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=qs(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Xs(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Dr,Lr,Ur),this._renderer.xr.enabled=Ir,e.scissorTest=!1,ki(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Dr=this._renderer.getRenderTarget(),Lr=this._renderer.getActiveCubeFace(),Ur=this._renderer.getActiveMipmapLevel(),Ir=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:1006,minFilter:1006,generateMipmaps:!1,type:1016,format:1023,colorSpace:Wn,depthBuffer:!1},r=Ws(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ws(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Mu(s)),this._blurMaterial=Su(s,e,t)}return r}_compileMaterial(e){const t=new ft(this._lodPlanes[0],e);this._renderer.compile(t,Pr)}_sceneToCubeUV(e,t,n,r,s){const c=new Lt(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],f=this._renderer,d=f.autoClear,u=f.toneMapping;f.getClearColor(Hs),f.toneMapping=0,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null));const _=new ga({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),m=new ft(new Tn,_);let p=!1;const A=e.background;A?A.isColor&&(_.color.copy(A),e.background=null,p=!0):(_.color.copy(Hs),p=!0);for(let E=0;E<6;E++){const x=E%3;x===0?(c.up.set(0,l[E],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[E],s.y,s.z)):x===1?(c.up.set(0,0,l[E]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[E],s.z)):(c.up.set(0,l[E],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[E]));const C=this._cubeSize;ki(r,x*C,E>2?C:0,C,C),f.setRenderTarget(r),p&&f.render(m,c),f.render(e,c)}m.geometry.dispose(),m.material.dispose(),f.toneMapping=u,f.autoClear=d,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=qs()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Xs());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new ft(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;ki(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Pr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=ks[(r-s-1)%ks.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,f=new ft(this._lodPlanes[r],l),d=l.uniforms,u=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*u):2*Math.PI/(2*Mn-1),_=s/g,m=isFinite(s)?1+Math.floor(h*_):Mn;m>Mn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Mn}`);const p=[];let A=0;for(let D=0;D<Mn;++D){const U=D/_,y=Math.exp(-U*U/2);p.push(y),D===0?A+=y:D<m&&(A+=2*y)}for(let D=0;D<p.length;D++)p[D]=p[D]/A;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=g,d.mipInt.value=E-n;const x=this._sizeLods[r],C=3*x*(r>E-Hn?r-E+Hn:0),w=4*(this._cubeSize-x);ki(t,C,w,3*x,2*x),c.setRenderTarget(t),c.render(f,Pr)}}function Mu(i){const e=[],t=[],n=[];let r=i;const s=i-Hn+1+Vs.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let c=1/o;a>i-Hn?c=Vs[a-i+Hn-1]:a===0&&(c=0),n.push(c);const l=1/(o-2),h=-l,f=1+l,d=[h,h,f,h,f,f,h,h,f,f,h,f],u=6,g=6,_=3,m=2,p=1,A=new Float32Array(_*g*u),E=new Float32Array(m*g*u),x=new Float32Array(p*g*u);for(let w=0;w<u;w++){const D=w%3*2/3-1,U=w>2?0:-1,y=[D,U,0,D+2/3,U,0,D+2/3,U+1,0,D,U,0,D+2/3,U+1,0,D,U+1,0];A.set(y,_*g*w),E.set(d,m*g*w);const M=[w,w,w,w,w,w];x.set(M,p*g*w)}const C=new wt;C.setAttribute("position",new Vt(A,_)),C.setAttribute("uv",new Vt(E,m)),C.setAttribute("faceIndex",new Vt(x,p)),e.push(C),r>Hn&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Ws(i,e,t){const n=new cn(i,e,t);return n.texture.mapping=306,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ki(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Su(i,e,t){const n=new Float32Array(Mn),r=new P(0,1,0);return new Xt({name:"SphericalGaussianBlur",defines:{n:Mn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:ts(),fragmentShader:`
|
|
3588
|
+
|
|
3589
|
+
precision mediump float;
|
|
3590
|
+
precision mediump int;
|
|
3591
|
+
|
|
3592
|
+
varying vec3 vOutputDirection;
|
|
3593
|
+
|
|
3594
|
+
uniform sampler2D envMap;
|
|
3595
|
+
uniform int samples;
|
|
3596
|
+
uniform float weights[ n ];
|
|
3597
|
+
uniform bool latitudinal;
|
|
3598
|
+
uniform float dTheta;
|
|
3599
|
+
uniform float mipInt;
|
|
3600
|
+
uniform vec3 poleAxis;
|
|
3601
|
+
|
|
3602
|
+
#define ENVMAP_TYPE_CUBE_UV
|
|
3603
|
+
#include <cube_uv_reflection_fragment>
|
|
3604
|
+
|
|
3605
|
+
vec3 getSample( float theta, vec3 axis ) {
|
|
3606
|
+
|
|
3607
|
+
float cosTheta = cos( theta );
|
|
3608
|
+
// Rodrigues' axis-angle rotation
|
|
3609
|
+
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
3610
|
+
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
3611
|
+
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
3612
|
+
|
|
3613
|
+
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
3614
|
+
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
void main() {
|
|
3618
|
+
|
|
3619
|
+
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
3620
|
+
|
|
3621
|
+
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
3622
|
+
|
|
3623
|
+
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
3624
|
+
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
axis = normalize( axis );
|
|
3628
|
+
|
|
3629
|
+
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
3630
|
+
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
3631
|
+
|
|
3632
|
+
for ( int i = 1; i < n; i++ ) {
|
|
3633
|
+
|
|
3634
|
+
if ( i >= samples ) {
|
|
3635
|
+
|
|
3636
|
+
break;
|
|
3637
|
+
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
float theta = dTheta * float( i );
|
|
3641
|
+
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
3642
|
+
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
3643
|
+
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
}
|
|
3647
|
+
`,blending:0,depthTest:!1,depthWrite:!1})}function Xs(){return new Xt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ts(),fragmentShader:`
|
|
3648
|
+
|
|
3649
|
+
precision mediump float;
|
|
3650
|
+
precision mediump int;
|
|
3651
|
+
|
|
3652
|
+
varying vec3 vOutputDirection;
|
|
3653
|
+
|
|
3654
|
+
uniform sampler2D envMap;
|
|
3655
|
+
|
|
3656
|
+
#include <common>
|
|
3657
|
+
|
|
3658
|
+
void main() {
|
|
3659
|
+
|
|
3660
|
+
vec3 outputDirection = normalize( vOutputDirection );
|
|
3661
|
+
vec2 uv = equirectUv( outputDirection );
|
|
3662
|
+
|
|
3663
|
+
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3664
|
+
|
|
3665
|
+
}
|
|
3666
|
+
`,blending:0,depthTest:!1,depthWrite:!1})}function qs(){return new Xt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ts(),fragmentShader:`
|
|
3667
|
+
|
|
3668
|
+
precision mediump float;
|
|
3669
|
+
precision mediump int;
|
|
3670
|
+
|
|
3671
|
+
uniform float flipEnvMap;
|
|
3672
|
+
|
|
3673
|
+
varying vec3 vOutputDirection;
|
|
3674
|
+
|
|
3675
|
+
uniform samplerCube envMap;
|
|
3676
|
+
|
|
3677
|
+
void main() {
|
|
3678
|
+
|
|
3679
|
+
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3680
|
+
|
|
3681
|
+
}
|
|
3682
|
+
`,blending:0,depthTest:!1,depthWrite:!1})}function ts(){return`
|
|
3683
|
+
|
|
3684
|
+
precision mediump float;
|
|
3685
|
+
precision mediump int;
|
|
3686
|
+
|
|
3687
|
+
attribute float faceIndex;
|
|
3688
|
+
|
|
3689
|
+
varying vec3 vOutputDirection;
|
|
3690
|
+
|
|
3691
|
+
// RH coordinate system; PMREM face-indexing convention
|
|
3692
|
+
vec3 getDirection( vec2 uv, float face ) {
|
|
3693
|
+
|
|
3694
|
+
uv = 2.0 * uv - 1.0;
|
|
3695
|
+
|
|
3696
|
+
vec3 direction = vec3( uv, 1.0 );
|
|
3697
|
+
|
|
3698
|
+
if ( face == 0.0 ) {
|
|
3699
|
+
|
|
3700
|
+
direction = direction.zyx; // ( 1, v, u ) pos x
|
|
3701
|
+
|
|
3702
|
+
} else if ( face == 1.0 ) {
|
|
3703
|
+
|
|
3704
|
+
direction = direction.xzy;
|
|
3705
|
+
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
3706
|
+
|
|
3707
|
+
} else if ( face == 2.0 ) {
|
|
3708
|
+
|
|
3709
|
+
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
3710
|
+
|
|
3711
|
+
} else if ( face == 3.0 ) {
|
|
3712
|
+
|
|
3713
|
+
direction = direction.zyx;
|
|
3714
|
+
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
3715
|
+
|
|
3716
|
+
} else if ( face == 4.0 ) {
|
|
3717
|
+
|
|
3718
|
+
direction = direction.xzy;
|
|
3719
|
+
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
3720
|
+
|
|
3721
|
+
} else if ( face == 5.0 ) {
|
|
3722
|
+
|
|
3723
|
+
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
3724
|
+
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3727
|
+
return direction;
|
|
3728
|
+
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
void main() {
|
|
3732
|
+
|
|
3733
|
+
vOutputDirection = getDirection( uv, faceIndex );
|
|
3734
|
+
gl_Position = vec4( position, 1.0 );
|
|
3735
|
+
|
|
3736
|
+
}
|
|
3737
|
+
`}function yu(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===303||c===304,h=c===301||c===302;if(l||h){let f=e.get(o);const d=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Vr(i)),f=l?t.fromEquirectangular(o,f):t.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const u=o.image;return l&&u&&u.height>0||h&&u&&r(u)?(t===null&&(t=new Vr(i)),f=l?t.fromEquirectangular(o):t.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",s),f.texture):null}}}return o}function r(o){let c=0;const l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function s(o){const c=o.target;c.removeEventListener("dispose",s);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function Eu(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&fi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function Tu(i,e,t,n){const r={},s=new WeakMap;function a(f){const d=f.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete r[d.id];const u=s.get(d);u&&(e.remove(u),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(f,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function c(f){const d=f.attributes;for(const u in d)e.update(d[u],i.ARRAY_BUFFER)}function l(f){const d=[],u=f.index,g=f.attributes.position;let _=0;if(u!==null){const A=u.array;_=u.version;for(let E=0,x=A.length;E<x;E+=3){const C=A[E+0],w=A[E+1],D=A[E+2];d.push(C,w,w,D,D,C)}}else if(g!==void 0){const A=g.array;_=g.version;for(let E=0,x=A.length/3-1;E<x;E+=3){const C=E+0,w=E+1,D=E+2;d.push(C,w,w,D,D,C)}}else return;const m=new(fa(d)?va:_a)(d,1);m.version=_;const p=s.get(f);p&&e.remove(p),s.set(f,m)}function h(f){const d=s.get(f);if(d){const u=f.index;u!==null&&d.version<u.version&&l(f)}else l(f);return s.get(f)}return{get:o,update:c,getWireframeAttribute:h}}function Au(i,e,t){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function c(d,u){i.drawElements(n,u,s,d*a),t.update(u,n,1)}function l(d,u,g){g!==0&&(i.drawElementsInstanced(n,u,s,d*a,g),t.update(u,n,g))}function h(d,u,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,s,d,0,g);let m=0;for(let p=0;p<g;p++)m+=u[p];t.update(m,n,1)}function f(d,u,g,_){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<d.length;p++)l(d[p]/a,u[p],_[p]);else{m.multiDrawElementsInstancedWEBGL(n,u,0,s,d,0,_,0,g);let p=0;for(let A=0;A<g;A++)p+=u[A]*_[A];t.update(p,n,1)}}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function bu(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function wu(i,e,t){const n=new WeakMap,r=new et;function s(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==f){let y=function(){D.dispose(),n.delete(o),o.removeEventListener("dispose",y)};d!==void 0&&d.texture.dispose();const u=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let E=0;u===!0&&(E=1),g===!0&&(E=2),_===!0&&(E=3);let x=o.attributes.position.count*E,C=1;x>e.maxTextureSize&&(C=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const w=new Float32Array(x*C*4*f),D=new da(w,x,C,f);D.type=1015,D.needsUpdate=!0;const U=E*4;for(let M=0;M<f;M++){const R=m[M],O=p[M],G=A[M],W=x*C*4*M;for(let q=0;q<R.count;q++){const k=q*U;u===!0&&(r.fromBufferAttribute(R,q),w[W+k+0]=r.x,w[W+k+1]=r.y,w[W+k+2]=r.z,w[W+k+3]=0),g===!0&&(r.fromBufferAttribute(O,q),w[W+k+4]=r.x,w[W+k+5]=r.y,w[W+k+6]=r.z,w[W+k+7]=0),_===!0&&(r.fromBufferAttribute(G,q),w[W+k+8]=r.x,w[W+k+9]=r.y,w[W+k+10]=r.z,w[W+k+11]=G.itemSize===4?r.w:1)}}d={count:f,texture:D,size:new le(x,C)},n.set(o,d),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let u=0;for(let _=0;_<l.length;_++)u+=l[_];const g=o.morphTargetsRelative?1:1-u;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function Ru(i,e,t,n){let r=new WeakMap;function s(c){const l=n.render.frame,h=c.geometry,f=e.get(c,h);if(r.get(f)!==l&&(e.update(f),r.set(f,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),r.get(c)!==l&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;r.get(d)!==l&&(d.update(),r.set(d,l))}return f}function a(){r=new WeakMap}function o(c){const l=c.target;l.removeEventListener("dispose",o),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:a}}const Oa=new Mt,Ys=new Sa(1,1),Ba=new da,za=new xo,Ga=new Ma,Js=[],Zs=[],Ks=new Float32Array(16),$s=new Float32Array(9),js=new Float32Array(4);function Zn(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=Js[r];if(s===void 0&&(s=new Float32Array(r),Js[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function dt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function pt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Qi(i,e){let t=Zs[e];t===void 0&&(t=new Int32Array(e),Zs[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Cu(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Pu(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;i.uniform2fv(this.addr,e),pt(t,e)}}function Du(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dt(t,e))return;i.uniform3fv(this.addr,e),pt(t,e)}}function Lu(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;i.uniform4fv(this.addr,e),pt(t,e)}}function Uu(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,n))return;js.set(n),i.uniformMatrix2fv(this.addr,!1,js),pt(t,n)}}function Iu(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,n))return;$s.set(n),i.uniformMatrix3fv(this.addr,!1,$s),pt(t,n)}}function Fu(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,n))return;Ks.set(n),i.uniformMatrix4fv(this.addr,!1,Ks),pt(t,n)}}function Nu(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Ou(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;i.uniform2iv(this.addr,e),pt(t,e)}}function Bu(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;i.uniform3iv(this.addr,e),pt(t,e)}}function zu(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;i.uniform4iv(this.addr,e),pt(t,e)}}function Gu(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Vu(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;i.uniform2uiv(this.addr,e),pt(t,e)}}function Hu(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;i.uniform3uiv(this.addr,e),pt(t,e)}}function ku(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;i.uniform4uiv(this.addr,e),pt(t,e)}}function Wu(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Ys.compareFunction=515,s=Ys):s=Oa,t.setTexture2D(e||s,r)}function Xu(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||za,r)}function qu(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Ga,r)}function Yu(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Ba,r)}function Ju(i){switch(i){case 5126:return Cu;case 35664:return Pu;case 35665:return Du;case 35666:return Lu;case 35674:return Uu;case 35675:return Iu;case 35676:return Fu;case 5124:case 35670:return Nu;case 35667:case 35671:return Ou;case 35668:case 35672:return Bu;case 35669:case 35673:return zu;case 5125:return Gu;case 36294:return Vu;case 36295:return Hu;case 36296:return ku;case 35678:case 36198:case 36298:case 36306:case 35682:return Wu;case 35679:case 36299:case 36307:return Xu;case 35680:case 36300:case 36308:case 36293:return qu;case 36289:case 36303:case 36311:case 36292:return Yu}}function Zu(i,e){i.uniform1fv(this.addr,e)}function Ku(i,e){const t=Zn(e,this.size,2);i.uniform2fv(this.addr,t)}function $u(i,e){const t=Zn(e,this.size,3);i.uniform3fv(this.addr,t)}function ju(i,e){const t=Zn(e,this.size,4);i.uniform4fv(this.addr,t)}function Qu(i,e){const t=Zn(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function ef(i,e){const t=Zn(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function tf(i,e){const t=Zn(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function nf(i,e){i.uniform1iv(this.addr,e)}function rf(i,e){i.uniform2iv(this.addr,e)}function sf(i,e){i.uniform3iv(this.addr,e)}function af(i,e){i.uniform4iv(this.addr,e)}function of(i,e){i.uniform1uiv(this.addr,e)}function lf(i,e){i.uniform2uiv(this.addr,e)}function cf(i,e){i.uniform3uiv(this.addr,e)}function hf(i,e){i.uniform4uiv(this.addr,e)}function uf(i,e,t){const n=this.cache,r=e.length,s=Qi(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),pt(n,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Oa,s[a])}function ff(i,e,t){const n=this.cache,r=e.length,s=Qi(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),pt(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||za,s[a])}function df(i,e,t){const n=this.cache,r=e.length,s=Qi(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),pt(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Ga,s[a])}function pf(i,e,t){const n=this.cache,r=e.length,s=Qi(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),pt(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Ba,s[a])}function mf(i){switch(i){case 5126:return Zu;case 35664:return Ku;case 35665:return $u;case 35666:return ju;case 35674:return Qu;case 35675:return ef;case 35676:return tf;case 5124:case 35670:return nf;case 35667:case 35671:return rf;case 35668:case 35672:return sf;case 35669:case 35673:return af;case 5125:return of;case 36294:return lf;case 36295:return cf;case 36296:return hf;case 35678:case 36198:case 36298:case 36306:case 35682:return uf;case 35679:case 36299:case 36307:return ff;case 35680:case 36300:case 36308:case 36293:return df;case 36289:case 36303:case 36311:case 36292:return pf}}class gf{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Ju(t.type)}}class _f{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=mf(t.type)}}class vf{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const Fr=/(\w+)(\])?(\[|\.)?/g;function Qs(i,e){i.seq.push(e),i.map[e.id]=e}function xf(i,e,t){const n=i.name,r=n.length;for(Fr.lastIndex=0;;){const s=Fr.exec(n),a=Fr.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===r){Qs(t,l===void 0?new gf(o,i,e):new _f(o,i,e));break}else{let f=t.map[o];f===void 0&&(f=new vf(o),Qs(t,f)),t=f}}}class Xi{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);xf(s,a,this)}}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function ea(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Mf=37297;let Sf=0;function yf(i,e){const t=i.split(`
|
|
3738
|
+
`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
|
|
3739
|
+
`)}const ta=new Ge;function Ef(i){Ze._getMatrix(ta,Ze.workingColorSpace,i);const e=`mat3( ${ta.elements.map(t=>t.toFixed(4))} )`;switch(Ze.getTransfer(i)){case qi:return[e,"LinearTransferOETF"];case Qe:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function na(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
|
|
3740
|
+
|
|
3741
|
+
`+s+`
|
|
3742
|
+
|
|
3743
|
+
`+yf(i.getShaderSource(e),o)}else return s}function Tf(i,e){const t=Ef(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
3744
|
+
`)}function Af(i,e){let t;switch(e){case 1:t="Linear";break;case 2:t="Reinhard";break;case 3:t="Cineon";break;case 4:t="ACESFilmic";break;case 6:t="AgX";break;case 7:t="Neutral";break;case 5:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Wi=new P;function bf(){Ze.getLuminanceCoefficients(Wi);const i=Wi.x.toFixed(4),e=Wi.y.toFixed(4),t=Wi.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
3745
|
+
`)}function wf(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ai).join(`
|
|
3746
|
+
`)}function Rf(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
3747
|
+
`)}function Cf(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function ai(i){return i!==""}function ia(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ra(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Pf=/^[ \t]*#include +<([\w\d./]+)>/gm;function Hr(i){return i.replace(Pf,Lf)}const Df=new Map;function Lf(i,e){let t=Ve[e];if(t===void 0){const n=Df.get(e);if(n!==void 0)t=Ve[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Hr(t)}const Uf=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function sa(i){return i.replace(Uf,If)}function If(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function aa(i){let e=`precision ${i.precision} float;
|
|
3748
|
+
precision ${i.precision} int;
|
|
3749
|
+
precision ${i.precision} sampler2D;
|
|
3750
|
+
precision ${i.precision} samplerCube;
|
|
3751
|
+
precision ${i.precision} sampler3D;
|
|
3752
|
+
precision ${i.precision} sampler2DArray;
|
|
3753
|
+
precision ${i.precision} sampler2DShadow;
|
|
3754
|
+
precision ${i.precision} samplerCubeShadow;
|
|
3755
|
+
precision ${i.precision} sampler2DArrayShadow;
|
|
3756
|
+
precision ${i.precision} isampler2D;
|
|
3757
|
+
precision ${i.precision} isampler3D;
|
|
3758
|
+
precision ${i.precision} isamplerCube;
|
|
3759
|
+
precision ${i.precision} isampler2DArray;
|
|
3760
|
+
precision ${i.precision} usampler2D;
|
|
3761
|
+
precision ${i.precision} usampler3D;
|
|
3762
|
+
precision ${i.precision} usamplerCube;
|
|
3763
|
+
precision ${i.precision} usampler2DArray;
|
|
3764
|
+
`;return i.precision==="highp"?e+=`
|
|
3765
|
+
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
3766
|
+
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
3767
|
+
#define LOW_PRECISION`),e}function Ff(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===1?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===2?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===3&&(e="SHADOWMAP_TYPE_VSM"),e}function Nf(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case 301:case 302:e="ENVMAP_TYPE_CUBE";break;case 306:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Of(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case 302:e="ENVMAP_MODE_REFRACTION";break}return e}function Bf(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD";break}return e}function zf(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function Gf(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=Ff(t),l=Nf(t),h=Of(t),f=Bf(t),d=zf(t),u=wf(t),g=Rf(s),_=r.createProgram();let m,p,A=t.glslVersion?"#version "+t.glslVersion+`
|
|
3768
|
+
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(ai).join(`
|
|
3769
|
+
`),m.length>0&&(m+=`
|
|
3770
|
+
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(ai).join(`
|
|
3771
|
+
`),p.length>0&&(p+=`
|
|
3772
|
+
`)):(m=[aa(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
3773
|
+
`].filter(ai).join(`
|
|
3774
|
+
`),p=[aa(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+f:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==0?"#define TONE_MAPPING":"",t.toneMapping!==0?Ve.tonemapping_pars_fragment:"",t.toneMapping!==0?Af("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,Tf("linearToOutputTexel",t.outputColorSpace),bf(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
3775
|
+
`].filter(ai).join(`
|
|
3776
|
+
`)),a=Hr(a),a=ia(a,t),a=ra(a,t),o=Hr(o),o=ia(o,t),o=ra(o,t),a=sa(a),o=sa(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es
|
|
3777
|
+
`,m=[u,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3778
|
+
`)+`
|
|
3779
|
+
`+m,p=["#define varying in",t.glslVersion===cs?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===cs?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
3780
|
+
`)+`
|
|
3781
|
+
`+p);const E=A+m+a,x=A+p+o,C=ea(r,r.VERTEX_SHADER,E),w=ea(r,r.FRAGMENT_SHADER,x);r.attachShader(_,C),r.attachShader(_,w),t.index0AttributeName!==void 0?r.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(_,0,"position"),r.linkProgram(_);function D(R){if(i.debug.checkShaderErrors){const O=r.getProgramInfoLog(_)||"",G=r.getShaderInfoLog(C)||"",W=r.getShaderInfoLog(w)||"",q=O.trim(),k=G.trim(),te=W.trim();let H=!0,ue=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(H=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,_,C,w);else{const _e=na(r,C,"vertex"),Me=na(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
|
|
3782
|
+
|
|
3783
|
+
Material Name: `+R.name+`
|
|
3784
|
+
Material Type: `+R.type+`
|
|
3785
|
+
|
|
3786
|
+
Program Info Log: `+q+`
|
|
3787
|
+
`+_e+`
|
|
3788
|
+
`+Me)}else q!==""?console.warn("THREE.WebGLProgram: Program Info Log:",q):(k===""||te==="")&&(ue=!1);ue&&(R.diagnostics={runnable:H,programLog:q,vertexShader:{log:k,prefix:m},fragmentShader:{log:te,prefix:p}})}r.deleteShader(C),r.deleteShader(w),U=new Xi(r,_),y=Cf(r,_)}let U;this.getUniforms=function(){return U===void 0&&D(this),U};let y;this.getAttributes=function(){return y===void 0&&D(this),y};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(_,Mf)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Sf++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=C,this.fragmentShader=w,this}let Vf=0;class Hf{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new kf(e),t.set(e,n)),n}}class kf{constructor(e){this.id=Vf++,this.code=e,this.usedTimes=0}}function Wf(i,e,t,n,r,s,a){const o=new pa,c=new Hf,l=new Set,h=[],f=r.logarithmicDepthBuffer,d=r.vertexTextures;let u=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(y){return l.add(y),y===0?"uv":`uv${y}`}function m(y,M,R,O,G){const W=O.fog,q=G.geometry,k=y.isMeshStandardMaterial?O.environment:null,te=(y.isMeshStandardMaterial?t:e).get(y.envMap||k),H=te&&te.mapping===306?te.image.height:null,ue=g[y.type];y.precision!==null&&(u=r.getMaxPrecision(y.precision),u!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",u,"instead."));const _e=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,Me=_e!==void 0?_e.length:0;let Be=0;q.morphAttributes.position!==void 0&&(Be=1),q.morphAttributes.normal!==void 0&&(Be=2),q.morphAttributes.color!==void 0&&(Be=3);let qe,$e,Ye,Y;if(ue){const Ke=Wt[ue];qe=Ke.vertexShader,$e=Ke.fragmentShader}else qe=y.vertexShader,$e=y.fragmentShader,c.update(y),Ye=c.getVertexShaderID(y),Y=c.getFragmentShaderID(y);const ee=i.getRenderTarget(),xe=i.state.buffers.depth.getReversed(),Ce=G.isInstancedMesh===!0,Ee=G.isBatchedMesh===!0,We=!!y.map,nt=!!y.matcap,b=!!te,Q=!!y.aoMap,K=!!y.lightMap,Z=!!y.bumpMap,J=!!y.normalMap,ce=!!y.displacementMap,ne=!!y.emissiveMap,he=!!y.metalnessMap,Ne=!!y.roughnessMap,Fe=y.anisotropy>0,T=y.clearcoat>0,v=y.dispersion>0,N=y.iridescence>0,V=y.sheen>0,j=y.transmission>0,X=Fe&&!!y.anisotropyMap,we=T&&!!y.clearcoatMap,oe=T&&!!y.clearcoatNormalMap,Te=T&&!!y.clearcoatRoughnessMap,Ae=N&&!!y.iridescenceMap,ie=N&&!!y.iridescenceThicknessMap,ge=V&&!!y.sheenColorMap,Ue=V&&!!y.sheenRoughnessMap,Re=!!y.specularMap,pe=!!y.specularColorMap,ze=!!y.specularIntensityMap,L=j&&!!y.transmissionMap,ae=j&&!!y.thicknessMap,fe=!!y.gradientMap,Se=!!y.alphaMap,re=y.alphaTest>0,$=!!y.alphaHash,be=!!y.extensions;let Oe=0;y.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(Oe=i.toneMapping);const it={shaderID:ue,shaderType:y.type,shaderName:y.name,vertexShader:qe,fragmentShader:$e,defines:y.defines,customVertexShaderID:Ye,customFragmentShaderID:Y,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:u,batching:Ee,batchingColor:Ee&&G._colorsTexture!==null,instancing:Ce,instancingColor:Ce&&G.instanceColor!==null,instancingMorph:Ce&&G.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:ee===null?i.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Wn,alphaToCoverage:!!y.alphaToCoverage,map:We,matcap:nt,envMap:b,envMapMode:b&&te.mapping,envMapCubeUVHeight:H,aoMap:Q,lightMap:K,bumpMap:Z,normalMap:J,displacementMap:d&&ce,emissiveMap:ne,normalMapObjectSpace:J&&y.normalMapType===1,normalMapTangentSpace:J&&y.normalMapType===0,metalnessMap:he,roughnessMap:Ne,anisotropy:Fe,anisotropyMap:X,clearcoat:T,clearcoatMap:we,clearcoatNormalMap:oe,clearcoatRoughnessMap:Te,dispersion:v,iridescence:N,iridescenceMap:Ae,iridescenceThicknessMap:ie,sheen:V,sheenColorMap:ge,sheenRoughnessMap:Ue,specularMap:Re,specularColorMap:pe,specularIntensityMap:ze,transmission:j,transmissionMap:L,thicknessMap:ae,gradientMap:fe,opaque:y.transparent===!1&&y.blending===1&&y.alphaToCoverage===!1,alphaMap:Se,alphaTest:re,alphaHash:$,combine:y.combine,mapUv:We&&_(y.map.channel),aoMapUv:Q&&_(y.aoMap.channel),lightMapUv:K&&_(y.lightMap.channel),bumpMapUv:Z&&_(y.bumpMap.channel),normalMapUv:J&&_(y.normalMap.channel),displacementMapUv:ce&&_(y.displacementMap.channel),emissiveMapUv:ne&&_(y.emissiveMap.channel),metalnessMapUv:he&&_(y.metalnessMap.channel),roughnessMapUv:Ne&&_(y.roughnessMap.channel),anisotropyMapUv:X&&_(y.anisotropyMap.channel),clearcoatMapUv:we&&_(y.clearcoatMap.channel),clearcoatNormalMapUv:oe&&_(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&_(y.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&_(y.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&_(y.iridescenceThicknessMap.channel),sheenColorMapUv:ge&&_(y.sheenColorMap.channel),sheenRoughnessMapUv:Ue&&_(y.sheenRoughnessMap.channel),specularMapUv:Re&&_(y.specularMap.channel),specularColorMapUv:pe&&_(y.specularColorMap.channel),specularIntensityMapUv:ze&&_(y.specularIntensityMap.channel),transmissionMapUv:L&&_(y.transmissionMap.channel),thicknessMapUv:ae&&_(y.thicknessMap.channel),alphaMapUv:Se&&_(y.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(J||Fe),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!q.attributes.uv&&(We||Se),fog:!!W,useFog:y.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:y.flatShading===!0&&y.wireframe===!1,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:xe,skinning:G.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Be,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&R.length>0,shadowMapType:i.shadowMap.type,toneMapping:Oe,decodeVideoTexture:We&&y.map.isVideoTexture===!0&&Ze.getTransfer(y.map.colorSpace)===Qe,decodeVideoTextureEmissive:ne&&y.emissiveMap.isVideoTexture===!0&&Ze.getTransfer(y.emissiveMap.colorSpace)===Qe,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===2,flipSided:y.side===1,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:be&&y.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(be&&y.extensions.multiDraw===!0||Ee)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return it.vertexUv1s=l.has(1),it.vertexUv2s=l.has(2),it.vertexUv3s=l.has(3),l.clear(),it}function p(y){const M=[];if(y.shaderID?M.push(y.shaderID):(M.push(y.customVertexShaderID),M.push(y.customFragmentShaderID)),y.defines!==void 0)for(const R in y.defines)M.push(R),M.push(y.defines[R]);return y.isRawShaderMaterial===!1&&(A(M,y),E(M,y),M.push(i.outputColorSpace)),M.push(y.customProgramCacheKey),M.join()}function A(y,M){y.push(M.precision),y.push(M.outputColorSpace),y.push(M.envMapMode),y.push(M.envMapCubeUVHeight),y.push(M.mapUv),y.push(M.alphaMapUv),y.push(M.lightMapUv),y.push(M.aoMapUv),y.push(M.bumpMapUv),y.push(M.normalMapUv),y.push(M.displacementMapUv),y.push(M.emissiveMapUv),y.push(M.metalnessMapUv),y.push(M.roughnessMapUv),y.push(M.anisotropyMapUv),y.push(M.clearcoatMapUv),y.push(M.clearcoatNormalMapUv),y.push(M.clearcoatRoughnessMapUv),y.push(M.iridescenceMapUv),y.push(M.iridescenceThicknessMapUv),y.push(M.sheenColorMapUv),y.push(M.sheenRoughnessMapUv),y.push(M.specularMapUv),y.push(M.specularColorMapUv),y.push(M.specularIntensityMapUv),y.push(M.transmissionMapUv),y.push(M.thicknessMapUv),y.push(M.combine),y.push(M.fogExp2),y.push(M.sizeAttenuation),y.push(M.morphTargetsCount),y.push(M.morphAttributeCount),y.push(M.numDirLights),y.push(M.numPointLights),y.push(M.numSpotLights),y.push(M.numSpotLightMaps),y.push(M.numHemiLights),y.push(M.numRectAreaLights),y.push(M.numDirLightShadows),y.push(M.numPointLightShadows),y.push(M.numSpotLightShadows),y.push(M.numSpotLightShadowsWithMaps),y.push(M.numLightProbes),y.push(M.shadowMapType),y.push(M.toneMapping),y.push(M.numClippingPlanes),y.push(M.numClipIntersection),y.push(M.depthPacking)}function E(y,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),M.gradientMap&&o.enable(22),y.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reversedDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),y.push(o.mask)}function x(y){const M=g[y.type];let R;if(M){const O=Wt[M];R=Uo.clone(O.uniforms)}else R=y.uniforms;return R}function C(y,M){let R;for(let O=0,G=h.length;O<G;O++){const W=h[O];if(W.cacheKey===M){R=W,++R.usedTimes;break}}return R===void 0&&(R=new Gf(i,M,y,s),h.push(R)),R}function w(y){if(--y.usedTimes===0){const M=h.indexOf(y);h[M]=h[h.length-1],h.pop(),y.destroy()}}function D(y){c.remove(y)}function U(){c.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:x,acquireProgram:C,releaseProgram:w,releaseShaderCache:D,programs:h,dispose:U}}function Xf(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,c){i.get(a)[o]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function qf(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function oa(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function la(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(f,d,u,g,_,m){let p=i[e];return p===void 0?(p={id:f.id,object:f,geometry:d,material:u,groupOrder:g,renderOrder:f.renderOrder,z:_,group:m},i[e]=p):(p.id=f.id,p.object=f,p.geometry=d,p.material=u,p.groupOrder=g,p.renderOrder=f.renderOrder,p.z=_,p.group=m),e++,p}function o(f,d,u,g,_,m){const p=a(f,d,u,g,_,m);u.transmission>0?n.push(p):u.transparent===!0?r.push(p):t.push(p)}function c(f,d,u,g,_,m){const p=a(f,d,u,g,_,m);u.transmission>0?n.unshift(p):u.transparent===!0?r.unshift(p):t.unshift(p)}function l(f,d){t.length>1&&t.sort(f||qf),n.length>1&&n.sort(d||oa),r.length>1&&r.sort(d||oa)}function h(){for(let f=e,d=i.length;f<d;f++){const u=i[f];if(u.id===null)break;u.id=null,u.object=null,u.geometry=null,u.material=null,u.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:o,unshift:c,finish:h,sort:l}}function Yf(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new la,i.set(n,[a])):r>=s.length?(a=new la,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Jf(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new ke};break;case"SpotLight":t={position:new P,direction:new P,color:new ke,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new ke,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new ke,groundColor:new ke};break;case"RectAreaLight":t={color:new ke,position:new P,halfWidth:new P,halfHeight:new P};break}return i[e.id]=t,t}}}function Zf(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new le};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new le};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new le,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Kf=0;function $f(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function jf(i){const e=new Jf,t=Zf(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new P);const r=new P,s=new rt,a=new rt;function o(l){let h=0,f=0,d=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let u=0,g=0,_=0,m=0,p=0,A=0,E=0,x=0,C=0,w=0,D=0;l.sort($f);for(let y=0,M=l.length;y<M;y++){const R=l[y],O=R.color,G=R.intensity,W=R.distance,q=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)h+=O.r*G,f+=O.g*G,d+=O.b*G;else if(R.isLightProbe){for(let k=0;k<9;k++)n.probe[k].addScaledVector(R.sh.coefficients[k],G);D++}else if(R.isDirectionalLight){const k=e.get(R);if(k.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const te=R.shadow,H=t.get(R);H.shadowIntensity=te.intensity,H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,n.directionalShadow[u]=H,n.directionalShadowMap[u]=q,n.directionalShadowMatrix[u]=R.shadow.matrix,A++}n.directional[u]=k,u++}else if(R.isSpotLight){const k=e.get(R);k.position.setFromMatrixPosition(R.matrixWorld),k.color.copy(O).multiplyScalar(G),k.distance=W,k.coneCos=Math.cos(R.angle),k.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),k.decay=R.decay,n.spot[_]=k;const te=R.shadow;if(R.map&&(n.spotLightMap[C]=R.map,C++,te.updateMatrices(R),R.castShadow&&w++),n.spotLightMatrix[_]=te.matrix,R.castShadow){const H=t.get(R);H.shadowIntensity=te.intensity,H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,n.spotShadow[_]=H,n.spotShadowMap[_]=q,x++}_++}else if(R.isRectAreaLight){const k=e.get(R);k.color.copy(O).multiplyScalar(G),k.halfWidth.set(R.width*.5,0,0),k.halfHeight.set(0,R.height*.5,0),n.rectArea[m]=k,m++}else if(R.isPointLight){const k=e.get(R);if(k.color.copy(R.color).multiplyScalar(R.intensity),k.distance=R.distance,k.decay=R.decay,R.castShadow){const te=R.shadow,H=t.get(R);H.shadowIntensity=te.intensity,H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,H.shadowCameraNear=te.camera.near,H.shadowCameraFar=te.camera.far,n.pointShadow[g]=H,n.pointShadowMap[g]=q,n.pointShadowMatrix[g]=R.shadow.matrix,E++}n.point[g]=k,g++}else if(R.isHemisphereLight){const k=e.get(R);k.skyColor.copy(R.color).multiplyScalar(G),k.groundColor.copy(R.groundColor).multiplyScalar(G),n.hemi[p]=k,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=de.LTC_FLOAT_1,n.rectAreaLTC2=de.LTC_FLOAT_2):(n.rectAreaLTC1=de.LTC_HALF_1,n.rectAreaLTC2=de.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=f,n.ambient[2]=d;const U=n.hash;(U.directionalLength!==u||U.pointLength!==g||U.spotLength!==_||U.rectAreaLength!==m||U.hemiLength!==p||U.numDirectionalShadows!==A||U.numPointShadows!==E||U.numSpotShadows!==x||U.numSpotMaps!==C||U.numLightProbes!==D)&&(n.directional.length=u,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=x+C-w,n.spotLightMap.length=C,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=D,U.directionalLength=u,U.pointLength=g,U.spotLength=_,U.rectAreaLength=m,U.hemiLength=p,U.numDirectionalShadows=A,U.numPointShadows=E,U.numSpotShadows=x,U.numSpotMaps=C,U.numLightProbes=D,n.version=Kf++)}function c(l,h){let f=0,d=0,u=0,g=0,_=0;const m=h.matrixWorldInverse;for(let p=0,A=l.length;p<A;p++){const E=l[p];if(E.isDirectionalLight){const x=n.directional[f];x.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),x.direction.sub(r),x.direction.transformDirection(m),f++}else if(E.isSpotLight){const x=n.spot[u];x.position.setFromMatrixPosition(E.matrixWorld),x.position.applyMatrix4(m),x.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),x.direction.sub(r),x.direction.transformDirection(m),u++}else if(E.isRectAreaLight){const x=n.rectArea[g];x.position.setFromMatrixPosition(E.matrixWorld),x.position.applyMatrix4(m),a.identity(),s.copy(E.matrixWorld),s.premultiply(m),a.extractRotation(s),x.halfWidth.set(E.width*.5,0,0),x.halfHeight.set(0,E.height*.5,0),x.halfWidth.applyMatrix4(a),x.halfHeight.applyMatrix4(a),g++}else if(E.isPointLight){const x=n.point[d];x.position.setFromMatrixPosition(E.matrixWorld),x.position.applyMatrix4(m),d++}else if(E.isHemisphereLight){const x=n.hemi[_];x.direction.setFromMatrixPosition(E.matrixWorld),x.direction.transformDirection(m),_++}}}return{setup:o,setupView:c,state:n}}function ca(i){const e=new jf(i),t=[],n=[];function r(h){l.camera=h,t.length=0,n.length=0}function s(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function c(h){e.setupView(t,h)}const l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:o,setupLightsView:c,pushLight:s,pushShadow:a}}function Qf(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new ca(i),e.set(r,[o])):s>=a.length?(o=new ca(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const ed=`void main() {
|
|
3789
|
+
gl_Position = vec4( position, 1.0 );
|
|
3790
|
+
}`,td=`uniform sampler2D shadow_pass;
|
|
3791
|
+
uniform vec2 resolution;
|
|
3792
|
+
uniform float radius;
|
|
3793
|
+
#include <packing>
|
|
3794
|
+
void main() {
|
|
3795
|
+
const float samples = float( VSM_SAMPLES );
|
|
3796
|
+
float mean = 0.0;
|
|
3797
|
+
float squared_mean = 0.0;
|
|
3798
|
+
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
3799
|
+
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
3800
|
+
for ( float i = 0.0; i < samples; i ++ ) {
|
|
3801
|
+
float uvOffset = uvStart + i * uvStride;
|
|
3802
|
+
#ifdef HORIZONTAL_PASS
|
|
3803
|
+
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
3804
|
+
mean += distribution.x;
|
|
3805
|
+
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
3806
|
+
#else
|
|
3807
|
+
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
3808
|
+
mean += depth;
|
|
3809
|
+
squared_mean += depth * depth;
|
|
3810
|
+
#endif
|
|
3811
|
+
}
|
|
3812
|
+
mean = mean / samples;
|
|
3813
|
+
squared_mean = squared_mean / samples;
|
|
3814
|
+
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3815
|
+
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3816
|
+
}`;function nd(i,e,t){let n=new Yr;const r=new le,s=new le,a=new et,o=new Al({depthPacking:3201}),c=new bl,l={},h=t.maxTextureSize,f={0:1,1:0,2:2},d=new Xt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new le},radius:{value:4}},vertexShader:ed,fragmentShader:td}),u=d.clone();u.defines.HORIZONTAL_PASS=1;const g=new wt;g.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new ft(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let p=this.type;this.render=function(w,D,U){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;const y=i.getRenderTarget(),M=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),O=i.state;O.setBlending(0),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const G=p!==3&&this.type===3,W=p===3&&this.type!==3;for(let q=0,k=w.length;q<k;q++){const te=w[q],H=te.shadow;if(H===void 0){console.warn("THREE.WebGLShadowMap:",te,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);const ue=H.getFrameExtents();if(r.multiply(ue),s.copy(H.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/ue.x),r.x=s.x*ue.x,H.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/ue.y),r.y=s.y*ue.y,H.mapSize.y=s.y)),H.map===null||G===!0||W===!0){const Me=this.type!==3?{minFilter:1003,magFilter:1003}:{};H.map!==null&&H.map.dispose(),H.map=new cn(r.x,r.y,Me),H.map.texture.name=te.name+".shadowMap",H.camera.updateProjectionMatrix()}i.setRenderTarget(H.map),i.clear();const _e=H.getViewportCount();for(let Me=0;Me<_e;Me++){const Be=H.getViewport(Me);a.set(s.x*Be.x,s.y*Be.y,s.x*Be.z,s.y*Be.w),O.viewport(a),H.updateMatrices(te,Me),n=H.getFrustum(),x(D,U,H.camera,te,this.type)}H.isPointLightShadow!==!0&&this.type===3&&A(H,U),H.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(y,M,R)};function A(w,D){const U=e.update(_);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,u.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,u.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new cn(r.x,r.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(D,null,U,d,_,null),u.uniforms.shadow_pass.value=w.mapPass.texture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(D,null,U,u,_,null)}function E(w,D,U,y){let M=null;const R=U.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0)M=R;else if(M=U.isPointLight===!0?c:o,i.localClippingEnabled&&D.clipShadows===!0&&Array.isArray(D.clippingPlanes)&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0||D.map&&D.alphaTest>0||D.alphaToCoverage===!0){const O=M.uuid,G=D.uuid;let W=l[O];W===void 0&&(W={},l[O]=W);let q=W[G];q===void 0&&(q=M.clone(),W[G]=q,D.addEventListener("dispose",C)),M=q}if(M.visible=D.visible,M.wireframe=D.wireframe,y===3?M.side=D.shadowSide!==null?D.shadowSide:D.side:M.side=D.shadowSide!==null?D.shadowSide:f[D.side],M.alphaMap=D.alphaMap,M.alphaTest=D.alphaToCoverage===!0?.5:D.alphaTest,M.map=D.map,M.clipShadows=D.clipShadows,M.clippingPlanes=D.clippingPlanes,M.clipIntersection=D.clipIntersection,M.displacementMap=D.displacementMap,M.displacementScale=D.displacementScale,M.displacementBias=D.displacementBias,M.wireframeLinewidth=D.wireframeLinewidth,M.linewidth=D.linewidth,U.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const O=i.properties.get(M);O.light=U}return M}function x(w,D,U,y,M){if(w.visible===!1)return;if(w.layers.test(D.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&M===3)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,w.matrixWorld);const G=e.update(w),W=w.material;if(Array.isArray(W)){const q=G.groups;for(let k=0,te=q.length;k<te;k++){const H=q[k],ue=W[H.materialIndex];if(ue&&ue.visible){const _e=E(w,ue,y,M);w.onBeforeShadow(i,w,D,U,G,_e,H),i.renderBufferDirect(U,null,G,_e,w,H),w.onAfterShadow(i,w,D,U,G,_e,H)}}}else if(W.visible){const q=E(w,W,y,M);w.onBeforeShadow(i,w,D,U,G,q,null),i.renderBufferDirect(U,null,G,q,w,null),w.onAfterShadow(i,w,D,U,G,q,null)}}const O=w.children;for(let G=0,W=O.length;G<W;G++)x(O[G],D,U,y,M)}function C(w){w.target.removeEventListener("dispose",C);for(const U in l){const y=l[U],M=w.target.uuid;M in y&&(y[M].dispose(),delete y[M])}}}const id={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3};function rd(i,e){function t(){let L=!1;const ae=new et;let fe=null;const Se=new et(0,0,0,0);return{setMask:function(re){fe!==re&&!L&&(i.colorMask(re,re,re,re),fe=re)},setLocked:function(re){L=re},setClear:function(re,$,be,Oe,it){it===!0&&(re*=Oe,$*=Oe,be*=Oe),ae.set(re,$,be,Oe),Se.equals(ae)===!1&&(i.clearColor(re,$,be,Oe),Se.copy(ae))},reset:function(){L=!1,fe=null,Se.set(-1,0,0,0)}}}function n(){let L=!1,ae=!1,fe=null,Se=null,re=null;return{setReversed:function($){if(ae!==$){const be=e.get("EXT_clip_control");$?be.clipControlEXT(be.LOWER_LEFT_EXT,be.ZERO_TO_ONE_EXT):be.clipControlEXT(be.LOWER_LEFT_EXT,be.NEGATIVE_ONE_TO_ONE_EXT),ae=$;const Oe=re;re=null,this.setClear(Oe)}},getReversed:function(){return ae},setTest:function($){$?ee(i.DEPTH_TEST):xe(i.DEPTH_TEST)},setMask:function($){fe!==$&&!L&&(i.depthMask($),fe=$)},setFunc:function($){if(ae&&($=id[$]),Se!==$){switch($){case 0:i.depthFunc(i.NEVER);break;case 1:i.depthFunc(i.ALWAYS);break;case 2:i.depthFunc(i.LESS);break;case 3:i.depthFunc(i.LEQUAL);break;case 4:i.depthFunc(i.EQUAL);break;case 5:i.depthFunc(i.GEQUAL);break;case 6:i.depthFunc(i.GREATER);break;case 7:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}Se=$}},setLocked:function($){L=$},setClear:function($){re!==$&&(ae&&($=1-$),i.clearDepth($),re=$)},reset:function(){L=!1,fe=null,Se=null,re=null,ae=!1}}}function r(){let L=!1,ae=null,fe=null,Se=null,re=null,$=null,be=null,Oe=null,it=null;return{setTest:function(Ke){L||(Ke?ee(i.STENCIL_TEST):xe(i.STENCIL_TEST))},setMask:function(Ke){ae!==Ke&&!L&&(i.stencilMask(Ke),ae=Ke)},setFunc:function(Ke,Yt,kt){(fe!==Ke||Se!==Yt||re!==kt)&&(i.stencilFunc(Ke,Yt,kt),fe=Ke,Se=Yt,re=kt)},setOp:function(Ke,Yt,kt){($!==Ke||be!==Yt||Oe!==kt)&&(i.stencilOp(Ke,Yt,kt),$=Ke,be=Yt,Oe=kt)},setLocked:function(Ke){L=Ke},setClear:function(Ke){it!==Ke&&(i.clearStencil(Ke),it=Ke)},reset:function(){L=!1,ae=null,fe=null,Se=null,re=null,$=null,be=null,Oe=null,it=null}}}const s=new t,a=new n,o=new r,c=new WeakMap,l=new WeakMap;let h={},f={},d=new WeakMap,u=[],g=null,_=!1,m=null,p=null,A=null,E=null,x=null,C=null,w=null,D=new ke(0,0,0),U=0,y=!1,M=null,R=null,O=null,G=null,W=null;const q=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,te=0;const H=i.getParameter(i.VERSION);H.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(H)[1]),k=te>=1):H.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),k=te>=2);let ue=null,_e={};const Me=i.getParameter(i.SCISSOR_BOX),Be=i.getParameter(i.VIEWPORT),qe=new et().fromArray(Me),$e=new et().fromArray(Be);function Ye(L,ae,fe,Se){const re=new Uint8Array(4),$=i.createTexture();i.bindTexture(L,$),i.texParameteri(L,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(L,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let be=0;be<fe;be++)L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY?i.texImage3D(ae,0,i.RGBA,1,1,Se,0,i.RGBA,i.UNSIGNED_BYTE,re):i.texImage2D(ae+be,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,re);return $}const Y={};Y[i.TEXTURE_2D]=Ye(i.TEXTURE_2D,i.TEXTURE_2D,1),Y[i.TEXTURE_CUBE_MAP]=Ye(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Y[i.TEXTURE_2D_ARRAY]=Ye(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Y[i.TEXTURE_3D]=Ye(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ee(i.DEPTH_TEST),a.setFunc(3),Z(!1),J(1),ee(i.CULL_FACE),Q(0);function ee(L){h[L]!==!0&&(i.enable(L),h[L]=!0)}function xe(L){h[L]!==!1&&(i.disable(L),h[L]=!1)}function Ce(L,ae){return f[L]!==ae?(i.bindFramebuffer(L,ae),f[L]=ae,L===i.DRAW_FRAMEBUFFER&&(f[i.FRAMEBUFFER]=ae),L===i.FRAMEBUFFER&&(f[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function Ee(L,ae){let fe=u,Se=!1;if(L){fe=d.get(ae),fe===void 0&&(fe=[],d.set(ae,fe));const re=L.textures;if(fe.length!==re.length||fe[0]!==i.COLOR_ATTACHMENT0){for(let $=0,be=re.length;$<be;$++)fe[$]=i.COLOR_ATTACHMENT0+$;fe.length=re.length,Se=!0}}else fe[0]!==i.BACK&&(fe[0]=i.BACK,Se=!0);Se&&i.drawBuffers(fe)}function We(L){return g!==L?(i.useProgram(L),g=L,!0):!1}const nt={100:i.FUNC_ADD,101:i.FUNC_SUBTRACT,102:i.FUNC_REVERSE_SUBTRACT};nt[103]=i.MIN,nt[104]=i.MAX;const b={200:i.ZERO,201:i.ONE,202:i.SRC_COLOR,204:i.SRC_ALPHA,210:i.SRC_ALPHA_SATURATE,208:i.DST_COLOR,206:i.DST_ALPHA,203:i.ONE_MINUS_SRC_COLOR,205:i.ONE_MINUS_SRC_ALPHA,209:i.ONE_MINUS_DST_COLOR,207:i.ONE_MINUS_DST_ALPHA,211:i.CONSTANT_COLOR,212:i.ONE_MINUS_CONSTANT_COLOR,213:i.CONSTANT_ALPHA,214:i.ONE_MINUS_CONSTANT_ALPHA};function Q(L,ae,fe,Se,re,$,be,Oe,it,Ke){if(L===0){_===!0&&(xe(i.BLEND),_=!1);return}if(_===!1&&(ee(i.BLEND),_=!0),L!==5){if(L!==m||Ke!==y){if((p!==100||x!==100)&&(i.blendEquation(i.FUNC_ADD),p=100,x=100),Ke)switch(L){case 1:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case 2:i.blendFunc(i.ONE,i.ONE);break;case 3:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case 4:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}else switch(L){case 1:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case 2:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case 3:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}A=null,E=null,C=null,w=null,D.set(0,0,0),U=0,m=L,y=Ke}return}re=re||ae,$=$||fe,be=be||Se,(ae!==p||re!==x)&&(i.blendEquationSeparate(nt[ae],nt[re]),p=ae,x=re),(fe!==A||Se!==E||$!==C||be!==w)&&(i.blendFuncSeparate(b[fe],b[Se],b[$],b[be]),A=fe,E=Se,C=$,w=be),(Oe.equals(D)===!1||it!==U)&&(i.blendColor(Oe.r,Oe.g,Oe.b,it),D.copy(Oe),U=it),m=L,y=!1}function K(L,ae){L.side===2?xe(i.CULL_FACE):ee(i.CULL_FACE);let fe=L.side===1;ae&&(fe=!fe),Z(fe),L.blending===1&&L.transparent===!1?Q(0):Q(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),s.setMask(L.colorWrite);const Se=L.stencilWrite;o.setTest(Se),Se&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),ne(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ee(i.SAMPLE_ALPHA_TO_COVERAGE):xe(i.SAMPLE_ALPHA_TO_COVERAGE)}function Z(L){M!==L&&(L?i.frontFace(i.CW):i.frontFace(i.CCW),M=L)}function J(L){L!==0?(ee(i.CULL_FACE),L!==R&&(L===1?i.cullFace(i.BACK):L===2?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):xe(i.CULL_FACE),R=L}function ce(L){L!==O&&(k&&i.lineWidth(L),O=L)}function ne(L,ae,fe){L?(ee(i.POLYGON_OFFSET_FILL),(G!==ae||W!==fe)&&(i.polygonOffset(ae,fe),G=ae,W=fe)):xe(i.POLYGON_OFFSET_FILL)}function he(L){L?ee(i.SCISSOR_TEST):xe(i.SCISSOR_TEST)}function Ne(L){L===void 0&&(L=i.TEXTURE0+q-1),ue!==L&&(i.activeTexture(L),ue=L)}function Fe(L,ae,fe){fe===void 0&&(ue===null?fe=i.TEXTURE0+q-1:fe=ue);let Se=_e[fe];Se===void 0&&(Se={type:void 0,texture:void 0},_e[fe]=Se),(Se.type!==L||Se.texture!==ae)&&(ue!==fe&&(i.activeTexture(fe),ue=fe),i.bindTexture(L,ae||Y[L]),Se.type=L,Se.texture=ae)}function T(){const L=_e[ue];L!==void 0&&L.type!==void 0&&(i.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function v(){try{i.compressedTexImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function N(){try{i.compressedTexImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function V(){try{i.texSubImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function j(){try{i.texSubImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function X(){try{i.compressedTexSubImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function we(){try{i.compressedTexSubImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function oe(){try{i.texStorage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function Te(){try{i.texStorage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function Ae(){try{i.texImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function ie(){try{i.texImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function ge(L){qe.equals(L)===!1&&(i.scissor(L.x,L.y,L.z,L.w),qe.copy(L))}function Ue(L){$e.equals(L)===!1&&(i.viewport(L.x,L.y,L.z,L.w),$e.copy(L))}function Re(L,ae){let fe=l.get(ae);fe===void 0&&(fe=new WeakMap,l.set(ae,fe));let Se=fe.get(L);Se===void 0&&(Se=i.getUniformBlockIndex(ae,L.name),fe.set(L,Se))}function pe(L,ae){const Se=l.get(ae).get(L);c.get(ae)!==Se&&(i.uniformBlockBinding(ae,Se,L.__bindingPointIndex),c.set(ae,Se))}function ze(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},ue=null,_e={},f={},d=new WeakMap,u=[],g=null,_=!1,m=null,p=null,A=null,E=null,x=null,C=null,w=null,D=new ke(0,0,0),U=0,y=!1,M=null,R=null,O=null,G=null,W=null,qe.set(0,0,i.canvas.width,i.canvas.height),$e.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:ee,disable:xe,bindFramebuffer:Ce,drawBuffers:Ee,useProgram:We,setBlending:Q,setMaterial:K,setFlipSided:Z,setCullFace:J,setLineWidth:ce,setPolygonOffset:ne,setScissorTest:he,activeTexture:Ne,bindTexture:Fe,unbindTexture:T,compressedTexImage2D:v,compressedTexImage3D:N,texImage2D:Ae,texImage3D:ie,updateUBOMapping:Re,uniformBlockBinding:pe,texStorage2D:oe,texStorage3D:Te,texSubImage2D:V,texSubImage3D:j,compressedTexSubImage2D:X,compressedTexSubImage3D:we,scissor:ge,viewport:Ue,reset:ze}}function sd(i,e,t,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new le,h=new WeakMap;let f;const d=new WeakMap;let u=!1;try{u=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(T,v){return u?new OffscreenCanvas(T,v):Yi("canvas")}function _(T,v,N){let V=1;const j=Fe(T);if((j.width>N||j.height>N)&&(V=N/Math.max(j.width,j.height)),V<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const X=Math.floor(V*j.width),we=Math.floor(V*j.height);f===void 0&&(f=g(X,we));const oe=v?g(X,we):f;return oe.width=X,oe.height=we,oe.getContext("2d").drawImage(T,0,0,X,we),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+j.width+"x"+j.height+") to ("+X+"x"+we+")."),oe}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+j.width+"x"+j.height+")."),T;return T}function m(T){return T.generateMipmaps}function p(T){i.generateMipmap(T)}function A(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function E(T,v,N,V,j=!1){if(T!==null){if(i[T]!==void 0)return i[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let X=v;if(v===i.RED&&(N===i.FLOAT&&(X=i.R32F),N===i.HALF_FLOAT&&(X=i.R16F),N===i.UNSIGNED_BYTE&&(X=i.R8)),v===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(X=i.R8UI),N===i.UNSIGNED_SHORT&&(X=i.R16UI),N===i.UNSIGNED_INT&&(X=i.R32UI),N===i.BYTE&&(X=i.R8I),N===i.SHORT&&(X=i.R16I),N===i.INT&&(X=i.R32I)),v===i.RG&&(N===i.FLOAT&&(X=i.RG32F),N===i.HALF_FLOAT&&(X=i.RG16F),N===i.UNSIGNED_BYTE&&(X=i.RG8)),v===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(X=i.RG8UI),N===i.UNSIGNED_SHORT&&(X=i.RG16UI),N===i.UNSIGNED_INT&&(X=i.RG32UI),N===i.BYTE&&(X=i.RG8I),N===i.SHORT&&(X=i.RG16I),N===i.INT&&(X=i.RG32I)),v===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(X=i.RGB8UI),N===i.UNSIGNED_SHORT&&(X=i.RGB16UI),N===i.UNSIGNED_INT&&(X=i.RGB32UI),N===i.BYTE&&(X=i.RGB8I),N===i.SHORT&&(X=i.RGB16I),N===i.INT&&(X=i.RGB32I)),v===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(X=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(X=i.RGBA16UI),N===i.UNSIGNED_INT&&(X=i.RGBA32UI),N===i.BYTE&&(X=i.RGBA8I),N===i.SHORT&&(X=i.RGBA16I),N===i.INT&&(X=i.RGBA32I)),v===i.RGB&&(N===i.UNSIGNED_INT_5_9_9_9_REV&&(X=i.RGB9_E5),N===i.UNSIGNED_INT_10F_11F_11F_REV&&(X=i.R11F_G11F_B10F)),v===i.RGBA){const we=j?qi:Ze.getTransfer(V);N===i.FLOAT&&(X=i.RGBA32F),N===i.HALF_FLOAT&&(X=i.RGBA16F),N===i.UNSIGNED_BYTE&&(X=we===Qe?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT_4_4_4_4&&(X=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(X=i.RGB5_A1)}return(X===i.R16F||X===i.R32F||X===i.RG16F||X===i.RG32F||X===i.RGBA16F||X===i.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function x(T,v){let N;return T?v===null||v===1014||v===1020?N=i.DEPTH24_STENCIL8:v===1015?N=i.DEPTH32F_STENCIL8:v===1012&&(N=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===1014||v===1020?N=i.DEPTH_COMPONENT24:v===1015?N=i.DEPTH_COMPONENT32F:v===1012&&(N=i.DEPTH_COMPONENT16),N}function C(T,v){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==1003&&T.minFilter!==1006?Math.log2(Math.max(v.width,v.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?v.mipmaps.length:1}function w(T){const v=T.target;v.removeEventListener("dispose",w),U(v),v.isVideoTexture&&h.delete(v)}function D(T){const v=T.target;v.removeEventListener("dispose",D),M(v)}function U(T){const v=n.get(T);if(v.__webglInit===void 0)return;const N=T.source,V=d.get(N);if(V){const j=V[v.__cacheKey];j.usedTimes--,j.usedTimes===0&&y(T),Object.keys(V).length===0&&d.delete(N)}n.remove(T)}function y(T){const v=n.get(T);i.deleteTexture(v.__webglTexture);const N=T.source,V=d.get(N);delete V[v.__cacheKey],a.memory.textures--}function M(T){const v=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(v.__webglFramebuffer[V]))for(let j=0;j<v.__webglFramebuffer[V].length;j++)i.deleteFramebuffer(v.__webglFramebuffer[V][j]);else i.deleteFramebuffer(v.__webglFramebuffer[V]);v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer[V])}else{if(Array.isArray(v.__webglFramebuffer))for(let V=0;V<v.__webglFramebuffer.length;V++)i.deleteFramebuffer(v.__webglFramebuffer[V]);else i.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&i.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let V=0;V<v.__webglColorRenderbuffer.length;V++)v.__webglColorRenderbuffer[V]&&i.deleteRenderbuffer(v.__webglColorRenderbuffer[V]);v.__webglDepthRenderbuffer&&i.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const N=T.textures;for(let V=0,j=N.length;V<j;V++){const X=n.get(N[V]);X.__webglTexture&&(i.deleteTexture(X.__webglTexture),a.memory.textures--),n.remove(N[V])}n.remove(T)}let R=0;function O(){R=0}function G(){const T=R;return T>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),R+=1,T}function W(T){const v=[];return v.push(T.wrapS),v.push(T.wrapT),v.push(T.wrapR||0),v.push(T.magFilter),v.push(T.minFilter),v.push(T.anisotropy),v.push(T.internalFormat),v.push(T.format),v.push(T.type),v.push(T.generateMipmaps),v.push(T.premultiplyAlpha),v.push(T.flipY),v.push(T.unpackAlignment),v.push(T.colorSpace),v.join()}function q(T,v){const N=n.get(T);if(T.isVideoTexture&&he(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&N.__version!==T.version){const V=T.image;if(V===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(N,T,v);return}}else T.isExternalTexture&&(N.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+v)}function k(T,v){const N=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&N.__version!==T.version){Y(N,T,v);return}t.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+v)}function te(T,v){const N=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&N.__version!==T.version){Y(N,T,v);return}t.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+v)}function H(T,v){const N=n.get(T);if(T.version>0&&N.__version!==T.version){ee(N,T,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+v)}const ue={1e3:i.REPEAT,1001:i.CLAMP_TO_EDGE,1002:i.MIRRORED_REPEAT},_e={1003:i.NEAREST,1004:i.NEAREST_MIPMAP_NEAREST,1005:i.NEAREST_MIPMAP_LINEAR,1006:i.LINEAR,1007:i.LINEAR_MIPMAP_NEAREST,1008:i.LINEAR_MIPMAP_LINEAR},Me={512:i.NEVER,519:i.ALWAYS,513:i.LESS,515:i.LEQUAL,514:i.EQUAL,518:i.GEQUAL,516:i.GREATER,517:i.NOTEQUAL};function Be(T,v){if(v.type===1015&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===1006||v.magFilter===1007||v.magFilter===1005||v.magFilter===1008||v.minFilter===1006||v.minFilter===1007||v.minFilter===1005||v.minFilter===1008)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,ue[v.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,ue[v.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,ue[v.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,_e[v.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,_e[v.minFilter]),v.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Me[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===1003||v.minFilter!==1005&&v.minFilter!==1008||v.type===1015&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function qe(T,v){let N=!1;T.__webglInit===void 0&&(T.__webglInit=!0,v.addEventListener("dispose",w));const V=v.source;let j=d.get(V);j===void 0&&(j={},d.set(V,j));const X=W(v);if(X!==T.__cacheKey){j[X]===void 0&&(j[X]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),j[X].usedTimes++;const we=j[T.__cacheKey];we!==void 0&&(j[T.__cacheKey].usedTimes--,we.usedTimes===0&&y(v)),T.__cacheKey=X,T.__webglTexture=j[X].texture}return N}function $e(T,v,N){return Math.floor(Math.floor(T/N)/v)}function Ye(T,v,N,V){const X=T.updateRanges;if(X.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,N,V,v.data);else{X.sort((ie,ge)=>ie.start-ge.start);let we=0;for(let ie=1;ie<X.length;ie++){const ge=X[we],Ue=X[ie],Re=ge.start+ge.count,pe=$e(Ue.start,v.width,4),ze=$e(ge.start,v.width,4);Ue.start<=Re+1&&pe===ze&&$e(Ue.start+Ue.count-1,v.width,4)===pe?ge.count=Math.max(ge.count,Ue.start+Ue.count-ge.start):(++we,X[we]=Ue)}X.length=we+1;const oe=i.getParameter(i.UNPACK_ROW_LENGTH),Te=i.getParameter(i.UNPACK_SKIP_PIXELS),Ae=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let ie=0,ge=X.length;ie<ge;ie++){const Ue=X[ie],Re=Math.floor(Ue.start/4),pe=Math.ceil(Ue.count/4),ze=Re%v.width,L=Math.floor(Re/v.width),ae=pe,fe=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,ze),i.pixelStorei(i.UNPACK_SKIP_ROWS,L),t.texSubImage2D(i.TEXTURE_2D,0,ze,L,ae,fe,N,V,v.data)}T.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,oe),i.pixelStorei(i.UNPACK_SKIP_PIXELS,Te),i.pixelStorei(i.UNPACK_SKIP_ROWS,Ae)}}function Y(T,v,N){let V=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(V=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(V=i.TEXTURE_3D);const j=qe(T,v),X=v.source;t.bindTexture(V,T.__webglTexture,i.TEXTURE0+N);const we=n.get(X);if(X.version!==we.__version||j===!0){t.activeTexture(i.TEXTURE0+N);const oe=Ze.getPrimaries(Ze.workingColorSpace),Te=v.colorSpace===""?null:Ze.getPrimaries(v.colorSpace),Ae=v.colorSpace===""||oe===Te?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae);let ie=_(v.image,!1,r.maxTextureSize);ie=Ne(v,ie);const ge=s.convert(v.format,v.colorSpace),Ue=s.convert(v.type);let Re=E(v.internalFormat,ge,Ue,v.colorSpace,v.isVideoTexture);Be(V,v);let pe;const ze=v.mipmaps,L=v.isVideoTexture!==!0,ae=we.__version===void 0||j===!0,fe=X.dataReady,Se=C(v,ie);if(v.isDepthTexture)Re=x(v.format===1027,v.type),ae&&(L?t.texStorage2D(i.TEXTURE_2D,1,Re,ie.width,ie.height):t.texImage2D(i.TEXTURE_2D,0,Re,ie.width,ie.height,0,ge,Ue,null));else if(v.isDataTexture)if(ze.length>0){L&&ae&&t.texStorage2D(i.TEXTURE_2D,Se,Re,ze[0].width,ze[0].height);for(let re=0,$=ze.length;re<$;re++)pe=ze[re],L?fe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,pe.width,pe.height,ge,Ue,pe.data):t.texImage2D(i.TEXTURE_2D,re,Re,pe.width,pe.height,0,ge,Ue,pe.data);v.generateMipmaps=!1}else L?(ae&&t.texStorage2D(i.TEXTURE_2D,Se,Re,ie.width,ie.height),fe&&Ye(v,ie,ge,Ue)):t.texImage2D(i.TEXTURE_2D,0,Re,ie.width,ie.height,0,ge,Ue,ie.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){L&&ae&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Se,Re,ze[0].width,ze[0].height,ie.depth);for(let re=0,$=ze.length;re<$;re++)if(pe=ze[re],v.format!==1023)if(ge!==null)if(L){if(fe)if(v.layerUpdates.size>0){const be=Gs(pe.width,pe.height,v.format,v.type);for(const Oe of v.layerUpdates){const it=pe.data.subarray(Oe*be/pe.data.BYTES_PER_ELEMENT,(Oe+1)*be/pe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,Oe,pe.width,pe.height,1,ge,it)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,pe.width,pe.height,ie.depth,ge,pe.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,re,Re,pe.width,pe.height,ie.depth,0,pe.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else L?fe&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,pe.width,pe.height,ie.depth,ge,Ue,pe.data):t.texImage3D(i.TEXTURE_2D_ARRAY,re,Re,pe.width,pe.height,ie.depth,0,ge,Ue,pe.data)}else{L&&ae&&t.texStorage2D(i.TEXTURE_2D,Se,Re,ze[0].width,ze[0].height);for(let re=0,$=ze.length;re<$;re++)pe=ze[re],v.format!==1023?ge!==null?L?fe&&t.compressedTexSubImage2D(i.TEXTURE_2D,re,0,0,pe.width,pe.height,ge,pe.data):t.compressedTexImage2D(i.TEXTURE_2D,re,Re,pe.width,pe.height,0,pe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):L?fe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,pe.width,pe.height,ge,Ue,pe.data):t.texImage2D(i.TEXTURE_2D,re,Re,pe.width,pe.height,0,ge,Ue,pe.data)}else if(v.isDataArrayTexture)if(L){if(ae&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Se,Re,ie.width,ie.height,ie.depth),fe)if(v.layerUpdates.size>0){const re=Gs(ie.width,ie.height,v.format,v.type);for(const $ of v.layerUpdates){const be=ie.data.subarray($*re/ie.data.BYTES_PER_ELEMENT,($+1)*re/ie.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,$,ie.width,ie.height,1,ge,Ue,be)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ie.width,ie.height,ie.depth,ge,Ue,ie.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Re,ie.width,ie.height,ie.depth,0,ge,Ue,ie.data);else if(v.isData3DTexture)L?(ae&&t.texStorage3D(i.TEXTURE_3D,Se,Re,ie.width,ie.height,ie.depth),fe&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ie.width,ie.height,ie.depth,ge,Ue,ie.data)):t.texImage3D(i.TEXTURE_3D,0,Re,ie.width,ie.height,ie.depth,0,ge,Ue,ie.data);else if(v.isFramebufferTexture){if(ae)if(L)t.texStorage2D(i.TEXTURE_2D,Se,Re,ie.width,ie.height);else{let re=ie.width,$=ie.height;for(let be=0;be<Se;be++)t.texImage2D(i.TEXTURE_2D,be,Re,re,$,0,ge,Ue,null),re>>=1,$>>=1}}else if(ze.length>0){if(L&&ae){const re=Fe(ze[0]);t.texStorage2D(i.TEXTURE_2D,Se,Re,re.width,re.height)}for(let re=0,$=ze.length;re<$;re++)pe=ze[re],L?fe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,ge,Ue,pe):t.texImage2D(i.TEXTURE_2D,re,Re,ge,Ue,pe);v.generateMipmaps=!1}else if(L){if(ae){const re=Fe(ie);t.texStorage2D(i.TEXTURE_2D,Se,Re,re.width,re.height)}fe&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ge,Ue,ie)}else t.texImage2D(i.TEXTURE_2D,0,Re,ge,Ue,ie);m(v)&&p(V),we.__version=X.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function ee(T,v,N){if(v.image.length!==6)return;const V=qe(T,v),j=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+N);const X=n.get(j);if(j.version!==X.__version||V===!0){t.activeTexture(i.TEXTURE0+N);const we=Ze.getPrimaries(Ze.workingColorSpace),oe=v.colorSpace===""?null:Ze.getPrimaries(v.colorSpace),Te=v.colorSpace===""||we===oe?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te);const Ae=v.isCompressedTexture||v.image[0].isCompressedTexture,ie=v.image[0]&&v.image[0].isDataTexture,ge=[];for(let $=0;$<6;$++)!Ae&&!ie?ge[$]=_(v.image[$],!0,r.maxCubemapSize):ge[$]=ie?v.image[$].image:v.image[$],ge[$]=Ne(v,ge[$]);const Ue=ge[0],Re=s.convert(v.format,v.colorSpace),pe=s.convert(v.type),ze=E(v.internalFormat,Re,pe,v.colorSpace),L=v.isVideoTexture!==!0,ae=X.__version===void 0||V===!0,fe=j.dataReady;let Se=C(v,Ue);Be(i.TEXTURE_CUBE_MAP,v);let re;if(Ae){L&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Se,ze,Ue.width,Ue.height);for(let $=0;$<6;$++){re=ge[$].mipmaps;for(let be=0;be<re.length;be++){const Oe=re[be];v.format!==1023?Re!==null?L?fe&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be,0,0,Oe.width,Oe.height,Re,Oe.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be,ze,Oe.width,Oe.height,0,Oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be,0,0,Oe.width,Oe.height,Re,pe,Oe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be,ze,Oe.width,Oe.height,0,Re,pe,Oe.data)}}}else{if(re=v.mipmaps,L&&ae){re.length>0&&Se++;const $=Fe(ge[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Se,ze,$.width,$.height)}for(let $=0;$<6;$++)if(ie){L?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,ge[$].width,ge[$].height,Re,pe,ge[$].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,ze,ge[$].width,ge[$].height,0,Re,pe,ge[$].data);for(let be=0;be<re.length;be++){const it=re[be].image[$].image;L?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be+1,0,0,it.width,it.height,Re,pe,it.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be+1,ze,it.width,it.height,0,Re,pe,it.data)}}else{L?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,Re,pe,ge[$]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,ze,Re,pe,ge[$]);for(let be=0;be<re.length;be++){const Oe=re[be];L?fe&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be+1,0,0,Re,pe,Oe.image[$]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,be+1,ze,Re,pe,Oe.image[$])}}}m(v)&&p(i.TEXTURE_CUBE_MAP),X.__version=j.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function xe(T,v,N,V,j,X){const we=s.convert(N.format,N.colorSpace),oe=s.convert(N.type),Te=E(N.internalFormat,we,oe,N.colorSpace),Ae=n.get(v),ie=n.get(N);if(ie.__renderTarget=v,!Ae.__hasExternalTextures){const ge=Math.max(1,v.width>>X),Ue=Math.max(1,v.height>>X);j===i.TEXTURE_3D||j===i.TEXTURE_2D_ARRAY?t.texImage3D(j,X,Te,ge,Ue,v.depth,0,we,oe,null):t.texImage2D(j,X,Te,ge,Ue,0,we,oe,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),ne(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,V,j,ie.__webglTexture,0,ce(v)):(j===i.TEXTURE_2D||j>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&j<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,V,j,ie.__webglTexture,X),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ce(T,v,N){if(i.bindRenderbuffer(i.RENDERBUFFER,T),v.depthBuffer){const V=v.depthTexture,j=V&&V.isDepthTexture?V.type:null,X=x(v.stencilBuffer,j),we=v.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=ce(v);ne(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,oe,X,v.width,v.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,oe,X,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,X,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,we,i.RENDERBUFFER,T)}else{const V=v.textures;for(let j=0;j<V.length;j++){const X=V[j],we=s.convert(X.format,X.colorSpace),oe=s.convert(X.type),Te=E(X.internalFormat,we,oe,X.colorSpace),Ae=ce(v);N&&ne(v)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ae,Te,v.width,v.height):ne(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ae,Te,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,Te,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ee(T,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const V=n.get(v.depthTexture);V.__renderTarget=v,(!V.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),q(v.depthTexture,0);const j=V.__webglTexture,X=ce(v);if(v.depthTexture.format===1026)ne(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,j,0,X):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,j,0);else if(v.depthTexture.format===1027)ne(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,j,0,X):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,j,0);else throw new Error("Unknown depthTexture format")}function We(T){const v=n.get(T),N=T.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==T.depthTexture){const V=T.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),V){const j=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,V.removeEventListener("dispose",j)};V.addEventListener("dispose",j),v.__depthDisposeCallback=j}v.__boundDepthTexture=V}if(T.depthTexture&&!v.__autoAllocateDepthBuffer){if(N)throw new Error("target.depthTexture not supported in Cube render targets");const V=T.texture.mipmaps;V&&V.length>0?Ee(v.__webglFramebuffer[0],T):Ee(v.__webglFramebuffer,T)}else if(N){v.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[V]),v.__webglDepthbuffer[V]===void 0)v.__webglDepthbuffer[V]=i.createRenderbuffer(),Ce(v.__webglDepthbuffer[V],T,!1);else{const j=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,X=v.__webglDepthbuffer[V];i.bindRenderbuffer(i.RENDERBUFFER,X),i.framebufferRenderbuffer(i.FRAMEBUFFER,j,i.RENDERBUFFER,X)}}else{const V=T.texture.mipmaps;if(V&&V.length>0?t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=i.createRenderbuffer(),Ce(v.__webglDepthbuffer,T,!1);else{const j=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,X=v.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,X),i.framebufferRenderbuffer(i.FRAMEBUFFER,j,i.RENDERBUFFER,X)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function nt(T,v,N){const V=n.get(T);v!==void 0&&xe(V.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&We(T)}function b(T){const v=T.texture,N=n.get(T),V=n.get(v);T.addEventListener("dispose",D);const j=T.textures,X=T.isWebGLCubeRenderTarget===!0,we=j.length>1;if(we||(V.__webglTexture===void 0&&(V.__webglTexture=i.createTexture()),V.__version=v.version,a.memory.textures++),X){N.__webglFramebuffer=[];for(let oe=0;oe<6;oe++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[oe]=[];for(let Te=0;Te<v.mipmaps.length;Te++)N.__webglFramebuffer[oe][Te]=i.createFramebuffer()}else N.__webglFramebuffer[oe]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let oe=0;oe<v.mipmaps.length;oe++)N.__webglFramebuffer[oe]=i.createFramebuffer()}else N.__webglFramebuffer=i.createFramebuffer();if(we)for(let oe=0,Te=j.length;oe<Te;oe++){const Ae=n.get(j[oe]);Ae.__webglTexture===void 0&&(Ae.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&ne(T)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let oe=0;oe<j.length;oe++){const Te=j[oe];N.__webglColorRenderbuffer[oe]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,N.__webglColorRenderbuffer[oe]);const Ae=s.convert(Te.format,Te.colorSpace),ie=s.convert(Te.type),ge=E(Te.internalFormat,Ae,ie,Te.colorSpace,T.isXRRenderTarget===!0),Ue=ce(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ue,ge,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.RENDERBUFFER,N.__webglColorRenderbuffer[oe])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(N.__webglDepthRenderbuffer=i.createRenderbuffer(),Ce(N.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(X){t.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture),Be(i.TEXTURE_CUBE_MAP,v);for(let oe=0;oe<6;oe++)if(v.mipmaps&&v.mipmaps.length>0)for(let Te=0;Te<v.mipmaps.length;Te++)xe(N.__webglFramebuffer[oe][Te],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,Te);else xe(N.__webglFramebuffer[oe],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0);m(v)&&p(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(we){for(let oe=0,Te=j.length;oe<Te;oe++){const Ae=j[oe],ie=n.get(Ae);let ge=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ge=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ge,ie.__webglTexture),Be(ge,Ae),xe(N.__webglFramebuffer,T,Ae,i.COLOR_ATTACHMENT0+oe,ge,0),m(Ae)&&p(ge)}t.unbindTexture()}else{let oe=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(oe=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(oe,V.__webglTexture),Be(oe,v),v.mipmaps&&v.mipmaps.length>0)for(let Te=0;Te<v.mipmaps.length;Te++)xe(N.__webglFramebuffer[Te],T,v,i.COLOR_ATTACHMENT0,oe,Te);else xe(N.__webglFramebuffer,T,v,i.COLOR_ATTACHMENT0,oe,0);m(v)&&p(oe),t.unbindTexture()}T.depthBuffer&&We(T)}function Q(T){const v=T.textures;for(let N=0,V=v.length;N<V;N++){const j=v[N];if(m(j)){const X=A(T),we=n.get(j).__webglTexture;t.bindTexture(X,we),p(X),t.unbindTexture()}}}const K=[],Z=[];function J(T){if(T.samples>0){if(ne(T)===!1){const v=T.textures,N=T.width,V=T.height;let j=i.COLOR_BUFFER_BIT;const X=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,we=n.get(T),oe=v.length>1;if(oe)for(let Ae=0;Ae<v.length;Ae++)t.bindFramebuffer(i.FRAMEBUFFER,we.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,we.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,we.__webglMultisampledFramebuffer);const Te=T.texture.mipmaps;Te&&Te.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglFramebuffer);for(let Ae=0;Ae<v.length;Ae++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(j|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(j|=i.STENCIL_BUFFER_BIT)),oe){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,we.__webglColorRenderbuffer[Ae]);const ie=n.get(v[Ae]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ie,0)}i.blitFramebuffer(0,0,N,V,0,0,N,V,j,i.NEAREST),c===!0&&(K.length=0,Z.length=0,K.push(i.COLOR_ATTACHMENT0+Ae),T.depthBuffer&&T.resolveDepthBuffer===!1&&(K.push(X),Z.push(X),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Z)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,K))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),oe)for(let Ae=0;Ae<v.length;Ae++){t.bindFramebuffer(i.FRAMEBUFFER,we.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.RENDERBUFFER,we.__webglColorRenderbuffer[Ae]);const ie=n.get(v[Ae]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,we.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ae,i.TEXTURE_2D,ie,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,we.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const v=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function ce(T){return Math.min(r.maxSamples,T.samples)}function ne(T){const v=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function he(T){const v=a.render.frame;h.get(T)!==v&&(h.set(T,v),T.update())}function Ne(T,v){const N=T.colorSpace,V=T.format,j=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||N!==Wn&&N!==""&&(Ze.getTransfer(N)===Qe?(V!==1023||j!==1009)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",N)),v}function Fe(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=G,this.resetTextureUnits=O,this.setTexture2D=q,this.setTexture2DArray=k,this.setTexture3D=te,this.setTextureCube=H,this.rebindTextures=nt,this.setupRenderTarget=b,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=We,this.setupFrameBufferTexture=xe,this.useMultisampledRTT=ne}function ad(i,e){function t(n,r=""){let s;const a=Ze.getTransfer(r);if(n===1009)return i.UNSIGNED_BYTE;if(n===1017)return i.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return i.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return i.BYTE;if(n===1011)return i.SHORT;if(n===1012)return i.UNSIGNED_SHORT;if(n===1013)return i.INT;if(n===1014)return i.UNSIGNED_INT;if(n===1015)return i.FLOAT;if(n===1016)return i.HALF_FLOAT;if(n===1021)return i.ALPHA;if(n===1022)return i.RGB;if(n===1023)return i.RGBA;if(n===1026)return i.DEPTH_COMPONENT;if(n===1027)return i.DEPTH_STENCIL;if(n===1028)return i.RED;if(n===1029)return i.RED_INTEGER;if(n===1030)return i.RG;if(n===1031)return i.RG_INTEGER;if(n===1033)return i.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===Qe)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===33776)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===33776)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===35840)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===36196||n===37492)return a===Qe?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===37496)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===37808)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===36492)return a===Qe?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===36283)return s.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const od=`
|
|
3817
|
+
void main() {
|
|
3818
|
+
|
|
3819
|
+
gl_Position = vec4( position, 1.0 );
|
|
3820
|
+
|
|
3821
|
+
}`,ld=`
|
|
3822
|
+
uniform sampler2DArray depthColor;
|
|
3823
|
+
uniform float depthWidth;
|
|
3824
|
+
uniform float depthHeight;
|
|
3825
|
+
|
|
3826
|
+
void main() {
|
|
3827
|
+
|
|
3828
|
+
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|
3829
|
+
|
|
3830
|
+
if ( coord.x >= 1.0 ) {
|
|
3831
|
+
|
|
3832
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
3833
|
+
|
|
3834
|
+
} else {
|
|
3835
|
+
|
|
3836
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
3837
|
+
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
}`;class cd{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new ya(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Xt({vertexShader:od,fragmentShader:ld,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ft(new vi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class hd extends Yn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,h=null,f=null,d=null,u=null,g=null;const _=typeof XRWebGLBinding<"u",m=new cd,p={},A=t.getContextAttributes();let E=null,x=null;const C=[],w=[],D=new le;let U=null;const y=new Lt;y.viewport=new et;const M=new Lt;M.viewport=new et;const R=[y,M],O=new Pl;let G=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let ee=C[Y];return ee===void 0&&(ee=new yr,C[Y]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(Y){let ee=C[Y];return ee===void 0&&(ee=new yr,C[Y]=ee),ee.getGripSpace()},this.getHand=function(Y){let ee=C[Y];return ee===void 0&&(ee=new yr,C[Y]=ee),ee.getHandSpace()};function q(Y){const ee=w.indexOf(Y.inputSource);if(ee===-1)return;const xe=C[ee];xe!==void 0&&(xe.update(Y.inputSource,Y.frame,l||a),xe.dispatchEvent({type:Y.type,data:Y.inputSource}))}function k(){r.removeEventListener("select",q),r.removeEventListener("selectstart",q),r.removeEventListener("selectend",q),r.removeEventListener("squeeze",q),r.removeEventListener("squeezestart",q),r.removeEventListener("squeezeend",q),r.removeEventListener("end",k),r.removeEventListener("inputsourceschange",te);for(let Y=0;Y<C.length;Y++){const ee=w[Y];ee!==null&&(w[Y]=null,C[Y].disconnect(ee))}G=null,W=null,m.reset();for(const Y in p)delete p[Y];e.setRenderTarget(E),u=null,d=null,f=null,r=null,x=null,Ye.stop(),n.isPresenting=!1,e.setPixelRatio(U),e.setSize(D.width,D.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:u},this.getBinding=function(){return f===null&&_&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(E=e.getRenderTarget(),r.addEventListener("select",q),r.addEventListener("selectstart",q),r.addEventListener("selectend",q),r.addEventListener("squeeze",q),r.addEventListener("squeezestart",q),r.addEventListener("squeezeend",q),r.addEventListener("end",k),r.addEventListener("inputsourceschange",te),A.xrCompatible!==!0&&await t.makeXRCompatible(),U=e.getPixelRatio(),e.getSize(D),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let xe=null,Ce=null,Ee=null;A.depth&&(Ee=A.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,xe=A.stencil?1027:1026,Ce=A.stencil?1020:1014);const We={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:s};f=this.getBinding(),d=f.createProjectionLayer(We),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new cn(d.textureWidth,d.textureHeight,{format:1023,type:1009,depthTexture:new Sa(d.textureWidth,d.textureHeight,Ce,void 0,void 0,void 0,void 0,void 0,void 0,xe),stencilBuffer:A.stencil,colorSpace:e.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const xe={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(r,t,xe),r.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),x=new cn(u.framebufferWidth,u.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await r.requestReferenceSpace(o),Ye.setContext(r),Ye.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function te(Y){for(let ee=0;ee<Y.removed.length;ee++){const xe=Y.removed[ee],Ce=w.indexOf(xe);Ce>=0&&(w[Ce]=null,C[Ce].disconnect(xe))}for(let ee=0;ee<Y.added.length;ee++){const xe=Y.added[ee];let Ce=w.indexOf(xe);if(Ce===-1){for(let We=0;We<C.length;We++)if(We>=w.length){w.push(xe),Ce=We;break}else if(w[We]===null){w[We]=xe,Ce=We;break}if(Ce===-1)break}const Ee=C[Ce];Ee&&Ee.connect(xe)}}const H=new P,ue=new P;function _e(Y,ee,xe){H.setFromMatrixPosition(ee.matrixWorld),ue.setFromMatrixPosition(xe.matrixWorld);const Ce=H.distanceTo(ue),Ee=ee.projectionMatrix.elements,We=xe.projectionMatrix.elements,nt=Ee[14]/(Ee[10]-1),b=Ee[14]/(Ee[10]+1),Q=(Ee[9]+1)/Ee[5],K=(Ee[9]-1)/Ee[5],Z=(Ee[8]-1)/Ee[0],J=(We[8]+1)/We[0],ce=nt*Z,ne=nt*J,he=Ce/(-Z+J),Ne=he*-Z;if(ee.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ne),Y.translateZ(he),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ee[10]===-1)Y.projectionMatrix.copy(ee.projectionMatrix),Y.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{const Fe=nt+he,T=b+he,v=ce-Ne,N=ne+(Ce-Ne),V=Q*b/T*Fe,j=K*b/T*Fe;Y.projectionMatrix.makePerspective(v,N,V,j,Fe,T),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function Me(Y,ee){ee===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(ee.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let ee=Y.near,xe=Y.far;m.texture!==null&&(m.depthNear>0&&(ee=m.depthNear),m.depthFar>0&&(xe=m.depthFar)),O.near=M.near=y.near=ee,O.far=M.far=y.far=xe,(G!==O.near||W!==O.far)&&(r.updateRenderState({depthNear:O.near,depthFar:O.far}),G=O.near,W=O.far),O.layers.mask=Y.layers.mask|6,y.layers.mask=O.layers.mask&3,M.layers.mask=O.layers.mask&5;const Ce=Y.parent,Ee=O.cameras;Me(O,Ce);for(let We=0;We<Ee.length;We++)Me(Ee[We],Ce);Ee.length===2?_e(O,y,M):O.projectionMatrix.copy(y.projectionMatrix),Be(Y,O,Ce)};function Be(Y,ee,xe){xe===null?Y.matrix.copy(ee.matrixWorld):(Y.matrix.copy(xe.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(ee.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(ee.projectionMatrix),Y.projectionMatrixInverse.copy(ee.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=ui*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(d===null&&u===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=Y)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(O)},this.getCameraTexture=function(Y){return p[Y]};let qe=null;function $e(Y,ee){if(h=ee.getViewerPose(l||a),g=ee,h!==null){const xe=h.views;u!==null&&(e.setRenderTargetFramebuffer(x,u.framebuffer),e.setRenderTarget(x));let Ce=!1;xe.length!==O.cameras.length&&(O.cameras.length=0,Ce=!0);for(let b=0;b<xe.length;b++){const Q=xe[b];let K=null;if(u!==null)K=u.getViewport(Q);else{const J=f.getViewSubImage(d,Q);K=J.viewport,b===0&&(e.setRenderTargetTextures(x,J.colorTexture,J.depthStencilTexture),e.setRenderTarget(x))}let Z=R[b];Z===void 0&&(Z=new Lt,Z.layers.enable(b),Z.viewport=new et,R[b]=Z),Z.matrix.fromArray(Q.transform.matrix),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.projectionMatrix.fromArray(Q.projectionMatrix),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert(),Z.viewport.set(K.x,K.y,K.width,K.height),b===0&&(O.matrix.copy(Z.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),Ce===!0&&O.cameras.push(Z)}const Ee=r.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&_){f=n.getBinding();const b=f.getDepthInformation(xe[0]);b&&b.isValid&&b.texture&&m.init(b,r.renderState)}if(Ee&&Ee.includes("camera-access")&&_){e.state.unbindTexture(),f=n.getBinding();for(let b=0;b<xe.length;b++){const Q=xe[b].camera;if(Q){let K=p[Q];K||(K=new ya,p[Q]=K);const Z=f.getCameraImage(Q);K.sourceTexture=Z}}}}for(let xe=0;xe<C.length;xe++){const Ce=w[xe],Ee=C[xe];Ce!==null&&Ee!==void 0&&Ee.update(Ce,ee,l||a)}qe&&qe(Y,ee),ee.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ee}),g=null}const Ye=new Na;Ye.setAnimationLoop($e),this.setAnimationLoop=function(Y){qe=Y},this.dispose=function(){}}}const _n=new Ht,ud=new rt;function fd(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,xa(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function r(m,p,A,E,x){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(m,p):p.isMeshToonMaterial?(s(m,p),f(m,p)):p.isMeshPhongMaterial?(s(m,p),h(m,p)):p.isMeshStandardMaterial?(s(m,p),d(m,p),p.isMeshPhysicalMaterial&&u(m,p,x)):p.isMeshMatcapMaterial?(s(m,p),g(m,p)):p.isMeshDepthMaterial?s(m,p):p.isMeshDistanceMaterial?(s(m,p),_(m,p)):p.isMeshNormalMaterial?s(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?c(m,p,A,E):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===1&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===1&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const A=e.get(p),E=A.envMap,x=A.envMapRotation;E&&(m.envMap.value=E,_n.copy(x),_n.x*=-1,_n.y*=-1,_n.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(_n.y*=-1,_n.z*=-1),m.envMapRotation.value.setFromMatrix4(ud.makeRotationFromEuler(_n)),m.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,A,E){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*A,m.scale.value=E*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function f(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function u(m,p,A){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===1&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=A.texture,m.transmissionSamplerSize.value.set(A.width,A.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){const A=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(A.matrixWorld),m.nearDistance.value=A.shadow.camera.near,m.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function dd(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(A,E){const x=E.program;n.uniformBlockBinding(A,x)}function l(A,E){let x=r[A.id];x===void 0&&(g(A),x=h(A),r[A.id]=x,A.addEventListener("dispose",m));const C=E.program;n.updateUBOMapping(A,C);const w=e.render.frame;s[A.id]!==w&&(d(A),s[A.id]=w)}function h(A){const E=f();A.__bindingPointIndex=E;const x=i.createBuffer(),C=A.__size,w=A.usage;return i.bindBuffer(i.UNIFORM_BUFFER,x),i.bufferData(i.UNIFORM_BUFFER,C,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,E,x),x}function f(){for(let A=0;A<o;A++)if(a.indexOf(A)===-1)return a.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(A){const E=r[A.id],x=A.uniforms,C=A.__cache;i.bindBuffer(i.UNIFORM_BUFFER,E);for(let w=0,D=x.length;w<D;w++){const U=Array.isArray(x[w])?x[w]:[x[w]];for(let y=0,M=U.length;y<M;y++){const R=U[y];if(u(R,w,y,C)===!0){const O=R.__offset,G=Array.isArray(R.value)?R.value:[R.value];let W=0;for(let q=0;q<G.length;q++){const k=G[q],te=_(k);typeof k=="number"||typeof k=="boolean"?(R.__data[0]=k,i.bufferSubData(i.UNIFORM_BUFFER,O+W,R.__data)):k.isMatrix3?(R.__data[0]=k.elements[0],R.__data[1]=k.elements[1],R.__data[2]=k.elements[2],R.__data[3]=0,R.__data[4]=k.elements[3],R.__data[5]=k.elements[4],R.__data[6]=k.elements[5],R.__data[7]=0,R.__data[8]=k.elements[6],R.__data[9]=k.elements[7],R.__data[10]=k.elements[8],R.__data[11]=0):(k.toArray(R.__data,W),W+=te.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,O,R.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function u(A,E,x,C){const w=A.value,D=E+"_"+x;if(C[D]===void 0)return typeof w=="number"||typeof w=="boolean"?C[D]=w:C[D]=w.clone(),!0;{const U=C[D];if(typeof w=="number"||typeof w=="boolean"){if(U!==w)return C[D]=w,!0}else if(U.equals(w)===!1)return U.copy(w),!0}return!1}function g(A){const E=A.uniforms;let x=0;const C=16;for(let D=0,U=E.length;D<U;D++){const y=Array.isArray(E[D])?E[D]:[E[D]];for(let M=0,R=y.length;M<R;M++){const O=y[M],G=Array.isArray(O.value)?O.value:[O.value];for(let W=0,q=G.length;W<q;W++){const k=G[W],te=_(k),H=x%C,ue=H%te.boundary,_e=H+ue;x+=ue,_e!==0&&C-_e<te.storage&&(x+=C-_e),O.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=x,x+=te.storage}}}const w=x%C;return w>0&&(x+=C-w),A.__size=x,A.__cache={},this}function _(A){const E={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(E.boundary=4,E.storage=4):A.isVector2?(E.boundary=8,E.storage=8):A.isVector3||A.isColor?(E.boundary=16,E.storage=12):A.isVector4?(E.boundary=16,E.storage=16):A.isMatrix3?(E.boundary=48,E.storage=48):A.isMatrix4?(E.boundary=64,E.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),E}function m(A){const E=A.target;E.removeEventListener("dispose",m);const x=a.indexOf(E.__bindingPointIndex);a.splice(x,1),i.deleteBuffer(r[E.id]),delete r[E.id],delete s[E.id]}function p(){for(const A in r)i.deleteBuffer(r[A]);a=[],r={},s={}}return{bind:c,update:l,dispose:p}}class pd{constructor(e={}){const{canvas:t=uo(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let u;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=n.getContextAttributes().alpha}else u=a;const g=new Uint32Array(4),_=new Int32Array(4);let m=null,p=null;const A=[],E=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const x=this;let C=!1;this._outputColorSpace=bt;let w=0,D=0,U=null,y=-1,M=null;const R=new et,O=new et;let G=null;const W=new ke(0);let q=0,k=t.width,te=t.height,H=1,ue=null,_e=null;const Me=new et(0,0,k,te),Be=new et(0,0,k,te);let qe=!1;const $e=new Yr;let Ye=!1,Y=!1;const ee=new rt,xe=new P,Ce=new et,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let We=!1;function nt(){return U===null?H:1}let b=n;function Q(S,I){return t.getContext(S,I)}try{const S={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r180"),t.addEventListener("webglcontextlost",fe,!1),t.addEventListener("webglcontextrestored",Se,!1),t.addEventListener("webglcontextcreationerror",re,!1),b===null){const I="webgl2";if(b=Q(I,S),b===null)throw Q(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(S){throw console.error("THREE.WebGLRenderer: "+S.message),S}let K,Z,J,ce,ne,he,Ne,Fe,T,v,N,V,j,X,we,oe,Te,Ae,ie,ge,Ue,Re,pe,ze;function L(){K=new Eu(b),K.init(),Re=new ad(b,K),Z=new gu(b,K,e,Re),J=new rd(b,K),Z.reversedDepthBuffer&&d&&J.buffers.depth.setReversed(!0),ce=new bu(b),ne=new Xf,he=new sd(b,K,J,ne,Z,Re,ce),Ne=new vu(x),Fe=new yu(x),T=new Ll(b),pe=new pu(b,T),v=new Tu(b,T,ce,pe),N=new Ru(b,v,T,ce),ie=new wu(b,Z,he),oe=new _u(ne),V=new Wf(x,Ne,Fe,K,Z,pe,oe),j=new fd(x,ne),X=new Yf,we=new Qf(K),Ae=new du(x,Ne,Fe,J,N,u,c),Te=new nd(x,N,Z),ze=new dd(b,ce,Z,J),ge=new mu(b,K,ce),Ue=new Au(b,K,ce),ce.programs=V.programs,x.capabilities=Z,x.extensions=K,x.properties=ne,x.renderLists=X,x.shadowMap=Te,x.state=J,x.info=ce}L();const ae=new hd(x,b);this.xr=ae,this.getContext=function(){return b},this.getContextAttributes=function(){return b.getContextAttributes()},this.forceContextLoss=function(){const S=K.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=K.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(S){S!==void 0&&(H=S,this.setSize(k,te,!1))},this.getSize=function(S){return S.set(k,te)},this.setSize=function(S,I,B=!0){if(ae.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}k=S,te=I,t.width=Math.floor(S*H),t.height=Math.floor(I*H),B===!0&&(t.style.width=S+"px",t.style.height=I+"px"),this.setViewport(0,0,S,I)},this.getDrawingBufferSize=function(S){return S.set(k*H,te*H).floor()},this.setDrawingBufferSize=function(S,I,B){k=S,te=I,H=B,t.width=Math.floor(S*B),t.height=Math.floor(I*B),this.setViewport(0,0,S,I)},this.getCurrentViewport=function(S){return S.copy(R)},this.getViewport=function(S){return S.copy(Me)},this.setViewport=function(S,I,B,z){S.isVector4?Me.set(S.x,S.y,S.z,S.w):Me.set(S,I,B,z),J.viewport(R.copy(Me).multiplyScalar(H).round())},this.getScissor=function(S){return S.copy(Be)},this.setScissor=function(S,I,B,z){S.isVector4?Be.set(S.x,S.y,S.z,S.w):Be.set(S,I,B,z),J.scissor(O.copy(Be).multiplyScalar(H).round())},this.getScissorTest=function(){return qe},this.setScissorTest=function(S){J.setScissorTest(qe=S)},this.setOpaqueSort=function(S){ue=S},this.setTransparentSort=function(S){_e=S},this.getClearColor=function(S){return S.copy(Ae.getClearColor())},this.setClearColor=function(){Ae.setClearColor(...arguments)},this.getClearAlpha=function(){return Ae.getClearAlpha()},this.setClearAlpha=function(){Ae.setClearAlpha(...arguments)},this.clear=function(S=!0,I=!0,B=!0){let z=0;if(S){let F=!1;if(U!==null){const se=U.texture.format;F=se===1033||se===1031||se===1029}if(F){const se=U.texture.type,me=se===1009||se===1014||se===1012||se===1020||se===1017||se===1018,ye=Ae.getClearColor(),ve=Ae.getClearAlpha(),Le=ye.r,Ie=ye.g,Pe=ye.b;me?(g[0]=Le,g[1]=Ie,g[2]=Pe,g[3]=ve,b.clearBufferuiv(b.COLOR,0,g)):(_[0]=Le,_[1]=Ie,_[2]=Pe,_[3]=ve,b.clearBufferiv(b.COLOR,0,_))}else z|=b.COLOR_BUFFER_BIT}I&&(z|=b.DEPTH_BUFFER_BIT),B&&(z|=b.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),b.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",fe,!1),t.removeEventListener("webglcontextrestored",Se,!1),t.removeEventListener("webglcontextcreationerror",re,!1),Ae.dispose(),X.dispose(),we.dispose(),ne.dispose(),Ne.dispose(),Fe.dispose(),N.dispose(),pe.dispose(),ze.dispose(),V.dispose(),ae.dispose(),ae.removeEventListener("sessionstart",kt),ae.removeEventListener("sessionend",is),hn.stop()};function fe(S){S.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),C=!0}function Se(){console.log("THREE.WebGLRenderer: Context Restored."),C=!1;const S=ce.autoReset,I=Te.enabled,B=Te.autoUpdate,z=Te.needsUpdate,F=Te.type;L(),ce.autoReset=S,Te.enabled=I,Te.autoUpdate=B,Te.needsUpdate=z,Te.type=F}function re(S){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function $(S){const I=S.target;I.removeEventListener("dispose",$),be(I)}function be(S){Oe(S),ne.remove(S)}function Oe(S){const I=ne.get(S).programs;I!==void 0&&(I.forEach(function(B){V.releaseProgram(B)}),S.isShaderMaterial&&V.releaseShaderCache(S))}this.renderBufferDirect=function(S,I,B,z,F,se){I===null&&(I=Ee);const me=F.isMesh&&F.matrixWorld.determinant()<0,ye=Va(S,I,B,z,F);J.setMaterial(z,me);let ve=B.index,Le=1;if(z.wireframe===!0){if(ve=v.getWireframeAttribute(B),ve===void 0)return;Le=2}const Ie=B.drawRange,Pe=B.attributes.position;let Xe=Ie.start*Le,je=(Ie.start+Ie.count)*Le;se!==null&&(Xe=Math.max(Xe,se.start*Le),je=Math.min(je,(se.start+se.count)*Le)),ve!==null?(Xe=Math.max(Xe,0),je=Math.min(je,ve.count)):Pe!=null&&(Xe=Math.max(Xe,0),je=Math.min(je,Pe.count));const ht=je-Xe;if(ht<0||ht===1/0)return;pe.setup(F,z,ye,B,ve);let st,tt=ge;if(ve!==null&&(st=T.get(ve),tt=Ue,tt.setIndex(st)),F.isMesh)z.wireframe===!0?(J.setLineWidth(z.wireframeLinewidth*nt()),tt.setMode(b.LINES)):tt.setMode(b.TRIANGLES);else if(F.isLine){let De=z.linewidth;De===void 0&&(De=1),J.setLineWidth(De*nt()),F.isLineSegments?tt.setMode(b.LINES):F.isLineLoop?tt.setMode(b.LINE_LOOP):tt.setMode(b.LINE_STRIP)}else F.isPoints?tt.setMode(b.POINTS):F.isSprite&&tt.setMode(b.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)fi("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),tt.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(K.get("WEBGL_multi_draw"))tt.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const De=F._multiDrawStarts,ot=F._multiDrawCounts,Je=F._multiDrawCount,Rt=ve?T.get(ve).bytesPerElement:1,An=ne.get(z).currentProgram.getUniforms();for(let Ct=0;Ct<Je;Ct++)An.setValue(b,"_gl_DrawID",Ct),tt.render(De[Ct]/Rt,ot[Ct])}else if(F.isInstancedMesh)tt.renderInstances(Xe,ht,F.count);else if(B.isInstancedBufferGeometry){const De=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,ot=Math.min(B.instanceCount,De);tt.renderInstances(Xe,ht,ot)}else tt.render(Xe,ht)};function it(S,I,B){S.transparent===!0&&S.side===2&&S.forceSinglePass===!1?(S.side=1,S.needsUpdate=!0,Mi(S,I,B),S.side=0,S.needsUpdate=!0,Mi(S,I,B),S.side=2):Mi(S,I,B)}this.compile=function(S,I,B=null){B===null&&(B=S),p=we.get(B),p.init(I),E.push(p),B.traverseVisible(function(F){F.isLight&&F.layers.test(I.layers)&&(p.pushLight(F),F.castShadow&&p.pushShadow(F))}),S!==B&&S.traverseVisible(function(F){F.isLight&&F.layers.test(I.layers)&&(p.pushLight(F),F.castShadow&&p.pushShadow(F))}),p.setupLights();const z=new Set;return S.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const se=F.material;if(se)if(Array.isArray(se))for(let me=0;me<se.length;me++){const ye=se[me];it(ye,B,F),z.add(ye)}else it(se,B,F),z.add(se)}),p=E.pop(),z},this.compileAsync=function(S,I,B=null){const z=this.compile(S,I,B);return new Promise(F=>{function se(){if(z.forEach(function(me){ne.get(me).currentProgram.isReady()&&z.delete(me)}),z.size===0){F(S);return}setTimeout(se,10)}K.get("KHR_parallel_shader_compile")!==null?se():setTimeout(se,10)})};let Ke=null;function Yt(S){Ke&&Ke(S)}function kt(){hn.stop()}function is(){hn.start()}const hn=new Na;hn.setAnimationLoop(Yt),typeof self<"u"&&hn.setContext(self),this.setAnimationLoop=function(S){Ke=S,ae.setAnimationLoop(S),S===null?hn.stop():hn.start()},ae.addEventListener("sessionstart",kt),ae.addEventListener("sessionend",is),this.render=function(S,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),ae.enabled===!0&&ae.isPresenting===!0&&(ae.cameraAutoUpdate===!0&&ae.updateCamera(I),I=ae.getCamera()),S.isScene===!0&&S.onBeforeRender(x,S,I,U),p=we.get(S,E.length),p.init(I),E.push(p),ee.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),$e.setFromProjectionMatrix(ee,2e3,I.reversedDepth),Y=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,Y),m=X.get(S,A.length),m.init(),A.push(m),ae.enabled===!0&&ae.isPresenting===!0){const se=x.xr.getDepthSensingMesh();se!==null&&er(se,I,-1/0,x.sortObjects)}er(S,I,0,x.sortObjects),m.finish(),x.sortObjects===!0&&m.sort(ue,_e),We=ae.enabled===!1||ae.isPresenting===!1||ae.hasDepthSensing()===!1,We&&Ae.addToRenderList(m,S),this.info.render.frame++,Ye===!0&&oe.beginShadows();const B=p.state.shadowsArray;Te.render(B,S,I),Ye===!0&&oe.endShadows(),this.info.autoReset===!0&&this.info.reset();const z=m.opaque,F=m.transmissive;if(p.setupLights(),I.isArrayCamera){const se=I.cameras;if(F.length>0)for(let me=0,ye=se.length;me<ye;me++){const ve=se[me];ss(z,F,S,ve)}We&&Ae.render(S);for(let me=0,ye=se.length;me<ye;me++){const ve=se[me];rs(m,S,ve,ve.viewport)}}else F.length>0&&ss(z,F,S,I),We&&Ae.render(S),rs(m,S,I);U!==null&&D===0&&(he.updateMultisampleRenderTarget(U),he.updateRenderTargetMipmap(U)),S.isScene===!0&&S.onAfterRender(x,S,I),pe.resetDefaultState(),y=-1,M=null,E.pop(),E.length>0?(p=E[E.length-1],Ye===!0&&oe.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,A.pop(),A.length>0?m=A[A.length-1]:m=null};function er(S,I,B,z){if(S.visible===!1)return;if(S.layers.test(I.layers)){if(S.isGroup)B=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(I);else if(S.isLight)p.pushLight(S),S.castShadow&&p.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||$e.intersectsSprite(S)){z&&Ce.setFromMatrixPosition(S.matrixWorld).applyMatrix4(ee);const me=N.update(S),ye=S.material;ye.visible&&m.push(S,me,ye,B,Ce.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||$e.intersectsObject(S))){const me=N.update(S),ye=S.material;if(z&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),Ce.copy(S.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),Ce.copy(me.boundingSphere.center)),Ce.applyMatrix4(S.matrixWorld).applyMatrix4(ee)),Array.isArray(ye)){const ve=me.groups;for(let Le=0,Ie=ve.length;Le<Ie;Le++){const Pe=ve[Le],Xe=ye[Pe.materialIndex];Xe&&Xe.visible&&m.push(S,me,Xe,B,Ce.z,Pe)}}else ye.visible&&m.push(S,me,ye,B,Ce.z,null)}}const se=S.children;for(let me=0,ye=se.length;me<ye;me++)er(se[me],I,B,z)}function rs(S,I,B,z){const F=S.opaque,se=S.transmissive,me=S.transparent;p.setupLightsView(B),Ye===!0&&oe.setGlobalState(x.clippingPlanes,B),z&&J.viewport(R.copy(z)),F.length>0&&xi(F,I,B),se.length>0&&xi(se,I,B),me.length>0&&xi(me,I,B),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function ss(S,I,B,z){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[z.id]===void 0&&(p.state.transmissionRenderTarget[z.id]=new cn(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")||K.has("EXT_color_buffer_float")?1016:1009,minFilter:1008,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ze.workingColorSpace}));const se=p.state.transmissionRenderTarget[z.id],me=z.viewport||R;se.setSize(me.z*x.transmissionResolutionScale,me.w*x.transmissionResolutionScale);const ye=x.getRenderTarget(),ve=x.getActiveCubeFace(),Le=x.getActiveMipmapLevel();x.setRenderTarget(se),x.getClearColor(W),q=x.getClearAlpha(),q<1&&x.setClearColor(16777215,.5),x.clear(),We&&Ae.render(B);const Ie=x.toneMapping;x.toneMapping=0;const Pe=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),p.setupLightsView(z),Ye===!0&&oe.setGlobalState(x.clippingPlanes,z),xi(S,B,z),he.updateMultisampleRenderTarget(se),he.updateRenderTargetMipmap(se),K.has("WEBGL_multisampled_render_to_texture")===!1){let Xe=!1;for(let je=0,ht=I.length;je<ht;je++){const st=I[je],tt=st.object,De=st.geometry,ot=st.material,Je=st.group;if(ot.side===2&&tt.layers.test(z.layers)){const Rt=ot.side;ot.side=1,ot.needsUpdate=!0,as(tt,B,z,De,ot,Je),ot.side=Rt,ot.needsUpdate=!0,Xe=!0}}Xe===!0&&(he.updateMultisampleRenderTarget(se),he.updateRenderTargetMipmap(se))}x.setRenderTarget(ye,ve,Le),x.setClearColor(W,q),Pe!==void 0&&(z.viewport=Pe),x.toneMapping=Ie}function xi(S,I,B){const z=I.isScene===!0?I.overrideMaterial:null;for(let F=0,se=S.length;F<se;F++){const me=S[F],ye=me.object,ve=me.geometry,Le=me.group;let Ie=me.material;Ie.allowOverride===!0&&z!==null&&(Ie=z),ye.layers.test(B.layers)&&as(ye,I,B,ve,Ie,Le)}}function as(S,I,B,z,F,se){S.onBeforeRender(x,I,B,z,F,se),S.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),F.onBeforeRender(x,I,B,z,S,se),F.transparent===!0&&F.side===2&&F.forceSinglePass===!1?(F.side=1,F.needsUpdate=!0,x.renderBufferDirect(B,I,z,F,S,se),F.side=0,F.needsUpdate=!0,x.renderBufferDirect(B,I,z,F,S,se),F.side=2):x.renderBufferDirect(B,I,z,F,S,se),S.onAfterRender(x,I,B,z,F,se)}function Mi(S,I,B){I.isScene!==!0&&(I=Ee);const z=ne.get(S),F=p.state.lights,se=p.state.shadowsArray,me=F.state.version,ye=V.getParameters(S,F.state,se,I,B),ve=V.getProgramCacheKey(ye);let Le=z.programs;z.environment=S.isMeshStandardMaterial?I.environment:null,z.fog=I.fog,z.envMap=(S.isMeshStandardMaterial?Fe:Ne).get(S.envMap||z.environment),z.envMapRotation=z.environment!==null&&S.envMap===null?I.environmentRotation:S.envMapRotation,Le===void 0&&(S.addEventListener("dispose",$),Le=new Map,z.programs=Le);let Ie=Le.get(ve);if(Ie!==void 0){if(z.currentProgram===Ie&&z.lightsStateVersion===me)return ls(S,ye),Ie}else ye.uniforms=V.getUniforms(S),S.onBeforeCompile(ye,x),Ie=V.acquireProgram(ye,ve),Le.set(ve,Ie),z.uniforms=ye.uniforms;const Pe=z.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Pe.clippingPlanes=oe.uniform),ls(S,ye),z.needsLights=ka(S),z.lightsStateVersion=me,z.needsLights&&(Pe.ambientLightColor.value=F.state.ambient,Pe.lightProbe.value=F.state.probe,Pe.directionalLights.value=F.state.directional,Pe.directionalLightShadows.value=F.state.directionalShadow,Pe.spotLights.value=F.state.spot,Pe.spotLightShadows.value=F.state.spotShadow,Pe.rectAreaLights.value=F.state.rectArea,Pe.ltc_1.value=F.state.rectAreaLTC1,Pe.ltc_2.value=F.state.rectAreaLTC2,Pe.pointLights.value=F.state.point,Pe.pointLightShadows.value=F.state.pointShadow,Pe.hemisphereLights.value=F.state.hemi,Pe.directionalShadowMap.value=F.state.directionalShadowMap,Pe.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Pe.spotShadowMap.value=F.state.spotShadowMap,Pe.spotLightMatrix.value=F.state.spotLightMatrix,Pe.spotLightMap.value=F.state.spotLightMap,Pe.pointShadowMap.value=F.state.pointShadowMap,Pe.pointShadowMatrix.value=F.state.pointShadowMatrix),z.currentProgram=Ie,z.uniformsList=null,Ie}function os(S){if(S.uniformsList===null){const I=S.currentProgram.getUniforms();S.uniformsList=Xi.seqWithValue(I.seq,S.uniforms)}return S.uniformsList}function ls(S,I){const B=ne.get(S);B.outputColorSpace=I.outputColorSpace,B.batching=I.batching,B.batchingColor=I.batchingColor,B.instancing=I.instancing,B.instancingColor=I.instancingColor,B.instancingMorph=I.instancingMorph,B.skinning=I.skinning,B.morphTargets=I.morphTargets,B.morphNormals=I.morphNormals,B.morphColors=I.morphColors,B.morphTargetsCount=I.morphTargetsCount,B.numClippingPlanes=I.numClippingPlanes,B.numIntersection=I.numClipIntersection,B.vertexAlphas=I.vertexAlphas,B.vertexTangents=I.vertexTangents,B.toneMapping=I.toneMapping}function Va(S,I,B,z,F){I.isScene!==!0&&(I=Ee),he.resetTextureUnits();const se=I.fog,me=z.isMeshStandardMaterial?I.environment:null,ye=U===null?x.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:Wn,ve=(z.isMeshStandardMaterial?Fe:Ne).get(z.envMap||me),Le=z.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Ie=!!B.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Pe=!!B.morphAttributes.position,Xe=!!B.morphAttributes.normal,je=!!B.morphAttributes.color;let ht=0;z.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(ht=x.toneMapping);const st=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,tt=st!==void 0?st.length:0,De=ne.get(z),ot=p.state.lights;if(Ye===!0&&(Y===!0||S!==M)){const St=S===M&&z.id===y;oe.setState(z,S,St)}let Je=!1;z.version===De.__version?(De.needsLights&&De.lightsStateVersion!==ot.state.version||De.outputColorSpace!==ye||F.isBatchedMesh&&De.batching===!1||!F.isBatchedMesh&&De.batching===!0||F.isBatchedMesh&&De.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&De.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&De.instancing===!1||!F.isInstancedMesh&&De.instancing===!0||F.isSkinnedMesh&&De.skinning===!1||!F.isSkinnedMesh&&De.skinning===!0||F.isInstancedMesh&&De.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&De.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&De.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&De.instancingMorph===!1&&F.morphTexture!==null||De.envMap!==ve||z.fog===!0&&De.fog!==se||De.numClippingPlanes!==void 0&&(De.numClippingPlanes!==oe.numPlanes||De.numIntersection!==oe.numIntersection)||De.vertexAlphas!==Le||De.vertexTangents!==Ie||De.morphTargets!==Pe||De.morphNormals!==Xe||De.morphColors!==je||De.toneMapping!==ht||De.morphTargetsCount!==tt)&&(Je=!0):(Je=!0,De.__version=z.version);let Rt=De.currentProgram;Je===!0&&(Rt=Mi(z,I,F));let An=!1,Ct=!1,Kn=!1;const lt=Rt.getUniforms(),Ut=De.uniforms;if(J.useProgram(Rt.program)&&(An=!0,Ct=!0,Kn=!0),z.id!==y&&(y=z.id,Ct=!0),An||M!==S){J.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),lt.setValue(b,"projectionMatrix",S.projectionMatrix),lt.setValue(b,"viewMatrix",S.matrixWorldInverse);const Tt=lt.map.cameraPosition;Tt!==void 0&&Tt.setValue(b,xe.setFromMatrixPosition(S.matrixWorld)),Z.logarithmicDepthBuffer&<.setValue(b,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&<.setValue(b,"isOrthographic",S.isOrthographicCamera===!0),M!==S&&(M=S,Ct=!0,Kn=!0)}if(F.isSkinnedMesh){lt.setOptional(b,F,"bindMatrix"),lt.setOptional(b,F,"bindMatrixInverse");const St=F.skeleton;St&&(St.boneTexture===null&&St.computeBoneTexture(),lt.setValue(b,"boneTexture",St.boneTexture,he))}F.isBatchedMesh&&(lt.setOptional(b,F,"batchingTexture"),lt.setValue(b,"batchingTexture",F._matricesTexture,he),lt.setOptional(b,F,"batchingIdTexture"),lt.setValue(b,"batchingIdTexture",F._indirectTexture,he),lt.setOptional(b,F,"batchingColorTexture"),F._colorsTexture!==null&<.setValue(b,"batchingColorTexture",F._colorsTexture,he));const It=B.morphAttributes;if((It.position!==void 0||It.normal!==void 0||It.color!==void 0)&&ie.update(F,B,Rt),(Ct||De.receiveShadow!==F.receiveShadow)&&(De.receiveShadow=F.receiveShadow,lt.setValue(b,"receiveShadow",F.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(Ut.envMap.value=ve,Ut.flipEnvMap.value=ve.isCubeTexture&&ve.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&I.environment!==null&&(Ut.envMapIntensity.value=I.environmentIntensity),Ct&&(lt.setValue(b,"toneMappingExposure",x.toneMappingExposure),De.needsLights&&Ha(Ut,Kn),se&&z.fog===!0&&j.refreshFogUniforms(Ut,se),j.refreshMaterialUniforms(Ut,z,H,te,p.state.transmissionRenderTarget[S.id]),Xi.upload(b,os(De),Ut,he)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Xi.upload(b,os(De),Ut,he),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&<.setValue(b,"center",F.center),lt.setValue(b,"modelViewMatrix",F.modelViewMatrix),lt.setValue(b,"normalMatrix",F.normalMatrix),lt.setValue(b,"modelMatrix",F.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){const St=z.uniformsGroups;for(let Tt=0,tr=St.length;Tt<tr;Tt++){const un=St[Tt];ze.update(un,Rt),ze.bind(un,Rt)}}return Rt}function Ha(S,I){S.ambientLightColor.needsUpdate=I,S.lightProbe.needsUpdate=I,S.directionalLights.needsUpdate=I,S.directionalLightShadows.needsUpdate=I,S.pointLights.needsUpdate=I,S.pointLightShadows.needsUpdate=I,S.spotLights.needsUpdate=I,S.spotLightShadows.needsUpdate=I,S.rectAreaLights.needsUpdate=I,S.hemisphereLights.needsUpdate=I}function ka(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(S,I,B){const z=ne.get(S);z.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),ne.get(S.texture).__webglTexture=I,ne.get(S.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:B,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,I){const B=ne.get(S);B.__webglFramebuffer=I,B.__useDefaultFramebuffer=I===void 0};const Wa=b.createFramebuffer();this.setRenderTarget=function(S,I=0,B=0){U=S,w=I,D=B;let z=!0,F=null,se=!1,me=!1;if(S){const ve=ne.get(S);if(ve.__useDefaultFramebuffer!==void 0)J.bindFramebuffer(b.FRAMEBUFFER,null),z=!1;else if(ve.__webglFramebuffer===void 0)he.setupRenderTarget(S);else if(ve.__hasExternalTextures)he.rebindTextures(S,ne.get(S.texture).__webglTexture,ne.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const Pe=S.depthTexture;if(ve.__boundDepthTexture!==Pe){if(Pe!==null&&ne.has(Pe)&&(S.width!==Pe.image.width||S.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");he.setupDepthRenderbuffer(S)}}const Le=S.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(me=!0);const Ie=ne.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Ie[I])?F=Ie[I][B]:F=Ie[I],se=!0):S.samples>0&&he.useMultisampledRTT(S)===!1?F=ne.get(S).__webglMultisampledFramebuffer:Array.isArray(Ie)?F=Ie[B]:F=Ie,R.copy(S.viewport),O.copy(S.scissor),G=S.scissorTest}else R.copy(Me).multiplyScalar(H).floor(),O.copy(Be).multiplyScalar(H).floor(),G=qe;if(B!==0&&(F=Wa),J.bindFramebuffer(b.FRAMEBUFFER,F)&&z&&J.drawBuffers(S,F),J.viewport(R),J.scissor(O),J.setScissorTest(G),se){const ve=ne.get(S.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_CUBE_MAP_POSITIVE_X+I,ve.__webglTexture,B)}else if(me){const ve=I;for(let Le=0;Le<S.textures.length;Le++){const Ie=ne.get(S.textures[Le]);b.framebufferTextureLayer(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0+Le,Ie.__webglTexture,B,ve)}}else if(S!==null&&B!==0){const ve=ne.get(S.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,ve.__webglTexture,B)}y=-1},this.readRenderTargetPixels=function(S,I,B,z,F,se,me,ye=0){if(!(S&&S.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ve=ne.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&me!==void 0&&(ve=ve[me]),ve){J.bindFramebuffer(b.FRAMEBUFFER,ve);try{const Le=S.textures[ye],Ie=Le.format,Pe=Le.type;if(!Z.textureFormatReadable(Ie)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Z.textureTypeReadable(Pe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=S.width-z&&B>=0&&B<=S.height-F&&(S.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+ye),b.readPixels(I,B,z,F,Re.convert(Ie),Re.convert(Pe),se))}finally{const Le=U!==null?ne.get(U).__webglFramebuffer:null;J.bindFramebuffer(b.FRAMEBUFFER,Le)}}},this.readRenderTargetPixelsAsync=async function(S,I,B,z,F,se,me,ye=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ve=ne.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&me!==void 0&&(ve=ve[me]),ve)if(I>=0&&I<=S.width-z&&B>=0&&B<=S.height-F){J.bindFramebuffer(b.FRAMEBUFFER,ve);const Le=S.textures[ye],Ie=Le.format,Pe=Le.type;if(!Z.textureFormatReadable(Ie))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Xe=b.createBuffer();b.bindBuffer(b.PIXEL_PACK_BUFFER,Xe),b.bufferData(b.PIXEL_PACK_BUFFER,se.byteLength,b.STREAM_READ),S.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+ye),b.readPixels(I,B,z,F,Re.convert(Ie),Re.convert(Pe),0);const je=U!==null?ne.get(U).__webglFramebuffer:null;J.bindFramebuffer(b.FRAMEBUFFER,je);const ht=b.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);return b.flush(),await fo(b,ht,4),b.bindBuffer(b.PIXEL_PACK_BUFFER,Xe),b.getBufferSubData(b.PIXEL_PACK_BUFFER,0,se),b.deleteBuffer(Xe),b.deleteSync(ht),se}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,I=null,B=0){const z=Math.pow(2,-B),F=Math.floor(S.image.width*z),se=Math.floor(S.image.height*z),me=I!==null?I.x:0,ye=I!==null?I.y:0;he.setTexture2D(S,0),b.copyTexSubImage2D(b.TEXTURE_2D,B,0,0,me,ye,F,se),J.unbindTexture()};const Xa=b.createFramebuffer(),qa=b.createFramebuffer();this.copyTextureToTexture=function(S,I,B=null,z=null,F=0,se=null){se===null&&(F!==0?(fi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),se=F,F=0):se=0);let me,ye,ve,Le,Ie,Pe,Xe,je,ht;const st=S.isCompressedTexture?S.mipmaps[se]:S.image;if(B!==null)me=B.max.x-B.min.x,ye=B.max.y-B.min.y,ve=B.isBox3?B.max.z-B.min.z:1,Le=B.min.x,Ie=B.min.y,Pe=B.isBox3?B.min.z:0;else{const It=Math.pow(2,-F);me=Math.floor(st.width*It),ye=Math.floor(st.height*It),S.isDataArrayTexture?ve=st.depth:S.isData3DTexture?ve=Math.floor(st.depth*It):ve=1,Le=0,Ie=0,Pe=0}z!==null?(Xe=z.x,je=z.y,ht=z.z):(Xe=0,je=0,ht=0);const tt=Re.convert(I.format),De=Re.convert(I.type);let ot;I.isData3DTexture?(he.setTexture3D(I,0),ot=b.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(he.setTexture2DArray(I,0),ot=b.TEXTURE_2D_ARRAY):(he.setTexture2D(I,0),ot=b.TEXTURE_2D),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,I.flipY),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),b.pixelStorei(b.UNPACK_ALIGNMENT,I.unpackAlignment);const Je=b.getParameter(b.UNPACK_ROW_LENGTH),Rt=b.getParameter(b.UNPACK_IMAGE_HEIGHT),An=b.getParameter(b.UNPACK_SKIP_PIXELS),Ct=b.getParameter(b.UNPACK_SKIP_ROWS),Kn=b.getParameter(b.UNPACK_SKIP_IMAGES);b.pixelStorei(b.UNPACK_ROW_LENGTH,st.width),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,st.height),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Le),b.pixelStorei(b.UNPACK_SKIP_ROWS,Ie),b.pixelStorei(b.UNPACK_SKIP_IMAGES,Pe);const lt=S.isDataArrayTexture||S.isData3DTexture,Ut=I.isDataArrayTexture||I.isData3DTexture;if(S.isDepthTexture){const It=ne.get(S),St=ne.get(I),Tt=ne.get(It.__renderTarget),tr=ne.get(St.__renderTarget);J.bindFramebuffer(b.READ_FRAMEBUFFER,Tt.__webglFramebuffer),J.bindFramebuffer(b.DRAW_FRAMEBUFFER,tr.__webglFramebuffer);for(let un=0;un<ve;un++)lt&&(b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,ne.get(S).__webglTexture,F,Pe+un),b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,ne.get(I).__webglTexture,se,ht+un)),b.blitFramebuffer(Le,Ie,me,ye,Xe,je,me,ye,b.DEPTH_BUFFER_BIT,b.NEAREST);J.bindFramebuffer(b.READ_FRAMEBUFFER,null),J.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else if(F!==0||S.isRenderTargetTexture||ne.has(S)){const It=ne.get(S),St=ne.get(I);J.bindFramebuffer(b.READ_FRAMEBUFFER,Xa),J.bindFramebuffer(b.DRAW_FRAMEBUFFER,qa);for(let Tt=0;Tt<ve;Tt++)lt?b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,It.__webglTexture,F,Pe+Tt):b.framebufferTexture2D(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,It.__webglTexture,F),Ut?b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,St.__webglTexture,se,ht+Tt):b.framebufferTexture2D(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,St.__webglTexture,se),F!==0?b.blitFramebuffer(Le,Ie,me,ye,Xe,je,me,ye,b.COLOR_BUFFER_BIT,b.NEAREST):Ut?b.copyTexSubImage3D(ot,se,Xe,je,ht+Tt,Le,Ie,me,ye):b.copyTexSubImage2D(ot,se,Xe,je,Le,Ie,me,ye);J.bindFramebuffer(b.READ_FRAMEBUFFER,null),J.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else Ut?S.isDataTexture||S.isData3DTexture?b.texSubImage3D(ot,se,Xe,je,ht,me,ye,ve,tt,De,st.data):I.isCompressedArrayTexture?b.compressedTexSubImage3D(ot,se,Xe,je,ht,me,ye,ve,tt,st.data):b.texSubImage3D(ot,se,Xe,je,ht,me,ye,ve,tt,De,st):S.isDataTexture?b.texSubImage2D(b.TEXTURE_2D,se,Xe,je,me,ye,tt,De,st.data):S.isCompressedTexture?b.compressedTexSubImage2D(b.TEXTURE_2D,se,Xe,je,st.width,st.height,tt,st.data):b.texSubImage2D(b.TEXTURE_2D,se,Xe,je,me,ye,tt,De,st);b.pixelStorei(b.UNPACK_ROW_LENGTH,Je),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,Rt),b.pixelStorei(b.UNPACK_SKIP_PIXELS,An),b.pixelStorei(b.UNPACK_SKIP_ROWS,Ct),b.pixelStorei(b.UNPACK_SKIP_IMAGES,Kn),se===0&&I.generateMipmaps&&b.generateMipmap(ot),J.unbindTexture()},this.initRenderTarget=function(S){ne.get(S).__webglFramebuffer===void 0&&he.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?he.setTextureCube(S,0):S.isData3DTexture?he.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?he.setTexture2DArray(S,0):he.setTexture2D(S,0),J.unbindTexture()},this.resetState=function(){w=0,D=0,U=null,J.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ze._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ze._getUnpackColorSpace()}}class md extends Ji{constructor(){super();const e=new Tn;e.deleteAttribute("uv");const t=new Gr({side:1}),n=new Gr,r=new Ia(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);const s=new ft(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),this.add(s);const a=new Vo(e,n,6),o=new _t;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);const c=new ft(e,Gn(50));c.position.set(-16.116,14.37,8.208),c.scale.set(.1,2.428,2.739),this.add(c);const l=new ft(e,Gn(50));l.position.set(-16.109,18.021,-8.207),l.scale.set(.1,2.425,2.751),this.add(l);const h=new ft(e,Gn(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);const f=new ft(e,Gn(43));f.position.set(-.462,8.89,14.52),f.scale.set(4.38,5.441,.088),this.add(f);const d=new ft(e,Gn(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);const u=new ft(e,Gn(100));u.position.set(0,20,0),u.scale.set(1,.1,1),this.add(u)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function Gn(i){return new Tl({color:0,emissive:16777215,emissiveIntensity:i})}const ri=new P;function Nt(i,e,t,n,r,s){const a=2*Math.PI*r/4,o=Math.max(s-2*r,0),c=Math.PI/4;ri.copy(e),ri[n]=0,ri.normalize();const l=.5*a/(a+o),h=1-ri.angleTo(i)/c;return Math.sign(ri[t])===1?h*l:o/(a+o)+l+l*(1-h)}class ns extends Tn{constructor(e=1,t=1,n=1,r=2,s=.1){const a=r*2+1;if(s=Math.min(e/2,t/2,n/2,s),super(1,1,1,a,a,a),this.type="RoundedBoxGeometry",this.parameters={width:e,height:t,depth:n,segments:r,radius:s},a===1)return;const o=this.toNonIndexed();this.index=null,this.attributes.position=o.attributes.position,this.attributes.normal=o.attributes.normal,this.attributes.uv=o.attributes.uv;const c=new P,l=new P,h=new P(e,t,n).divideScalar(2).subScalar(s),f=this.attributes.position.array,d=this.attributes.normal.array,u=this.attributes.uv.array,g=f.length/6,_=new P,m=.5/a;for(let p=0,A=0;p<f.length;p+=3,A+=2)switch(c.fromArray(f,p),l.copy(c),l.x-=Math.sign(l.x)*m,l.y-=Math.sign(l.y)*m,l.z-=Math.sign(l.z)*m,l.normalize(),f[p+0]=h.x*Math.sign(c.x)+l.x*s,f[p+1]=h.y*Math.sign(c.y)+l.y*s,f[p+2]=h.z*Math.sign(c.z)+l.z*s,d[p+0]=l.x,d[p+1]=l.y,d[p+2]=l.z,Math.floor(p/g)){case 0:_.set(1,0,0),u[A+0]=Nt(_,l,"z","y",s,n),u[A+1]=1-Nt(_,l,"y","z",s,t);break;case 1:_.set(-1,0,0),u[A+0]=1-Nt(_,l,"z","y",s,n),u[A+1]=1-Nt(_,l,"y","z",s,t);break;case 2:_.set(0,1,0),u[A+0]=1-Nt(_,l,"x","z",s,e),u[A+1]=Nt(_,l,"z","x",s,n);break;case 3:_.set(0,-1,0),u[A+0]=1-Nt(_,l,"x","z",s,e),u[A+1]=1-Nt(_,l,"z","x",s,n);break;case 4:_.set(0,0,1),u[A+0]=1-Nt(_,l,"x","y",s,e),u[A+1]=1-Nt(_,l,"y","x",s,t);break;case 5:_.set(0,0,-1),u[A+0]=Nt(_,l,"x","y",s,e),u[A+1]=1-Nt(_,l,"y","x",s,t);break}}static fromJSON(e){return new ns(e.width,e.height,e.depth,e.segments,e.radius)}}class gd{constructor(){mt(this,"geometries",new Set);mt(this,"materials",new Set);mt(this,"textures",new Set)}material(e){const t=new La(e);return this.materials.add(t),t}texture(e,t=1){const n=new Xo(e);return n.colorSpace=bt,n.wrapS=n.wrapT=1e3,n.repeat.set(t,t),n.anisotropy=4,this.textures.add(n),n}mesh(e,t,n,r=[0,0,0]){this.geometries.add(t);const s=new ft(t,n);return s.position.set(r[0],r[1],r[2]),s.castShadow=!0,s.receiveShadow=!0,e.add(s),s}box(e,t,n,r,s=.025){return this.mesh(e,new ns(t[0],t[1],t[2],2,Math.min(s,Math.min(...t)*.45)),r,n)}sphere(e,t,n,r){const s=this.mesh(e,new Qr(1,28,18),r,n);return s.scale.set(t[0],t[1],t[2]),s}cylinder(e,t,n,r,s,a=r){const o=new P(...t),c=new P(...n),l=this.mesh(e,new Qt(a,r,o.distanceTo(c),20),s);return l.position.copy(o.add(c).multiplyScalar(.5)),l.quaternion.setFromUnitVectors(new P(0,1,0),new P(...n).sub(new P(...t)).normalize()),l}tube(e,t,n,r){const s=new Or(t.map(a=>new P(...a)));return this.mesh(e,new es(s,28,n,8,!1),r)}tapered(e,t,n,r){const s=new Or(t.map(d=>new P(...d))),a=28,o=12,c=s.computeFrenetFrames(a,!1),l=[],h=[];for(let d=0;d<=a;d++){const u=s.getPointAt(d/a),g=n*Math.pow(1-d/a,.8)+.001;for(let _=0;_<=o;_++){const m=_/o*Math.PI*2,p=u.clone().addScaledVector(c.normals[d],Math.cos(m)*g).addScaledVector(c.binormals[d],Math.sin(m)*g);if(l.push(p.x,p.y,p.z),d<a&&_<o){const A=d*(o+1)+_;h.push(A,A+o+1,A+1,A+1,A+o+1,A+o+2)}}}const f=new wt;return f.setAttribute("position",new at(l,3)),f.setIndex(h),f.computeVertexNormals(),this.mesh(e,f,r)}dispose(){this.geometries.forEach(e=>e.dispose()),this.materials.forEach(e=>e.dispose()),this.textures.forEach(e=>e.dispose()),this.geometries.clear(),this.materials.clear(),this.textures.clear()}}function Nr(i=512){const e=document.createElement("canvas");return e.width=e.height=i,{canvas:e,ctx:e.getContext("2d")}}function ha(i){return()=>(i=Math.imul(i,1664525)+1013904223|0,(i>>>0)/4294967296)}function _d(i){const e=(l,h)=>{const f=Nr(),d=ha(81);f.ctx.fillStyle=l,f.ctx.fillRect(0,0,512,512);for(let u=0;u<180;u++){const g=d()*512;f.ctx.strokeStyle=h,f.ctx.globalAlpha=.02+d()*.05,f.ctx.lineWidth=.8+d()*1.5,f.ctx.beginPath(),f.ctx.moveTo(0,g),f.ctx.bezierCurveTo(120,g+d()*12,350,g-d()*8,512,g+d()*4),f.ctx.stroke()}return i.texture(f.canvas)},t=Nr(256);t.ctx.fillStyle="#bf9a52",t.ctx.fillRect(0,0,256,256);for(let l=-16;l<272;l+=16)for(let h=0;h<256;h+=16)t.ctx.lineCap="round",t.ctx.strokeStyle="#ab8849",t.ctx.lineWidth=5,t.ctx.beginPath(),t.ctx.moveTo(h+3,l+2),t.ctx.lineTo(h+8,l+14),t.ctx.lineTo(h+13,l+2),t.ctx.stroke(),t.ctx.strokeStyle="#cdae6d",t.ctx.lineWidth=2,t.ctx.beginPath(),t.ctx.moveTo(h+4,l+2),t.ctx.lineTo(h+8,l+12),t.ctx.lineTo(h+12,l+2),t.ctx.stroke();const n=i.texture(t.canvas,2.5),r=Nr(),s=ha(71);r.ctx.fillStyle="#7b8a7d",r.ctx.fillRect(0,0,512,512);for(let l=0;l<4e3;l++)r.ctx.fillStyle=s()>.5?"#d3d3be":"#6d8176",r.ctx.globalAlpha=.025,r.ctx.fillRect(s()*512,s()*512,1.5,1.5);const a=e("#9c754b","#352818"),o=e("#934b39","#331b12");return{blue:i.material({color:"#486872",metalness:.35,roughness:.46,clearcoat:.18,clearcoatRoughness:.3}),darkBlue:i.material({color:"#273e48",metalness:.4,roughness:.43}),red:i.material({map:o,bumpMap:o,bumpScale:.0025,roughness:.65}),oak:i.material({map:a,bumpMap:a,bumpScale:.001,roughness:.72}),knit:i.material({map:n,bumpMap:n,bumpScale:.008,roughness:.94,sheen:.55,sheenColor:"#dac594"}),brass:i.material({color:"#ba9661",metalness:.77,roughness:.36}),iron:i.material({color:"#202b2e",metalness:.65,roughness:.46}),ivory:i.material({color:"#ede1ba",roughness:.43}),amber:i.material({color:"#edc96b",roughness:.2,metalness:.16,clearcoat:1,emissive:"#b88b36",emissiveIntensity:.12}),black:i.material({color:"#101718",roughness:.42}),tongue:i.material({color:"#9c6050",roughness:.7}),membrane:i.material({color:"#bda064",roughness:.9,side:2}),wall:i.material({map:i.texture(r.canvas,2),roughness:1}),cream:i.material({color:"#ded2b5",roughness:.86}),green:i.material({color:"#2d573d",roughness:.68,side:2}),terracotta:i.material({color:"#9b6650",roughness:.9}),glow:i.material({color:"#ffdf9c",emissive:"#ffcb75",emissiveIntensity:2,roughness:1})}}function vd(i,e,t,n){t.box(i,[12,.1,12],[0,-.07,0],t.material({color:"#827565",roughness:1})).castShadow=!1,t.box(i,[11,6,.16],[0,2.8,-2.2],n.wall).castShadow=!1,t.box(i,[.16,6,9],[-4.5,2.8,0],n.cream).castShadow=!1;const r=document.createElement("canvas");r.width=64,r.height=256;const s=r.getContext("2d"),a=s.createLinearGradient(0,0,0,256);a.addColorStop(0,"#405d68"),a.addColorStop(.7,"#8ba09d"),a.addColorStop(1,"#b7b49c"),s.fillStyle=a,s.fillRect(0,0,64,256);const o=t.texture(r),c=t.material({map:o,emissive:"#b1c6c9",emissiveMap:o,emissiveIntensity:.25,roughness:1});t.box(i,[2.05,2.48,.1],[-2.65,2.48,-2.08],n.darkBlue,.025),t.box(i,[1.9,2.33,.035],[-2.65,2.48,-2.01],c,.005),t.box(i,[.045,2.35,.06],[-2.65,2.48,-1.97],n.darkBlue,.005),t.box(i,[2.2,.09,.3],[-2.65,1.21,-1.9],n.oak),t.box(i,[1.65,.86,.55],[2,.54,-1.6],n.oak,.04),t.mesh(i,new Qt(.25,.2,.42,32),n.terracotta,[2,1.18,-1.58]),t.mesh(i,new Qt(.225,.225,.02,32),n.iron,[2,1.39,-1.58]);for(let h=0;h<6;h++){const f=h*2.4,d=1.6+h*.14,u=2+Math.sin(f)*.3,g=-1.58+Math.cos(f)*.26;t.tube(i,[[2,1.38,-1.58],[2,d-.1,-1.58],[u,d,g]],.012,n.green),t.sphere(i,[.11,.018,.24],[u,d,g],n.green).rotation.set(.4,f,-Math.sin(f)*.3)}t.mesh(i,new Qt(.27,.3,.06,32),n.darkBlue,[-1.9,.04,-1.3]),t.cylinder(i,[-1.9,.07,-1.3],[-1.9,1.9,-1.3],.022,n.brass),t.mesh(i,new Qt(.22,.35,.39,32,1,!0),n.cream,[-1.9,2,-1.3]),t.sphere(i,[.23,.015,.23],[-1.9,1.81,-1.3],n.glow);const l=new Ia("#ffd6a4",5,4,2);l.position.set(-1.9,1.8,-1.3),i.add(l),e.add(l.clone()),t.box(e,[1.18,1.3,.18],[0,1.3,-.65],n.darkBlue,.16),t.box(e,[1.12,.16,.9],[0,.72,-.24],n.darkBlue,.07),t.cylinder(e,[0,.16,-.3],[0,.68,-.3],.07,n.iron),t.box(e,[4.9,.16,2.1],[0,.94,1.1],n.oak,.055);for(const h of[-2.15,2.15])for(const f of[.34,1.88])t.box(e,[.08,.91,.08],[h,.43,f],n.iron,.015)}function xd(i,e,t){const n=new At;i.add(n),n.position.set(0,0,-.12),n.rotation.y=.12;const r=new At;n.add(r),e.sphere(r,[.56,.64,.38],[0,1.48,0],t.knit),e.box(r,[.42,.48,.12],[0,1.53,.35],t.blue,.12);for(let u=0;u<5;u++)e.box(r,[.27,.018,.025],[0,1.4+u*.06,.418],t.iron,.008);e.sphere(r,[.018,.018,.012],[.13,1.75,.415],t.glow),e.cylinder(r,[0,1.93,0],[0,2.19,.05],.24,t.darkBlue,.22);for(let u=0;u<4;u++){const g=e.mesh(r,new $i(.236,.025,8,32),t.brass,[0,1.99+u*.055,.02]);g.rotation.x=Math.PI/2}const s=[];for(const u of[-1,1]){const g=new At;g.position.set(u*.43,1.87,-.33),g.scale.x=u,g.rotation.y=u*-.28,n.add(g),s.push(g);const _=new Ki;_.moveTo(0,0),_.lineTo(.2,.89),_.lineTo(1.15,.73),_.quadraticCurveTo(.91,.62,.94,.37),_.quadraticCurveTo(.64,.4,.55,.08),_.quadraticCurveTo(.28,.19,0,0),e.mesh(g,new jr(_,24),t.membrane,[0,0,.005]);for(const[m,p]of[[[0,0,0],[.2,.89,0]],[[.2,.89,0],[1.15,.73,0]],[[.2,.89,0],[.94,.37,0]],[[.2,.89,0],[.55,.08,0]]])e.cylinder(g,m,p,.042,t.red);for(const m of[[0,0,.035],[.2,.89,.035]])e.sphere(g,[.075,.075,.035],m,t.darkBlue),e.sphere(g,[.032,.032,.016],[m[0],m[1],m[2]+.025],t.brass)}e.tapered(n,[[.28,.82,-.24],[.88,.44,-.48],[1.38,.32,-.04],[1.52,.58,.46],[1.25,.79,.55]],.22,t.blue);for(let u=0;u<5;u++){const g=e.mesh(n,new Jr(.095-u*.008,.18,4),t.red,[.6+u*.19,.63-Math.sin(u*.6)*.1,-.36+u*.12]);g.rotation.z=-.15}const a=[];for(const u of[-1,1]){const g=new At;g.position.set(u*.47,1.77,.03),n.add(g),a.push(g),e.cylinder(g,[0,0,0],[u*.24,-.39,.2],.17,t.knit,.145),e.sphere(g,[.16,.18,.19],[u*.05,-.03,0],t.blue),e.sphere(g,[.055,.18,.18],[u*.18,-.035,.01],t.red),e.sphere(g,[.024,.065,.065],[u*.233,-.035,.01],t.brass),e.sphere(g,[.15,.13,.14],[u*.24,-.39,.2],t.darkBlue),e.cylinder(g,[u*.24,-.39,.22],[u*.17,-.62,.63],.14,t.knit,.115),e.cylinder(g,[u*.17,-.61,.59],[u*.16,-.65,.68],.128,t.brass),e.box(g,[.29,.13,.29],[u*.14,-.69,.75],t.blue,.05);for(let _=-1;_<=1;_++){const m=u*.14+_*.095;e.sphere(g,[.047,.046,.07],[m,-.69,.9],t.darkBlue),e.tapered(g,[[m,-.69,.91],[m,-.7,.99],[m,-.755,1.055]],.037,t.ivory)}}const o=new At;o.position.set(0,2.25,.13),n.add(o),e.box(o,[.98,.72,.81],[0,.08,0],t.blue,.19),e.box(o,[.86,.32,.94],[0,-.19,.56],t.blue,.11),e.box(o,[.15,.43,.08],[0,.16,.423],t.red,.025),e.box(o,[.16,.045,.71],[0,-.009,.66],t.red,.018);for(const u of[-1,1]){e.sphere(o,[.07,.22,.29],[u*.48,-.16,.15],t.red),e.sphere(o,[.018,.083,.083],[u*.546,-.15,.16],t.brass),e.sphere(o,[.012,.047,.047],[u*.56,-.15,.16],t.iron),e.box(o,[.035,.008,.07],[u*.57,-.15,.16],t.brass,.002);const g=new At;g.position.set(u*.28,-.095,1.006),g.rotation.x=-.15,o.add(g);const _=e.mesh(g,new $i(.071,.018,10,28),t.darkBlue);_.scale.y=1.1,e.sphere(g,[.056,.063,.012],[0,0,-.009],t.black);for(let p=0;p<3;p++)e.sphere(o,[.012,.012,.009],[u*.35,-.29,.48+p*.17],t.brass);const m=new Ki;m.moveTo(0,0),m.lineTo(u*.37,.12),m.lineTo(u*.17,-.12),m.closePath(),e.mesh(o,new $r(m,{depth:.06,bevelEnabled:!0,bevelSize:.02,bevelThickness:.01,bevelSegments:2,steps:1}),t.red,[u*.43,.22,-.13])}const c=[],l=[];for(const u of[-1,1]){const g=new At;g.position.set(u*.322,.19,.397),g.rotation.y=u*.28,o.add(g),e.sphere(g,[.19,.205,.06],[0,0,0],t.darkBlue);const _=new At;g.add(_),c.push(_),e.sphere(_,[.15,.166,.065],[0,0,.024],t.amber);const m=new At;m.position.set(.018,.006,.083),_.add(m),l.push(m),e.sphere(m,[.034,.103,.014],[0,0,0],t.black),e.sphere(_,[.029,.035,.009],[-.042,.067,.084],t.ivory),e.sphere(_,[.011,.013,.008],[.052,-.048,.083],t.ivory);const p=e.box(g,[.34,.065,.095],[0,.185,.04],t.red,.025);p.rotation.z=u*.09}const h=new At;h.position.set(0,-.405,-.02),o.add(h),e.box(h,[.9,.17,1.11],[0,-.06,.55],t.red,.08);const f=e.box(h,[.78,.06,.94],[0,.03,.6],t.black,.03);e.sphere(h,[.17,.018,.15],[0,.063,.88],t.tongue);for(const u of[-1,1])e.tapered(o,[[u*.32,-.32,.84],[u*.32,-.38,.87]],.03,t.ivory),e.tube(o,[[u*.41,-.31,.3],[u*.43,-.33,.66],[u*.38,-.32,1.005]],.018,t.darkBlue);e.sphere(o,[.54,.37,.46],[0,.63,-.035],t.knit);const d=e.mesh(o,new Qt(.53,.53,.17,64),t.knit,[0,.4,-.025]);d.scale.z=.88;for(let u=0;u<44;u++){const g=u/44*Math.PI*2;e.cylinder(o,[Math.sin(g)*.532,.325,Math.cos(g)*.471-.025],[Math.sin(g)*.532,.474,Math.cos(g)*.471-.025],.009,t.knit)}e.box(o,[.13,.105,.017],[.21,.4,.435],t.darkBlue,.008);for(let u=0;u<3;u++)e.box(o,[.012,.045-u*.007,.01],[.18+u*.027,.4,.449],t.brass,.002);for(const u of[-1,1])e.tapered(o,[[u*.425,.6,-.1],[u*.64,.78,-.1],[u*.68,1.03,-.15],[u*.56,1.2,-.17]],.1,t.ivory);return e.sphere(o,[.08,.07,.08],[0,.994,-.035],t.knit),{update(u){o.rotation.set(u.headPitch,u.headYaw,u.headRoll),o.position.y=2.25+u.breath,r.scale.y=1+u.breath*.4,h.rotation.x=u.jaw*.3,f.scale.x=1-u.round*.08,c.forEach(g=>{g.scale.y=Math.max(.055,1-u.blink*.95)}),l.forEach(g=>{g.position.x=.018+u.gazeX,g.position.y=.006+u.gazeY}),a[1].rotation.z=u.gesture*.035,a[1].rotation.x=-u.gesture*.035,s.forEach((g,_)=>{g.rotation.z=(_?-1:1)*u.breath*.8})}}}const kr=(i,e=0,t=1)=>Math.min(t,Math.max(e,i));function Md(i){const e=Math.max(1,Math.floor(i.sampleRate/80)),t=Math.ceil(i.samples.length/e),n=new Float32Array(t),r=new Float32Array(t);for(let d=0;d<t;d++){let u=0;const g=Math.min(i.samples.length,(d+1)*e);for(let _=d*e;_<g;_++)u+=i.samples[_]**2;n[d]=Math.sqrt(u/Math.max(1,g-d*e))}const s=Array.from(n).sort((d,u)=>d-u),a=Math.max(.012,s[Math.floor(s.length*.92)]||0);let o=0;for(let d=0;d<t;d++)n[d]=kr((n[d]/a-.055)/.945),o+=n[d]>.035?.25+Math.sqrt(n[d]):0,r[d]=o;if(o)for(let d=0;d<t;d++)r[d]/=o;const l=(i.text.toLowerCase().match(/sh|ch|th|ee|oo|ou|ow|[a-z]/g)||[]).map(d=>/^[bmp]$/.test(d)?{open:0,round:0,weight:.7}:/^(oo|ou|ow|o|u|w)$/.test(d)?{open:.6,round:1,weight:1.25}:/^(ee|e|i|y)$/.test(d)?{open:.48,round:-.4,weight:1.1}:d==="a"?{open:1,round:0,weight:1.4}:/^[fv]$/.test(d)?{open:.2,round:-.15,weight:.9}:{open:.35,round:.1,weight:.8}),h=l.reduce((d,u)=>d+u.weight,0);let f=0;for(const d of l)f+=d.weight/Math.max(1,h),d.weight=f;return{amplitude:n,progress:r,shapes:l,duration:i.duration,questioning:/\?\s*$/.test(i.text)}}function Sd(i,e){if(!Number.isFinite(e)||e<0||e>=i.duration||!i.amplitude.length)return{jaw:0,round:0,energy:0};const t=Math.min(i.amplitude.length-1,Math.floor(e/i.duration*i.amplitude.length)),n=i.amplitude[t],r=i.shapes.find(s=>s.weight>=i.progress[t])||{open:.6,round:0};return{jaw:n*r.open,round:r.round*n,energy:n}}class yd{constructor(){mt(this,"cue",null);mt(this,"track",null);mt(this,"jaw",0);mt(this,"round",0)}sample(e,t,n){var g,_;this.cue!==e.playback&&(this.cue=e.playback,this.track=this.cue&&!this.cue.level?Md(this.cue):null,this.jaw=0,this.round=0);const r=this.cue?this.cue.now()-this.cue.startedAt:NaN,s=e.mode==="speaking"&&this.cue&&Number.isFinite(r)&&r>=0&&r<this.cue.duration;let a=0;if(s&&((g=this.cue)!=null&&g.level))try{const m=this.cue.level();a=Number.isFinite(m)?kr(m):0}catch{}const o=s&&this.track?Sd(this.track,r):a>.02?{jaw:Math.sqrt(a)*.7,round:0,energy:a}:{jaw:0,round:0,energy:0},c=1-Math.exp(-Math.min(n,.1)*28);this.jaw=s&&o.energy>0?this.jaw+(o.jaw-this.jaw)*c:0,this.round=s&&o.energy>0?this.round+(o.round-this.round)*c:0;const l=e.motion&&e.mode!=="ended",h=e.mode==="listening",f=e.mode==="thinking",d=t%5.7,u=d>5.35?Math.sin(kr((d-5.35)/.24)*Math.PI):0;return{jaw:l?this.jaw:0,round:l?this.round:0,smile:.35,blink:l?u:0,headPitch:l?(h?.025:f?-.035:0)+Math.sin(t*1.5)*.009+o.energy*Math.sin(t*3.4)*.025:0,headYaw:l?(f?-.12:0)+Math.sin(t*.35)*.028:0,headRoll:l?(h?-.035:0)+Math.sin(t*.8)*.008+(s&&((_=this.track)!=null&&_.questioning)?.035:0):0,gazeX:l&&f?-.04:0,gazeY:l&&f?.025:0,breath:l?Math.sin(t*1.4)*.008:0,gesture:l&&s?Math.max(0,Math.sin(t*1.7))*o.energy:0}}dispose(){this.cue=null,this.track=null}}const ua=`varying vec2 vUv;
|
|
3841
|
+
void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }`,Ed=`uniform sampler2D image; uniform vec2 stepSize; varying vec2 vUv;
|
|
3842
|
+
void main() {
|
|
3843
|
+
gl_FragColor = texture2D(image, vUv) * 0.137022;
|
|
3844
|
+
gl_FragColor += (texture2D(image, vUv + stepSize) + texture2D(image, vUv - stepSize)) * 0.129618;
|
|
3845
|
+
gl_FragColor += (texture2D(image, vUv + stepSize * 2.0) + texture2D(image, vUv - stepSize * 2.0)) * 0.109719;
|
|
3846
|
+
gl_FragColor += (texture2D(image, vUv + stepSize * 3.0) + texture2D(image, vUv - stepSize * 3.0)) * 0.083109;
|
|
3847
|
+
gl_FragColor += (texture2D(image, vUv + stepSize * 4.0) + texture2D(image, vUv - stepSize * 4.0)) * 0.056331;
|
|
3848
|
+
gl_FragColor += (texture2D(image, vUv + stepSize * 5.0) + texture2D(image, vUv - stepSize * 5.0)) * 0.034166;
|
|
3849
|
+
gl_FragColor += (texture2D(image, vUv + stepSize * 6.0) + texture2D(image, vUv - stepSize * 6.0)) * 0.018544;
|
|
3850
|
+
}`;class Td{constructor(e){mt(this,"targets");mt(this,"geometry",new vi(2,2));mt(this,"blur",new Xt({vertexShader:ua,fragmentShader:Ed,toneMapped:!1,depthTest:!1,depthWrite:!1,uniforms:{image:{value:null},stepSize:{value:new le}}}));mt(this,"display",new Xt({vertexShader:ua,depthTest:!1,depthWrite:!1,uniforms:{image:{value:null}},fragmentShader:`uniform sampler2D image; varying vec2 vUv;
|
|
3851
|
+
void main() { gl_FragColor = texture2D(image, vUv);
|
|
3852
|
+
#include <tonemapping_fragment>
|
|
3853
|
+
#include <colorspace_fragment>
|
|
3854
|
+
}`}));mt(this,"screen",new Ji);mt(this,"camera",new qr);mt(this,"quad",new ft(this.geometry,this.blur));mt(this,"dirty",!0);mt(this,"disposed",!1);mt(this,"renders",0);this.renderer=e;const t=e.extensions.has("EXT_color_buffer_float")?1016:1009;this.targets=Array.from({length:2},()=>new cn(1,1,{type:t,depthBuffer:!0})),this.quad.frustumCulled=!1,this.screen.add(this.quad)}resize(e,t){const n=Math.max(1,Math.round(Math.min(640,e*.5))),r=Math.max(1,Math.round(n*t/e));this.dirty=!0,!(n===this.targets[0].width&&r===this.targets[0].height)&&this.targets.forEach(s=>s.setSize(n,r))}render(e,t,n){if(this.disposed)return;const r=this.renderer,s=r.getRenderTarget(),a=r.autoClear;try{if(r.autoClear=!0,this.dirty){const[o,c]=this.targets;r.setRenderTarget(o),r.render(e,t),this.quad.material=this.blur,this.blur.uniforms.image.value=o.texture,this.blur.uniforms.stepSize.value.set(1/o.width,0),r.setRenderTarget(c),r.render(this.screen,this.camera),this.blur.uniforms.image.value=c.texture,this.blur.uniforms.stepSize.value.set(0,1/o.height),r.setRenderTarget(o),r.render(this.screen,this.camera),this.display.uniforms.image.value=o.texture,this.dirty=!1,this.renders++,r.shadowMap.needsUpdate=!0}this.quad.material=this.display,r.setRenderTarget(s),r.render(this.screen,this.camera),r.autoClear=!1,r.clearDepth(),r.render(n,t)}finally{r.setRenderTarget(s),r.autoClear=a}}dispose(){this.disposed||(this.disposed=!0,this.targets.forEach(e=>e.dispose()),this.geometry.dispose(),this.blur.dispose(),this.display.dispose(),this.screen.clear())}}function bd(i){const e=new pd({canvas:i,antialias:!1,alpha:!1,preserveDrawingBuffer:!0,powerPreference:"low-power"}),t=new gd,n=new Ji,r=new Ji,s=new yd;let a,o;try{const c=e.getContext(),l=c.getExtension("WEBGL_debug_renderer_info"),h=l?/swiftshader|llvmpipe|software/i.test(c.getParameter(l.UNMASKED_RENDERER_WEBGL)):!1,f=h?16e4:9e5;i.dataset.quality=h?"economy":"full",e.shadowMap.enabled=!h,e.shadowMap.type=2,e.shadowMap.autoUpdate=!1,e.shadowMap.needsUpdate=!0,e.toneMapping=4,e.toneMappingExposure=.95,e.outputColorSpace=bt,r.background=new ke("#849087");const d=new Vr(e),u=new md;try{a=d.fromScene(u,.04),n.environment=a.texture,n.environmentIntensity=.3}finally{u.dispose(),d.dispose()}r.environment=n.environment,r.environmentIntensity=n.environmentIntensity,n.add(new wl("#dde7e4","#64513a",.65));const g=new Cr("#ffead0",2.1);g.position.set(-3,6,4),g.castShadow=!0,g.shadow.mapSize.set(h?512:1024,h?512:1024),g.shadow.camera.left=-4,g.shadow.camera.right=4,g.shadow.camera.top=5,g.shadow.camera.bottom=-3,g.shadow.camera.near=.5,g.shadow.camera.far=18,g.shadow.normalBias=.035,g.shadow.bias=-1e-4,n.add(g);const _=new Cr("#a3cad6",1);_.position.set(3.5,3.8,-.8),n.add(_);const m=new Cr("#ffe7c4",.45);m.position.set(.5,3,5),n.add(m);const p=_d(t);h&&t.materials.forEach(M=>{M instanceof La&&(M.clearcoat=0,M.sheen=0)}),n.children.forEach(M=>{if(M instanceof ji){const R=M.clone();R.castShadow=!1,r.add(R)}}),vd(r,n,t,p);const A=xd(n,t,p),E=new Lt(32,1,.1,35);E.position.set(1.3,2.65,5.8),E.lookAt(0,2.12,.15),o=new Td(e);let x={mode:"idle",motion:!0,playback:null},C=0,w=-1,D=0,U=0,y=!1;return{maxFps:h?10:30,update(M){x=M},resize(M,R){y||!M||!R||D===M&&U===R||(D=M,U=R,e.setPixelRatio(Math.min(window.devicePixelRatio||1,h?1:1.5,Math.sqrt(f/(D*U)))),e.setSize(D,U,!1),E.aspect=D/U,E.fov=us.radToDeg(2*Math.atan(Math.tan(us.degToRad(16))*Math.max(1,1.45/E.aspect))),E.updateProjectionMatrix(),o.resize(D,U))},render(M){if(y)return;const R=s.sample(x,M,C?M-C:1/30);C=M,A.update(R),M-w>(h?1.5:.5)&&(e.shadowMap.needsUpdate=!0,w=M),o.render(r,E,n),i.dataset.background="blurred",i.dataset.backgroundRenders=String(o.renders),i.dataset.mouth=String(Math.round(R.jaw*100))},dispose(){y||(y=!0,x={mode:"ended",motion:!1,playback:null},s.dispose(),g.shadow.dispose(),o==null||o.dispose(),t.dispose(),a==null||a.dispose(),n.clear(),r.clear(),e.dispose(),e.forceContextLoss(),delete i.dataset.mouth)}}}catch(c){throw o==null||o.dispose(),t.dispose(),a==null||a.dispose(),n.clear(),r.clear(),e.dispose(),e.forceContextLoss(),c}}export{bd as createPersonaScene};
|