4831 lines
1.8 MiB
JavaScript
4831 lines
1.8 MiB
JavaScript
|
|
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function b7(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var $b={exports:{}},$p={};/**
|
|||
|
|
* @license React
|
|||
|
|
* react-jsx-runtime.production.js
|
|||
|
|
*
|
|||
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|||
|
|
*
|
|||
|
|
* This source code is licensed under the MIT license found in the
|
|||
|
|
* LICENSE file in the root directory of this source tree.
|
|||
|
|
*/var U5;function SF(){if(U5)return $p;U5=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,r,s){var a=null;if(s!==void 0&&(a=""+s),r.key!==void 0&&(a=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:i,type:n,key:a,ref:r!==void 0?r:null,props:s}}return $p.Fragment=e,$p.jsx=t,$p.jsxs=t,$p}var B5;function TF(){return B5||(B5=1,$b.exports=SF()),$b.exports}var W=TF(),Xb={exports:{}},Xp={},Yb={exports:{}},Qb={};/**
|
|||
|
|
* @license React
|
|||
|
|
* scheduler.production.js
|
|||
|
|
*
|
|||
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|||
|
|
*
|
|||
|
|
* This source code is licensed under the MIT license found in the
|
|||
|
|
* LICENSE file in the root directory of this source tree.
|
|||
|
|
*/var O5;function wF(){return O5||(O5=1,(function(i){function e(Z,ae){var Ae=Z.length;Z.push(ae);e:for(;0<Ae;){var Se=Ae-1>>>1,xe=Z[Se];if(0<r(xe,ae))Z[Se]=ae,Z[Ae]=xe,Ae=Se;else break e}}function t(Z){return Z.length===0?null:Z[0]}function n(Z){if(Z.length===0)return null;var ae=Z[0],Ae=Z.pop();if(Ae!==ae){Z[0]=Ae;e:for(var Se=0,xe=Z.length,le=xe>>>1;Se<le;){var we=2*(Se+1)-1,He=Z[we],Te=we+1,ke=Z[Te];if(0>r(He,Ae))Te<xe&&0>r(ke,He)?(Z[Se]=ke,Z[Te]=Ae,Se=Te):(Z[Se]=He,Z[we]=Ae,Se=we);else if(Te<xe&&0>r(ke,Ae))Z[Se]=ke,Z[Te]=Ae,Se=Te;else break e}}return ae}function r(Z,ae){var Ae=Z.sortIndex-ae.sortIndex;return Ae!==0?Ae:Z.id-ae.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();i.unstable_now=function(){return a.now()-l}}var u=[],h=[],g=1,v=null,x=3,S=!1,w=!1,R=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function O(Z){for(var ae=t(h);ae!==null;){if(ae.callback===null)n(h);else if(ae.startTime<=Z)n(h),ae.sortIndex=ae.expirationTime,e(u,ae);else break;ae=t(h)}}function z(Z){if(R=!1,O(Z),!w)if(t(u)!==null)w=!0,G||(G=!0,ee());else{var ae=t(h);ae!==null&&ne(z,ae.startTime-Z)}}var G=!1,k=-1,H=5,F=-1;function V(){return C?!0:!(i.unstable_now()-F<H)}function X(){if(C=!1,G){var Z=i.unstable_now();F=Z;var ae=!0;try{e:{w=!1,R&&(R=!1,B(k),k=-1),S=!0;var Ae=x;try{t:{for(O(Z),v=t(u);v!==null&&!(v.expirationTime>Z&&V());){var Se=v.callback;if(typeof Se=="function"){v.callback=null,x=v.priorityLevel;var xe=Se(v.expirationTime<=Z);if(Z=i.unstable_now(),typeof xe=="function"){v.callback=xe,O(Z),ae=!0;break t}v===t(u)&&n(u),O(Z)}else n(u);v=t(u)}if(v!==null)ae=!0;else{var le=t(h);le!==null&&ne(z,le.startTime-Z),ae=!1}}break e}finally{v=null,x=Ae,S=!1}ae=void 0}}finally{ae?ee():G=!1}}}var ee;if(typeof L=="function")ee=function(){L(X)};else if(typeof MessageChannel<"u"){var te=new MessageChannel,se=te.port2;te.port1.onmessage=X,ee=function(){se.postMessage(null)}}else ee=function(){E(X,0)};function ne(Z,ae){k=E(function(){Z(i.unstable_now())},ae)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(Z){Z.callback=null},i.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<Z?Math.floor(1e3/Z):5},i.unstable_getCurrentPriorityLevel=function(){return x},i.unstable_next=function(Z){switch(x){case 1:case 2:case 3:var ae=3;break;default:ae=x}var Ae=x;x=ae;try{return Z()}finally{x=Ae}},i.unstable_requestPaint=function(){C=!0},i.unstable_runWithPriority=function(Z,ae){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var Ae=x;x=Z;try{return ae()}finally{x=Ae}},i.unstable_scheduleCallback=function(Z,ae,Ae){var Se=i.unstable_now();switch(typeof Ae=="object"&&Ae!==null?(Ae=Ae.delay,Ae=typeof Ae=="number"&&0<Ae?Se+Ae:Se):Ae=Se,Z){case 1:var xe=-1;break;case 2:xe=250;break;case 5:xe=1073741823;break;case 4:xe=1e4;break;default:xe=5e3}return xe=Ae+xe,Z={id:g++,callback:ae,priorityLevel:Z,startTime:Ae,expirationTime:xe,sortIndex:-1},Ae>Se?(Z.sortIndex=Ae,e(h,Z),t(u)===null&&Z===t(h)&&(R?(B(k),k=-1):R=!0,ne(z,Ae-Se))):(Z.sortIndex=xe,e(u,Z),w||S||(w=!0,G||(G=!0,ee()))),Z},i.unstable_shouldYield=V,i.unstable_wrapCallback=function(Z){var ae=x;return function(){var Ae=x;x=ae;try{return Z.apply(this,arguments)}finally{x=Ae}}}})(Qb)),Qb}var I5;function MF(){return I5||(I5=1,Yb.exports=wF()),Yb.exports}var Kb={exports:{}},Jn={};/**
|
|||
|
|
* @license React
|
|||
|
|
* react.production.js
|
|||
|
|
*
|
|||
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|||
|
|
*
|
|||
|
|
* This source code is licensed under the MIT license found in the
|
|||
|
|
* LICENSE file in the root directory of this source tree.
|
|||
|
|
*/var F5;function EF(){if(F5)return Jn;F5=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(le){return le===null||typeof le!="object"?null:(le=x&&le[x]||le["@@iterator"],typeof le=="function"?le:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,C={};function E(le,we,He){this.props=le,this.context=we,this.refs=C,this.updater=He||w}E.prototype.isReactComponent={},E.prototype.setState=function(le,we){if(typeof le!="object"&&typeof le!="function"&&le!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,le,we,"setState")},E.prototype.forceUpdate=function(le){this.updater.enqueueForceUpdate(this,le,"forceUpdate")};function B(){}B.prototype=E.prototype;function L(le,we,He){this.props=le,this.context=we,this.refs=C,this.updater=He||w}var O=L.prototype=new B;O.constructor=L,R(O,E.prototype),O.isPureReactComponent=!0;var z=Array.isArray;function G(){}var k={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function F(le,we,He){var Te=He.ref;return{$$typeof:i,type:le,key:we,ref:Te!==void 0?Te:null,props:He}}function V(le,we){return F(le.type,we,le.props)}function X(le){return typeof le=="object"&&le!==null&&le.$$typeof===i}function ee(le){var we={"=":"=0",":":"=2"};return"$"+le.replace(/[=:]/g,function(He){return we[He]})}var te=/\/+/g;function se(le,we){return typeof le=="object"&&le!==null&&le.key!=null?ee(""+le.key):we.toString(36)}function ne(le){switch(le.status){case"fulfilled":return le.value;case"rejected":throw le.reason;default:switch(typeof le.status=="string"?le.then(G,G):(le.status="pending",le.then(function(we){le.status==="pending"&&(le.status="fulfilled",le.value=we)},function(we){le.status==="pending"&&(le.status="rejected",le.reason=we)})),le.status){case"fulfilled":return le.value;case"rejected":throw le.reason}}throw le}function Z(le,we,He,Te,ke){var _e=typeof le;(_e==="undefined"||_e==="boolean")&&(le=null);var De=!1;if(le===null)De=!0;else switch(_e){case"bigint":case"string":case"number":De=!0;break;case"object":switch(le.$$typeof){case i:case e:De=!0;break;case g:return De=le._init,Z(De(le._payload),we,He,Te,ke)}}if(De)return ke=ke(le),De=Te===""?"."+se(le,0):Te,z(ke)?(He="",De!=null&&(He=De.replace(te,"$&/")+"/"),Z(ke,we,He,"",function(Je){return Je})):ke!=null&&(X(ke)&&(ke=V(ke,He+(ke.key==null||le&&le.key===ke.key?"":(""+ke.key).replace(te,"$&/")+"/")+De)),we.push(ke)),1;De=0;var Oe=Te===""?".":Te+":";if(z(le))for(var tt=0;tt<le.length;tt++)Te=le[tt],_e=Oe+se(Te,tt),De+=Z(Te,we,He,_e,ke);else if(tt=S(le),typeof tt=="function")for(le=tt.call(le),tt=0;!(Te=le.next()).done;)Te=Te.value,_e=Oe+se(Te,tt++),De+=Z(Te,we,He,_e,ke);else if(_e==="object"){if(typeof le.then=="function")return Z(ne(le),we,He,Te,ke);throw we=String(le),Error("Objects are not valid as a React child (found: "+(we==="[object Object]"?"object with keys {"+Object.keys(le).join(", ")+"}":we)+"). If you meant to render a collection of children, use an array instead.")}return De}function ae(le,we,He){if(le==null)return le;var Te=[],ke=0;return Z(le,Te,"","",function(_e){return we.call(He,_e,ke++)}),Te}function Ae(le){if(le._status===-1){var we=le._result;we=we(),we.then(function(He){(le._status===0||le._status===-1)&&(le._status=1,le._result=He)},function(He){(le._status===0||le._status===-1)&&(le._status=2,le._result=He)}),le._status===-1&&(le._status=0,le._result=we)}if(le._status===1)return le._result.default;throw le._result}var Se=typeof reportError=="function"?reportError:function(le){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var we=new
|
|||
|
|
* @license React
|
|||
|
|
* react-dom.production.js
|
|||
|
|
*
|
|||
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|||
|
|
*
|
|||
|
|
* This source code is licensed under the MIT license found in the
|
|||
|
|
* LICENSE file in the root directory of this source tree.
|
|||
|
|
*/var z5;function CF(){if(z5)return Zs;z5=1;var i=vw();function e(u){var h="https://react.dev/errors/"+u;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+u+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var n={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},r=Symbol.for("react.portal");function s(u,h,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:v==null?null:""+v,children:u,containerInfo:h,implementation:g}}var a=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(u,h){if(u==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Zs.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,Zs.createPortal=function(u,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(e(299));return s(u,h,null,g)},Zs.flushSync=function(u){var h=a.T,g=n.p;try{if(a.T=null,n.p=2,u)return u()}finally{a.T=h,n.p=g,n.d.f()}},Zs.preconnect=function(u,h){typeof u=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,n.d.C(u,h))},Zs.prefetchDNS=function(u){typeof u=="string"&&n.d.D(u)},Zs.preinit=function(u,h){if(typeof u=="string"&&h&&typeof h.as=="string"){var g=h.as,v=l(g,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,S=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?n.d.S(u,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:x,fetchPriority:S}):g==="script"&&n.d.X(u,{crossOrigin:v,integrity:x,fetchPriority:S,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Zs.preinitModule=function(u,h){if(typeof u=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=l(h.as,h.crossOrigin);n.d.M(u,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&n.d.M(u)},Zs.preload=function(u,h){if(typeof u=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,v=l(g,h.crossOrigin);n.d.L(u,g,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Zs.preloadModule=function(u,h){if(typeof u=="string")if(h){var g=l(h.as,h.crossOrigin);n.d.m(u,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else n.d.m(u)},Zs.requestFormReset=function(u){n.d.r(u)},Zs.unstable_batchedUpdates=function(u,h){return u(h)},Zs.useFormState=function(u,h,g){return a.H.useFormState(u,h,g)},Zs.useFormStatus=function(){return a.H.useHostTransitionStatus()},Zs.version="19.2.4",Zs}var G5;function RF(){if(G5)return Zb.exports;G5=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Zb.exports=CF(),Zb.exports}/**
|
|||
|
|
* @license React
|
|||
|
|
* react-dom-client.production.js
|
|||
|
|
*
|
|||
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|||
|
|
*
|
|||
|
|
* This source code is licensed under the MIT license found in the
|
|||
|
|
* LICENSE file in the root directory of this source tree.
|
|||
|
|
*/var q5;function NF(){if(q5)return Xp;q5=1;var i=MF(),e=vw(),t=RF();function n(o){var c="https://react.dev/errors/"+o;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)c+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+o+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function s(o){var c=o,m=o;if(o.alternate)for(;c.return;)c=c.return;else{o=c;do c=o,(c.flags&4098)!==0&&(m=c.return),o=c.return;while(o)}return c.tag===3?m:null}function a(o){if(o.tag===13){var c=o.memoizedState;if(c===null&&(o=o.alternate,o!==null&&(c=o.memoizedState)),c!==null)return c.dehydrated}return null}function l(o){if(o.tag===31){var c=o.memoizedState;if(c===null&&(o=o.alternate,o!==null&&(c=o.memoizedState)),c!==null)return c.dehydrated}return null}function u(o){if(s(o)!==o)throw Error(n(188))}function h(o){var c=o.alternate;if(!c){if(c=s(o),c===null)throw Error(n(188));return c!==o?null:o}for(var m=o,b=c;;){var D=m.return;if(D===null)break;var P=D.alternate;if(P===null){if(b=D.return,b!==null){m=b;continue}break}if(D.child===P.child){for(P=D.child;P;){if(P===m)return u(D),o;if(P===b)return u(D),c;P=P.sibling}throw Error(n(188))}if(m.return!==b.return)m=D,b=P;else{for(var $=!1,re=D.child;re;){if(re===m){$=!0,m=D,b=P;break}if(re===b){$=!0,b=D,m=P;break}re=re.sibling}if(!$){for(re=P.child;re;){if(re===m){$=!0,m=P,b=D;break}if(re===b){$=!0,b=P,m=D;break}re=re.sibling}if(!$)throw Error(n(189))}}if(m.alternate!==b)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?o:c}function g(o){var c=o.tag;if(c===5||c===26||c===27||c===6)return o;for(o=o.child;o!==null;){if(c=g(o),c!==null)return c;o=o.sibling}return null}var v=Object.assign,x=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),L=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),X=Symbol.iterator;function ee(o){return o===null||typeof o!="object"?null:(o=X&&o[X]||o["@@iterator"],typeof o=="function"?o:null)}var te=Symbol.for("react.client.reference");function se(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===te?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case R:return"Fragment";case E:return"Profiler";case C:return"StrictMode";case z:return"Suspense";case G:return"SuspenseList";case F:return"Activity"}if(typeof o=="object")switch(o.$$typeof){case w:return"Portal";case L:return o.displayName||"Context";case B:return(o._context.displayName||"Context")+".Consumer";case O:var c=o.render;return o=o.displayName,o||(o=c.displayName||c.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case k:return c=o.displayName||null,c!==null?c:se(o.type)||"Memo";case H:c=o._payload,o=o._init;try{return se(o(c))}catch{}}return null}var ne=Array.isArray,Z=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ae={pending:!1,data:null,method:null,action:null},Se=[],xe=-1;function le(o){return{current:o}}function we(o){0>xe||(o.current=Se[xe],Se[xe]=null,xe--)}function He(o,c){xe++,Se[xe]=o.current,o.current=c}var Te=le(null),ke=le(null),_e=le(null),De=le(null);function Oe(o,c){switch(He(_e,c),He(ke,o),He(Te,null),c.nodeType){case 9:case 11:o=(o=c.documentElement)&&(o=o.namespaceURI)?i5(o):0;break;default:if(o=c.tagName,c=c.namespaceURI)c=i5(c),o=r5(c,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}we(Te),He(Te,o)}function tt(){we(Te),we(ke),we(_e)}function Je(o){o.memoizedState!==null&&He(De,o);var c=Te.current,m=r5(c,o.type);c!
|
|||
|
|
at`)?" (<anonymous>)":-1<m.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|||
|
|
`+We+o+rt}var kt=!1;function mt(o,c){if(!o||kt)return"";kt=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var b={DetermineComponentFrameRoot:function(){try{if(c){var bt=function(){throw Error()};if(Object.defineProperty(bt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(bt,[])}catch(it){var et=it}Reflect.construct(o,[],bt)}else{try{bt.call()}catch(it){et=it}o.call(bt.prototype)}}else{try{throw Error()}catch(it){et=it}(bt=o())&&typeof bt.catch=="function"&&bt.catch(function(){})}}catch(it){if(it&&et&&typeof it.stack=="string")return[it.stack,et.stack]}return[null,null]}};b.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var D=Object.getOwnPropertyDescriptor(b.DetermineComponentFrameRoot,"name");D&&D.configurable&&Object.defineProperty(b.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var P=b.DetermineComponentFrameRoot(),$=P[0],re=P[1];if($&&re){var be=$.split(`
|
|||
|
|
`),Ze=re.split(`
|
|||
|
|
`);for(D=b=0;b<be.length&&!be[b].includes("DetermineComponentFrameRoot");)b++;for(;D<Ze.length&&!Ze[D].includes("DetermineComponentFrameRoot");)D++;if(b===be.length||D===Ze.length)for(b=be.length-1,D=Ze.length-1;1<=b&&0<=D&&be[b]!==Ze[D];)D--;for(;1<=b&&0<=D;b--,D--)if(be[b]!==Ze[D]){if(b!==1||D!==1)do if(b--,D--,0>D||be[b]!==Ze[D]){var At=`
|
|||
|
|
`+be[b].replace(" at new "," at ");return o.displayName&&At.includes("<anonymous>")&&(At=At.replace("<anonymous>",o.displayName)),At}while(1<=b&&0<=D);break}}}finally{kt=!1,Error.prepareStackTrace=m}return(m=o?o.displayName||o.name:"")?ce(m):""}function Lt(o,c){switch(o.tag){case 26:case 27:case 5:return ce(o.type);case 16:return ce("Lazy");case 13:return o.child!==c&&c!==null?ce("Suspense Fallback"):ce("Suspense");case 19:return ce("SuspenseList");case 0:case 15:return mt(o.type,!1);case 11:return mt(o.type.render,!1);case 1:return mt(o.type,!0);case 31:return ce("Activity");default:return""}}function wt(o){try{var c="",m=null;do c+=Lt(o,m),m=o,o=o.return;while(o);return c}catch(b){return`
|
|||
|
|
Error generating stack: `+b.message+`
|
|||
|
|
`+b.stack}}var tn=Object.prototype.hasOwnProperty,St=i.unstable_scheduleCallback,he=i.unstable_cancelCallback,Y=i.unstable_shouldYield,Ce=i.unstable_requestPaint,je=i.unstable_now,st=i.unstable_getCurrentPriorityLevel,nt=i.unstable_ImmediatePriority,Vt=i.unstable_UserBlockingPriority,Ut=i.unstable_NormalPriority,Wt=i.unstable_LowPriority,ln=i.unstable_IdlePriority,Tt=i.log,Kt=i.unstable_setDisableYieldValue,rn=null,Ht=null;function It(o){if(typeof Tt=="function"&&Kt(o),Ht&&typeof Ht.setStrictMode=="function")try{Ht.setStrictMode(rn,o)}catch{}}var Gt=Math.clz32?Math.clz32:me,In=Math.log,Mi=Math.LN2;function me(o){return o>>>=0,o===0?32:31-(In(o)/Mi|0)|0}var jt=256,at=262144,yt=4194304;function $t(o){var c=o&42;if(c!==0)return c;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Ft(o,c,m){var b=o.pendingLanes;if(b===0)return 0;var D=0,P=o.suspendedLanes,$=o.pingedLanes;o=o.warmLanes;var re=b&134217727;return re!==0?(b=re&~P,b!==0?D=$t(b):($&=re,$!==0?D=$t($):m||(m=re&~o,m!==0&&(D=$t(m))))):(re=b&~P,re!==0?D=$t(re):$!==0?D=$t($):m||(m=b&~o,m!==0&&(D=$t(m)))),D===0?0:c!==0&&c!==D&&(c&P)===0&&(P=D&-D,m=c&-c,P>=m||P===32&&(m&4194048)!==0)?c:D}function xn(o,c){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&c)===0}function qi(o,c){switch(o){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rr(){var o=yt;return yt<<=1,(yt&62914560)===0&&(yt=4194304),o}function pn(o){for(var c=[],m=0;31>m;m++)c.push(o);return c}function $i(o,c){o.pendingLanes|=c,c!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function Jr(o,c,m,b,D,P){var $=o.pendingLanes;o.pendingLanes=m,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=m,o.entangledLanes&=m,o.errorRecoveryDisabledLanes&=m,o.shellSuspendCounter=0;var re=o.entanglements,be=o.expirationTimes,Ze=o.hiddenUpdates;for(m=$&~m;0<m;){var At=31-Gt(m),bt=1<<At;re[At]=0,be[At]=-1;var et=Ze[At];if(et!==null)for(Ze[At]=null,At=0;At<et.length;At++){var it=et[At];it!==null&&(it.lane&=-536870913)}m&=~bt}b!==0&&Ke(o,b,0),P!==0&&D===0&&o.tag!==0&&(o.suspendedLanes|=P&~($&~c))}function Ke(o,c,m){o.pendingLanes|=c,o.suspendedLanes&=~c;var b=31-Gt(c);o.entangledLanes|=c,o.entanglements[b]=o.entanglements[b]|1073741824|m&261930}function gt(o,c){var m=o.entangledLanes|=c;for(o=o.entanglements;m;){var b=31-Gt(m),D=1<<b;D&c|o[b]&c&&(o[b]|=c),m&=~D}}function Ot(o,c){var m=c&-c;return m=(m&42)!==0?1:lt(m),(m&(o.suspendedLanes|c))!==0?0:m}function lt(o){switch(o){case 2:o=1;break;case 8:o=4;break;case 32:o=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:o=128;break;case 268435456:o=134217728;break;default:o=0}return o}function d(o){return o&=-o,2<o?8<o?(o&134217727)!==0?32:268435456:8:2}function J(){var o=ae.p;return o!==0?o:(o=window.event,o===void 0?32:E5(o.type))}function $n(o,c){var m=ae.p;try{return ae.p=o,c()}finally{ae.p=m}}var Gn=Math.random().toString(36).slice(2),Xn="__reactFiber$"+Gn,un="__reactProps$"+Gn,qn="__reactContainer$"+Gn,Hs="__reactEvents$"+Gn,li="__reactListeners$"+Gn,Fn="__reactHandles$"+Gn,cs="__reactResources$"
|
|||
|
|
`).replace(jI,"")}function t5(o,c){return c=e5(c),e5(o)===c}function Ji(o,c,m,b,D,P){switch(m){case"children":typeof b=="string"?c==="body"||c==="textarea"&&b===""||pi(o,b):(typeof b=="number"||typeof b=="bigint")&&c!=="body"&&pi(o,""+b);break;case"className":_i(o,"class",b);break;case"tabIndex":_i(o,"tabindex",b);break;case"dir":case"role":case"viewBox":case"width":case"height":_i(o,m,b);break;case"style":Zh(o,b,P);break;case"data":if(c!=="object"){_i(o,"data",b);break}case"src":case"href":if(b===""&&(c!=="a"||m!=="href")){o.removeAttribute(m);break}if(b==null||typeof b=="function"||typeof b=="symbol"||typeof b=="boolean"){o.removeAttribute(m);break}b=Wc(""+b),o.setAttribute(m,b);break;case"action":case"formAction":if(typeof b=="function"){o.setAttribute(m,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof P=="function"&&(m==="formAction"?(c!=="input"&&Ji(o,c,"name",D.name,D,null),Ji(o,c,"formEncType",D.formEncType,D,null),Ji(o,c,"formMethod",D.formMethod,D,null),Ji(o,c,"formTarget",D.formTarget,D,null)):(Ji(o,c,"encType",D.encType,D,null),Ji(o,c,"method",D.method,D,null),Ji(o,c,"target",D.target,D,null)));if(b==null||typeof b=="symbol"||typeof b=="boolean"){o.removeAttribute(m);break}b=Wc(""+b),o.setAttribute(m,b);break;case"onClick":b!=null&&(o.onclick=Po);break;case"onScroll":b!=null&&vi("scroll",o);break;case"onScrollEnd":b!=null&&vi("scrollend",o);break;case"dangerouslySetInnerHTML":if(b!=null){if(typeof b!="object"||!("__html"in b))throw Error(n(61));if(m=b.__html,m!=null){if(D.children!=null)throw Error(n(60));o.innerHTML=m}}break;case"multiple":o.multiple=b&&typeof b!="function"&&typeof b!="symbol";break;case"muted":o.muted=b&&typeof b!="function"&&typeof b!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(b==null||typeof b=="function"||typeof b=="boolean"||typeof b=="symbol"){o.removeAttribute("xlink:href");break}m=Wc(""+b),o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",m);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":b!=null&&typeof b!="function"&&typeof b!="symbol"?o.setAttribute(m,""+b):o.removeAttribute(m);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":b&&typeof b!="function"&&typeof b!="symbol"?o.setAttribute(m,""):o.removeAttribute(m);break;case"capture":case"download":b===!0?o.setAttribute(m,""):b!==!1&&b!=null&&typeof b!="function"&&typeof b!="symbol"?o.setAttribute(m,b):o.removeAttribute(m);break;case"cols":case"rows":case"size":case"span":b!=null&&typeof b!="function"&&typeof b!="symbol"&&!isNaN(b)&&1<=b?o.setAttribute(m,b):o.removeAttribute(m);break;case"rowSpan":case"start":b==null||typeof b=="function"||typeof b=="symbol"||isNaN(b)?o.removeAttribute(m):o.setAttribute(m,b);break;case"popover":vi("beforetoggle",o),vi("toggle",o),ci(o,"popover",b);break;case"xlinkActuate":Q(o,"http://www.w3.org/1999/xlink","xlink:actuate",b);break;case"xlinkArcrole":Q(o,"http://www.w3.org/1999/xlink","xlink:arcrole",b);break;case"xlinkRole":Q(o,"http://www.w3.org/1999/xlink","xlink:role",b);break;case"xlinkShow":Q(o,"http://www.w3.org/1999/xlink","xlink:show",b);break;case"xlinkTitle":Q(o,"http://www.w3.org/1999/xlink","xlink:title",b);break;case"xlinkType":Q(o,"http://www.w3.org/1999/xlink","xlink:type",b);break;case"xmlBase":Q(o,"http://www.w3.org/XML/1998/namespace","xml:base",b);
|
|||
|
|
* @license
|
|||
|
|
* Copyright 2010-2024 Three.js Authors
|
|||
|
|
* SPDX-License-Identifier: MIT
|
|||
|
|
*/const V0="172",Xo={ROTATE:0,DOLLY:1,PAN:2},Gd={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},S7=0,qS=1,T7=2,UF=0,_w=1,BF=2,xo=3,Nl=0,hr=1,as=2,Qa=0,Ka=1,a0=2,o0=3,l0=4,yw=5,Eo=100,xw=101,bw=102,w7=103,M7=104,Sw=200,Tw=201,ww=202,Mw=203,qm=204,Vm=205,Ew=206,Cw=207,Rw=208,Nw=209,Dw=210,OF=211,IF=212,FF=213,kF=214,Hm=0,jm=1,Wm=2,kh=3,$m=4,Xm=5,Ym=6,Qm=7,Lg=0,E7=1,C7=2,Za=0,R7=1,N7=2,D7=3,P7=4,zF=5,L7=6,U7=7,Pw=300,Qo=301,Ko=302,zh=303,Gh=304,sA=306,aA=1e3,eu=1001,oA=1002,mr=1003,s_=1004,tu=1005,gs=1006,Jd=1007,Va=1008,GF=1008,aa=1009,Qf=1010,Kf=1011,wl=1012,Ns=1013,Rr=1014,$r=1015,Gs=1016,Ay=1017,dy=1018,Au=1020,py=35902,Lw=1021,Ug=1022,ks=1023,Uw=1024,Bw=1025,au=1026,du=1027,Bg=1028,H0=1029,lA=1030,j0=1031,qF=1032,W0=1033,Zf=33776,Bh=33777,Oh=33778,Ih=33779,Km=35840,Zm=35841,Jm=35842,eg=35843,tg=36196,u0=37492,c0=37496,h0=37808,f0=37809,A0=37810,d0=37811,p0=37812,m0=37813,g0=37814,v0=37815,_0=37816,y0=37817,x0=37818,b0=37819,S0=37820,T0=37821,Jf=36492,VS=36494,HS=36495,Ow=36283,ng=36284,ig=36285,rg=36286,VF=0,HF=1,H5=2,jF=3200,WF=3201,Dc=0,B7=1,Co="",_n="srgb",Ro="srgb-linear",a_="linear",Vi="srgb",$F=0,Uf=7680,XF=7681,YF=7682,QF=7683,KF=34055,ZF=34056,JF=5386,ek=512,tk=513,nk=514,ik=515,rk=516,sk=517,ak=518,jS=519,Iw=512,my=513,Fw=514,gy=515,kw=516,zw=517,Gw=518,qw=519,o_=35044,qd=35048,j5="300 es",Ha=2e3,pu=2001;class zc{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){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[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 Js=["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 W5=1234567;const Em=Math.PI/180,w0=180/Math.PI;function ou(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Js[i&255]+Js[i>>8&255]+Js[i>>16&255]+Js[i>>24&255]+"-"+Js[e&255]+Js[e>>8&255]+"-"+Js[e>>16&15|64]+Js[e>>24&255]+"-"+Js[t&63|128]+Js[t>>8&255]+"-"+Js[t>>16&255]+Js[t>>24&255]+Js[n&255]+Js[n>>8&255]+Js[n>>16&255]+Js[n>>24&255]).toLowerCase()}function ni(i,e,t){return Math.max(e,Math.min(t,i))}function Vw(i,e){return(i%e+e)%e}function ok(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function lk(i,e,t){return i!==e?(t-i)/(e-i):0}function Cm(i,e,t){return(1-t)*i+t*e}function uk(i,e,t,n){return Cm(i,e,1-Math.exp(-t*n))}function ck(i,e=1){return e-Math.abs(Vw(i,e*2)-e)}function hk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function fk(i,e,
|
|||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|||
|
|
}`,Hk=`void main() {
|
|||
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|||
|
|
}`;class Ja extends ua{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Vk,this.fragmentShader=Hk,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=E0(e.uniforms),this.uniformsGroups=qk(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 _y extends vr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new kn,this.projectionMatrix=new kn,this.projectionMatrixInverse=new kn,this.coordinateSystem=Ha}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 yh=new ue,lC=new pt,uC=new pt;class ya extends _y{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=w0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Em*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return w0*2*Math.atan(Math.tan(Em*.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){yh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yh.x,yh.y).multiplyScalar(-e/yh.z),yh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(yh.x,yh.y).multiplyScalar(-e/yh.z)}getViewSize(e,t){return this.getViewBounds(e,lC,uC),t.subVectors(uC,lC)}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.o
|
|||
|
|
|
|||
|
|
varying vec3 vWorldDirection;
|
|||
|
|
|
|||
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|||
|
|
|
|||
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|||
|
|
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,fragmentShader:`
|
|||
|
|
|
|||
|
|
uniform sampler2D tEquirect;
|
|||
|
|
|
|||
|
|
varying vec3 vWorldDirection;
|
|||
|
|
|
|||
|
|
#include <common>
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vec3 direction = normalize( vWorldDirection );
|
|||
|
|
|
|||
|
|
vec2 sampleUV = equirectUv( direction );
|
|||
|
|
|
|||
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`},r=new $h(5,5,5),s=new Ja({name:"CubemapFromEquirect",uniforms:E0(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:hr,blending:Qa});s.uniforms.tEquirect.value=t;const a=new zi(r,s),l=t.minFilter;return t.minFilter===Va&&(t.minFilter=gs),new q7(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Xw extends vr{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 la,this.environmentIntensity=1,this.environmentRotation=new la,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 Yw{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=o_,this.updateRanges=[],this.version=0,this.uuid=ou()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ou()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ou()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ga=new ue;class nu{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)ga.fromBufferAttribute(this,t),ga.applyMatrix4(e),this.setXYZ(t,ga.x,ga.y,ga.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ga.fromBufferAttribute(this,t),ga.applyNormalMatrix(e),this.setXYZ(t,ga.x,ga.y,ga.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ga.fromBufferAttribute(this,t),ga.transformDirection
|
|||
|
|
* @license
|
|||
|
|
* Copyright 2010-2024 Three.js Authors
|
|||
|
|
* SPDX-License-Identifier: MIT
|
|||
|
|
*/function oD(){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 Zz(i){const e=new WeakMap;function t(l,u){const h=l.array,g=l.usage,v=h.byteLength,x=i.createBuffer();i.bindBuffer(u,x),i.bufferData(u,h,g),l.onUploadCallback();let S;if(h instanceof Float32Array)S=i.FLOAT;else if(h instanceof Uint16Array)l.isFloat16BufferAttribute?S=i.HALF_FLOAT:S=i.UNSIGNED_SHORT;else if(h instanceof Int16Array)S=i.SHORT;else if(h instanceof Uint32Array)S=i.UNSIGNED_INT;else if(h instanceof Int32Array)S=i.INT;else if(h instanceof Int8Array)S=i.BYTE;else if(h instanceof Uint8Array)S=i.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)S=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:x,type:S,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version,size:v}}function n(l,u,h){const g=u.array,v=u.updateRanges;if(i.bindBuffer(h,l),v.length===0)i.bufferSubData(h,0,g);else{v.sort((S,w)=>S.start-w.start);let x=0;for(let S=1;S<v.length;S++){const w=v[x],R=v[S];R.start<=w.start+w.count+1?w.count=Math.max(w.count,R.start+R.count-w.start):(++x,v[x]=R)}v.length=x+1;for(let S=0,w=v.length;S<w;S++){const R=v[S];i.bufferSubData(h,R.start*g.BYTES_PER_ELEMENT,g,R.start,R.count)}u.clearUpdateRanges()}u.onUploadCallback()}function r(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function s(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=e.get(l);u&&(i.deleteBuffer(u.buffer),e.delete(l))}function a(l,u){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const g=e.get(l);(!g||g.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const h=e.get(l);if(h===void 0)e.set(l,t(l,u));else if(h.version<l.version){if(h.size!==l.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(h.buffer,l,u),h.version=l.version}}return{get:r,remove:s,update:a}}var Jz=`#ifdef USE_ALPHAHASH
|
|||
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|||
|
|
#endif`,eG=`#ifdef USE_ALPHAHASH
|
|||
|
|
const float ALPHA_HASH_SCALE = 0.05;
|
|||
|
|
float hash2D( vec2 value ) {
|
|||
|
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|||
|
|
}
|
|||
|
|
float hash3D( vec3 value ) {
|
|||
|
|
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|||
|
|
}
|
|||
|
|
float getAlphaHashThreshold( vec3 position ) {
|
|||
|
|
float maxDeriv = max(
|
|||
|
|
length( dFdx( position.xyz ) ),
|
|||
|
|
length( dFdy( position.xyz ) )
|
|||
|
|
);
|
|||
|
|
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|||
|
|
vec2 pixScales = vec2(
|
|||
|
|
exp2( floor( log2( pixScale ) ) ),
|
|||
|
|
exp2( ceil( log2( pixScale ) ) )
|
|||
|
|
);
|
|||
|
|
vec2 alpha = vec2(
|
|||
|
|
hash3D( floor( pixScales.x * position.xyz ) ),
|
|||
|
|
hash3D( floor( pixScales.y * position.xyz ) )
|
|||
|
|
);
|
|||
|
|
float lerpFactor = fract( log2( pixScale ) );
|
|||
|
|
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|||
|
|
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|||
|
|
vec3 cases = vec3(
|
|||
|
|
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|||
|
|
( x - 0.5 * a ) / ( 1.0 - a ),
|
|||
|
|
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|||
|
|
);
|
|||
|
|
float threshold = ( x < ( 1.0 - a ) )
|
|||
|
|
? ( ( x < a ) ? cases.x : cases.y )
|
|||
|
|
: cases.z;
|
|||
|
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|||
|
|
}
|
|||
|
|
#endif`,tG=`#ifdef USE_ALPHAMAP
|
|||
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|||
|
|
#endif`,nG=`#ifdef USE_ALPHAMAP
|
|||
|
|
uniform sampler2D alphaMap;
|
|||
|
|
#endif`,iG=`#ifdef USE_ALPHATEST
|
|||
|
|
#ifdef ALPHA_TO_COVERAGE
|
|||
|
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|||
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|||
|
|
#else
|
|||
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|||
|
|
#endif
|
|||
|
|
#endif`,rG=`#ifdef USE_ALPHATEST
|
|||
|
|
uniform float alphaTest;
|
|||
|
|
#endif`,sG=`#ifdef USE_AOMAP
|
|||
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|||
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|||
|
|
#if defined( USE_CLEARCOAT )
|
|||
|
|
clearcoatSpecularIndirect *= ambientOcclusion;
|
|||
|
|
#endif
|
|||
|
|
#if defined( USE_SHEEN )
|
|||
|
|
sheenSpecularIndirect *= ambientOcclusion;
|
|||
|
|
#endif
|
|||
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|||
|
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|||
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|||
|
|
#endif
|
|||
|
|
#endif`,aG=`#ifdef USE_AOMAP
|
|||
|
|
uniform sampler2D aoMap;
|
|||
|
|
uniform float aoMapIntensity;
|
|||
|
|
#endif`,oG=`#ifdef USE_BATCHING
|
|||
|
|
#if ! defined( GL_ANGLE_multi_draw )
|
|||
|
|
#define gl_DrawID _gl_DrawID
|
|||
|
|
uniform int _gl_DrawID;
|
|||
|
|
#endif
|
|||
|
|
uniform highp sampler2D batchingTexture;
|
|||
|
|
uniform highp usampler2D batchingIdTexture;
|
|||
|
|
mat4 getBatchingMatrix( const in float i ) {
|
|||
|
|
int size = textureSize( batchingTexture, 0 ).x;
|
|||
|
|
int j = int( i ) * 4;
|
|||
|
|
int x = j % size;
|
|||
|
|
int y = j / size;
|
|||
|
|
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|||
|
|
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|||
|
|
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|||
|
|
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|||
|
|
return mat4( v1, v2, v3, v4 );
|
|||
|
|
}
|
|||
|
|
float getIndirectIndex( const in int i ) {
|
|||
|
|
int size = textureSize( batchingIdTexture, 0 ).x;
|
|||
|
|
int x = i % size;
|
|||
|
|
int y = i / size;
|
|||
|
|
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_BATCHING_COLOR
|
|||
|
|
uniform sampler2D batchingColorTexture;
|
|||
|
|
vec3 getBatchingColor( const in float i ) {
|
|||
|
|
int size = textureSize( batchingColorTexture, 0 ).x;
|
|||
|
|
int j = int( i );
|
|||
|
|
int x = j % size;
|
|||
|
|
int y = j / size;
|
|||
|
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|||
|
|
}
|
|||
|
|
#endif`,lG=`#ifdef USE_BATCHING
|
|||
|
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|||
|
|
#endif`,uG=`vec3 transformed = vec3( position );
|
|||
|
|
#ifdef USE_ALPHAHASH
|
|||
|
|
vPosition = vec3( position );
|
|||
|
|
#endif`,cG=`vec3 objectNormal = vec3( normal );
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|||
|
|
#endif`,hG=`float G_BlinnPhong_Implicit( ) {
|
|||
|
|
return 0.25;
|
|||
|
|
}
|
|||
|
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|||
|
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|||
|
|
}
|
|||
|
|
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|||
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|||
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|||
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|||
|
|
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|||
|
|
float G = G_BlinnPhong_Implicit( );
|
|||
|
|
float D = D_BlinnPhong( shininess, dotNH );
|
|||
|
|
return F * ( G * D );
|
|||
|
|
} // validated`,fG=`#ifdef USE_IRIDESCENCE
|
|||
|
|
const mat3 XYZ_TO_REC709 = mat3(
|
|||
|
|
3.2404542, -0.9692660, 0.0556434,
|
|||
|
|
-1.5371385, 1.8760108, -0.2040259,
|
|||
|
|
-0.4985314, 0.0415560, 1.0572252
|
|||
|
|
);
|
|||
|
|
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|||
|
|
vec3 sqrtF0 = sqrt( fresnel0 );
|
|||
|
|
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|||
|
|
}
|
|||
|
|
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|||
|
|
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|||
|
|
}
|
|||
|
|
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|||
|
|
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|||
|
|
}
|
|||
|
|
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|||
|
|
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|||
|
|
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|||
|
|
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|||
|
|
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|||
|
|
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|||
|
|
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 ) );
|
|||
|
|
xyz /= 1.0685e-7;
|
|||
|
|
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|||
|
|
return rgb;
|
|||
|
|
}
|
|||
|
|
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|||
|
|
vec3 I;
|
|||
|
|
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|||
|
|
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|||
|
|
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|||
|
|
if ( cosTheta2Sq < 0.0 ) {
|
|||
|
|
return vec3( 1.0 );
|
|||
|
|
}
|
|||
|
|
float cosTheta2 = sqrt( cosTheta2Sq );
|
|||
|
|
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|||
|
|
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|||
|
|
float T121 = 1.0 - R12;
|
|||
|
|
float phi12 = 0.0;
|
|||
|
|
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|||
|
|
float phi21 = PI - phi12;
|
|||
|
|
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|||
|
|
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|||
|
|
vec3 phi23 = vec3( 0.0 );
|
|||
|
|
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|||
|
|
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|||
|
|
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|||
|
|
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|||
|
|
vec3 phi = vec3( phi21 ) + phi23;
|
|||
|
|
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|||
|
|
vec3 r123 = sqrt( R123 );
|
|||
|
|
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|||
|
|
vec3 C0 = R12 + Rs;
|
|||
|
|
I = C0;
|
|||
|
|
vec3 Cm = Rs - T121;
|
|||
|
|
for ( int m = 1; m <= 2; ++ m ) {
|
|||
|
|
Cm *= r123;
|
|||
|
|
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|||
|
|
I += Cm * Sm;
|
|||
|
|
}
|
|||
|
|
return max( I, vec3( 0.0 ) );
|
|||
|
|
}
|
|||
|
|
#endif`,AG=`#ifdef USE_BUMPMAP
|
|||
|
|
uniform sampler2D bumpMap;
|
|||
|
|
uniform float bumpScale;
|
|||
|
|
vec2 dHdxy_fwd() {
|
|||
|
|
vec2 dSTdx = dFdx( vBumpMapUv );
|
|||
|
|
vec2 dSTdy = dFdy( vBumpMapUv );
|
|||
|
|
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|||
|
|
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|||
|
|
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|||
|
|
return vec2( dBx, dBy );
|
|||
|
|
}
|
|||
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|||
|
|
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|||
|
|
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|||
|
|
vec3 vN = surf_norm;
|
|||
|
|
vec3 R1 = cross( vSigmaY, vN );
|
|||
|
|
vec3 R2 = cross( vN, vSigmaX );
|
|||
|
|
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|||
|
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|||
|
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|||
|
|
}
|
|||
|
|
#endif`,dG=`#if NUM_CLIPPING_PLANES > 0
|
|||
|
|
vec4 plane;
|
|||
|
|
#ifdef ALPHA_TO_COVERAGE
|
|||
|
|
float distanceToPlane, distanceGradient;
|
|||
|
|
float clipOpacity = 1.0;
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|||
|
|
plane = clippingPlanes[ i ];
|
|||
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|||
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|||
|
|
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|||
|
|
if ( clipOpacity == 0.0 ) discard;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|||
|
|
float unionClipOpacity = 1.0;
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|||
|
|
plane = clippingPlanes[ i ];
|
|||
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|||
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|||
|
|
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
clipOpacity *= 1.0 - unionClipOpacity;
|
|||
|
|
#endif
|
|||
|
|
diffuseColor.a *= clipOpacity;
|
|||
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|||
|
|
#else
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|||
|
|
plane = clippingPlanes[ i ];
|
|||
|
|
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|||
|
|
bool clipped = true;
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|||
|
|
plane = clippingPlanes[ i ];
|
|||
|
|
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
if ( clipped ) discard;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#endif`,pG=`#if NUM_CLIPPING_PLANES > 0
|
|||
|
|
varying vec3 vClipPosition;
|
|||
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|||
|
|
#endif`,mG=`#if NUM_CLIPPING_PLANES > 0
|
|||
|
|
varying vec3 vClipPosition;
|
|||
|
|
#endif`,gG=`#if NUM_CLIPPING_PLANES > 0
|
|||
|
|
vClipPosition = - mvPosition.xyz;
|
|||
|
|
#endif`,vG=`#if defined( USE_COLOR_ALPHA )
|
|||
|
|
diffuseColor *= vColor;
|
|||
|
|
#elif defined( USE_COLOR )
|
|||
|
|
diffuseColor.rgb *= vColor;
|
|||
|
|
#endif`,_G=`#if defined( USE_COLOR_ALPHA )
|
|||
|
|
varying vec4 vColor;
|
|||
|
|
#elif defined( USE_COLOR )
|
|||
|
|
varying vec3 vColor;
|
|||
|
|
#endif`,yG=`#if defined( USE_COLOR_ALPHA )
|
|||
|
|
varying vec4 vColor;
|
|||
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|||
|
|
varying vec3 vColor;
|
|||
|
|
#endif`,xG=`#if defined( USE_COLOR_ALPHA )
|
|||
|
|
vColor = vec4( 1.0 );
|
|||
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|||
|
|
vColor = vec3( 1.0 );
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_COLOR
|
|||
|
|
vColor *= color;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_INSTANCING_COLOR
|
|||
|
|
vColor.xyz *= instanceColor.xyz;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_BATCHING_COLOR
|
|||
|
|
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|||
|
|
vColor.xyz *= batchingColor.xyz;
|
|||
|
|
#endif`,bG=`#define PI 3.141592653589793
|
|||
|
|
#define PI2 6.283185307179586
|
|||
|
|
#define PI_HALF 1.5707963267948966
|
|||
|
|
#define RECIPROCAL_PI 0.3183098861837907
|
|||
|
|
#define RECIPROCAL_PI2 0.15915494309189535
|
|||
|
|
#define EPSILON 1e-6
|
|||
|
|
#ifndef saturate
|
|||
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|||
|
|
#endif
|
|||
|
|
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|||
|
|
float pow2( const in float x ) { return x*x; }
|
|||
|
|
vec3 pow2( const in vec3 x ) { return x*x; }
|
|||
|
|
float pow3( const in float x ) { return x*x*x; }
|
|||
|
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|||
|
|
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|||
|
|
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|||
|
|
highp float rand( const in vec2 uv ) {
|
|||
|
|
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|||
|
|
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|||
|
|
return fract( sin( sn ) * c );
|
|||
|
|
}
|
|||
|
|
#ifdef HIGH_PRECISION
|
|||
|
|
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|||
|
|
#else
|
|||
|
|
float precisionSafeLength( vec3 v ) {
|
|||
|
|
float maxComponent = max3( abs( v ) );
|
|||
|
|
return length( v / maxComponent ) * maxComponent;
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
struct IncidentLight {
|
|||
|
|
vec3 color;
|
|||
|
|
vec3 direction;
|
|||
|
|
bool visible;
|
|||
|
|
};
|
|||
|
|
struct ReflectedLight {
|
|||
|
|
vec3 directDiffuse;
|
|||
|
|
vec3 directSpecular;
|
|||
|
|
vec3 indirectDiffuse;
|
|||
|
|
vec3 indirectSpecular;
|
|||
|
|
};
|
|||
|
|
#ifdef USE_ALPHAHASH
|
|||
|
|
varying vec3 vPosition;
|
|||
|
|
#endif
|
|||
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|||
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|||
|
|
}
|
|||
|
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|||
|
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|||
|
|
}
|
|||
|
|
mat3 transposeMat3( const in mat3 m ) {
|
|||
|
|
mat3 tmp;
|
|||
|
|
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|||
|
|
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|||
|
|
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|||
|
|
return tmp;
|
|||
|
|
}
|
|||
|
|
bool isPerspectiveMatrix( mat4 m ) {
|
|||
|
|
return m[ 2 ][ 3 ] == - 1.0;
|
|||
|
|
}
|
|||
|
|
vec2 equirectUv( in vec3 dir ) {
|
|||
|
|
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|||
|
|
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|||
|
|
return vec2( u, v );
|
|||
|
|
}
|
|||
|
|
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|||
|
|
return RECIPROCAL_PI * diffuseColor;
|
|||
|
|
}
|
|||
|
|
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|||
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|||
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|||
|
|
}
|
|||
|
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|||
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|||
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|||
|
|
} // validated`,SG=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|||
|
|
#define cubeUV_minMipLevel 4.0
|
|||
|
|
#define cubeUV_minTileSize 16.0
|
|||
|
|
float getFace( vec3 direction ) {
|
|||
|
|
vec3 absDirection = abs( direction );
|
|||
|
|
float face = - 1.0;
|
|||
|
|
if ( absDirection.x > absDirection.z ) {
|
|||
|
|
if ( absDirection.x > absDirection.y )
|
|||
|
|
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|||
|
|
else
|
|||
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|||
|
|
} else {
|
|||
|
|
if ( absDirection.z > absDirection.y )
|
|||
|
|
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|||
|
|
else
|
|||
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|||
|
|
}
|
|||
|
|
return face;
|
|||
|
|
}
|
|||
|
|
vec2 getUV( vec3 direction, float face ) {
|
|||
|
|
vec2 uv;
|
|||
|
|
if ( face == 0.0 ) {
|
|||
|
|
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|||
|
|
} else if ( face == 1.0 ) {
|
|||
|
|
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|||
|
|
} else if ( face == 2.0 ) {
|
|||
|
|
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|||
|
|
} else if ( face == 3.0 ) {
|
|||
|
|
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|||
|
|
} else if ( face == 4.0 ) {
|
|||
|
|
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|||
|
|
} else {
|
|||
|
|
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|||
|
|
}
|
|||
|
|
return 0.5 * ( uv + 1.0 );
|
|||
|
|
}
|
|||
|
|
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|||
|
|
float face = getFace( direction );
|
|||
|
|
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|||
|
|
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|||
|
|
float faceSize = exp2( mipInt );
|
|||
|
|
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|||
|
|
if ( face > 2.0 ) {
|
|||
|
|
uv.y += faceSize;
|
|||
|
|
face -= 3.0;
|
|||
|
|
}
|
|||
|
|
uv.x += face * faceSize;
|
|||
|
|
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|||
|
|
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|||
|
|
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|||
|
|
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|||
|
|
#ifdef texture2DGradEXT
|
|||
|
|
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|||
|
|
#else
|
|||
|
|
return texture2D( envMap, uv ).rgb;
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
#define cubeUV_r0 1.0
|
|||
|
|
#define cubeUV_m0 - 2.0
|
|||
|
|
#define cubeUV_r1 0.8
|
|||
|
|
#define cubeUV_m1 - 1.0
|
|||
|
|
#define cubeUV_r4 0.4
|
|||
|
|
#define cubeUV_m4 2.0
|
|||
|
|
#define cubeUV_r5 0.305
|
|||
|
|
#define cubeUV_m5 3.0
|
|||
|
|
#define cubeUV_r6 0.21
|
|||
|
|
#define cubeUV_m6 4.0
|
|||
|
|
float roughnessToMip( float roughness ) {
|
|||
|
|
float mip = 0.0;
|
|||
|
|
if ( roughness >= cubeUV_r1 ) {
|
|||
|
|
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|||
|
|
} else if ( roughness >= cubeUV_r4 ) {
|
|||
|
|
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|||
|
|
} else if ( roughness >= cubeUV_r5 ) {
|
|||
|
|
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|||
|
|
} else if ( roughness >= cubeUV_r6 ) {
|
|||
|
|
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|||
|
|
} else {
|
|||
|
|
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|||
|
|
return mip;
|
|||
|
|
}
|
|||
|
|
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|||
|
|
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|||
|
|
float mipF = fract( mip );
|
|||
|
|
float mipInt = floor( mip );
|
|||
|
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|||
|
|
if ( mipF == 0.0 ) {
|
|||
|
|
return vec4( color0, 1.0 );
|
|||
|
|
} else {
|
|||
|
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|||
|
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endif`,TG=`vec3 transformedNormal = objectNormal;
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
vec3 transformedTangent = objectTangent;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_BATCHING
|
|||
|
|
mat3 bm = mat3( batchingMatrix );
|
|||
|
|
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|||
|
|
transformedNormal = bm * transformedNormal;
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
transformedTangent = bm * transformedTangent;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_INSTANCING
|
|||
|
|
mat3 im = mat3( instanceMatrix );
|
|||
|
|
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|||
|
|
transformedNormal = im * transformedNormal;
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
transformedTangent = im * transformedTangent;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|||
|
|
#ifdef FLIP_SIDED
|
|||
|
|
transformedNormal = - transformedNormal;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|||
|
|
#ifdef FLIP_SIDED
|
|||
|
|
transformedTangent = - transformedTangent;
|
|||
|
|
#endif
|
|||
|
|
#endif`,wG=`#ifdef USE_DISPLACEMENTMAP
|
|||
|
|
uniform sampler2D displacementMap;
|
|||
|
|
uniform float displacementScale;
|
|||
|
|
uniform float displacementBias;
|
|||
|
|
#endif`,MG=`#ifdef USE_DISPLACEMENTMAP
|
|||
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|||
|
|
#endif`,EG=`#ifdef USE_EMISSIVEMAP
|
|||
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|||
|
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|||
|
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|||
|
|
#endif
|
|||
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|||
|
|
#endif`,CG=`#ifdef USE_EMISSIVEMAP
|
|||
|
|
uniform sampler2D emissiveMap;
|
|||
|
|
#endif`,RG="gl_FragColor = linearToOutputTexel( gl_FragColor );",NG=`vec4 LinearTransferOETF( in vec4 value ) {
|
|||
|
|
return value;
|
|||
|
|
}
|
|||
|
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|||
|
|
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 );
|
|||
|
|
}
|
|||
|
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|||
|
|
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 );
|
|||
|
|
}`,DG=`#ifdef USE_ENVMAP
|
|||
|
|
#ifdef ENV_WORLDPOS
|
|||
|
|
vec3 cameraToFrag;
|
|||
|
|
if ( isOrthographic ) {
|
|||
|
|
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|||
|
|
} else {
|
|||
|
|
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|||
|
|
}
|
|||
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|||
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|||
|
|
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|||
|
|
#else
|
|||
|
|
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|||
|
|
#endif
|
|||
|
|
#else
|
|||
|
|
vec3 reflectVec = vReflect;
|
|||
|
|
#endif
|
|||
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|||
|
|
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|||
|
|
#else
|
|||
|
|
vec4 envColor = vec4( 0.0 );
|
|||
|
|
#endif
|
|||
|
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|||
|
|
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|||
|
|
#elif defined( ENVMAP_BLENDING_MIX )
|
|||
|
|
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|||
|
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|||
|
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|||
|
|
#endif
|
|||
|
|
#endif`,PG=`#ifdef USE_ENVMAP
|
|||
|
|
uniform float envMapIntensity;
|
|||
|
|
uniform float flipEnvMap;
|
|||
|
|
uniform mat3 envMapRotation;
|
|||
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|||
|
|
uniform samplerCube envMap;
|
|||
|
|
#else
|
|||
|
|
uniform sampler2D envMap;
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif`,LG=`#ifdef USE_ENVMAP
|
|||
|
|
uniform float reflectivity;
|
|||
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|||
|
|
#define ENV_WORLDPOS
|
|||
|
|
#endif
|
|||
|
|
#ifdef ENV_WORLDPOS
|
|||
|
|
varying vec3 vWorldPosition;
|
|||
|
|
uniform float refractionRatio;
|
|||
|
|
#else
|
|||
|
|
varying vec3 vReflect;
|
|||
|
|
#endif
|
|||
|
|
#endif`,UG=`#ifdef USE_ENVMAP
|
|||
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|||
|
|
#define ENV_WORLDPOS
|
|||
|
|
#endif
|
|||
|
|
#ifdef ENV_WORLDPOS
|
|||
|
|
|
|||
|
|
varying vec3 vWorldPosition;
|
|||
|
|
#else
|
|||
|
|
varying vec3 vReflect;
|
|||
|
|
uniform float refractionRatio;
|
|||
|
|
#endif
|
|||
|
|
#endif`,BG=`#ifdef USE_ENVMAP
|
|||
|
|
#ifdef ENV_WORLDPOS
|
|||
|
|
vWorldPosition = worldPosition.xyz;
|
|||
|
|
#else
|
|||
|
|
vec3 cameraToVertex;
|
|||
|
|
if ( isOrthographic ) {
|
|||
|
|
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|||
|
|
} else {
|
|||
|
|
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|||
|
|
}
|
|||
|
|
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|||
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|||
|
|
vReflect = reflect( cameraToVertex, worldNormal );
|
|||
|
|
#else
|
|||
|
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#endif`,OG=`#ifdef USE_FOG
|
|||
|
|
vFogDepth = - mvPosition.z;
|
|||
|
|
#endif`,IG=`#ifdef USE_FOG
|
|||
|
|
varying float vFogDepth;
|
|||
|
|
#endif`,FG=`#ifdef USE_FOG
|
|||
|
|
#ifdef FOG_EXP2
|
|||
|
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|||
|
|
#else
|
|||
|
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|||
|
|
#endif
|
|||
|
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|||
|
|
#endif`,kG=`#ifdef USE_FOG
|
|||
|
|
uniform vec3 fogColor;
|
|||
|
|
varying float vFogDepth;
|
|||
|
|
#ifdef FOG_EXP2
|
|||
|
|
uniform float fogDensity;
|
|||
|
|
#else
|
|||
|
|
uniform float fogNear;
|
|||
|
|
uniform float fogFar;
|
|||
|
|
#endif
|
|||
|
|
#endif`,zG=`#ifdef USE_GRADIENTMAP
|
|||
|
|
uniform sampler2D gradientMap;
|
|||
|
|
#endif
|
|||
|
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|||
|
|
float dotNL = dot( normal, lightDirection );
|
|||
|
|
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|||
|
|
#ifdef USE_GRADIENTMAP
|
|||
|
|
return vec3( texture2D( gradientMap, coord ).r );
|
|||
|
|
#else
|
|||
|
|
vec2 fw = fwidth( coord ) * 0.5;
|
|||
|
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|||
|
|
#endif
|
|||
|
|
}`,GG=`#ifdef USE_LIGHTMAP
|
|||
|
|
uniform sampler2D lightMap;
|
|||
|
|
uniform float lightMapIntensity;
|
|||
|
|
#endif`,qG=`LambertMaterial material;
|
|||
|
|
material.diffuseColor = diffuseColor.rgb;
|
|||
|
|
material.specularStrength = specularStrength;`,VG=`varying vec3 vViewPosition;
|
|||
|
|
struct LambertMaterial {
|
|||
|
|
vec3 diffuseColor;
|
|||
|
|
float specularStrength;
|
|||
|
|
};
|
|||
|
|
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 ) {
|
|||
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|||
|
|
vec3 irradiance = dotNL * directLight.color;
|
|||
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
}
|
|||
|
|
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 ) {
|
|||
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
}
|
|||
|
|
#define RE_Direct RE_Direct_Lambert
|
|||
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,HG=`uniform bool receiveShadow;
|
|||
|
|
uniform vec3 ambientLightColor;
|
|||
|
|
#if defined( USE_LIGHT_PROBES )
|
|||
|
|
uniform vec3 lightProbe[ 9 ];
|
|||
|
|
#endif
|
|||
|
|
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|||
|
|
float x = normal.x, y = normal.y, z = normal.z;
|
|||
|
|
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|||
|
|
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|||
|
|
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|||
|
|
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|||
|
|
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|||
|
|
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|||
|
|
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|||
|
|
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|||
|
|
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|||
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|||
|
|
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|||
|
|
return irradiance;
|
|||
|
|
}
|
|||
|
|
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|||
|
|
vec3 irradiance = ambientLightColor;
|
|||
|
|
return irradiance;
|
|||
|
|
}
|
|||
|
|
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|||
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|||
|
|
if ( cutoffDistance > 0.0 ) {
|
|||
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|||
|
|
}
|
|||
|
|
return distanceFalloff;
|
|||
|
|
}
|
|||
|
|
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|||
|
|
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|||
|
|
}
|
|||
|
|
#if NUM_DIR_LIGHTS > 0
|
|||
|
|
struct DirectionalLight {
|
|||
|
|
vec3 direction;
|
|||
|
|
vec3 color;
|
|||
|
|
};
|
|||
|
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|||
|
|
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|||
|
|
light.color = directionalLight.color;
|
|||
|
|
light.direction = directionalLight.direction;
|
|||
|
|
light.visible = true;
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
#if NUM_POINT_LIGHTS > 0
|
|||
|
|
struct PointLight {
|
|||
|
|
vec3 position;
|
|||
|
|
vec3 color;
|
|||
|
|
float distance;
|
|||
|
|
float decay;
|
|||
|
|
};
|
|||
|
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|||
|
|
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|||
|
|
vec3 lVector = pointLight.position - geometryPosition;
|
|||
|
|
light.direction = normalize( lVector );
|
|||
|
|
float lightDistance = length( lVector );
|
|||
|
|
light.color = pointLight.color;
|
|||
|
|
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|||
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
#if NUM_SPOT_LIGHTS > 0
|
|||
|
|
struct SpotLight {
|
|||
|
|
vec3 position;
|
|||
|
|
vec3 direction;
|
|||
|
|
vec3 color;
|
|||
|
|
float distance;
|
|||
|
|
float decay;
|
|||
|
|
float coneCos;
|
|||
|
|
float penumbraCos;
|
|||
|
|
};
|
|||
|
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|||
|
|
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|||
|
|
vec3 lVector = spotLight.position - geometryPosition;
|
|||
|
|
light.direction = normalize( lVector );
|
|||
|
|
float angleCos = dot( light.direction, spotLight.direction );
|
|||
|
|
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|||
|
|
if ( spotAttenuation > 0.0 ) {
|
|||
|
|
float lightDistance = length( lVector );
|
|||
|
|
light.color = spotLight.color * spotAttenuation;
|
|||
|
|
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|||
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|||
|
|
} else {
|
|||
|
|
light.color = vec3( 0.0 );
|
|||
|
|
light.visible = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|||
|
|
struct RectAreaLight {
|
|||
|
|
vec3 color;
|
|||
|
|
vec3 position;
|
|||
|
|
vec3 halfWidth;
|
|||
|
|
vec3 halfHeight;
|
|||
|
|
};
|
|||
|
|
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|||
|
|
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|||
|
|
#endif
|
|||
|
|
#if NUM_HEMI_LIGHTS > 0
|
|||
|
|
struct HemisphereLight {
|
|||
|
|
vec3 direction;
|
|||
|
|
vec3 skyColor;
|
|||
|
|
vec3 groundColor;
|
|||
|
|
};
|
|||
|
|
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|||
|
|
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|||
|
|
float dotNL = dot( normal, hemiLight.direction );
|
|||
|
|
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|||
|
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|||
|
|
return irradiance;
|
|||
|
|
}
|
|||
|
|
#endif`,jG=`#ifdef USE_ENVMAP
|
|||
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|||
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|||
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|||
|
|
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
|||
|
|
return PI * envMapColor.rgb * envMapIntensity;
|
|||
|
|
#else
|
|||
|
|
return vec3( 0.0 );
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|||
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|||
|
|
vec3 reflectVec = reflect( - viewDir, normal );
|
|||
|
|
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
|||
|
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|||
|
|
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
|||
|
|
return envMapColor.rgb * envMapIntensity;
|
|||
|
|
#else
|
|||
|
|
return vec3( 0.0 );
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
#ifdef USE_ANISOTROPY
|
|||
|
|
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|||
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|||
|
|
vec3 bentNormal = cross( bitangent, viewDir );
|
|||
|
|
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|||
|
|
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|||
|
|
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|||
|
|
#else
|
|||
|
|
return vec3( 0.0 );
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
#endif`,WG=`ToonMaterial material;
|
|||
|
|
material.diffuseColor = diffuseColor.rgb;`,$G=`varying vec3 vViewPosition;
|
|||
|
|
struct ToonMaterial {
|
|||
|
|
vec3 diffuseColor;
|
|||
|
|
};
|
|||
|
|
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 ) {
|
|||
|
|
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|||
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
}
|
|||
|
|
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 ) {
|
|||
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
}
|
|||
|
|
#define RE_Direct RE_Direct_Toon
|
|||
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,XG=`BlinnPhongMaterial material;
|
|||
|
|
material.diffuseColor = diffuseColor.rgb;
|
|||
|
|
material.specularColor = specular;
|
|||
|
|
material.specularShininess = shininess;
|
|||
|
|
material.specularStrength = specularStrength;`,YG=`varying vec3 vViewPosition;
|
|||
|
|
struct BlinnPhongMaterial {
|
|||
|
|
vec3 diffuseColor;
|
|||
|
|
vec3 specularColor;
|
|||
|
|
float specularShininess;
|
|||
|
|
float specularStrength;
|
|||
|
|
};
|
|||
|
|
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 ) {
|
|||
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|||
|
|
vec3 irradiance = dotNL * directLight.color;
|
|||
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|||
|
|
}
|
|||
|
|
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 ) {
|
|||
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
}
|
|||
|
|
#define RE_Direct RE_Direct_BlinnPhong
|
|||
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,QG=`PhysicalMaterial material;
|
|||
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|||
|
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|||
|
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|||
|
|
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|||
|
|
material.roughness = min( material.roughness, 1.0 );
|
|||
|
|
#ifdef IOR
|
|||
|
|
material.ior = ior;
|
|||
|
|
#ifdef USE_SPECULAR
|
|||
|
|
float specularIntensityFactor = specularIntensity;
|
|||
|
|
vec3 specularColorFactor = specularColor;
|
|||
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|||
|
|
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|||
|
|
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|||
|
|
#endif
|
|||
|
|
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|||
|
|
#else
|
|||
|
|
float specularIntensityFactor = 1.0;
|
|||
|
|
vec3 specularColorFactor = vec3( 1.0 );
|
|||
|
|
material.specularF90 = 1.0;
|
|||
|
|
#endif
|
|||
|
|
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|||
|
|
#else
|
|||
|
|
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|||
|
|
material.specularF90 = 1.0;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
material.clearcoat = clearcoat;
|
|||
|
|
material.clearcoatRoughness = clearcoatRoughness;
|
|||
|
|
material.clearcoatF0 = vec3( 0.04 );
|
|||
|
|
material.clearcoatF90 = 1.0;
|
|||
|
|
#ifdef USE_CLEARCOATMAP
|
|||
|
|
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|||
|
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|||
|
|
#endif
|
|||
|
|
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|||
|
|
material.clearcoatRoughness += geometryRoughness;
|
|||
|
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_DISPERSION
|
|||
|
|
material.dispersion = dispersion;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
material.iridescence = iridescence;
|
|||
|
|
material.iridescenceIOR = iridescenceIOR;
|
|||
|
|
#ifdef USE_IRIDESCENCEMAP
|
|||
|
|
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|||
|
|
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|||
|
|
#else
|
|||
|
|
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN
|
|||
|
|
material.sheenColor = sheenColor;
|
|||
|
|
#ifdef USE_SHEEN_COLORMAP
|
|||
|
|
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|||
|
|
#endif
|
|||
|
|
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|||
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|||
|
|
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ANISOTROPY
|
|||
|
|
#ifdef USE_ANISOTROPYMAP
|
|||
|
|
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|||
|
|
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|||
|
|
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|||
|
|
#else
|
|||
|
|
vec2 anisotropyV = anisotropyVector;
|
|||
|
|
#endif
|
|||
|
|
material.anisotropy = length( anisotropyV );
|
|||
|
|
if( material.anisotropy == 0.0 ) {
|
|||
|
|
anisotropyV = vec2( 1.0, 0.0 );
|
|||
|
|
} else {
|
|||
|
|
anisotropyV /= material.anisotropy;
|
|||
|
|
material.anisotropy = saturate( material.anisotropy );
|
|||
|
|
}
|
|||
|
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|||
|
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|||
|
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|||
|
|
#endif`,KG=`struct PhysicalMaterial {
|
|||
|
|
vec3 diffuseColor;
|
|||
|
|
float roughness;
|
|||
|
|
vec3 specularColor;
|
|||
|
|
float specularF90;
|
|||
|
|
float dispersion;
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
float clearcoat;
|
|||
|
|
float clearcoatRoughness;
|
|||
|
|
vec3 clearcoatF0;
|
|||
|
|
float clearcoatF90;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
float iridescence;
|
|||
|
|
float iridescenceIOR;
|
|||
|
|
float iridescenceThickness;
|
|||
|
|
vec3 iridescenceFresnel;
|
|||
|
|
vec3 iridescenceF0;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN
|
|||
|
|
vec3 sheenColor;
|
|||
|
|
float sheenRoughness;
|
|||
|
|
#endif
|
|||
|
|
#ifdef IOR
|
|||
|
|
float ior;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_TRANSMISSION
|
|||
|
|
float transmission;
|
|||
|
|
float transmissionAlpha;
|
|||
|
|
float thickness;
|
|||
|
|
float attenuationDistance;
|
|||
|
|
vec3 attenuationColor;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ANISOTROPY
|
|||
|
|
float anisotropy;
|
|||
|
|
float alphaT;
|
|||
|
|
vec3 anisotropyT;
|
|||
|
|
vec3 anisotropyB;
|
|||
|
|
#endif
|
|||
|
|
};
|
|||
|
|
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|||
|
|
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|||
|
|
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|||
|
|
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|||
|
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|||
|
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|||
|
|
float x2 = x * x;
|
|||
|
|
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|||
|
|
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|||
|
|
}
|
|||
|
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|||
|
|
float a2 = pow2( alpha );
|
|||
|
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|||
|
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|||
|
|
return 0.5 / max( gv + gl, EPSILON );
|
|||
|
|
}
|
|||
|
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
|||
|
|
float a2 = pow2( alpha );
|
|||
|
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|||
|
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
|||
|
|
}
|
|||
|
|
#ifdef USE_ANISOTROPY
|
|||
|
|
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 ) {
|
|||
|
|
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|||
|
|
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|||
|
|
float v = 0.5 / ( gv + gl );
|
|||
|
|
return saturate(v);
|
|||
|
|
}
|
|||
|
|
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|||
|
|
float a2 = alphaT * alphaB;
|
|||
|
|
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|||
|
|
highp float v2 = dot( v, v );
|
|||
|
|
float w2 = a2 / v2;
|
|||
|
|
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|||
|
|
vec3 f0 = material.clearcoatF0;
|
|||
|
|
float f90 = material.clearcoatF90;
|
|||
|
|
float roughness = material.clearcoatRoughness;
|
|||
|
|
float alpha = pow2( roughness );
|
|||
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|||
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|||
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|||
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|||
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|||
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|||
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|||
|
|
float D = D_GGX( alpha, dotNH );
|
|||
|
|
return F * ( V * D );
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|||
|
|
vec3 f0 = material.specularColor;
|
|||
|
|
float f90 = material.specularF90;
|
|||
|
|
float roughness = material.roughness;
|
|||
|
|
float alpha = pow2( roughness );
|
|||
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|||
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|||
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|||
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|||
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|||
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ANISOTROPY
|
|||
|
|
float dotTL = dot( material.anisotropyT, lightDir );
|
|||
|
|
float dotTV = dot( material.anisotropyT, viewDir );
|
|||
|
|
float dotTH = dot( material.anisotropyT, halfDir );
|
|||
|
|
float dotBL = dot( material.anisotropyB, lightDir );
|
|||
|
|
float dotBV = dot( material.anisotropyB, viewDir );
|
|||
|
|
float dotBH = dot( material.anisotropyB, halfDir );
|
|||
|
|
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|||
|
|
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|||
|
|
#else
|
|||
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|||
|
|
float D = D_GGX( alpha, dotNH );
|
|||
|
|
#endif
|
|||
|
|
return F * ( V * D );
|
|||
|
|
}
|
|||
|
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|||
|
|
const float LUT_SIZE = 64.0;
|
|||
|
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|||
|
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|||
|
|
float dotNV = saturate( dot( N, V ) );
|
|||
|
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|||
|
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
|||
|
|
return uv;
|
|||
|
|
}
|
|||
|
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|||
|
|
float l = length( f );
|
|||
|
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|||
|
|
}
|
|||
|
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|||
|
|
float x = dot( v1, v2 );
|
|||
|
|
float y = abs( x );
|
|||
|
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|||
|
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|||
|
|
float v = a / b;
|
|||
|
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|||
|
|
return cross( v1, v2 ) * theta_sintheta;
|
|||
|
|
}
|
|||
|
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|||
|
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|||
|
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|||
|
|
vec3 lightNormal = cross( v1, v2 );
|
|||
|
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|||
|
|
vec3 T1, T2;
|
|||
|
|
T1 = normalize( V - N * dot( V, N ) );
|
|||
|
|
T2 = - cross( N, T1 );
|
|||
|
|
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
|||
|
|
vec3 coords[ 4 ];
|
|||
|
|
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|||
|
|
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|||
|
|
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|||
|
|
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|||
|
|
coords[ 0 ] = normalize( coords[ 0 ] );
|
|||
|
|
coords[ 1 ] = normalize( coords[ 1 ] );
|
|||
|
|
coords[ 2 ] = normalize( coords[ 2 ] );
|
|||
|
|
coords[ 3 ] = normalize( coords[ 3 ] );
|
|||
|
|
vec3 vectorFormFactor = vec3( 0.0 );
|
|||
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|||
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|||
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|||
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|||
|
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|||
|
|
return vec3( result );
|
|||
|
|
}
|
|||
|
|
#if defined( USE_SHEEN )
|
|||
|
|
float D_Charlie( float roughness, float dotNH ) {
|
|||
|
|
float alpha = pow2( roughness );
|
|||
|
|
float invAlpha = 1.0 / alpha;
|
|||
|
|
float cos2h = dotNH * dotNH;
|
|||
|
|
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|||
|
|
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|||
|
|
}
|
|||
|
|
float V_Neubelt( float dotNV, float dotNL ) {
|
|||
|
|
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|||
|
|
}
|
|||
|
|
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|||
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|||
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|||
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|||
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|||
|
|
float D = D_Charlie( sheenRoughness, dotNH );
|
|||
|
|
float V = V_Neubelt( dotNV, dotNL );
|
|||
|
|
return sheenColor * ( D * V );
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|||
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|||
|
|
float r2 = roughness * roughness;
|
|||
|
|
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|||
|
|
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|||
|
|
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|||
|
|
return saturate( DG * RECIPROCAL_PI );
|
|||
|
|
}
|
|||
|
|
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|||
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|||
|
|
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|||
|
|
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|||
|
|
vec4 r = roughness * c0 + c1;
|
|||
|
|
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|||
|
|
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|||
|
|
return fab;
|
|||
|
|
}
|
|||
|
|
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|||
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|||
|
|
return specularColor * fab.x + specularF90 * fab.y;
|
|||
|
|
}
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
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 ) {
|
|||
|
|
#else
|
|||
|
|
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 ) {
|
|||
|
|
#endif
|
|||
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|||
|
|
#else
|
|||
|
|
vec3 Fr = specularColor;
|
|||
|
|
#endif
|
|||
|
|
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|||
|
|
float Ess = fab.x + fab.y;
|
|||
|
|
float Ems = 1.0 - Ess;
|
|||
|
|
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|||
|
|
singleScatter += FssEss;
|
|||
|
|
multiScatter += Fms * Ems;
|
|||
|
|
}
|
|||
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|||
|
|
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 ) {
|
|||
|
|
vec3 normal = geometryNormal;
|
|||
|
|
vec3 viewDir = geometryViewDir;
|
|||
|
|
vec3 position = geometryPosition;
|
|||
|
|
vec3 lightPos = rectAreaLight.position;
|
|||
|
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|||
|
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|||
|
|
vec3 lightColor = rectAreaLight.color;
|
|||
|
|
float roughness = material.roughness;
|
|||
|
|
vec3 rectCoords[ 4 ];
|
|||
|
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|||
|
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|||
|
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|||
|
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|||
|
|
vec4 t1 = texture2D( ltc_1, uv );
|
|||
|
|
vec4 t2 = texture2D( ltc_2, uv );
|
|||
|
|
mat3 mInv = mat3(
|
|||
|
|
vec3( t1.x, 0, t1.y ),
|
|||
|
|
vec3( 0, 1, 0 ),
|
|||
|
|
vec3( t1.z, 0, t1.w )
|
|||
|
|
);
|
|||
|
|
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|||
|
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|||
|
|
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
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 ) {
|
|||
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|||
|
|
vec3 irradiance = dotNL * directLight.color;
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|||
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|||
|
|
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN
|
|||
|
|
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|||
|
|
#endif
|
|||
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|||
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
}
|
|||
|
|
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 ) {
|
|||
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|||
|
|
}
|
|||
|
|
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) {
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN
|
|||
|
|
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|||
|
|
#endif
|
|||
|
|
vec3 singleScattering = vec3( 0.0 );
|
|||
|
|
vec3 multiScattering = vec3( 0.0 );
|
|||
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|||
|
|
#else
|
|||
|
|
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|||
|
|
#endif
|
|||
|
|
vec3 totalScattering = singleScattering + multiScattering;
|
|||
|
|
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|||
|
|
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|||
|
|
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|||
|
|
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|||
|
|
}
|
|||
|
|
#define RE_Direct RE_Direct_Physical
|
|||
|
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|||
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|||
|
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|||
|
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|||
|
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|||
|
|
}`,ZG=`
|
|||
|
|
vec3 geometryPosition = - vViewPosition;
|
|||
|
|
vec3 geometryNormal = normal;
|
|||
|
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|||
|
|
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
geometryClearcoatNormal = clearcoatNormal;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|||
|
|
if ( material.iridescenceThickness == 0.0 ) {
|
|||
|
|
material.iridescence = 0.0;
|
|||
|
|
} else {
|
|||
|
|
material.iridescence = saturate( material.iridescence );
|
|||
|
|
}
|
|||
|
|
if ( material.iridescence > 0.0 ) {
|
|||
|
|
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|||
|
|
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
IncidentLight directLight;
|
|||
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|||
|
|
PointLight pointLight;
|
|||
|
|
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|||
|
|
PointLightShadow pointLightShadow;
|
|||
|
|
#endif
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|||
|
|
pointLight = pointLights[ i ];
|
|||
|
|
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|||
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|||
|
|
pointLightShadow = pointLightShadows[ i ];
|
|||
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|||
|
|
#endif
|
|||
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|||
|
|
SpotLight spotLight;
|
|||
|
|
vec4 spotColor;
|
|||
|
|
vec3 spotLightCoord;
|
|||
|
|
bool inSpotLightMap;
|
|||
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|||
|
|
SpotLightShadow spotLightShadow;
|
|||
|
|
#endif
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|||
|
|
spotLight = spotLights[ i ];
|
|||
|
|
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|||
|
|
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|||
|
|
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|||
|
|
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|||
|
|
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|||
|
|
#else
|
|||
|
|
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|||
|
|
#endif
|
|||
|
|
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|||
|
|
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|||
|
|
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|||
|
|
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|||
|
|
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|||
|
|
#endif
|
|||
|
|
#undef SPOT_LIGHT_MAP_INDEX
|
|||
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|||
|
|
spotLightShadow = spotLightShadows[ i ];
|
|||
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|||
|
|
#endif
|
|||
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|||
|
|
DirectionalLight directionalLight;
|
|||
|
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|||
|
|
DirectionalLightShadow directionalLightShadow;
|
|||
|
|
#endif
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|||
|
|
directionalLight = directionalLights[ i ];
|
|||
|
|
getDirectionalLightInfo( directionalLight, directLight );
|
|||
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|||
|
|
directionalLightShadow = directionalLightShadows[ i ];
|
|||
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|||
|
|
#endif
|
|||
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|||
|
|
RectAreaLight rectAreaLight;
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|||
|
|
rectAreaLight = rectAreaLights[ i ];
|
|||
|
|
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#if defined( RE_IndirectDiffuse )
|
|||
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|||
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|||
|
|
#if defined( USE_LIGHT_PROBES )
|
|||
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|||
|
|
#endif
|
|||
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|||
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#if defined( RE_IndirectSpecular )
|
|||
|
|
vec3 radiance = vec3( 0.0 );
|
|||
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|||
|
|
#endif`,JG=`#if defined( RE_IndirectDiffuse )
|
|||
|
|
#ifdef USE_LIGHTMAP
|
|||
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|||
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|||
|
|
irradiance += lightMapIrradiance;
|
|||
|
|
#endif
|
|||
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|||
|
|
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|||
|
|
#ifdef USE_ANISOTROPY
|
|||
|
|
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|||
|
|
#else
|
|||
|
|
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|||
|
|
#endif
|
|||
|
|
#endif`,eq=`#if defined( RE_IndirectDiffuse )
|
|||
|
|
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|||
|
|
#endif
|
|||
|
|
#if defined( RE_IndirectSpecular )
|
|||
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|||
|
|
#endif`,tq=`#if defined( USE_LOGDEPTHBUF )
|
|||
|
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|||
|
|
#endif`,nq=`#if defined( USE_LOGDEPTHBUF )
|
|||
|
|
uniform float logDepthBufFC;
|
|||
|
|
varying float vFragDepth;
|
|||
|
|
varying float vIsPerspective;
|
|||
|
|
#endif`,iq=`#ifdef USE_LOGDEPTHBUF
|
|||
|
|
varying float vFragDepth;
|
|||
|
|
varying float vIsPerspective;
|
|||
|
|
#endif`,rq=`#ifdef USE_LOGDEPTHBUF
|
|||
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|||
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|||
|
|
#endif`,sq=`#ifdef USE_MAP
|
|||
|
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|||
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|||
|
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|||
|
|
#endif
|
|||
|
|
diffuseColor *= sampledDiffuseColor;
|
|||
|
|
#endif`,aq=`#ifdef USE_MAP
|
|||
|
|
uniform sampler2D map;
|
|||
|
|
#endif`,oq=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|||
|
|
#if defined( USE_POINTS_UV )
|
|||
|
|
vec2 uv = vUv;
|
|||
|
|
#else
|
|||
|
|
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_MAP
|
|||
|
|
diffuseColor *= texture2D( map, uv );
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ALPHAMAP
|
|||
|
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|||
|
|
#endif`,lq=`#if defined( USE_POINTS_UV )
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
#else
|
|||
|
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|||
|
|
uniform mat3 uvTransform;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_MAP
|
|||
|
|
uniform sampler2D map;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ALPHAMAP
|
|||
|
|
uniform sampler2D alphaMap;
|
|||
|
|
#endif`,uq=`float metalnessFactor = metalness;
|
|||
|
|
#ifdef USE_METALNESSMAP
|
|||
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|||
|
|
metalnessFactor *= texelMetalness.b;
|
|||
|
|
#endif`,cq=`#ifdef USE_METALNESSMAP
|
|||
|
|
uniform sampler2D metalnessMap;
|
|||
|
|
#endif`,hq=`#ifdef USE_INSTANCING_MORPH
|
|||
|
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|||
|
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|||
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|||
|
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|||
|
|
}
|
|||
|
|
#endif`,fq=`#if defined( USE_MORPHCOLORS )
|
|||
|
|
vColor *= morphTargetBaseInfluence;
|
|||
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|||
|
|
#if defined( USE_COLOR_ALPHA )
|
|||
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|||
|
|
#elif defined( USE_COLOR )
|
|||
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
#endif`,Aq=`#ifdef USE_MORPHNORMALS
|
|||
|
|
objectNormal *= morphTargetBaseInfluence;
|
|||
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|||
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|||
|
|
}
|
|||
|
|
#endif`,dq=`#ifdef USE_MORPHTARGETS
|
|||
|
|
#ifndef USE_INSTANCING_MORPH
|
|||
|
|
uniform float morphTargetBaseInfluence;
|
|||
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|||
|
|
#endif
|
|||
|
|
uniform sampler2DArray morphTargetsTexture;
|
|||
|
|
uniform ivec2 morphTargetsTextureSize;
|
|||
|
|
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|||
|
|
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|||
|
|
int y = texelIndex / morphTargetsTextureSize.x;
|
|||
|
|
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|||
|
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|||
|
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|||
|
|
}
|
|||
|
|
#endif`,pq=`#ifdef USE_MORPHTARGETS
|
|||
|
|
transformed *= morphTargetBaseInfluence;
|
|||
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|||
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|||
|
|
}
|
|||
|
|
#endif`,mq=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|||
|
|
#ifdef FLAT_SHADED
|
|||
|
|
vec3 fdx = dFdx( vViewPosition );
|
|||
|
|
vec3 fdy = dFdy( vViewPosition );
|
|||
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|||
|
|
#else
|
|||
|
|
vec3 normal = normalize( vNormal );
|
|||
|
|
#ifdef DOUBLE_SIDED
|
|||
|
|
normal *= faceDirection;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|||
|
|
#else
|
|||
|
|
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|||
|
|
#if defined( USE_NORMALMAP )
|
|||
|
|
vNormalMapUv
|
|||
|
|
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|||
|
|
vClearcoatNormalMapUv
|
|||
|
|
#else
|
|||
|
|
vUv
|
|||
|
|
#endif
|
|||
|
|
);
|
|||
|
|
#endif
|
|||
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|||
|
|
tbn[0] *= faceDirection;
|
|||
|
|
tbn[1] *= faceDirection;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|||
|
|
#else
|
|||
|
|
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|||
|
|
#endif
|
|||
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|||
|
|
tbn2[0] *= faceDirection;
|
|||
|
|
tbn2[1] *= faceDirection;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
vec3 nonPerturbedNormal = normal;`,gq=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|||
|
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|||
|
|
#ifdef FLIP_SIDED
|
|||
|
|
normal = - normal;
|
|||
|
|
#endif
|
|||
|
|
#ifdef DOUBLE_SIDED
|
|||
|
|
normal = normal * faceDirection;
|
|||
|
|
#endif
|
|||
|
|
normal = normalize( normalMatrix * normal );
|
|||
|
|
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|||
|
|
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|||
|
|
mapN.xy *= normalScale;
|
|||
|
|
normal = normalize( tbn * mapN );
|
|||
|
|
#elif defined( USE_BUMPMAP )
|
|||
|
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|||
|
|
#endif`,vq=`#ifndef FLAT_SHADED
|
|||
|
|
varying vec3 vNormal;
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
varying vec3 vTangent;
|
|||
|
|
varying vec3 vBitangent;
|
|||
|
|
#endif
|
|||
|
|
#endif`,_q=`#ifndef FLAT_SHADED
|
|||
|
|
varying vec3 vNormal;
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
varying vec3 vTangent;
|
|||
|
|
varying vec3 vBitangent;
|
|||
|
|
#endif
|
|||
|
|
#endif`,yq=`#ifndef FLAT_SHADED
|
|||
|
|
vNormal = normalize( transformedNormal );
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
vTangent = normalize( transformedTangent );
|
|||
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|||
|
|
#endif
|
|||
|
|
#endif`,xq=`#ifdef USE_NORMALMAP
|
|||
|
|
uniform sampler2D normalMap;
|
|||
|
|
uniform vec2 normalScale;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|||
|
|
uniform mat3 normalMatrix;
|
|||
|
|
#endif
|
|||
|
|
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|||
|
|
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|||
|
|
vec3 q0 = dFdx( eye_pos.xyz );
|
|||
|
|
vec3 q1 = dFdy( eye_pos.xyz );
|
|||
|
|
vec2 st0 = dFdx( uv.st );
|
|||
|
|
vec2 st1 = dFdy( uv.st );
|
|||
|
|
vec3 N = surf_norm;
|
|||
|
|
vec3 q1perp = cross( q1, N );
|
|||
|
|
vec3 q0perp = cross( N, q0 );
|
|||
|
|
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|||
|
|
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|||
|
|
float det = max( dot( T, T ), dot( B, B ) );
|
|||
|
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|||
|
|
return mat3( T * scale, B * scale, N );
|
|||
|
|
}
|
|||
|
|
#endif`,bq=`#ifdef USE_CLEARCOAT
|
|||
|
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|||
|
|
#endif`,Sq=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|||
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|||
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|||
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|||
|
|
#endif`,Tq=`#ifdef USE_CLEARCOATMAP
|
|||
|
|
uniform sampler2D clearcoatMap;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|||
|
|
uniform sampler2D clearcoatNormalMap;
|
|||
|
|
uniform vec2 clearcoatNormalScale;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|||
|
|
uniform sampler2D clearcoatRoughnessMap;
|
|||
|
|
#endif`,wq=`#ifdef USE_IRIDESCENCEMAP
|
|||
|
|
uniform sampler2D iridescenceMap;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|||
|
|
uniform sampler2D iridescenceThicknessMap;
|
|||
|
|
#endif`,Mq=`#ifdef OPAQUE
|
|||
|
|
diffuseColor.a = 1.0;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_TRANSMISSION
|
|||
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|||
|
|
#endif
|
|||
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Eq=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|||
|
|
return normalize( normal ) * 0.5 + 0.5;
|
|||
|
|
}
|
|||
|
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|||
|
|
return 2.0 * rgb.xyz - 1.0;
|
|||
|
|
}
|
|||
|
|
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
|
|||
|
|
const float Inv255 = 1. / 255.;
|
|||
|
|
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
|||
|
|
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
|||
|
|
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
|||
|
|
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
|||
|
|
vec4 packDepthToRGBA( const in float v ) {
|
|||
|
|
if( v <= 0.0 )
|
|||
|
|
return vec4( 0., 0., 0., 0. );
|
|||
|
|
if( v >= 1.0 )
|
|||
|
|
return vec4( 1., 1., 1., 1. );
|
|||
|
|
float vuf;
|
|||
|
|
float af = modf( v * PackFactors.a, vuf );
|
|||
|
|
float bf = modf( vuf * ShiftRight8, vuf );
|
|||
|
|
float gf = modf( vuf * ShiftRight8, vuf );
|
|||
|
|
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
|||
|
|
}
|
|||
|
|
vec3 packDepthToRGB( const in float v ) {
|
|||
|
|
if( v <= 0.0 )
|
|||
|
|
return vec3( 0., 0., 0. );
|
|||
|
|
if( v >= 1.0 )
|
|||
|
|
return vec3( 1., 1., 1. );
|
|||
|
|
float vuf;
|
|||
|
|
float bf = modf( v * PackFactors.b, vuf );
|
|||
|
|
float gf = modf( vuf * ShiftRight8, vuf );
|
|||
|
|
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
|||
|
|
}
|
|||
|
|
vec2 packDepthToRG( const in float v ) {
|
|||
|
|
if( v <= 0.0 )
|
|||
|
|
return vec2( 0., 0. );
|
|||
|
|
if( v >= 1.0 )
|
|||
|
|
return vec2( 1., 1. );
|
|||
|
|
float vuf;
|
|||
|
|
float gf = modf( v * 256., vuf );
|
|||
|
|
return vec2( vuf * Inv255, gf );
|
|||
|
|
}
|
|||
|
|
float unpackRGBAToDepth( const in vec4 v ) {
|
|||
|
|
return dot( v, UnpackFactors4 );
|
|||
|
|
}
|
|||
|
|
float unpackRGBToDepth( const in vec3 v ) {
|
|||
|
|
return dot( v, UnpackFactors3 );
|
|||
|
|
}
|
|||
|
|
float unpackRGToDepth( const in vec2 v ) {
|
|||
|
|
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
|||
|
|
}
|
|||
|
|
vec4 pack2HalfToRGBA( const in vec2 v ) {
|
|||
|
|
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|||
|
|
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|||
|
|
}
|
|||
|
|
vec2 unpackRGBATo2Half( const in vec4 v ) {
|
|||
|
|
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|||
|
|
}
|
|||
|
|
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|||
|
|
return ( viewZ + near ) / ( near - far );
|
|||
|
|
}
|
|||
|
|
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|||
|
|
return depth * ( near - far ) - near;
|
|||
|
|
}
|
|||
|
|
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|||
|
|
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|||
|
|
}
|
|||
|
|
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|||
|
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|||
|
|
}`,Cq=`#ifdef PREMULTIPLIED_ALPHA
|
|||
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|||
|
|
#endif`,Rq=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|||
|
|
#ifdef USE_BATCHING
|
|||
|
|
mvPosition = batchingMatrix * mvPosition;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_INSTANCING
|
|||
|
|
mvPosition = instanceMatrix * mvPosition;
|
|||
|
|
#endif
|
|||
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|||
|
|
gl_Position = projectionMatrix * mvPosition;`,Nq=`#ifdef DITHERING
|
|||
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|||
|
|
#endif`,Dq=`#ifdef DITHERING
|
|||
|
|
vec3 dithering( vec3 color ) {
|
|||
|
|
float grid_position = rand( gl_FragCoord.xy );
|
|||
|
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|||
|
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|||
|
|
return color + dither_shift_RGB;
|
|||
|
|
}
|
|||
|
|
#endif`,Pq=`float roughnessFactor = roughness;
|
|||
|
|
#ifdef USE_ROUGHNESSMAP
|
|||
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|||
|
|
roughnessFactor *= texelRoughness.g;
|
|||
|
|
#endif`,Lq=`#ifdef USE_ROUGHNESSMAP
|
|||
|
|
uniform sampler2D roughnessMap;
|
|||
|
|
#endif`,Uq=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|||
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|||
|
|
#endif
|
|||
|
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|||
|
|
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHADOWMAP
|
|||
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|||
|
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|||
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|||
|
|
struct DirectionalLightShadow {
|
|||
|
|
float shadowIntensity;
|
|||
|
|
float shadowBias;
|
|||
|
|
float shadowNormalBias;
|
|||
|
|
float shadowRadius;
|
|||
|
|
vec2 shadowMapSize;
|
|||
|
|
};
|
|||
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|||
|
|
#endif
|
|||
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|||
|
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|||
|
|
struct SpotLightShadow {
|
|||
|
|
float shadowIntensity;
|
|||
|
|
float shadowBias;
|
|||
|
|
float shadowNormalBias;
|
|||
|
|
float shadowRadius;
|
|||
|
|
vec2 shadowMapSize;
|
|||
|
|
};
|
|||
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|||
|
|
#endif
|
|||
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|||
|
|
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|||
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|||
|
|
struct PointLightShadow {
|
|||
|
|
float shadowIntensity;
|
|||
|
|
float shadowBias;
|
|||
|
|
float shadowNormalBias;
|
|||
|
|
float shadowRadius;
|
|||
|
|
vec2 shadowMapSize;
|
|||
|
|
float shadowCameraNear;
|
|||
|
|
float shadowCameraFar;
|
|||
|
|
};
|
|||
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|||
|
|
#endif
|
|||
|
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|||
|
|
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
|||
|
|
}
|
|||
|
|
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|||
|
|
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|||
|
|
}
|
|||
|
|
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
|||
|
|
float occlusion = 1.0;
|
|||
|
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|||
|
|
float hard_shadow = step( compare , distribution.x );
|
|||
|
|
if (hard_shadow != 1.0 ) {
|
|||
|
|
float distance = compare - distribution.x ;
|
|||
|
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|||
|
|
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 );
|
|||
|
|
}
|
|||
|
|
return occlusion;
|
|||
|
|
}
|
|||
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|||
|
|
float shadow = 1.0;
|
|||
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|||
|
|
shadowCoord.z += shadowBias;
|
|||
|
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|||
|
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|||
|
|
if ( frustumTest ) {
|
|||
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|||
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|||
|
|
float dx0 = - texelSize.x * shadowRadius;
|
|||
|
|
float dy0 = - texelSize.y * shadowRadius;
|
|||
|
|
float dx1 = + texelSize.x * shadowRadius;
|
|||
|
|
float dy1 = + texelSize.y * shadowRadius;
|
|||
|
|
float dx2 = dx0 / 2.0;
|
|||
|
|
float dy2 = dy0 / 2.0;
|
|||
|
|
float dx3 = dx1 / 2.0;
|
|||
|
|
float dy3 = dy1 / 2.0;
|
|||
|
|
shadow = (
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|||
|
|
) * ( 1.0 / 17.0 );
|
|||
|
|
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|||
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|||
|
|
float dx = texelSize.x;
|
|||
|
|
float dy = texelSize.y;
|
|||
|
|
vec2 uv = shadowCoord.xy;
|
|||
|
|
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|||
|
|
uv -= f * texelSize;
|
|||
|
|
shadow = (
|
|||
|
|
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|||
|
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|||
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|||
|
|
f.x ) +
|
|||
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|||
|
|
f.x ) +
|
|||
|
|
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|||
|
|
f.y ) +
|
|||
|
|
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|||
|
|
f.y ) +
|
|||
|
|
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|||
|
|
f.x ),
|
|||
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|||
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|||
|
|
f.x ),
|
|||
|
|
f.y )
|
|||
|
|
) * ( 1.0 / 9.0 );
|
|||
|
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
|||
|
|
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|||
|
|
#else
|
|||
|
|
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|||
|
|
}
|
|||
|
|
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|||
|
|
vec3 absV = abs( v );
|
|||
|
|
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|||
|
|
absV *= scaleToCube;
|
|||
|
|
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|||
|
|
vec2 planar = v.xy;
|
|||
|
|
float almostATexel = 1.5 * texelSizeY;
|
|||
|
|
float almostOne = 1.0 - almostATexel;
|
|||
|
|
if ( absV.z >= almostOne ) {
|
|||
|
|
if ( v.z > 0.0 )
|
|||
|
|
planar.x = 4.0 - v.x;
|
|||
|
|
} else if ( absV.x >= almostOne ) {
|
|||
|
|
float signX = sign( v.x );
|
|||
|
|
planar.x = v.z * signX + 2.0 * signX;
|
|||
|
|
} else if ( absV.y >= almostOne ) {
|
|||
|
|
float signY = sign( v.y );
|
|||
|
|
planar.x = v.x + 2.0 * signY + 2.0;
|
|||
|
|
planar.y = v.z * signY - 2.0;
|
|||
|
|
}
|
|||
|
|
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|||
|
|
}
|
|||
|
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|||
|
|
float shadow = 1.0;
|
|||
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|||
|
|
|
|||
|
|
float lightToPositionLength = length( lightToPosition );
|
|||
|
|
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|||
|
|
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|||
|
|
vec3 bd3D = normalize( lightToPosition );
|
|||
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|||
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|||
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|||
|
|
shadow = (
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|||
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|||
|
|
) * ( 1.0 / 9.0 );
|
|||
|
|
#else
|
|||
|
|
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|||
|
|
}
|
|||
|
|
#endif`,Bq=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|||
|
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|||
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHADOWMAP
|
|||
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|||
|
|
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|||
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|||
|
|
struct DirectionalLightShadow {
|
|||
|
|
float shadowIntensity;
|
|||
|
|
float shadowBias;
|
|||
|
|
float shadowNormalBias;
|
|||
|
|
float shadowRadius;
|
|||
|
|
vec2 shadowMapSize;
|
|||
|
|
};
|
|||
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|||
|
|
#endif
|
|||
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|||
|
|
struct SpotLightShadow {
|
|||
|
|
float shadowIntensity;
|
|||
|
|
float shadowBias;
|
|||
|
|
float shadowNormalBias;
|
|||
|
|
float shadowRadius;
|
|||
|
|
vec2 shadowMapSize;
|
|||
|
|
};
|
|||
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|||
|
|
#endif
|
|||
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|||
|
|
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|||
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|||
|
|
struct PointLightShadow {
|
|||
|
|
float shadowIntensity;
|
|||
|
|
float shadowBias;
|
|||
|
|
float shadowNormalBias;
|
|||
|
|
float shadowRadius;
|
|||
|
|
vec2 shadowMapSize;
|
|||
|
|
float shadowCameraNear;
|
|||
|
|
float shadowCameraFar;
|
|||
|
|
};
|
|||
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|||
|
|
#endif
|
|||
|
|
#endif`,Oq=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|||
|
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|||
|
|
vec4 shadowWorldPosition;
|
|||
|
|
#endif
|
|||
|
|
#if defined( USE_SHADOWMAP )
|
|||
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|||
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|||
|
|
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|||
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|||
|
|
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#if NUM_SPOT_LIGHT_COORDS > 0
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|||
|
|
shadowWorldPosition = worldPosition;
|
|||
|
|
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|||
|
|
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|||
|
|
#endif
|
|||
|
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif`,Iq=`float getShadowMask() {
|
|||
|
|
float shadow = 1.0;
|
|||
|
|
#ifdef USE_SHADOWMAP
|
|||
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|||
|
|
DirectionalLightShadow directionalLight;
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|||
|
|
directionalLight = directionalLightShadows[ i ];
|
|||
|
|
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|||
|
|
SpotLightShadow spotLight;
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|||
|
|
spotLight = spotLightShadows[ i ];
|
|||
|
|
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|||
|
|
PointLightShadow pointLight;
|
|||
|
|
#pragma unroll_loop_start
|
|||
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|||
|
|
pointLight = pointLightShadows[ i ];
|
|||
|
|
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|||
|
|
}
|
|||
|
|
#pragma unroll_loop_end
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
return shadow;
|
|||
|
|
}`,Fq=`#ifdef USE_SKINNING
|
|||
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|||
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|||
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|||
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|||
|
|
#endif`,kq=`#ifdef USE_SKINNING
|
|||
|
|
uniform mat4 bindMatrix;
|
|||
|
|
uniform mat4 bindMatrixInverse;
|
|||
|
|
uniform highp sampler2D boneTexture;
|
|||
|
|
mat4 getBoneMatrix( const in float i ) {
|
|||
|
|
int size = textureSize( boneTexture, 0 ).x;
|
|||
|
|
int j = int( i ) * 4;
|
|||
|
|
int x = j % size;
|
|||
|
|
int y = j / size;
|
|||
|
|
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|||
|
|
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|||
|
|
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|||
|
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|||
|
|
return mat4( v1, v2, v3, v4 );
|
|||
|
|
}
|
|||
|
|
#endif`,zq=`#ifdef USE_SKINNING
|
|||
|
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|||
|
|
vec4 skinned = vec4( 0.0 );
|
|||
|
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|||
|
|
skinned += boneMatY * skinVertex * skinWeight.y;
|
|||
|
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|||
|
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|||
|
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|||
|
|
#endif`,Gq=`#ifdef USE_SKINNING
|
|||
|
|
mat4 skinMatrix = mat4( 0.0 );
|
|||
|
|
skinMatrix += skinWeight.x * boneMatX;
|
|||
|
|
skinMatrix += skinWeight.y * boneMatY;
|
|||
|
|
skinMatrix += skinWeight.z * boneMatZ;
|
|||
|
|
skinMatrix += skinWeight.w * boneMatW;
|
|||
|
|
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|||
|
|
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|||
|
|
#ifdef USE_TANGENT
|
|||
|
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|||
|
|
#endif
|
|||
|
|
#endif`,qq=`float specularStrength;
|
|||
|
|
#ifdef USE_SPECULARMAP
|
|||
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|||
|
|
specularStrength = texelSpecular.r;
|
|||
|
|
#else
|
|||
|
|
specularStrength = 1.0;
|
|||
|
|
#endif`,Vq=`#ifdef USE_SPECULARMAP
|
|||
|
|
uniform sampler2D specularMap;
|
|||
|
|
#endif`,Hq=`#if defined( TONE_MAPPING )
|
|||
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|||
|
|
#endif`,jq=`#ifndef saturate
|
|||
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|||
|
|
#endif
|
|||
|
|
uniform float toneMappingExposure;
|
|||
|
|
vec3 LinearToneMapping( vec3 color ) {
|
|||
|
|
return saturate( toneMappingExposure * color );
|
|||
|
|
}
|
|||
|
|
vec3 ReinhardToneMapping( vec3 color ) {
|
|||
|
|
color *= toneMappingExposure;
|
|||
|
|
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|||
|
|
}
|
|||
|
|
vec3 CineonToneMapping( vec3 color ) {
|
|||
|
|
color *= toneMappingExposure;
|
|||
|
|
color = max( vec3( 0.0 ), color - 0.004 );
|
|||
|
|
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|||
|
|
}
|
|||
|
|
vec3 RRTAndODTFit( vec3 v ) {
|
|||
|
|
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|||
|
|
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|||
|
|
return a / b;
|
|||
|
|
}
|
|||
|
|
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|||
|
|
const mat3 ACESInputMat = mat3(
|
|||
|
|
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|||
|
|
vec3( 0.04823, 0.01566, 0.83777 )
|
|||
|
|
);
|
|||
|
|
const mat3 ACESOutputMat = mat3(
|
|||
|
|
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|||
|
|
vec3( -0.07367, -0.00605, 1.07602 )
|
|||
|
|
);
|
|||
|
|
color *= toneMappingExposure / 0.6;
|
|||
|
|
color = ACESInputMat * color;
|
|||
|
|
color = RRTAndODTFit( color );
|
|||
|
|
color = ACESOutputMat * color;
|
|||
|
|
return saturate( color );
|
|||
|
|
}
|
|||
|
|
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|||
|
|
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|||
|
|
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|||
|
|
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|||
|
|
);
|
|||
|
|
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|||
|
|
vec3( 0.6274, 0.0691, 0.0164 ),
|
|||
|
|
vec3( 0.3293, 0.9195, 0.0880 ),
|
|||
|
|
vec3( 0.0433, 0.0113, 0.8956 )
|
|||
|
|
);
|
|||
|
|
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|||
|
|
vec3 x2 = x * x;
|
|||
|
|
vec3 x4 = x2 * x2;
|
|||
|
|
return + 15.5 * x4 * x2
|
|||
|
|
- 40.14 * x4 * x
|
|||
|
|
+ 31.96 * x4
|
|||
|
|
- 6.868 * x2 * x
|
|||
|
|
+ 0.4298 * x2
|
|||
|
|
+ 0.1191 * x
|
|||
|
|
- 0.00232;
|
|||
|
|
}
|
|||
|
|
vec3 AgXToneMapping( vec3 color ) {
|
|||
|
|
const mat3 AgXInsetMatrix = mat3(
|
|||
|
|
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|||
|
|
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|||
|
|
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|||
|
|
);
|
|||
|
|
const mat3 AgXOutsetMatrix = mat3(
|
|||
|
|
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|||
|
|
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|||
|
|
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|||
|
|
);
|
|||
|
|
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|||
|
|
color *= toneMappingExposure;
|
|||
|
|
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|||
|
|
color = AgXInsetMatrix * color;
|
|||
|
|
color = max( color, 1e-10 ); color = log2( color );
|
|||
|
|
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|||
|
|
color = clamp( color, 0.0, 1.0 );
|
|||
|
|
color = agxDefaultContrastApprox( color );
|
|||
|
|
color = AgXOutsetMatrix * color;
|
|||
|
|
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|||
|
|
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|||
|
|
color = clamp( color, 0.0, 1.0 );
|
|||
|
|
return color;
|
|||
|
|
}
|
|||
|
|
vec3 NeutralToneMapping( vec3 color ) {
|
|||
|
|
const float StartCompression = 0.8 - 0.04;
|
|||
|
|
const float Desaturation = 0.15;
|
|||
|
|
color *= toneMappingExposure;
|
|||
|
|
float x = min( color.r, min( color.g, color.b ) );
|
|||
|
|
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|||
|
|
color -= offset;
|
|||
|
|
float peak = max( color.r, max( color.g, color.b ) );
|
|||
|
|
if ( peak < StartCompression ) return color;
|
|||
|
|
float d = 1. - StartCompression;
|
|||
|
|
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|||
|
|
color *= newPeak / peak;
|
|||
|
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|||
|
|
return mix( color, vec3( newPeak ), g );
|
|||
|
|
}
|
|||
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,Wq=`#ifdef USE_TRANSMISSION
|
|||
|
|
material.transmission = transmission;
|
|||
|
|
material.transmissionAlpha = 1.0;
|
|||
|
|
material.thickness = thickness;
|
|||
|
|
material.attenuationDistance = attenuationDistance;
|
|||
|
|
material.attenuationColor = attenuationColor;
|
|||
|
|
#ifdef USE_TRANSMISSIONMAP
|
|||
|
|
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_THICKNESSMAP
|
|||
|
|
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|||
|
|
#endif
|
|||
|
|
vec3 pos = vWorldPosition;
|
|||
|
|
vec3 v = normalize( cameraPosition - pos );
|
|||
|
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|||
|
|
vec4 transmitted = getIBLVolumeRefraction(
|
|||
|
|
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|||
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|||
|
|
material.attenuationColor, material.attenuationDistance );
|
|||
|
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|||
|
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|||
|
|
#endif`,$q=`#ifdef USE_TRANSMISSION
|
|||
|
|
uniform float transmission;
|
|||
|
|
uniform float thickness;
|
|||
|
|
uniform float attenuationDistance;
|
|||
|
|
uniform vec3 attenuationColor;
|
|||
|
|
#ifdef USE_TRANSMISSIONMAP
|
|||
|
|
uniform sampler2D transmissionMap;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_THICKNESSMAP
|
|||
|
|
uniform sampler2D thicknessMap;
|
|||
|
|
#endif
|
|||
|
|
uniform vec2 transmissionSamplerSize;
|
|||
|
|
uniform sampler2D transmissionSamplerMap;
|
|||
|
|
uniform mat4 modelMatrix;
|
|||
|
|
uniform mat4 projectionMatrix;
|
|||
|
|
varying vec3 vWorldPosition;
|
|||
|
|
float w0( float a ) {
|
|||
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|||
|
|
}
|
|||
|
|
float w1( float a ) {
|
|||
|
|
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|||
|
|
}
|
|||
|
|
float w2( float a ){
|
|||
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|||
|
|
}
|
|||
|
|
float w3( float a ) {
|
|||
|
|
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|||
|
|
}
|
|||
|
|
float g0( float a ) {
|
|||
|
|
return w0( a ) + w1( a );
|
|||
|
|
}
|
|||
|
|
float g1( float a ) {
|
|||
|
|
return w2( a ) + w3( a );
|
|||
|
|
}
|
|||
|
|
float h0( float a ) {
|
|||
|
|
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|||
|
|
}
|
|||
|
|
float h1( float a ) {
|
|||
|
|
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|||
|
|
}
|
|||
|
|
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|||
|
|
uv = uv * texelSize.zw + 0.5;
|
|||
|
|
vec2 iuv = floor( uv );
|
|||
|
|
vec2 fuv = fract( uv );
|
|||
|
|
float g0x = g0( fuv.x );
|
|||
|
|
float g1x = g1( fuv.x );
|
|||
|
|
float h0x = h0( fuv.x );
|
|||
|
|
float h1x = h1( fuv.x );
|
|||
|
|
float h0y = h0( fuv.y );
|
|||
|
|
float h1y = h1( fuv.y );
|
|||
|
|
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|||
|
|
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|||
|
|
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|||
|
|
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|||
|
|
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|||
|
|
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|||
|
|
}
|
|||
|
|
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|||
|
|
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|||
|
|
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|||
|
|
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|||
|
|
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|||
|
|
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|||
|
|
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|||
|
|
return mix( fSample, cSample, fract( lod ) );
|
|||
|
|
}
|
|||
|
|
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|||
|
|
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|||
|
|
vec3 modelScale;
|
|||
|
|
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|||
|
|
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|||
|
|
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|||
|
|
return normalize( refractionVector ) * thickness * modelScale;
|
|||
|
|
}
|
|||
|
|
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|||
|
|
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|||
|
|
}
|
|||
|
|
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|||
|
|
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|||
|
|
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|||
|
|
}
|
|||
|
|
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|||
|
|
if ( isinf( attenuationDistance ) ) {
|
|||
|
|
return vec3( 1.0 );
|
|||
|
|
} else {
|
|||
|
|
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|||
|
|
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|||
|
|
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|||
|
|
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
|
|||
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|||
|
|
vec4 transmittedLight;
|
|||
|
|
vec3 transmittance;
|
|||
|
|
#ifdef USE_DISPERSION
|
|||
|
|
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
|||
|
|
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
|||
|
|
for ( int i = 0; i < 3; i ++ ) {
|
|||
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
|
|||
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|||
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|||
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|||
|
|
refractionCoords += 1.0;
|
|||
|
|
refractionCoords /= 2.0;
|
|||
|
|
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
|||
|
|
transmittedLight[ i ] = transmissionSample[ i ];
|
|||
|
|
transmittedLight.a += transmissionSample.a;
|
|||
|
|
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
|||
|
|
}
|
|||
|
|
transmittedLight.a /= 3.0;
|
|||
|
|
#else
|
|||
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|||
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|||
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|||
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|||
|
|
refractionCoords += 1.0;
|
|||
|
|
refractionCoords /= 2.0;
|
|||
|
|
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|||
|
|
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|||
|
|
#endif
|
|||
|
|
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|||
|
|
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|||
|
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|||
|
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|||
|
|
}
|
|||
|
|
#endif`,Xq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_MAP
|
|||
|
|
varying vec2 vMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ALPHAMAP
|
|||
|
|
varying vec2 vAlphaMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_LIGHTMAP
|
|||
|
|
varying vec2 vLightMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_AOMAP
|
|||
|
|
varying vec2 vAoMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_BUMPMAP
|
|||
|
|
varying vec2 vBumpMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_NORMALMAP
|
|||
|
|
varying vec2 vNormalMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_EMISSIVEMAP
|
|||
|
|
varying vec2 vEmissiveMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_METALNESSMAP
|
|||
|
|
varying vec2 vMetalnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ROUGHNESSMAP
|
|||
|
|
varying vec2 vRoughnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ANISOTROPYMAP
|
|||
|
|
varying vec2 vAnisotropyMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOATMAP
|
|||
|
|
varying vec2 vClearcoatMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|||
|
|
varying vec2 vClearcoatNormalMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|||
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCEMAP
|
|||
|
|
varying vec2 vIridescenceMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|||
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN_COLORMAP
|
|||
|
|
varying vec2 vSheenColorMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|||
|
|
varying vec2 vSheenRoughnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULARMAP
|
|||
|
|
varying vec2 vSpecularMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|||
|
|
varying vec2 vSpecularColorMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|||
|
|
varying vec2 vSpecularIntensityMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_TRANSMISSIONMAP
|
|||
|
|
uniform mat3 transmissionMapTransform;
|
|||
|
|
varying vec2 vTransmissionMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_THICKNESSMAP
|
|||
|
|
uniform mat3 thicknessMapTransform;
|
|||
|
|
varying vec2 vThicknessMapUv;
|
|||
|
|
#endif`,Yq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_MAP
|
|||
|
|
uniform mat3 mapTransform;
|
|||
|
|
varying vec2 vMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ALPHAMAP
|
|||
|
|
uniform mat3 alphaMapTransform;
|
|||
|
|
varying vec2 vAlphaMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_LIGHTMAP
|
|||
|
|
uniform mat3 lightMapTransform;
|
|||
|
|
varying vec2 vLightMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_AOMAP
|
|||
|
|
uniform mat3 aoMapTransform;
|
|||
|
|
varying vec2 vAoMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_BUMPMAP
|
|||
|
|
uniform mat3 bumpMapTransform;
|
|||
|
|
varying vec2 vBumpMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_NORMALMAP
|
|||
|
|
uniform mat3 normalMapTransform;
|
|||
|
|
varying vec2 vNormalMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_DISPLACEMENTMAP
|
|||
|
|
uniform mat3 displacementMapTransform;
|
|||
|
|
varying vec2 vDisplacementMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_EMISSIVEMAP
|
|||
|
|
uniform mat3 emissiveMapTransform;
|
|||
|
|
varying vec2 vEmissiveMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_METALNESSMAP
|
|||
|
|
uniform mat3 metalnessMapTransform;
|
|||
|
|
varying vec2 vMetalnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ROUGHNESSMAP
|
|||
|
|
uniform mat3 roughnessMapTransform;
|
|||
|
|
varying vec2 vRoughnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ANISOTROPYMAP
|
|||
|
|
uniform mat3 anisotropyMapTransform;
|
|||
|
|
varying vec2 vAnisotropyMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOATMAP
|
|||
|
|
uniform mat3 clearcoatMapTransform;
|
|||
|
|
varying vec2 vClearcoatMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|||
|
|
uniform mat3 clearcoatNormalMapTransform;
|
|||
|
|
varying vec2 vClearcoatNormalMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|||
|
|
uniform mat3 clearcoatRoughnessMapTransform;
|
|||
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN_COLORMAP
|
|||
|
|
uniform mat3 sheenColorMapTransform;
|
|||
|
|
varying vec2 vSheenColorMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|||
|
|
uniform mat3 sheenRoughnessMapTransform;
|
|||
|
|
varying vec2 vSheenRoughnessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCEMAP
|
|||
|
|
uniform mat3 iridescenceMapTransform;
|
|||
|
|
varying vec2 vIridescenceMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|||
|
|
uniform mat3 iridescenceThicknessMapTransform;
|
|||
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULARMAP
|
|||
|
|
uniform mat3 specularMapTransform;
|
|||
|
|
varying vec2 vSpecularMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|||
|
|
uniform mat3 specularColorMapTransform;
|
|||
|
|
varying vec2 vSpecularColorMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|||
|
|
uniform mat3 specularIntensityMapTransform;
|
|||
|
|
varying vec2 vSpecularIntensityMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_TRANSMISSIONMAP
|
|||
|
|
uniform mat3 transmissionMapTransform;
|
|||
|
|
varying vec2 vTransmissionMapUv;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_THICKNESSMAP
|
|||
|
|
uniform mat3 thicknessMapTransform;
|
|||
|
|
varying vec2 vThicknessMapUv;
|
|||
|
|
#endif`,Qq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|||
|
|
vUv = vec3( uv, 1 ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_MAP
|
|||
|
|
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ALPHAMAP
|
|||
|
|
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_LIGHTMAP
|
|||
|
|
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_AOMAP
|
|||
|
|
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_BUMPMAP
|
|||
|
|
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_NORMALMAP
|
|||
|
|
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_DISPLACEMENTMAP
|
|||
|
|
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_EMISSIVEMAP
|
|||
|
|
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_METALNESSMAP
|
|||
|
|
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ROUGHNESSMAP
|
|||
|
|
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ANISOTROPYMAP
|
|||
|
|
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOATMAP
|
|||
|
|
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|||
|
|
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|||
|
|
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCEMAP
|
|||
|
|
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|||
|
|
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN_COLORMAP
|
|||
|
|
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|||
|
|
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULARMAP
|
|||
|
|
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|||
|
|
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|||
|
|
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_TRANSMISSIONMAP
|
|||
|
|
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_THICKNESSMAP
|
|||
|
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|||
|
|
#endif`,Kq=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|||
|
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|||
|
|
#ifdef USE_BATCHING
|
|||
|
|
worldPosition = batchingMatrix * worldPosition;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_INSTANCING
|
|||
|
|
worldPosition = instanceMatrix * worldPosition;
|
|||
|
|
#endif
|
|||
|
|
worldPosition = modelMatrix * worldPosition;
|
|||
|
|
#endif`;const Zq=`varying vec2 vUv;
|
|||
|
|
uniform mat3 uvTransform;
|
|||
|
|
void main() {
|
|||
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|||
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|||
|
|
}`,Jq=`uniform sampler2D t2D;
|
|||
|
|
uniform float backgroundIntensity;
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
void main() {
|
|||
|
|
vec4 texColor = texture2D( t2D, vUv );
|
|||
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|||
|
|
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 );
|
|||
|
|
#endif
|
|||
|
|
texColor.rgb *= backgroundIntensity;
|
|||
|
|
gl_FragColor = texColor;
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
}`,eV=`varying vec3 vWorldDirection;
|
|||
|
|
#include <common>
|
|||
|
|
void main() {
|
|||
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
gl_Position.z = gl_Position.w;
|
|||
|
|
}`,tV=`#ifdef ENVMAP_TYPE_CUBE
|
|||
|
|
uniform samplerCube envMap;
|
|||
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|||
|
|
uniform sampler2D envMap;
|
|||
|
|
#endif
|
|||
|
|
uniform float flipEnvMap;
|
|||
|
|
uniform float backgroundBlurriness;
|
|||
|
|
uniform float backgroundIntensity;
|
|||
|
|
uniform mat3 backgroundRotation;
|
|||
|
|
varying vec3 vWorldDirection;
|
|||
|
|
#include <cube_uv_reflection_fragment>
|
|||
|
|
void main() {
|
|||
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|||
|
|
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|||
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|||
|
|
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|||
|
|
#else
|
|||
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|||
|
|
#endif
|
|||
|
|
texColor.rgb *= backgroundIntensity;
|
|||
|
|
gl_FragColor = texColor;
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
}`,nV=`varying vec3 vWorldDirection;
|
|||
|
|
#include <common>
|
|||
|
|
void main() {
|
|||
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
gl_Position.z = gl_Position.w;
|
|||
|
|
}`,iV=`uniform samplerCube tCube;
|
|||
|
|
uniform float tFlip;
|
|||
|
|
uniform float opacity;
|
|||
|
|
varying vec3 vWorldDirection;
|
|||
|
|
void main() {
|
|||
|
|
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|||
|
|
gl_FragColor = texColor;
|
|||
|
|
gl_FragColor.a *= opacity;
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
}`,rV=`#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
varying vec2 vHighPrecisionZW;
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#ifdef USE_DISPLACEMENTMAP
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#endif
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
vHighPrecisionZW = gl_Position.zw;
|
|||
|
|
}`,sV=`#if DEPTH_PACKING == 3200
|
|||
|
|
uniform float opacity;
|
|||
|
|
#endif
|
|||
|
|
#include <common>
|
|||
|
|
#include <packing>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
varying vec2 vHighPrecisionZW;
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
#if DEPTH_PACKING == 3200
|
|||
|
|
diffuseColor.a = opacity;
|
|||
|
|
#endif
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
|||
|
|
#if DEPTH_PACKING == 3200
|
|||
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|||
|
|
#elif DEPTH_PACKING == 3201
|
|||
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|||
|
|
#elif DEPTH_PACKING == 3202
|
|||
|
|
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|||
|
|
#elif DEPTH_PACKING == 3203
|
|||
|
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|||
|
|
#endif
|
|||
|
|
}`,aV=`#define DISTANCE
|
|||
|
|
varying vec3 vWorldPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#ifdef USE_DISPLACEMENTMAP
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#endif
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
vWorldPosition = worldPosition.xyz;
|
|||
|
|
}`,oV=`#define DISTANCE
|
|||
|
|
uniform vec3 referencePosition;
|
|||
|
|
uniform float nearDistance;
|
|||
|
|
uniform float farDistance;
|
|||
|
|
varying vec3 vWorldPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <packing>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main () {
|
|||
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
float dist = length( vWorldPosition - referencePosition );
|
|||
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|||
|
|
dist = saturate( dist );
|
|||
|
|
gl_FragColor = packDepthToRGBA( dist );
|
|||
|
|
}`,lV=`varying vec3 vWorldDirection;
|
|||
|
|
#include <common>
|
|||
|
|
void main() {
|
|||
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
}`,uV=`uniform sampler2D tEquirect;
|
|||
|
|
varying vec3 vWorldDirection;
|
|||
|
|
#include <common>
|
|||
|
|
void main() {
|
|||
|
|
vec3 direction = normalize( vWorldDirection );
|
|||
|
|
vec2 sampleUV = equirectUv( direction );
|
|||
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
}`,cV=`uniform float scale;
|
|||
|
|
attribute float lineDistance;
|
|||
|
|
varying float vLineDistance;
|
|||
|
|
#include <common>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
vLineDistance = scale * lineDistance;
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,hV=`uniform vec3 diffuse;
|
|||
|
|
uniform float opacity;
|
|||
|
|
uniform float dashSize;
|
|||
|
|
uniform float totalSize;
|
|||
|
|
varying float vLineDistance;
|
|||
|
|
#include <common>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|||
|
|
discard;
|
|||
|
|
}
|
|||
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
outgoingLight = diffuseColor.rgb;
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
}`,fV=`#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <envmap_pars_vertex>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#endif
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <envmap_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,AV=`uniform vec3 diffuse;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#ifndef FLAT_SHADED
|
|||
|
|
varying vec3 vNormal;
|
|||
|
|
#endif
|
|||
|
|
#include <common>
|
|||
|
|
#include <dithering_pars_fragment>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <aomap_pars_fragment>
|
|||
|
|
#include <lightmap_pars_fragment>
|
|||
|
|
#include <envmap_common_pars_fragment>
|
|||
|
|
#include <envmap_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <specularmap_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
#include <specularmap_fragment>
|
|||
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|||
|
|
#ifdef USE_LIGHTMAP
|
|||
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|||
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|||
|
|
#else
|
|||
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|||
|
|
#endif
|
|||
|
|
#include <aomap_fragment>
|
|||
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|||
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|||
|
|
#include <envmap_fragment>
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
#include <dithering_fragment>
|
|||
|
|
}`,dV=`#define LAMBERT
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <envmap_pars_vertex>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <normal_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <shadowmap_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#include <normal_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
vViewPosition = - mvPosition.xyz;
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <envmap_vertex>
|
|||
|
|
#include <shadowmap_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,pV=`#define LAMBERT
|
|||
|
|
uniform vec3 diffuse;
|
|||
|
|
uniform vec3 emissive;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#include <common>
|
|||
|
|
#include <packing>
|
|||
|
|
#include <dithering_pars_fragment>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <aomap_pars_fragment>
|
|||
|
|
#include <lightmap_pars_fragment>
|
|||
|
|
#include <emissivemap_pars_fragment>
|
|||
|
|
#include <envmap_common_pars_fragment>
|
|||
|
|
#include <envmap_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <bsdfs>
|
|||
|
|
#include <lights_pars_begin>
|
|||
|
|
#include <normal_pars_fragment>
|
|||
|
|
#include <lights_lambert_pars_fragment>
|
|||
|
|
#include <shadowmap_pars_fragment>
|
|||
|
|
#include <bumpmap_pars_fragment>
|
|||
|
|
#include <normalmap_pars_fragment>
|
|||
|
|
#include <specularmap_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|||
|
|
vec3 totalEmissiveRadiance = emissive;
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
#include <specularmap_fragment>
|
|||
|
|
#include <normal_fragment_begin>
|
|||
|
|
#include <normal_fragment_maps>
|
|||
|
|
#include <emissivemap_fragment>
|
|||
|
|
#include <lights_lambert_fragment>
|
|||
|
|
#include <lights_fragment_begin>
|
|||
|
|
#include <lights_fragment_maps>
|
|||
|
|
#include <lights_fragment_end>
|
|||
|
|
#include <aomap_fragment>
|
|||
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|||
|
|
#include <envmap_fragment>
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
#include <dithering_fragment>
|
|||
|
|
}`,mV=`#define MATCAP
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <normal_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#include <normal_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
vViewPosition = - mvPosition.xyz;
|
|||
|
|
}`,gV=`#define MATCAP
|
|||
|
|
uniform vec3 diffuse;
|
|||
|
|
uniform float opacity;
|
|||
|
|
uniform sampler2D matcap;
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <dithering_pars_fragment>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <normal_pars_fragment>
|
|||
|
|
#include <bumpmap_pars_fragment>
|
|||
|
|
#include <normalmap_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
#include <normal_fragment_begin>
|
|||
|
|
#include <normal_fragment_maps>
|
|||
|
|
vec3 viewDir = normalize( vViewPosition );
|
|||
|
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|||
|
|
vec3 y = cross( viewDir, x );
|
|||
|
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|||
|
|
#ifdef USE_MATCAP
|
|||
|
|
vec4 matcapColor = texture2D( matcap, uv );
|
|||
|
|
#else
|
|||
|
|
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|||
|
|
#endif
|
|||
|
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
#include <dithering_fragment>
|
|||
|
|
}`,vV=`#define NORMAL
|
|||
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#endif
|
|||
|
|
#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <normal_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#include <normal_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|||
|
|
vViewPosition = - mvPosition.xyz;
|
|||
|
|
#endif
|
|||
|
|
}`,_V=`#define NORMAL
|
|||
|
|
uniform float opacity;
|
|||
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#endif
|
|||
|
|
#include <packing>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <normal_pars_fragment>
|
|||
|
|
#include <bumpmap_pars_fragment>
|
|||
|
|
#include <normalmap_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <normal_fragment_begin>
|
|||
|
|
#include <normal_fragment_maps>
|
|||
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
|||
|
|
#ifdef OPAQUE
|
|||
|
|
gl_FragColor.a = 1.0;
|
|||
|
|
#endif
|
|||
|
|
}`,yV=`#define PHONG
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <envmap_pars_vertex>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <normal_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <shadowmap_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#include <normal_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
vViewPosition = - mvPosition.xyz;
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <envmap_vertex>
|
|||
|
|
#include <shadowmap_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,xV=`#define PHONG
|
|||
|
|
uniform vec3 diffuse;
|
|||
|
|
uniform vec3 emissive;
|
|||
|
|
uniform vec3 specular;
|
|||
|
|
uniform float shininess;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#include <common>
|
|||
|
|
#include <packing>
|
|||
|
|
#include <dithering_pars_fragment>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <aomap_pars_fragment>
|
|||
|
|
#include <lightmap_pars_fragment>
|
|||
|
|
#include <emissivemap_pars_fragment>
|
|||
|
|
#include <envmap_common_pars_fragment>
|
|||
|
|
#include <envmap_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <bsdfs>
|
|||
|
|
#include <lights_pars_begin>
|
|||
|
|
#include <normal_pars_fragment>
|
|||
|
|
#include <lights_phong_pars_fragment>
|
|||
|
|
#include <shadowmap_pars_fragment>
|
|||
|
|
#include <bumpmap_pars_fragment>
|
|||
|
|
#include <normalmap_pars_fragment>
|
|||
|
|
#include <specularmap_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|||
|
|
vec3 totalEmissiveRadiance = emissive;
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
#include <specularmap_fragment>
|
|||
|
|
#include <normal_fragment_begin>
|
|||
|
|
#include <normal_fragment_maps>
|
|||
|
|
#include <emissivemap_fragment>
|
|||
|
|
#include <lights_phong_fragment>
|
|||
|
|
#include <lights_fragment_begin>
|
|||
|
|
#include <lights_fragment_maps>
|
|||
|
|
#include <lights_fragment_end>
|
|||
|
|
#include <aomap_fragment>
|
|||
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|||
|
|
#include <envmap_fragment>
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
#include <dithering_fragment>
|
|||
|
|
}`,bV=`#define STANDARD
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#ifdef USE_TRANSMISSION
|
|||
|
|
varying vec3 vWorldPosition;
|
|||
|
|
#endif
|
|||
|
|
#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <normal_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <shadowmap_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#include <normal_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
vViewPosition = - mvPosition.xyz;
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <shadowmap_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
#ifdef USE_TRANSMISSION
|
|||
|
|
vWorldPosition = worldPosition.xyz;
|
|||
|
|
#endif
|
|||
|
|
}`,SV=`#define STANDARD
|
|||
|
|
#ifdef PHYSICAL
|
|||
|
|
#define IOR
|
|||
|
|
#define USE_SPECULAR
|
|||
|
|
#endif
|
|||
|
|
uniform vec3 diffuse;
|
|||
|
|
uniform vec3 emissive;
|
|||
|
|
uniform float roughness;
|
|||
|
|
uniform float metalness;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#ifdef IOR
|
|||
|
|
uniform float ior;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR
|
|||
|
|
uniform float specularIntensity;
|
|||
|
|
uniform vec3 specularColor;
|
|||
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|||
|
|
uniform sampler2D specularColorMap;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|||
|
|
uniform sampler2D specularIntensityMap;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
uniform float clearcoat;
|
|||
|
|
uniform float clearcoatRoughness;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_DISPERSION
|
|||
|
|
uniform float dispersion;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_IRIDESCENCE
|
|||
|
|
uniform float iridescence;
|
|||
|
|
uniform float iridescenceIOR;
|
|||
|
|
uniform float iridescenceThicknessMinimum;
|
|||
|
|
uniform float iridescenceThicknessMaximum;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN
|
|||
|
|
uniform vec3 sheenColor;
|
|||
|
|
uniform float sheenRoughness;
|
|||
|
|
#ifdef USE_SHEEN_COLORMAP
|
|||
|
|
uniform sampler2D sheenColorMap;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|||
|
|
uniform sampler2D sheenRoughnessMap;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_ANISOTROPY
|
|||
|
|
uniform vec2 anisotropyVector;
|
|||
|
|
#ifdef USE_ANISOTROPYMAP
|
|||
|
|
uniform sampler2D anisotropyMap;
|
|||
|
|
#endif
|
|||
|
|
#endif
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <packing>
|
|||
|
|
#include <dithering_pars_fragment>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <aomap_pars_fragment>
|
|||
|
|
#include <lightmap_pars_fragment>
|
|||
|
|
#include <emissivemap_pars_fragment>
|
|||
|
|
#include <iridescence_fragment>
|
|||
|
|
#include <cube_uv_reflection_fragment>
|
|||
|
|
#include <envmap_common_pars_fragment>
|
|||
|
|
#include <envmap_physical_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <lights_pars_begin>
|
|||
|
|
#include <normal_pars_fragment>
|
|||
|
|
#include <lights_physical_pars_fragment>
|
|||
|
|
#include <transmission_pars_fragment>
|
|||
|
|
#include <shadowmap_pars_fragment>
|
|||
|
|
#include <bumpmap_pars_fragment>
|
|||
|
|
#include <normalmap_pars_fragment>
|
|||
|
|
#include <clearcoat_pars_fragment>
|
|||
|
|
#include <iridescence_pars_fragment>
|
|||
|
|
#include <roughnessmap_pars_fragment>
|
|||
|
|
#include <metalnessmap_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|||
|
|
vec3 totalEmissiveRadiance = emissive;
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
#include <roughnessmap_fragment>
|
|||
|
|
#include <metalnessmap_fragment>
|
|||
|
|
#include <normal_fragment_begin>
|
|||
|
|
#include <normal_fragment_maps>
|
|||
|
|
#include <clearcoat_normal_fragment_begin>
|
|||
|
|
#include <clearcoat_normal_fragment_maps>
|
|||
|
|
#include <emissivemap_fragment>
|
|||
|
|
#include <lights_physical_fragment>
|
|||
|
|
#include <lights_fragment_begin>
|
|||
|
|
#include <lights_fragment_maps>
|
|||
|
|
#include <lights_fragment_end>
|
|||
|
|
#include <aomap_fragment>
|
|||
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|||
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|||
|
|
#include <transmission_fragment>
|
|||
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|||
|
|
#ifdef USE_SHEEN
|
|||
|
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|||
|
|
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|||
|
|
#endif
|
|||
|
|
#ifdef USE_CLEARCOAT
|
|||
|
|
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|||
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|||
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|||
|
|
#endif
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
#include <dithering_fragment>
|
|||
|
|
}`,TV=`#define TOON
|
|||
|
|
varying vec3 vViewPosition;
|
|||
|
|
#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <displacementmap_pars_vertex>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <normal_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <shadowmap_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#include <normal_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <displacementmap_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
vViewPosition = - mvPosition.xyz;
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <shadowmap_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,wV=`#define TOON
|
|||
|
|
uniform vec3 diffuse;
|
|||
|
|
uniform vec3 emissive;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#include <common>
|
|||
|
|
#include <packing>
|
|||
|
|
#include <dithering_pars_fragment>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <aomap_pars_fragment>
|
|||
|
|
#include <lightmap_pars_fragment>
|
|||
|
|
#include <emissivemap_pars_fragment>
|
|||
|
|
#include <gradientmap_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <bsdfs>
|
|||
|
|
#include <lights_pars_begin>
|
|||
|
|
#include <normal_pars_fragment>
|
|||
|
|
#include <lights_toon_pars_fragment>
|
|||
|
|
#include <shadowmap_pars_fragment>
|
|||
|
|
#include <bumpmap_pars_fragment>
|
|||
|
|
#include <normalmap_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|||
|
|
vec3 totalEmissiveRadiance = emissive;
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
#include <normal_fragment_begin>
|
|||
|
|
#include <normal_fragment_maps>
|
|||
|
|
#include <emissivemap_fragment>
|
|||
|
|
#include <lights_toon_fragment>
|
|||
|
|
#include <lights_fragment_begin>
|
|||
|
|
#include <lights_fragment_maps>
|
|||
|
|
#include <lights_fragment_end>
|
|||
|
|
#include <aomap_fragment>
|
|||
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
#include <dithering_fragment>
|
|||
|
|
}`,MV=`uniform float size;
|
|||
|
|
uniform float scale;
|
|||
|
|
#include <common>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
#ifdef USE_POINTS_UV
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
uniform mat3 uvTransform;
|
|||
|
|
#endif
|
|||
|
|
void main() {
|
|||
|
|
#ifdef USE_POINTS_UV
|
|||
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|||
|
|
#endif
|
|||
|
|
#include <color_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphcolor_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
gl_PointSize = size;
|
|||
|
|
#ifdef USE_SIZEATTENUATION
|
|||
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|||
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|||
|
|
#endif
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,EV=`uniform vec3 diffuse;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#include <common>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <map_particle_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_particle_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
outgoingLight = diffuseColor.rgb;
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
}`,CV=`#include <common>
|
|||
|
|
#include <batching_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <morphtarget_pars_vertex>
|
|||
|
|
#include <skinning_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <shadowmap_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <batching_vertex>
|
|||
|
|
#include <beginnormal_vertex>
|
|||
|
|
#include <morphinstance_vertex>
|
|||
|
|
#include <morphnormal_vertex>
|
|||
|
|
#include <skinbase_vertex>
|
|||
|
|
#include <skinnormal_vertex>
|
|||
|
|
#include <defaultnormal_vertex>
|
|||
|
|
#include <begin_vertex>
|
|||
|
|
#include <morphtarget_vertex>
|
|||
|
|
#include <skinning_vertex>
|
|||
|
|
#include <project_vertex>
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <worldpos_vertex>
|
|||
|
|
#include <shadowmap_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,RV=`uniform vec3 color;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#include <common>
|
|||
|
|
#include <packing>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <bsdfs>
|
|||
|
|
#include <lights_pars_begin>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <shadowmap_pars_fragment>
|
|||
|
|
#include <shadowmask_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
}`,NV=`uniform float rotation;
|
|||
|
|
uniform vec2 center;
|
|||
|
|
#include <common>
|
|||
|
|
#include <uv_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
void main() {
|
|||
|
|
#include <uv_vertex>
|
|||
|
|
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|||
|
|
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|||
|
|
#ifndef USE_SIZEATTENUATION
|
|||
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|||
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|||
|
|
#endif
|
|||
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|||
|
|
vec2 rotatedPosition;
|
|||
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|||
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|||
|
|
mvPosition.xy += rotatedPosition;
|
|||
|
|
gl_Position = projectionMatrix * mvPosition;
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
}`,DV=`uniform vec3 diffuse;
|
|||
|
|
uniform float opacity;
|
|||
|
|
#include <common>
|
|||
|
|
#include <uv_pars_fragment>
|
|||
|
|
#include <map_pars_fragment>
|
|||
|
|
#include <alphamap_pars_fragment>
|
|||
|
|
#include <alphatest_pars_fragment>
|
|||
|
|
#include <alphahash_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
void main() {
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <map_fragment>
|
|||
|
|
#include <alphamap_fragment>
|
|||
|
|
#include <alphatest_fragment>
|
|||
|
|
#include <alphahash_fragment>
|
|||
|
|
outgoingLight = diffuseColor.rgb;
|
|||
|
|
#include <opaque_fragment>
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
}`,Zn={alphahash_fragment:Jz,alphahash_pars_fragment:eG,alphamap_fragment:tG,alphamap_pars_fragment:nG,alphatest_fragment:iG,alphatest_pars_fragment:rG,aomap_fragment:sG,aomap_pars_fragment:aG,batching_pars_vertex:oG,batching_vertex:lG,begin_vertex:uG,beginnormal_vertex:cG,bsdfs:hG,iridescence_fragment:fG,bumpmap_pars_fragment:AG,clipping_planes_fragment:dG,clipping_planes_pars_fragment:pG,clipping_planes_pars_vertex:mG,clipping_planes_vertex:gG,color_fragment:vG,color_pars_fragment:_G,color_pars_vertex:yG,color_vertex:xG,common:bG,cube_uv_reflection_fragment:SG,defaultnormal_vertex:TG,displacementmap_pars_vertex:wG,displacementmap_vertex:MG,emissivemap_fragment:EG,emissivemap_pars_fragment:CG,colorspace_fragment:RG,colorspace_pars_fragment:NG,envmap_fragment:DG,envmap_common_pars_fragment:PG,envmap_pars_fragment:LG,envmap_pars_vertex:UG,envmap_physical_pars_fragment:jG,envmap_vertex:BG,fog_vertex:OG,fog_pars_vertex:IG,fog_fragment:FG,fog_pars_fragment:kG,gradientmap_pars_fragment:zG,lightmap_pars_fragment:GG,lights_lambert_fragment:qG,lights_lambert_pars_fragment:VG,lights_pars_begin:HG,lights_toon_fragment:WG,lights_toon_pars_fragment:$G,lights_phong_fragment:XG,lights_phong_pars_fragment:YG,lights_physical_fragment:QG,lights_physical_pars_fragment:KG,lights_fragment_begin:ZG,lights_fragment_maps:JG,lights_fragment_end:eq,logdepthbuf_fragment:tq,logdepthbuf_pars_fragment:nq,logdepthbuf_pars_vertex:iq,logdepthbuf_vertex:rq,map_fragment:sq,map_pars_fragment:aq,map_particle_fragment:oq,map_particle_pars_fragment:lq,metalnessmap_fragment:uq,metalnessmap_pars_fragment:cq,morphinstance_vertex:hq,morphcolor_vertex:fq,morphnormal_vertex:Aq,morphtarget_pars_vertex:dq,morphtarget_vertex:pq,normal_fragment_begin:mq,normal_fragment_maps:gq,normal_pars_fragment:vq,normal_pars_vertex:_q,normal_vertex:yq,normalmap_pars_fragment:xq,clearcoat_normal_fragment_begin:bq,clearcoat_normal_fragment_maps:Sq,clearcoat_pars_fragment:Tq,iridescence_pars_fragment:wq,opaque_fragment:Mq,packing:Eq,premultiplied_alpha_fragment:Cq,project_vertex:Rq,dithering_fragment:Nq,dithering_pars_fragment:Dq,roughnessmap_fragment:Pq,roughnessmap_pars_fragment:Lq,shadowmap_pars_fragment:Uq,shadowmap_pars_vertex:Bq,shadowmap_vertex:Oq,shadowmask_pars_fragment:Iq,skinbase_vertex:Fq,skinning_pars_vertex:kq,skinning_vertex:zq,skinnormal_vertex:Gq,specularmap_fragment:qq,specularmap_pars_fragment:Vq,tonemapping_fragment:Hq,tonemapping_pars_fragment:jq,transmission_fragment:Wq,transmission_pars_fragment:$q,uv_pars_fragment:Xq,uv_pars_vertex:Yq,uv_vertex:Qq,worldpos_vertex:Kq,background_vert:Zq,background_frag:Jq,backgroundCube_vert:eV,backgroundCube_frag:tV,cube_vert:nV,cube_frag:iV,depth_vert:rV,depth_frag:sV,distanceRGBA_vert:aV,distanceRGBA_frag:oV,equirect_vert:lV,equirect_frag:uV,linedashed_vert:cV,linedashed_frag:hV,meshbasic_vert:fV,meshbasic_frag:AV,meshlambert_vert:dV,meshlambert_frag:pV,meshmatcap_vert:mV,meshmatcap_frag:gV,meshnormal_vert:vV,meshnormal_frag:_V,meshphong_vert:yV,meshphong_frag:xV,meshphysical_vert:bV,meshphysical_frag:SV,meshtoon_vert:TV,meshtoon_frag:wV,points_vert:MV,points_frag:EV,shadow_vert:CV,shadow_frag:RV,sprite_vert:NV,sprite_frag:DV},Yt={common:{diffuse:{value:new sn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Vn},alphaMap:{value:null},alphaMapTransform:{value:new Vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Vn}},envmap:{envMap:{value:null},envMapRotation:{value:new Vn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Vn},normalScale:{value:new pt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Vn},displacementScale:{value:1},displacementBias:{value:0}},emissi
|
|||
|
|
|
|||
|
|
precision mediump float;
|
|||
|
|
precision mediump int;
|
|||
|
|
|
|||
|
|
varying vec3 vOutputDirection;
|
|||
|
|
|
|||
|
|
uniform sampler2D envMap;
|
|||
|
|
uniform int samples;
|
|||
|
|
uniform float weights[ n ];
|
|||
|
|
uniform bool latitudinal;
|
|||
|
|
uniform float dTheta;
|
|||
|
|
uniform float mipInt;
|
|||
|
|
uniform vec3 poleAxis;
|
|||
|
|
|
|||
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|||
|
|
#include <cube_uv_reflection_fragment>
|
|||
|
|
|
|||
|
|
vec3 getSample( float theta, vec3 axis ) {
|
|||
|
|
|
|||
|
|
float cosTheta = cos( theta );
|
|||
|
|
// Rodrigues' axis-angle rotation
|
|||
|
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
|||
|
|
+ cross( axis, vOutputDirection ) * sin( theta )
|
|||
|
|
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|||
|
|
|
|||
|
|
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|||
|
|
|
|||
|
|
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|||
|
|
|
|||
|
|
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
axis = normalize( axis );
|
|||
|
|
|
|||
|
|
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|||
|
|
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|||
|
|
|
|||
|
|
for ( int i = 1; i < n; i++ ) {
|
|||
|
|
|
|||
|
|
if ( i >= samples ) {
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
float theta = dTheta * float( i );
|
|||
|
|
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|||
|
|
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,blending:Qa,depthTest:!1,depthWrite:!1})}function OC(){return new Ja({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:aM(),fragmentShader:`
|
|||
|
|
|
|||
|
|
precision mediump float;
|
|||
|
|
precision mediump int;
|
|||
|
|
|
|||
|
|
varying vec3 vOutputDirection;
|
|||
|
|
|
|||
|
|
uniform sampler2D envMap;
|
|||
|
|
|
|||
|
|
#include <common>
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|||
|
|
vec2 uv = equirectUv( outputDirection );
|
|||
|
|
|
|||
|
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,blending:Qa,depthTest:!1,depthWrite:!1})}function IC(){return new Ja({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:aM(),fragmentShader:`
|
|||
|
|
|
|||
|
|
precision mediump float;
|
|||
|
|
precision mediump int;
|
|||
|
|
|
|||
|
|
uniform float flipEnvMap;
|
|||
|
|
|
|||
|
|
varying vec3 vOutputDirection;
|
|||
|
|
|
|||
|
|
uniform samplerCube envMap;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,blending:Qa,depthTest:!1,depthWrite:!1})}function aM(){return`
|
|||
|
|
|
|||
|
|
precision mediump float;
|
|||
|
|
precision mediump int;
|
|||
|
|
|
|||
|
|
attribute float faceIndex;
|
|||
|
|
|
|||
|
|
varying vec3 vOutputDirection;
|
|||
|
|
|
|||
|
|
// RH coordinate system; PMREM face-indexing convention
|
|||
|
|
vec3 getDirection( vec2 uv, float face ) {
|
|||
|
|
|
|||
|
|
uv = 2.0 * uv - 1.0;
|
|||
|
|
|
|||
|
|
vec3 direction = vec3( uv, 1.0 );
|
|||
|
|
|
|||
|
|
if ( face == 0.0 ) {
|
|||
|
|
|
|||
|
|
direction = direction.zyx; // ( 1, v, u ) pos x
|
|||
|
|
|
|||
|
|
} else if ( face == 1.0 ) {
|
|||
|
|
|
|||
|
|
direction = direction.xzy;
|
|||
|
|
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|||
|
|
|
|||
|
|
} else if ( face == 2.0 ) {
|
|||
|
|
|
|||
|
|
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|||
|
|
|
|||
|
|
} else if ( face == 3.0 ) {
|
|||
|
|
|
|||
|
|
direction = direction.zyx;
|
|||
|
|
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|||
|
|
|
|||
|
|
} else if ( face == 4.0 ) {
|
|||
|
|
|
|||
|
|
direction = direction.xzy;
|
|||
|
|
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|||
|
|
|
|||
|
|
} else if ( face == 5.0 ) {
|
|||
|
|
|
|||
|
|
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return direction;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vOutputDirection = getDirection( uv, faceIndex );
|
|||
|
|
gl_Position = vec4( position, 1.0 );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`}function GV(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===zh||u===Gh,g=u===Qo||u===Ko;if(h||g){let v=e.get(l);const x=v!==void 0?v.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==x)return t===null&&(t=new UC(i)),v=h?t.fromEquirectangular(l,v):t.fromCubemap(l,v),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),v.texture;if(v!==void 0)return v.texture;{const S=l.image;return h&&S&&S.height>0||g&&S&&r(S)?(t===null&&(t=new UC(i)),v=h?t.fromEquirectangular(l):t.fromCubemap(l),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),l.addEventListener("dispose",s),v.texture):null}}}return l}function r(l){let u=0;const h=6;for(let g=0;g<h;g++)l[g]!==void 0&&u++;return u===h}function s(l){const u=l.target;u.removeEventListener("dispose",s);const h=e.get(u);h!==void 0&&(e.delete(u),h.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function qV(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&&kf("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function VV(i,e,t,n){const r={},s=new WeakMap;function a(v){const x=v.target;x.index!==null&&e.remove(x.index);for(const w in x.attributes)e.remove(x.attributes[w]);x.removeEventListener("dispose",a),delete r[x.id];const S=s.get(x);S&&(e.remove(S),s.delete(x)),n.releaseStatesOfGeometry(x),x.isInstancedBufferGeometry===!0&&delete x._maxInstanceCount,t.memory.geometries--}function l(v,x){return r[x.id]===!0||(x.addEventListener("dispose",a),r[x.id]=!0,t.memory.geometries++),x}function u(v){const x=v.attributes;for(const S in x)e.update(x[S],i.ARRAY_BUFFER)}function h(v){const x=[],S=v.index,w=v.attributes.position;let R=0;if(S!==null){const B=S.array;R=S.version;for(let L=0,O=B.length;L<O;L+=3){const z=B[L+0],G=B[L+1],k=B[L+2];x.push(z,G,G,k,k,z)}}else if(w!==void 0){const B=w.array;R=w.version;for(let L=0,O=B.length/3-1;L<O;L+=3){const z=L+0,G=L+1,k=L+2;x.push(z,G,G,k,k,z)}}else return;const C=new(O7(x)?$w:Ww)(x,1);C.version=R;const E=s.get(v);E&&e.remove(E),s.set(v,C)}function g(v){const x=s.get(v);if(x){const S=v.index;S!==null&&x.version<S.version&&h(v)}else h(v);return s.get(v)}return{get:l,update:u,getWireframeAttribute:g}}function HV(i,e,t){let n;function r(x){n=x}let s,a;function l(x){s=x.type,a=x.bytesPerElement}function u(x,S){i.drawElements(n,S,s,x*a),t.update(S,n,1)}function h(x,S,w){w!==0&&(i.drawElementsInstanced(n,S,s,x*a,w),t.update(S,n,w))}function g(x,S,w){if(w===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,S,0,s,x,0,w);let C=0;for(let E=0;E<w;E++)C+=S[E];t.update(C,n,1)}function v(x,S,w,R){if(w===0)return;const C=e.get("WEBGL_multi_draw");if(C===null)for(let E=0;E<x.length;E++)h(x[E]/a,S[E],R[E]);else{C.multiDrawElementsInstancedWEBGL(n,S,0,s,x,0,R,0,w);let E=0;for(let B=0;B<w;B++)E+=S[B]*R[B];t.update(E,n,1)}}this.setMode=r,this.setIndex=l,this.render=u,this.renderInstances=h,this.renderMultiDraw=g,this.renderMultiDrawInstances=v}function jV(i){const e={geometries:0,textures:0},t={fra
|
|||
|
|
`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const l=a+1;n.push(`${l===e?">":" "} ${l}: ${t[a]}`)}return n.join(`
|
|||
|
|
`)}const WC=new Vn;function GH(i){ai._getMatrix(WC,ai.workingColorSpace,i);const e=`mat3( ${WC.elements.map(t=>t.toFixed(4))} )`;switch(ai.getTransfer(i)){case a_:return[e,"LinearTransferOETF"];case Vi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function $C(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
|
|||
|
|
|
|||
|
|
`+r+`
|
|||
|
|
|
|||
|
|
`+zH(i.getShaderSource(e),a)}else return r}function qH(i,e){const t=GH(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|||
|
|
`)}function VH(i,e){let t;switch(e){case R7:t="Linear";break;case N7:t="Reinhard";break;case D7:t="Cineon";break;case P7:t="ACESFilmic";break;case L7:t="AgX";break;case U7:t="Neutral";break;case zF:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const $2=new ue;function HH(){ai.getLuminanceCoefficients($2);const i=$2.x.toFixed(4),e=$2.y.toFixed(4),t=$2.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|||
|
|
`)}function jH(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(_m).join(`
|
|||
|
|
`)}function WH(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|||
|
|
`)}function $H(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 l=1;s.type===i.FLOAT_MAT2&&(l=2),s.type===i.FLOAT_MAT3&&(l=3),s.type===i.FLOAT_MAT4&&(l=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:l}}return t}function _m(i){return i!==""}function XC(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 YC(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const XH=/^[ \t]*#include +<([\w\d./]+)>/gm;function KS(i){return i.replace(XH,QH)}const YH=new Map;function QH(i,e){let t=Zn[e];if(t===void 0){const n=YH.get(e);if(n!==void 0)t=Zn[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 KS(t)}const KH=/#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 QC(i){return i.replace(KH,ZH)}function ZH(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 KC(i){let e=`precision ${i.precision} float;
|
|||
|
|
precision ${i.precision} int;
|
|||
|
|
precision ${i.precision} sampler2D;
|
|||
|
|
precision ${i.precision} samplerCube;
|
|||
|
|
precision ${i.precision} sampler3D;
|
|||
|
|
precision ${i.precision} sampler2DArray;
|
|||
|
|
precision ${i.precision} sampler2DShadow;
|
|||
|
|
precision ${i.precision} samplerCubeShadow;
|
|||
|
|
precision ${i.precision} sampler2DArrayShadow;
|
|||
|
|
precision ${i.precision} isampler2D;
|
|||
|
|
precision ${i.precision} isampler3D;
|
|||
|
|
precision ${i.precision} isamplerCube;
|
|||
|
|
precision ${i.precision} isampler2DArray;
|
|||
|
|
precision ${i.precision} usampler2D;
|
|||
|
|
precision ${i.precision} usampler3D;
|
|||
|
|
precision ${i.precision} usamplerCube;
|
|||
|
|
precision ${i.precision} usampler2DArray;
|
|||
|
|
`;return i.precision==="highp"?e+=`
|
|||
|
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|||
|
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|||
|
|
#define LOW_PRECISION`),e}function JH(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===_w?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===BF?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===xo&&(e="SHADOWMAP_TYPE_VSM"),e}function ej(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Qo:case Ko:e="ENVMAP_TYPE_CUBE";break;case sA:e="ENVMAP_TYPE_CUBE_UV";break}return e}function tj(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Ko:e="ENVMAP_MODE_REFRACTION";break}return e}function nj(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Lg:e="ENVMAP_BLENDING_MULTIPLY";break;case E7:e="ENVMAP_BLENDING_MIX";break;case C7:e="ENVMAP_BLENDING_ADD";break}return e}function ij(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 rj(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,l=t.fragmentShader;const u=JH(t),h=ej(t),g=tj(t),v=nj(t),x=ij(t),S=jH(t),w=WH(s),R=r.createProgram();let C,E,B=t.glslVersion?"#version "+t.glslVersion+`
|
|||
|
|
`:"";t.isRawShaderMaterial?(C=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(_m).join(`
|
|||
|
|
`),C.length>0&&(C+=`
|
|||
|
|
`),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(_m).join(`
|
|||
|
|
`),E.length>0&&(E+=`
|
|||
|
|
`)):(C=[KC(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,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 "+g:"",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":"",
|
|||
|
|
`].filter(_m).join(`
|
|||
|
|
`),E=[KC(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,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 "+h:"",t.envMap?"#define "+g:"",t.envMap?"#define "+v:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.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 "+u:"",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_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Za?"#define TONE_MAPPING":"",t.toneMapping!==Za?Zn.tonemapping_pars_fragment:"",t.toneMapping!==Za?VH("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Zn.colorspace_pars_fragment,qH("linearToOutputTexel",t.outputColorSpace),HH(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|||
|
|
`].filter(_m).join(`
|
|||
|
|
`)),a=KS(a),a=XC(a,t),a=YC(a,t),l=KS(l),l=XC(l,t),l=YC(l,t),a=QC(a),l=QC(l),t.isRawShaderMaterial!==!0&&(B=`#version 300 es
|
|||
|
|
`,C=[S,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|||
|
|
`)+`
|
|||
|
|
`+C,E=["#define varying in",t.glslVersion===j5?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===j5?"":"#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(`
|
|||
|
|
`)+`
|
|||
|
|
`+E);const L=B+C+a,O=B+E+l,z=jC(r,r.VERTEX_SHADER,L),G=jC(r,r.FRAGMENT_SHADER,O);r.attachShader(R,z),r.attachShader(R,G),t.index0AttributeName!==void 0?r.bindAttribLocation(R,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(R,0,"position"),r.linkProgram(R);function k(X){if(i.debug.checkShaderErrors){const ee=r.getProgramInfoLog(R).trim(),te=r.getShaderInfoLog(z).trim(),se=r.getShaderInfoLog(G).trim();let ne=!0,Z=!0;if(r.getProgramParameter(R,r.LINK_STATUS)===!1)if(ne=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,R,z,G);else{const ae=$C(r,z,"vertex"),Ae=$C(r,G,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(R,r.VALIDATE_STATUS)+`
|
|||
|
|
|
|||
|
|
Material Name: `+X.name+`
|
|||
|
|
Material Type: `+X.type+`
|
|||
|
|
|
|||
|
|
Program Info Log: `+ee+`
|
|||
|
|
`+ae+`
|
|||
|
|
`+Ae)}else ee!==""?console.warn("THREE.WebGLProgram: Program Info Log:",ee):(te===""||se==="")&&(Z=!1);Z&&(X.diagnostics={runnable:ne,programLog:ee,vertexShader:{log:te,prefix:C},fragmentShader:{log:se,prefix:E}})}r.deleteShader(z),r.deleteShader(G),H=new qv(r,R),F=$H(r,R)}let H;this.getUniforms=function(){return H===void 0&&k(this),H};let F;this.getAttributes=function(){return F===void 0&&k(this),F};let V=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return V===!1&&(V=r.getProgramParameter(R,FH)),V},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(R),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=kH++,this.cacheKey=e,this.usedTimes=1,this.program=R,this.vertexShader=z,this.fragmentShader=G,this}let sj=0;class aj{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 oj(e),t.set(e,n)),n}}class oj{constructor(e){this.id=sj++,this.code=e,this.usedTimes=0}}function lj(i,e,t,n,r,s,a){const l=new jw,u=new aj,h=new Set,g=[],v=r.logarithmicDepthBuffer,x=r.vertexTextures;let S=r.precision;const w={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 R(F){return h.add(F),F===0?"uv":`uv${F}`}function C(F,V,X,ee,te){const se=ee.fog,ne=te.geometry,Z=F.isMeshStandardMaterial?ee.environment:null,ae=(F.isMeshStandardMaterial?t:e).get(F.envMap||Z),Ae=ae&&ae.mapping===sA?ae.image.height:null,Se=w[F.type];F.precision!==null&&(S=r.getMaxPrecision(F.precision),S!==F.precision&&console.warn("THREE.WebGLProgram.getParameters:",F.precision,"not supported, using",S,"instead."));const xe=ne.morphAttributes.position||ne.morphAttributes.normal||ne.morphAttributes.color,le=xe!==void 0?xe.length:0;let we=0;ne.morphAttributes.position!==void 0&&(we=1),ne.morphAttributes.normal!==void 0&&(we=2),ne.morphAttributes.color!==void 0&&(we=3);let He,Te,ke,_e;if(Se){const pn=Ga[Se];He=pn.vertexShader,Te=pn.fragmentShader}else He=F.vertexShader,Te=F.fragmentShader,u.update(F),ke=u.getVertexShaderID(F),_e=u.getFragmentShaderID(F);const De=i.getRenderTarget(),Oe=i.state.buffers.depth.getReversed(),tt=te.isInstancedMesh===!0,Je=te.isBatchedMesh===!0,ft=!!F.map,We=!!F.matcap,rt=!!ae,ce=!!F.aoMap,kt=!!F.lightMap,mt=!!F.bumpMap,Lt=!!F.normalMap,wt=!!F.displacementMap,tn=!!F.emissiveMap,St=!!F.metalnessMap,he=!!F.roughnessMap,Y=F.anisotropy>0,Ce=F.clearcoat>0,je=F.dispersion>0,st=F.iridescence>0,nt=F.sheen>0,Vt=F.transmission>0,Ut=Y&&!!F.anisotropyMap,Wt=Ce&&!!F.clearcoatMap,ln=Ce&&!!F.clearcoatNormalMap,Tt=Ce&&!!F.clearcoatRoughnessMap,Kt=st&&!!F.iridescenceMap,rn=st&&!!F.iridescenceThicknessMap,Ht=nt&&!!F.sheenColorMap,It=nt&&!!F.sheenRoughnessMap,Gt=!!F.specularMap,In=!!F.specularColorMap,Mi=!!F.specularIntensityMap,me=Vt&&!!F.transmissionMap,jt=Vt&&!!F.thicknessMap,at=!!F.gradientMap,yt=!!F.alphaMap,$t=F.alphaTest>0,Ft=!!F.alphaHash,xn=!!F.extensions;let qi=Za;F.toneMapped&&(De===null||De.isXRRenderTarget===!0)&&(qi=i.tone
|
|||
|
|
gl_Position = vec4( position, 1.0 );
|
|||
|
|
}`,_j=`uniform sampler2D shadow_pass;
|
|||
|
|
uniform vec2 resolution;
|
|||
|
|
uniform float radius;
|
|||
|
|
#include <packing>
|
|||
|
|
void main() {
|
|||
|
|
const float samples = float( VSM_SAMPLES );
|
|||
|
|
float mean = 0.0;
|
|||
|
|
float squared_mean = 0.0;
|
|||
|
|
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|||
|
|
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|||
|
|
for ( float i = 0.0; i < samples; i ++ ) {
|
|||
|
|
float uvOffset = uvStart + i * uvStride;
|
|||
|
|
#ifdef HORIZONTAL_PASS
|
|||
|
|
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|||
|
|
mean += distribution.x;
|
|||
|
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|||
|
|
#else
|
|||
|
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|||
|
|
mean += depth;
|
|||
|
|
squared_mean += depth * depth;
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
mean = mean / samples;
|
|||
|
|
squared_mean = squared_mean / samples;
|
|||
|
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|||
|
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|||
|
|
}`;function yj(i,e,t){let n=new Fg;const r=new pt,s=new pt,a=new Pn,l=new Dz({depthPacking:WF}),u=new Pz,h={},g=t.maxTextureSize,v={[Nl]:hr,[hr]:Nl,[as]:as},x=new Ja({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new pt},radius:{value:4}},vertexShader:vj,fragmentShader:_j}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const w=new Ki;w.setAttribute("position",new wr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new zi(w,x),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_w;let E=this.type;this.render=function(G,k,H){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||G.length===0)return;const F=i.getRenderTarget(),V=i.getActiveCubeFace(),X=i.getActiveMipmapLevel(),ee=i.state;ee.setBlending(Qa),ee.buffers.color.setClear(1,1,1,1),ee.buffers.depth.setTest(!0),ee.setScissorTest(!1);const te=E!==xo&&this.type===xo,se=E===xo&&this.type!==xo;for(let ne=0,Z=G.length;ne<Z;ne++){const ae=G[ne],Ae=ae.shadow;if(Ae===void 0){console.warn("THREE.WebGLShadowMap:",ae,"has no shadow.");continue}if(Ae.autoUpdate===!1&&Ae.needsUpdate===!1)continue;r.copy(Ae.mapSize);const Se=Ae.getFrameExtents();if(r.multiply(Se),s.copy(Ae.mapSize),(r.x>g||r.y>g)&&(r.x>g&&(s.x=Math.floor(g/Se.x),r.x=s.x*Se.x,Ae.mapSize.x=s.x),r.y>g&&(s.y=Math.floor(g/Se.y),r.y=s.y*Se.y,Ae.mapSize.y=s.y)),Ae.map===null||te===!0||se===!0){const le=this.type!==xo?{minFilter:mr,magFilter:mr}:{};Ae.map!==null&&Ae.map.dispose(),Ae.map=new qh(r.x,r.y,le),Ae.map.texture.name=ae.name+".shadowMap",Ae.camera.updateProjectionMatrix()}i.setRenderTarget(Ae.map),i.clear();const xe=Ae.getViewportCount();for(let le=0;le<xe;le++){const we=Ae.getViewport(le);a.set(s.x*we.x,s.y*we.y,s.x*we.z,s.y*we.w),ee.viewport(a),Ae.updateMatrices(ae,le),n=Ae.getFrustum(),O(k,H,Ae.camera,ae,this.type)}Ae.isPointLightShadow!==!0&&this.type===xo&&B(Ae,H),Ae.needsUpdate=!1}E=this.type,C.needsUpdate=!1,i.setRenderTarget(F,V,X)};function B(G,k){const H=e.update(R);x.defines.VSM_SAMPLES!==G.blurSamples&&(x.defines.VSM_SAMPLES=G.blurSamples,S.defines.VSM_SAMPLES=G.blurSamples,x.needsUpdate=!0,S.needsUpdate=!0),G.mapPass===null&&(G.mapPass=new qh(r.x,r.y)),x.uniforms.shadow_pass.value=G.map.texture,x.uniforms.resolution.value=G.mapSize,x.uniforms.radius.value=G.radius,i.setRenderTarget(G.mapPass),i.clear(),i.renderBufferDirect(k,null,H,x,R,null),S.uniforms.shadow_pass.value=G.mapPass.texture,S.uniforms.resolution.value=G.mapSize,S.uniforms.radius.value=G.radius,i.setRenderTarget(G.map),i.clear(),i.renderBufferDirect(k,null,H,S,R,null)}function L(G,k,H,F){let V=null;const X=H.isPointLight===!0?G.customDistanceMaterial:G.customDepthMaterial;if(X!==void 0)V=X;else if(V=H.isPointLight===!0?u:l,i.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const ee=V.uuid,te=k.uuid;let se=h[ee];se===void 0&&(se={},h[ee]=se);let ne=se[te];ne===void 0&&(ne=V.clone(),se[te]=ne,k.addEventListener("dispose",z)),V=ne}if(V.visible=k.visible,V.wireframe=k.wireframe,F===xo?V.side=k.shadowSide!==null?k.shadowSide:k.side:V.side=k.shadowSide!==null?k.shadowSide:v[k.side],V.alphaMap=k.alphaMap,V.alphaTest=k.alphaTest,V.map=k.map,V.clipShadows=k.clipShadows,V.clippingPlanes=k.clippingPlanes,V.clipIntersection=k.clipIntersection,V.displacementMap=k.displacementMap,V.displacementScale=k.displacementScale,V.displacementBias=k.displacementBias,V.wireframeLinewidth=k.wireframeLinewidth,V.linewidth=k.linewidth,H.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const ee=i.properties.get(V);ee.light=H}return V}function O(G,k,H,F,V){if(G.visible===!1)return;if(G.layers.test(k.layers)&&(G.isMesh||G.isLine||G.isPoints)&&(G.castShadow||G.receiveShadow&&V===xo)&&(!G.frustumCulled||n.intersectsObject(G))){G.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,G.matrixWorld);const te=e.update(G),se=G.material;if(Array.isArray(se)){const ne=te.groups;for(let Z=0,ae=ne.length;Z<ae;Z++){const Ae=ne[Z],Se=se[Ae.materialIndex];if(Se&&Se.visible){const
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
gl_Position = vec4( position, 1.0 );
|
|||
|
|
|
|||
|
|
}`,Ej=`
|
|||
|
|
uniform sampler2DArray depthColor;
|
|||
|
|
uniform float depthWidth;
|
|||
|
|
uniform float depthHeight;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|||
|
|
|
|||
|
|
if ( coord.x >= 1.0 ) {
|
|||
|
|
|
|||
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}`;class Cj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new vs,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Ja({vertexShader:Mj,fragmentShader:Ej,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new zi(new Ty(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Rj extends zc{constructor(e,t){super();const n=this;let r=null,s=1,a=null,l="local-floor",u=1,h=null,g=null,v=null,x=null,S=null,w=null;const R=new Cj,C=t.getContextAttributes();let E=null,B=null;const L=[],O=[],z=new pt;let G=null;const k=new ya;k.viewport=new Pn;const H=new ya;H.viewport=new Pn;const F=[k,H],V=new $z;let X=null,ee=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Te){let ke=L[Te];return ke===void 0&&(ke=new D3,L[Te]=ke),ke.getTargetRaySpace()},this.getControllerGrip=function(Te){let ke=L[Te];return ke===void 0&&(ke=new D3,L[Te]=ke),ke.getGripSpace()},this.getHand=function(Te){let ke=L[Te];return ke===void 0&&(ke=new D3,L[Te]=ke),ke.getHandSpace()};function te(Te){const ke=O.indexOf(Te.inputSource);if(ke===-1)return;const _e=L[ke];_e!==void 0&&(_e.update(Te.inputSource,Te.frame,h||a),_e.dispatchEvent({type:Te.type,data:Te.inputSource}))}function se(){r.removeEventListener("select",te),r.removeEventListener("selectstart",te),r.removeEventListener("selectend",te),r.removeEventListener("squeeze",te),r.removeEventListener("squeezestart",te),r.removeEventListener("squeezeend",te),r.removeEventListener("end",se),r.removeEventListener("inputsourceschange",ne);for(let Te=0;Te<L.length;Te++){const ke=O[Te];ke!==null&&(O[Te]=null,L[Te].disconnect(ke))}X=null,ee=null,R.reset(),e.setRenderTarget(E),S=null,x=null,v=null,r=null,B=null,He.stop(),n.isPresenting=!1,e.setPixelRatio(G),e.setSize(z.width,z.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Te){s=Te,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Te){l=Te,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||a},this.setReferenceSpace=function(Te){h=Te},this.getBaseLayer=function(){return x!==null?x:S},this.getBinding=function(){return v},this.getFrame=function(){return w},this.getSession=function(){return r},this.setSession=async function(Te){if(r=Te,r!==null){if(E=e.getRenderTarget(),r.addEventListener("select",te),r.addEventListener("selectstart",te),r.addEventListener("selectend",te),r.addEventListener("squeeze",te),r.addEventListener("squeezestart",te),r.addEventListener("squeezeend",te),r.addEventListener("end",se),r.addEventListener("inputsourceschange",ne),C.xrCompatible!==!0&&await t.makeXRCompatible(),G=e.getPixelRatio(),e.getSize(z),r.enabledFeatures!==void 0&&r.enabledFeatures.includes("layers")){let _e=null,De=null,Oe=null;C.depth&&(Oe=C.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,_e=C.stencil?du:au,De=C.stencil?Au:Rr);const tt={colorFormat:t.RGBA8,depthFormat:Oe,scaleFactor:s};v=new XRWebGLBinding(r,t),x=v.createProjectionLayer(tt),r.updateRenderState({layers:[x]}),e.setPixelRatio(1),e.setSize(x.textureWidth,x.textureHeight,!1),B=new qh(x.textureWidth,x.textureHeight,{format:ks,type:aa,depthTexture:new qc(x.textureWidth,x.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,_e),stencilBuffer:C.stencil,colorSpace:e.outputColorSpace,samples:C.antialias?4:0,resolveDepthBuffer:x.ignoreDepthValues===!1})}else{const _e={antialias:C.antialias,alpha:!0,depth:C.depth,stencil:C.stencil,framebufferScaleFactor:s};S=new XRWebGLLayer(r,t,_e),r.updateRenderState({baseLayer:S}),e.setPixelRatio(1),e.setSize(S.framebuff
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function AW(i,e){return lW(i)||hW(i,e)||dW(i,e)||fW()}function dW(i,e){if(i){if(typeof i=="string")return l6(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l6(i,e):void 0}}var pW=cW(function i(e,t){var n=t.default,r=n===void 0?null:n,s=t.triggerUpdate,a=s===void 0?!0:s,l=t.onChange,u=l===void 0?function(h,g){}:l;uW(this,i),this.name=e,this.defaultVal=r,this.triggerUpdate=a,this.onChange=u});function xs(i){var e=i.stateInit,t=e===void 0?function(){return{}}:e,n=i.props,r=n===void 0?{}:n,s=i.methods,a=s===void 0?{}:s,l=i.aliases,u=l===void 0?{}:l,h=i.init,g=h===void 0?function(){}:h,v=i.update,x=v===void 0?function(){}:v,S=Object.keys(r).map(function(w){return new pW(w,r[w])});return function w(){for(var R=arguments.length,C=new Array(R),E=0;E<R;E++)C[E]=arguments[E];var B=!!(this instanceof w&&this.constructor),L=B?C.shift():void 0,O=C[0],z=O===void 0?{}:O,G=Object.assign({},t instanceof Function?t(z):t,{initialised:!1}),k={};function H(X){return F(X,z),V(),H}var F=function(ee,te){g.call(H,ee,G,te),G.initialised=!0},V=oW(function(){G.initialised&&(x.call(H,G,k),k={})},1);return S.forEach(function(X){H[X.name]=ee(X);function ee(te){var se=te.name,ne=te.triggerUpdate,Z=ne===void 0?!1:ne,ae=te.onChange,Ae=ae===void 0?function(le,we){}:ae,Se=te.defaultVal,xe=Se===void 0?null:Se;return function(le){var we=G[se];if(!arguments.length)return we;var He=le===void 0?xe:le;return G[se]=He,Ae.call(H,He,G,we),!k.hasOwnProperty(se)&&(k[se]=we),Z&&V(),H}}}),Object.keys(a).forEach(function(X){H[X]=function(){for(var ee,te=arguments.length,se=new Array(te),ne=0;ne<te;ne++)se[ne]=arguments[ne];return(ee=a[X]).call.apply(ee,[H,G].concat(se))}}),Object.entries(u).forEach(function(X){var ee=AW(X,2),te=ee[0],se=ee[1];return H[te]=H[se]}),H.resetProps=function(){return S.forEach(function(X){H[X.name](X.defaultVal)}),H},H.resetProps(),G._rerender=V,B&&L&&H(L),H}}var os=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jX(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function WX(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return BX(i)}function xT(i,e){return xT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},xT(i,e)}function $v(i,e){return LX(i)||VX(i,e)||JD(i,e)||HX()}function KD(i){return UX(i)||qX(i)||JD(i)||jX()}function $X(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function ZD(i){var e=$X(i,"string");return typeof e=="symbol"?e:e+""}function JD(i,e){if(i){if(typeof i=="string")return yT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?yT(i,e):void 0}}var eP=function(e){e instanceof Array?e.forEach(eP):(e.map&&e.map.dispose(),e.dispose())},tP=function(e){e.geometry&&e.geometry.dispose(),e.material&&eP(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(tP)},eR=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),tP(t)}};function nP(i,e,t){var n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return{x:t*Math.sin(n)*Math.cos(r),y:t*Math.cos(n),z:t*Math.sin(n)*Math.sin(r)}}function XX(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),r}}function Mf(i){return i*Math.PI/180}var iP=function(e){return 1-(gM(0,(.5-e)*Math.PI)[1]/Math.PI+1)/2},I3=function(e){return Math.max(0,Math.min(1,iP(e)))},tR=function(e){return .5-gM.invert(0,(2*(1-e)-1)*Math.PI)[1]/Math.PI},YX=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=Pc().domain([1,0]).range([t,n]).clamp(!0),s=Pc().domain([I3(t),I3(n)]).range([1,0]).clamp(!0),a=function(v){return s(I3(r(v)))},l=e.array,u=0,h=l.length;u<h;u+=2)l[u+1]=a(l[u+1]);e.needsUpdate=!0},nR=function(e,t,n,r){var s=Math.pow(2,e),a=Math.max(0,Math.min(s-1,Math.floor((n+180)*s/360))),l=(90-r)/180;t&&(l=Math.max(0,Math.min(1,iP(l))));var u=Math.floor(l*s);return[a,u]},bT=function(e,t){for(var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,l=[],u=Math.pow(2,e),h=360/u,g=180/u,v=s===void 0?u-1:s,x=a===void 0?u-1:a,S=n,w=Math.min(u-1,v);S<=w;S++)for(var R=r,C=Math.min(u-1,x);R<=C;R++){var E=R,B=g;if(t){E=R===0?R:tR(R/u)*u;var L=R+1===u?R+1:tR((R+1)/u)*u;B=(L-E)*180/u}var O=-180+(S+.5)*h,z=90-(E*180/u+B/2),G=B;l.push({x:S,y:R,lng:O,lat:z,latLen:G})}return l},QX=6,KX=7,ZX=3,JX=90,Ql=new WeakMap,Nh=new WeakMap,F3=new WeakMap,nv=new WeakMap,Vo=new WeakMap,I_=new WeakMap,r0=new WeakMap,Ef=new WeakMap,iv=new WeakSet,eY=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,a=r.minLevel,l=a===void 0?0:a,u=r.maxLevel,h=u===void 0?17:u,g=r.mercatorProjection,v=g===void 0?!0:g;return IX(this,e),n=OX(this,e),FX(n,iv),xh(n,Ql,void 0),xh(n,Nh,void 0),xh(n,F3,void 0),xh(n,nv,void 0),xh(n,Vo,{}),xh(n,I_,void 0),xh(n,r0,void 0),xh(n,Ef,void 0),yd(n,"minLevel",void 0),yd(n,"maxLevel",void 0),yd(n,"thresholds",KD(new Array(30)).map(function(x,S){return 8/Math.pow(2,S)})),yd(n,"curvatureResolution",5),yd(n,"tileMargin",0),yd(n,"clearTiles",function(){Object.values(fi(Vo,n)).forEach(function(x){x.forEach(function(S){S.obj&&(n.remove(S.obj),eR(S.obj),delete S.obj)})}),bh(Vo,n,{})}),bh(Ql,n,t),n.tileUrl=s,bh(Nh,n,v),n.minLevel=l,n.maxLevel=h,n.level=0,n.add(bh(Ef,n,new zi(new Eu(fi(Ql,n)*.99,180,90),new pA({color:0})))),fi(Ef,n).visible=!1,fi(Ef,n).material.polygonOffset=!0,fi(Ef,n).material.polygonO
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,l=!1;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return a=u.done,u},e:function(u){l=!0,s=u},f:function(){try{a||t.return==null||t.return()}finally{if(l)throw s}}}}function k_(i){return k_=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},k_(i)}function MY(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&MT(i,e)}function lP(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lP=function(){return!!i})()}function EY(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function CY(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(g){h=!0,r=g}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function RY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NY(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function DY(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xY(i)}function MT(i,e){return MT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},MT(i,e)}function nm(i,e){return _Y(i)||CY(i,e)||vM(i,e)||RY()}function PY(i){return yY(i)||EY(i)||vM(i)||NY()}function vM(i,e){if(i){if(typeof i=="string")return wT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?wT(i,e):void 0}}var sR=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var a=Vh(s,r)*180/Math.PI;if(a>t)for(var l=dM(r,s),u=r.length>2||s.length>2?fg(r[2]||0,s[2]||0):null,h=u?function(x){return[].concat(PY(l(x)),[u(x)])}:l,g=1/Math.ceil(a/t),v=g;v<1;)n.push(h(v)),v+=g}n.push(r=s)}),n},ET=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Ki,Float32BufferAttribute:wi},LY=new ET.BufferGeometry().setAttribute?"setAttribute":"addAttribute",uP=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;SY(this,e),n=bY(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var a=({Point:g,MultiPoint:v,LineString:x,MultiLineString:S,Polygon:w,MultiPolygon:R}[t.type]||function(){return[]})(t.coordinates,r),l=[],u=[],h=0;a.forEach(function(C){var E=l.length;im({indices:l,vertices:u},C),n.addGroup(E,l.length-E,h++)}),l.length&&n.setIndex(l),u.length&&n[LY]("position",new ET.Float32BufferAttribute(u,3));function g(C,E){var B=k3(C[1],C[0],E+(C[2]||0)),L=[];return[{vertices:B,indices:L}]}function v(C,E){var B={vertices:[],indices:[]};return C.map(function(L){return g(L,E)}).forEach(function(L){var O=nm(L,1),z=O[0];im(B,z)}),[B]}function x(C,E){for(var B=sR(C,s).map(function(H){var F=nm(H,3),V=F[0],X=F[1],ee=F[2],te=ee===void 0?0:ee;return k3(X,V,E+te)}),L=F_([B]),O=L.vertices,z=Math.round(O.length/3),G=[],k=1;k<z;k++)G.push(k-1,k);return[{vertices:O,indices:G}]}function S(C,E){var B={vertices:[],indices:[]};return C.map(function(L){return x(L,E)}).forEach(function(L){var O=nm(L,1),z=O[0];im(B,z)}),[B]}function w(C,E){for(var B=C.map(function(ne){return sR(ne,s).map(function(Z){var ae=nm(Z,3),Ae=ae[0],Se=ae[1],xe=ae[2],le=xe===void 0?0:xe;return k3(Se,Ae,E+le)})}),L=F_(B),O=L.vertices,z=L.holes,G=z[0]||1/0,k=O.slice(0,G*3),H=O.slice(G*3),F=new Set(z),V=Math.round(O.length/3),X=[],ee=[],te=1;te<V;te++)F.has(te)||(te<G?X.push(te-1,te):ee.push(te-1-G,te-G));var se=[{indices:X,vertices:k}];return z.length&&se.push({indices:ee,vertices:H}),se}function R(C,E){var B={vertices:[],indices:[]},L={vertices:[],indices:[]};C.map(function(z){return w(z,E)}).forEach(function(z){var G=nm(z,2),k=G[0],H=G[1];im(B,k),H&&im(L,H)});var O=[B];return L.vertices.length&&O.push(L),O}return n}return MY(e,i),TY(e)})(ET.BufferGeometry);function im(i,e){var t=Math.round(i.vertices.length/3);aR(i.vertices,e.vertices),aR(i.indices,e.indices.map(function(n){return n+t}))}function aR(i,e){var t=wY(e),n;try{for(t.s();!(n=t.n()).done;){var r=n.value;i.push(r)}}catch(s){t.e(s)}finally{t.f()}}function k3(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function UY(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(a){if(a.normalized||a.isInterleavedBufferAttribute){const l=new Float32Array(a.count*a
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function TQ(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wQ(i,e){return pQ(i)||bQ(i,e)||AP(i,e)||SQ()}function MQ(i){return mQ(i)||xQ(i)||AP(i)||TQ()}function EQ(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function CQ(i){var e=EQ(i,"string");return typeof e=="symbol"?e:e+""}function AP(i,e){if(i){if(typeof i=="string")return NT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?NT(i,e):void 0}}var bd=new WeakMap,rm=new WeakMap,Sd=new WeakMap,z3=new WeakMap,G3=new WeakMap,q3=new WeakMap,RQ=(function(){function i(){vQ(this,i),xd(this,bd,new Map),xd(this,rm,new Map),xd(this,Sd,function(e){return e}),xd(this,z3,function(){return{}}),xd(this,G3,function(){}),xd(this,q3,function(){})}return yQ(i,[{key:"getObj",value:function(t){return ta(bd,this).get(ta(Sd,this).call(this,t))}},{key:"getData",value:function(t){return ta(rm,this).get(t)}},{key:"entries",value:function(){return MQ(ta(rm,this).entries()).map(function(t){var n=wQ(t,2),r=n[0],s=n[1];return[s,r]})}},{key:"id",value:function(t){return av(Sd,this,Et(t)),this}},{key:"onCreateObj",value:function(t){return av(z3,this,t),this}},{key:"onUpdateObj",value:function(t){return av(G3,this,t),this}},{key:"onRemoveObj",value:function(t){return av(q3,this,t),this}},{key:"digest",value:function(t){var n=this;t.filter(function(s){return!ta(bd,n).has(ta(Sd,n).call(n,s))}).forEach(function(s){var a=ta(z3,n).call(n,s);ta(bd,n).set(ta(Sd,n).call(n,s),a),ta(rm,n).set(a,s)});var r=new Map(t.map(function(s){return[ta(Sd,n).call(n,s),s]}));return ta(bd,this).forEach(function(s,a){r.has(a)?ta(G3,n).call(n,s,r.get(a)):(ta(q3,n).call(n,s,a),ta(bd,n).delete(a),ta(rm,n).delete(s))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])})(),Xv={exports:{}},NQ=Xv.exports,AR;function DQ(){return AR||(AR=1,(function(i,e){(function(t,n){i.exports=n()})(NQ,function(){return(function(t){function n(s){if(r[s])return r[s].exports;var a=r[s]={exports:{},id:s,loaded:!1};return t[s].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}var r={};return n.m=t,n.c=r,n.p="",n(0)})([function(t,n,r){var s=r(1),a=(function(){function l(u,h,g){u===void 0&&(u=NaN),h===void 0&&(h=NaN),g===void 0&&(g=!1),this._minFPS=h,this._maxFPS=u,this._timeScale=1,this._currentTick=0,this._currentTime=0,this._tickDeltaTime=0,this._isRunning=!1,this._maxInterval=isNaN(this._minFPS)?NaN:1e3/this._minFPS,this._minInterval=isNaN(this._maxFPS)?NaN:1e3/this._maxFPS,this._onResume=new s.default,this._onPause=new s.default,this._onTick=new s.default,this._onTickOncePerFrame=new s.default,g||this.resume()}return l.prototype.updateOnce=function(u){u(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},l.prototype.resume=function(){this._isRunning||(this._isRunning=!0,this._lastTimeUpdated=this.getTimer(),this._onResume.dispatch(),this.animateOnce())},l.prototype.pause=function(){this._isRunning&&(this._isRunning=!1,this._onPause.dispatch(),window.cancelAnimationFrame(this._animationFrameHandle))},l.prototype.dispose=function(){this.pause(),this._onResume.removeAll(),this._onPause.removeAll(),this._onTick.removeAll()},Object.defineProperty(l.prototype,"currentTick",{get:function(){return this._currentTick},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"currentTimeSeconds",{get:function(){return this._currentTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"tickDeltaTimeSeconds",{get:function(){return this._tickDeltaTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"timeScale",{get:function(){return this._timeScale},set:function(u){this._timeScale!==u&&(this._timeScale=u)},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"onResume",{get:function(){return this._onResume
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function PK(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LK(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return TK(i)}function LT(i,e){return LT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},LT(i,e)}function Kl(i,e){return bK(i)||NK(i,e)||gP(i,e)||DK()}function j3(i){return SK(i)||RK(i)||gP(i)||PK()}function gP(i,e){if(i){if(typeof i=="string")return PT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?PT(i,e):void 0}}function UK(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=BK(i,n),s=ug(r),a=OK(i,n),l=[].concat(j3(s),j3(a)),u={type:"Polygon",coordinates:i},h=ID(u),g=Kl(h,2),v=Kl(g[0],2),x=v[0],S=v[1],w=Kl(g[1],2),R=w[0],C=w[1],E=x>R||C>=89||S<=-89,B=[];if(E){var L=xK(l).triangles(),O=new Map(l.map(function(ae,Ae){var Se=Kl(ae,2),xe=Se[0],le=Se[1];return["".concat(xe,"-").concat(le),Ae]}));L.features.forEach(function(ae){var Ae,Se=ae.geometry.coordinates[0].slice(0,3).reverse(),xe=[];if(Se.forEach(function(we){var He=Kl(we,2),Te=He[0],ke=He[1],_e="".concat(Te,"-").concat(ke);O.has(_e)&&xe.push(O.get(_e))}),xe.length===3){if(xe.some(function(we){return we<s.length})){var le=ae.properties.circumcenter;if(!UT(le,u,E))return}(Ae=B).push.apply(Ae,xe)}})}else if(a.length)for(var F=gg.from(l),V=function(Ae){var Se,xe=[2,1,0].map(function(He){return F.triangles[Ae+He]}),le=xe.map(function(He){return l[He]});if(xe.some(function(He){return He<s.length})){var we=[0,1].map(function(He){return WW(le,function(Te){return Te[He]})});if(!UT(we,u,E))return 1}(Se=B).push.apply(Se,j3(xe))},X=0,ee=F.triangles.length;X<ee;X+=3)V(X);else{var z=F_(r),G=z.vertices,k=z.holes,H=k===void 0?[]:k;B=nY(G,H,2)}var te=Pc(A_(l,function(ae){return ae[0]}),[0,1]),se=Pc(A_(l,function(ae){return ae[1]}),[0,1]),ne=l.map(function(ae){var Ae=Kl(ae,2),Se=Ae[0],xe=Ae[1];return[te(Se),se(xe)]}),Z={points:l,indices:B,uvs:ne};return{contour:r,triangles:Z}}function BK(i,e){return i.map(function(t){var n=[],r;return t.forEach(function(s){if(r){var a=Vh(s,r)*180/Math.PI;if(a>e)for(var l=dM(r,s),u=1/Math.ceil(a/e),h=u;h<1;)n.push(l(h)),h+=u}n.push(r=s)}),n})}function OK(i,e){var t={type:"Polygon",coordinates:i},n=ID(t),r=Kl(n,2),s=Kl(r[0],2),a=s[0],l=s[1],u=Kl(r[1],2),h=u[0],g=u[1];if(Math.min(Math.abs(h-a),Math.abs(g-l))<e)return[];var v=a>h||g>=89||l<=-89;return IK(e,{minLng:a,maxLng:h,minLat:l,maxLat:g}).filter(function(x){return UT(x,t,v)})}function IK(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/i,2)/Math.PI),l=(1+Math.sqrt(5))/2,u=function(E){return E/l*360%360-180},h=function(E){return Math.acos(2*E/a-1)/Math.PI*180-90},g=function(E){return a*(Math.cos((E+90)*Math.PI/180)+1)/2},v=[s!==void 0?Math.ceil(g(s)):0,r!==void 0?Math.floor(g(r)):a-1],x=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(C){return C<=n}:n===void 0?function(C){return C>=t}:n>=t?function(C){return C>=t&&C<=n}:function(C){return C>=t||C<=n},S=[],w=v[0];w<=v[1];w++){var R=u(w);x(R)&&S.push([R,h(w)])}return S}function UT(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?mX(e,i):QQ(i,e)}var Yv=window.THREE?window.THREE:{BufferGeometry:Ki,Float32BufferAttribute:wi},wR=new Yv.BufferGeometry().setAttribute?"setAttribute":"addAttribute",TM=(function(i){function e(t,n,r,s,a,l,u){var h;MK(this,e),h=wK(this,e),h.type="ConicPolygonGeometry",h.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:a,includeSides:l,curvatureResolution:u},n=n||0,r=r||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,l=l!==void 0?l:!0,u=u||5;var g=UK(t,{resolution:u}),v=g.contour,x=g.triangles,S=ug(x.uvs),w=[],R=[],C=[],E=0,B=function(k){var H=Math.round(w.length/3),F=C.length;w=
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function HK(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jK(i,e){if(i==null)return{};var t,n,r=WK(i,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(n=0;n<s.length;n++)t=s[n],e.includes(t)||{}.propertyIsEnumerable.call(i,t)&&(r[t]=i[t])}return r}function WK(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.includes(n))continue;t[n]=i[n]}return t}function $K(i,e){return kK(i)||qK(i,e)||vP(i,e)||VK()}function XK(i){return zK(i)||GK(i)||vP(i)||HK()}function YK(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function QK(i){var e=YK(i,"string");return typeof e=="symbol"?e:e+""}function vP(i,e){if(i){if(typeof i=="string")return BT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?BT(i,e):void 0}}var KK=(function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),s=i.reduce(function(l,u){var h=l,g=u;return r.forEach(function(v,x){var S=v.keyAccessor,w=v.isProp,R;if(w){var C=g,E=C[S],B=jK(C,[S].map(QK));R=E,g=B}else R=S(g,x);x+1<r.length?(h.hasOwnProperty(R)||(h[R]={}),h=h[R]):t?(h.hasOwnProperty(R)||(h[R]=[]),h[R].push(g)):h[R]=g}),l},{});t instanceof Function&&(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;h===r.length?Object.keys(u).forEach(function(g){return u[g]=t(u[g])}):Object.values(u).forEach(function(g){return l(g,h+1)})})(s);var a=s;return n&&(a=[],(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];h.length===r.length?a.push({keys:h,vals:u}):Object.entries(u).forEach(function(g){var v=$K(g,2),x=v[0],S=v[1];return l(S,[].concat(XK(h),[x]))})})(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a}),Si=(function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Ke){return e.locateFile?e.locateFile(Ke,r):r+Ke}var a;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",a=function(gt,Ot,lt){var d=new XMLHttpRequest;d.open("GET",gt,!0),d.responseType="arraybuffer",d.onload=function(){if(d.status==200||d.status==0&&d.response){Ot(d.response);return}var $n=Gt(gt);if($n){Ot($n.buffer);return}lt()},d.onerror=lt,d.send(null)};var l=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var h=0,g=function(Ke){h=Ke},v=function(){return h},x=8;function S(Ke,gt,Ot,lt){switch(Ot=Ot||"i8",Ot.charAt(Ot.length-1)==="*"&&(Ot="i32"),Ot){case"i1":ee[Ke>>0]=gt;break;case"i8":ee[Ke>>0]=gt;break;case"i16":se[Ke>>1]=gt;break;case"i32":ne[Ke>>2]=gt;break;case"i64":st=[gt>>>0,(je=gt,+rt(je)>=1?je>0?(mt(+kt(je/4294967296),4294967295)|0)>>>0:~~+ce((je-+(~~je>>>0))/4294967296)>>>0:0)],ne[Ke>>2]=st[0],ne[Ke+4>>2]=st[1];break;case"float":Z[Ke>>2]=gt;break;case"double":ae[Ke>>3]=gt;break;default:Jr("invalid type for setValue: "+Ot)}}function w(Ke,gt,Ot){switch(gt=gt||"i8",gt.charAt(gt.length-1)==="*"&&(gt="i32"),gt){case"i1":return ee[Ke>>0];case"i8":return ee[Ke>>0];case"i16":return se[Ke>>1];case"i32":return ne[Ke>>2];case"i64":return ne[Ke>>2];case"float":return Z[Ke>>2];case"double":return ae[Ke>>3];default:Jr("invalid type for getValue: "+gt)}return null}var R=!1;function C(Ke,gt){Ke||Jr("Assertion failed: "+gt)}function E(Ke){var gt=e["_"+Ke];return C(gt,"Cannot call unknown function "+Ke+", make sure it is expo
|
|||
|
|
* @license
|
|||
|
|
* Copyright 2010-2024 Three.js Authors
|
|||
|
|
* SPDX-License-Identifier: MIT
|
|||
|
|
*/const kZ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class zZ{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=kZ,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:n,material:r,object:s}=e;if(t={material:this.getMaterialData(r),geometry:{attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:a,height:l}=e.context;t.bufferWidth=a,t.bufferHeight=l}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,s=this.getRenderObjectData(e);if(s.worldMatrix.equals(t.matrixWorld)!==!0)return s.worldMatrix.copy(t.matrixWorld),!1;const a=s.material;for(const R in a){const C=a[R],E=n[R];if(C.equals!==void 0){if(C.equals(E)===!1)return C.copy(E),!1}else if(E.isTexture===!0){if(C.id!==E.id||C.version!==E.version)return C.id=E.id,C.version=E.version,!1}else if(C!==E)return a[R]=E,!1}if(a.transmission>0){const{width:R,height:C}=e.context;if(s.bufferWidth!==R||s.bufferHeight!==C)return s.bufferWidth=R,s.bufferHeight=C,!1}const l=s.geometry,u=r.attributes,h=l.attributes,g=Object.keys(h),v=Object.keys(u);if(g.length!==v.length)return s.geometry.attributes=this.getAttributesData(u),!1;for(const R of g){const C=h[R],E=u[R];if(E===void 0)return delete h[R],!1;if(C.version!==E.version)return C.version=E.version,!1}const x=r.index,S=l.indexVersion,w=x?x.version:null;if(S!==w)return l.indexVersion=w,!1;if(l.drawRange.start!==r.drawRange.start||l.drawRange.count!==r.drawRange.count)return l.drawRange.start=r.drawRange.start,l.drawRange.count=r.drawRange.count,!1;if(s.morphTargetInfluences){let R=!1;for(let C=0;C<s.morphTargetInfluences.length;C++)s.morphTargetInfluences[C]!==t.morphTargetInfluences[C]&&(R=!0);if(R)return!0}return s.center&&s.center.equals(t.center)===!1?(s.center.copy(t.center),!0):(e.bundle!==null&&(s.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||s?!1:this.equals(e)!==!0}}function yg(i,e=0){let t=3735928559^e,n=1103547991^e;if(i instanceof Array)for(let r=0,s;r<i.length;r++)s=i[r],t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677);else for(let r=0,s;r<i.length;r++)s=i.charCodeAt(r),t=Math.imul(t^s,2654435761
|
|||
|
|
${e.tab}if ( ${g} ) {
|
|||
|
|
|
|||
|
|
`).addFlowTab();let v=a.build(e,n);if(v&&(u?v=h+" = "+v+";":v="return "+v+";"),e.removeFlowTab().addFlowCode(e.tab+" "+v+`
|
|||
|
|
|
|||
|
|
`+e.tab+"}"),l!==null){e.addFlowCode(` else {
|
|||
|
|
|
|||
|
|
`).addFlowTab();let x=l.build(e,n);x&&(u?x=h+" = "+x+";":x="return "+x+";"),e.removeFlowTab().addFlowCode(e.tab+" "+x+`
|
|||
|
|
|
|||
|
|
`+e.tab+`}
|
|||
|
|
|
|||
|
|
`)}else e.addFlowCode(`
|
|||
|
|
|
|||
|
|
`);return e.format(h,n,t)}}const zs=ht(gJ);ct("select",zs);const KL=(...i)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),zs(...i));ct("cond",KL);class ZL extends Mn{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const zy=ht(ZL),JL=(i,e)=>zy(i,{label:e});ct("context",zy);ct("label",JL);class Kv extends Mn{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const e9=ht(Kv);ct("toVar",(...i)=>e9(...i).append());const t9=i=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),e9(i));ct("temp",t9);class vJ extends Mn{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,s),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||r){const s=this.getNodeType(e),a=e.getPropertyName(n,OT.VERTEX);e.flowNodeFromShaderStage(OT.VERTEX,this.node,s,a),t.propertyName=a,r?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const ro=ht(vJ),n9=i=>ro(i);ct("varying",ro);ct("vertexStage",n9);const i9=Ve(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return Fi(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),r9=Ve(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return Fi(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),jg="WorkingColorSpace",eE="OutputColorSpace";class Wg extends Zr{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===jg?ai.workingColorSpace:t===eE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return ai.enabled===!1||n===r||!n||!r||(ai.getTransfer(n)===Vi&&(s=dn(i9(s.rgb),s.a)),ai.getPrimaries(n)!==ai.getPrimaries(r)&&(s=dn(ha(ai._getMatrix(new Vn,n,r)).mul(s.rgb),s.a)),ai.getTransfer(r)===Vi&&(s=dn(r9(s.rgb),s.a))),s}}const s9=i=>vt(new Wg(vt(i),jg,eE)),a9=i=>vt(new Wg(vt(i),eE,jg)),o9=(i,e)=>vt(new Wg(vt(i),jg,e)),tE=(i,e)=>vt(new Wg(vt(i),e,jg)),_J=(i,e,t)=>vt(new Wg(vt(i),e,t));ct("toOutputColorSpace",s9);ct("toWorkingColorSpace",a9);ct("workingToColorSpace",o9);ct("colorSpaceToWorking",tE);let yJ=class extends vA{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNod
|
|||
|
|
`:"")+e.tab+G+` {
|
|||
|
|
|
|||
|
|
`).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
|
|||
|
|
`+e.tab+s);for(let l=0,u=this.params.length-1;l<u;l++)e.addFlowCode((l===0?"":e.tab)+`}
|
|||
|
|
|
|||
|
|
`).removeFlowTab();return e.addFlowTab(),a}}const ki=(...i)=>vt(new yee(tA(i,"int"))).append(),xee=()=>Hh("continue").append(),TU=()=>Hh("break").append(),bee=(...i)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),ki(...i)),$3=new WeakMap,vo=new Pn,BR=Ve(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const a=ye(gU).mul(t).add(s),l=a.div(n),u=a.sub(l.mul(n));return Fr(i,ms(u,l)).depth(r).mul(e)});function See(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let a=$3.get(i);if(a===void 0||a.count!==s){let B=function(){C.dispose(),$3.delete(i),i.removeEventListener("dispose",B)};var l=B;a!==void 0&&a.texture.dispose();const u=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],g=i.morphAttributes.color||[];let v=0;e===!0&&(v=1),t===!0&&(v=2),n===!0&&(v=3);let x=i.attributes.position.count*v,S=1;const w=4096;x>w&&(S=Math.ceil(x/w),x=w);const R=new Float32Array(x*S*4*s),C=new Hw(R,x,S,s);C.type=$r,C.needsUpdate=!0;const E=v*4;for(let L=0;L<s;L++){const O=u[L],z=h[L],G=g[L],k=x*S*4*L;for(let H=0;H<O.count;H++){const F=H*E;e===!0&&(vo.fromBufferAttribute(O,H),R[k+F+0]=vo.x,R[k+F+1]=vo.y,R[k+F+2]=vo.z,R[k+F+3]=0),t===!0&&(vo.fromBufferAttribute(z,H),R[k+F+4]=vo.x,R[k+F+5]=vo.y,R[k+F+6]=vo.z,R[k+F+7]=0),n===!0&&(vo.fromBufferAttribute(G,H),R[k+F+8]=vo.x,R[k+F+9]=vo.y,R[k+F+10]=vo.z,R[k+F+11]=G.itemSize===4?vo.w:1)}}a={count:s,texture:C,stride:v,size:new pt(x,S)},$3.set(i,a),i.addEventListener("dispose",B)}return a}class Tee extends Mn{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=gn(1),this.updateType=jn.OBJECT}setup(e){const{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=s!==void 0?s.length:0,{texture:l,stride:u,size:h}=See(t);n===!0&&Gr.mulAssign(this.morphBaseInfluence),r===!0&&no.mulAssign(this.morphBaseInfluence);const g=ye(h.width);ki(a,({i:v})=>{const x=ge(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?x.assign(Fr(this.mesh.morphTexture,ms(ye(v).add(1),ye(Jg))).r):x.assign(ji("morphTargetInfluences","float").element(v).toVar()),n===!0&&Gr.addAssign(BR({bufferMap:l,influence:x,stride:u,width:g,depth:v,offset:ye(0)})),r===!0&&no.addAssign(BR({bufferMap:l,influence:x,stride:u,width:g,depth:v,offset:ye(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const wU=ht(Tee);class K0 extends Mn{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class wee extends K0{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Mee extends ZL{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Ne().toVar("directDiffuse"),r=Ne().toVar("directSpecular"),s=Ne().toVar("indirectDiffuse"),a=Ne().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:Ne().toVar("radiance"),irradiance:Ne().toVar("irradiance"),iblIrradiance:Ne().toVar("iblIrradiance"),ambientOcclusion:ge(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const MU=ht(Mee);class Eee extends K0{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let am,om;class ss extends Mn{static get type(){return"S
|
|||
|
|
`,t==="property"?l:e.format(`${l}()`,s,t)}}const SB=(i,e=[],t="")=>{for(let s=0;s<e.length;s++){const a=e[s];typeof a=="function"&&(e[s]=a.functionNode)}const n=vt(new bB(i,e,t)),r=(...s)=>n.call(...s);return r.functionNode=n,r},rre=(i,e)=>SB(i,e,"glsl"),sre=(i,e)=>SB(i,e,"wgsl");class are extends Mn{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new zc,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ge()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=FP(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=kP(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const n_=ht(are);class TB extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class ore{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const i_=new TB;class lre extends Mn{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new TB,this._output=n_(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=n_(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=n_(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}
|
|||
|
|
`,s=`
|
|||
|
|
return { ...output, `+n+" };",a=r+this.codeNode.code+s;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[DP(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Ny(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const ure=ht(lre);function wB(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Xr.z).negate()}const wE=Ve(([i,e],t)=>{const n=wB(t);return kc(i,e,n)}),ME=Ve(([i],e)=>{const t=wB(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Ng=Ve(([i,e])=>dn(e.toFloat().mix(Eg.rgb,i.toVec3()),Eg.a));function cre(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Ng(i,wE(e,t))}function hre(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Ng(i,ME(e))}let Rf=null,Nf=null;class fre extends Mn{static get type(){return"RangeNode"}constructor(e=ge(),t=ge()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Uh(this.minNode.value)),n=e.getTypeLength(Uh(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Uh(r)),l=e.getTypeLength(Uh(s));Rf=Rf||new Pn,Nf=Nf||new Pn,Rf.setScalar(0),Nf.setScalar(0),a===1?Rf.setScalar(r):r.isColor?Rf.set(r.r,r.g,r.b,1):Rf.set(r.x,r.y,r.z||0,r.w||0),l===1?Nf.setScalar(s):s.isColor?Nf.set(s.r,s.g,s.b,1):Nf.set(s.x,s.y,s.z||0,s.w||0);const u=4,h=u*t.count,g=new Float32Array(h);for(let x=0;x<h;x++){const S=x%u,w=Rf.getComponent(S),R=Nf.getComponent(S);g[x]=M0.lerp(w,R,Math.random())}const v=this.getNodeType(e);if(t.count<=4096)n=Yg(g,"vec4",t.count).element(Jg).convert(v);else{const x=new Ig(g,4);e.geometry.setAttribute("__range"+this.id,x),n=J_(x).convert(v)}}else n=ge(0);return n}}const Are=ht(fre);class dre extends Mn{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){const n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage==="compute"?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const Zy=(i,e)=>vt(new dre(i,e)),pre=Zy("numWorkgroups","uvec3"),mre=Zy("workgroupId","uvec3"),gre=Zy("localId","uvec3"),vre=Zy("subgroupSize","uint");class _re extends Mn{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|||
|
|
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const EE=ht(_re),yre=()=>EE("workgroup").append(),xre=()=>EE("storage").append(),bre=()=>EE("texture").append();class Sre extends vA{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class Tre extends Mn{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return vt(new Sre(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const wre=(i,e)=>vt(new Tre("Workgroup",i,e));class Ds extends Zr{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,l=[];l.push(`&${s.build(e,r)}`),l.push(a.build(e,r));const u=`${e.getMethod(t,n)}( ${l.join(", ")} )`;if(this.storeNode!==null){const h=this.storeNode.build(e,r);e.addLineFlowCode(`${h} = ${u}`,this)}else e.addLineFlowCode(u,this)}}Ds.ATOMIC_LOAD="atomicLoad";Ds.ATOMIC_STORE="atomicStore";Ds.ATOMIC_ADD="atomicAdd";Ds.ATOMIC_SUB="atomicSub";Ds.ATOMIC_MAX="atomicMax";Ds.ATOMIC_MIN="atomicMin";Ds.ATOMIC_AND="atomicAnd";Ds.ATOMIC_OR="atomicOr";Ds.ATOMIC_XOR="atomicXor";const Mre=ht(Ds),jc=(i,e,t,n=null)=>{const r=Mre(i,e,t,n);return r.append(),r},Ere=(i,e,t=null)=>jc(Ds.ATOMIC_STORE,i,e,t),Cre=(i,e,t=null)=>jc(Ds.ATOMIC_ADD,i,e,t),Rre=(i,e,t=null)=>jc(Ds.ATOMIC_SUB,i,e,t),Nre=(i,e,t=null)=>jc(Ds.ATOMIC_MAX,i,e,t),Dre=(i,e,t=null)=>jc(Ds.ATOMIC_MIN,i,e,t),Pre=(i,e,t=null)=>jc(Ds.ATOMIC_AND,i,e,t),Lre=(i,e,t=null)=>jc(Ds.ATOMIC_OR,i,e,t),Ure=(i,e,t=null)=>jc(Ds.ATOMIC_XOR,i,e,t);let pv;function t1(i){pv=pv||new WeakMap;let e=pv.get(i);return e===void 0&&pv.set(i,e={}),e}function CE(i){const e=t1(i);return e.shadowMatrix||(e.shadowMatrix=gn("mat4").setGroup(Rn).onRenderUpdate(()=>(i.castShadow!==!0&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function MB(i){const e=t1(i);if(e.projectionUV===void 0){const t=CE(i).mul(Nc);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function RE(i){const e=t1(i);return e.position||(e.position=gn(new ue).setGroup(Rn).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function EB(i){const e=t1(i);return e.targetPosition||(e.targetPosition=gn(new ue).setGroup(Rn).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Jy(i){const e=t1(i);return e.viewPosition||(e.viewPosition=gn(new ue).setGroup(Rn).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new ue,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const NE=i=>so.transformDirection(RE(i).sub(EB(i))),Bre=i=>i.sort((e,t)=>e.id-t.id),Ore=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},oS=new WeakMap;class DE extends Mn{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Ne().toVar("totalDiffuse"),this.totalSpecularNode=Ne().toVar("totalSpecular"),this.outgoingLightNode=Ne().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;n<t.length;n++)e.push(t[n].id);return Ny(e)}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const n of this._lightNodes)t.push(n.getSelf().getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const n of t.nodes)n.build(e)}setupLightsNode(e){const t=[],n=this._lightNode
|
|||
|
|
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new bB,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const l=Object.values(this);return{next:()=>({value:l[a],done:a++>=l.length})}}};for(const a of t.inputs)n[a.name]=new eB(a.type,a.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.cache,a=this.buildStage,l=this.stack,u={code:""};this.flow=u,this.vars={},this.cache=new uS,this.stack=e_();for(const h of IT)this.setBuildStage(h),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=s,this.stack=l,this.setBuildStage(a),u}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,n);return r!==null&&(a.code+=`${this.tab+r} = ${a.result};
|
|||
|
|
`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+`
|
|||
|
|
`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new Vr),r.build(this)}else this.addFlow("compute",e);for(const r of IT){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of FT){this.setShaderStage(s);const a=this.flowNodes[s];for(const l of a)r==="generate"?this.flowNode(l):l.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new Bae(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Oae(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new Iae(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new Fae(e);if(t==="color")return new kae(e);if(t==="mat3")return new zae(e);if(t==="mat4")return new Gae(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),n):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${V0} - Node System
|
|||
|
|
`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class gN{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===jn.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===jn.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===jn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===jn.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===jn.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===jn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===jn.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===jn.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===jn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class FE{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}FE.isNodeFunctionInput=!0;class Xae extends xA{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=NE(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:s},e.stack,e)}}const pS=new kn,_v=new kn;let dm=null;class Yae extends xA{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=gn(new ue).setGroup(Rn),this.halfWidth=gn(new ue).setGroup(Rn),this.updateType=jn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;_v.identity(),pS.copy(t.matrixWorld),pS.premultiply(n),_v.extractRotation(pS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(_v),this.halfHeight.value.applyMatrix4(_v)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=Ai(dm.LTC_FLOAT_1),n=Ai(dm.LTC_FLOAT_2)):(t=Ai(dm.LTC_HALF_1),n=Ai(dm.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,l=Jy(s),u=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:l,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){dm=e}}class XB extends xA{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=gn(0).setGroup(Rn),this.penumbraCosNode=gn(0).setGroup(Rn),this.cutoffDistanceNode=gn(0).setGroup(Rn),this.decayExponentNode=gn(0).setGroup(Rn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return kc(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,l=Jy(a).sub(Xr),u=l.normalize(),h=u.dot(NE(a)),g=this.getSpotAttenuation(h),v=l.length(),x=LE({lightDi
|
|||
|
|
|
|||
|
|
Message: ${e.message}`;e.reason&&(t+=`
|
|||
|
|
Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:a}=e,l=this._currentRenderContext,u=this._bundles.get(r,s),h=this.backend.get(u);h.renderContexts===void 0&&(h.renderContexts=new Set);const g=r.version!==h.version,v=h.renderContexts.has(l)===!1||g;if(h.renderContexts.add(l),v){this.backend.beginBundle(l),(h.renderObjects===void 0||g)&&(h.renderObjects=[]),this._currentRenderBundle=u;const x=a.opaque;this.opaque===!0&&x.length>0&&this._renderObjects(x,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(l,u),h.version=r.version}else{const{renderObjects:x}=h;for(let S=0,w=x.length;S<w;S++){const R=x[S];this._nodes.needsRefresh(R)&&(this._nodes.updateBefore(R),this._nodes.updateForRender(R),this._bindings.updateForRender(R),this._nodes.updateAfter(R))}}this.backend.addBundle(l,u)}render(e,t){if(this._initialized===!1)return console.warn("THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead."),this.renderAsync(e,t);this._renderScene(e,t)}_getFrameBufferTarget(){const{currentToneMapping:e,currentColorSpace:t}=this;if(e!==Za===!1&&t!==Ro===!1)return null;const{width:s,height:a}=this.getDrawingBufferSize(yv),{depth:l,stencil:u}=this;let h=this._frameBufferTarget;return h===null&&(h=new Wh(s,a,{depthBuffer:l,stencilBuffer:u,type:Gs,format:ks,colorSpace:Ro,generateMipmaps:!1,minFilter:gs,magFilter:gs,samples:this.samples}),h.isPostProcessingRenderTarget=!0,this._frameBufferTarget=h),h.depthBuffer=l,h.stencilBuffer=u,h.setSize(s,a),h.viewport.copy(this._viewport),h.scissor.copy(this._scissor),h.viewport.multiplyScalar(this._pixelRatio),h.scissor.multiplyScalar(this._pixelRatio),h.scissorTest=this._scissorTest,h}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;const r=n?this._getFrameBufferTarget():null,s=this._nodes.nodeFrame,a=s.renderId,l=this._currentRenderContext,u=this._currentRenderObjectFunction,h=e.isScene===!0?e:yN,g=this._renderTarget,v=this._activeCubeFace,x=this._activeMipmapLevel;let S;r!==null?(S=r,this.setRenderTarget(S)):S=g;const w=this._renderContexts.get(e,t,S);this._currentRenderContext=w,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,s.renderId=this.info.calls;const R=this.coordinateSystem;t.coordinateSystem!==R&&(t.coordinateSystem=R,t.updateProjectionMatrix()),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld();let C=this._viewport,E=this._scissor,B=this._pixelRatio;S!==null&&(C=S.viewport,E=S.scissor,B=1),this.getDrawingBufferSize(yv),gS.set(0,0,yv.width,yv.height);const L=C.minDepth===void 0?0:C.minDepth,O=C.maxDepth===void 0?1:C.maxDepth;w.viewportValue.copy(C).multiplyScalar(B).floor(),w.viewportValue.width>>=x,w.viewportValue.height>>=x,w.viewportValue.minDepth=L,w.viewportValue.maxDepth=O,w.viewport=w.viewportValue.equals(gS)===!1,w.scissorValue.copy(E).multiplyScalar(B).floor(),w.scissor=this._scissorTest&&w.scissorValue.equals(gS)===!1,w.scissorValue.width>>=x,w.scissorValue.height>>=x,w.clippingContext||(w.clippingContext=new ay),w.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,S),xv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),vS.setFromProjectionMatrix(xv,R);const z=this._renderLists.get(e,t);if(z.begin(),this._projectObject(e,t,0,z,w.clippingContext),z.finish(),this.sortObjects===!0&&z.sort(this._opaqueSort,this._transparentSort),S!==null){this._textures.updateRenderTarget(S,x);const X=this._textures.get(S);w.textures=X.textures,w.depthTexture=X.depthTexture,w.width=X.width,w.height=X.height,w.renderTarget=S,w.depth=S.depthBuffer,w.stencil=S.stencilBuffer}else w.textures=null,w.depthTexture=null,w.width=this.domElement.width,w.height=this.domElement.height,w.depth=this.depth,w.stencil=this.stencil;w.width>>=x,w.height>>=x,w.activeCubeFace=v,w.activeMipmapLevel=x,w.occlusionQueryCount=z.occlusionQueryCount,this._background.update(h,z,w),this.backend.beginRender(
|
|||
|
|
precision highp float;
|
|||
|
|
precision highp int;
|
|||
|
|
precision highp sampler2D;
|
|||
|
|
precision highp sampler3D;
|
|||
|
|
precision highp samplerCube;
|
|||
|
|
precision highp sampler2DArray;
|
|||
|
|
|
|||
|
|
precision highp usampler2D;
|
|||
|
|
precision highp usampler3D;
|
|||
|
|
precision highp usamplerCube;
|
|||
|
|
precision highp usampler2DArray;
|
|||
|
|
|
|||
|
|
precision highp isampler2D;
|
|||
|
|
precision highp isampler3D;
|
|||
|
|
precision highp isamplerCube;
|
|||
|
|
precision highp isampler2DArray;
|
|||
|
|
|
|||
|
|
precision lowp sampler2DShadow;
|
|||
|
|
`;class xoe extends $B{constructor(e,t){super(e,t,new roe),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]},this.useComparisonMethod=!0}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Co}getMethod(e){return _oe[e]||e}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const a of t.inputs)r.push(this.getType(a.type)+" "+a.name);return`${this.getType(t.type)} ${t.name}( ${r.join(", ")} ) {
|
|||
|
|
|
|||
|
|
${n.vars}
|
|||
|
|
|
|||
|
|
${n.code}
|
|||
|
|
return ${n.result};
|
|||
|
|
|
|||
|
|
}`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const n=t.array,r=t.count*t.itemSize,{itemSize:s}=t,a=t.array.constructor.name.toLowerCase().includes("int");let l=a?H0:Bg;s===2?l=a?j0:lA:s===3?l=a?qF:Ug:s===4&&(l=a?W0:ks);const u={Float32Array:$r,Uint8Array:aa,Uint16Array:wl,Uint32Array:Rr,Int8Array:Qf,Int16Array:Kf,Int32Array:Ns,Uint8ClampedArray:aa},h=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/s))));let g=Math.ceil(r/s/h);h*g*s<r&&g++;const v=h*g*s,x=new n.constructor(v);x.set(n,0),t.array=x;const S=new Wk(t.array,h,g,l,u[t.array.constructor.name]||$r);S.needsUpdate=!0,S.isPBOTexture=!0;const w=new yu(S,null,null);w.setPrecision("high"),t.pboNode=w,t.pbo=w.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.label)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?t.charAt(0)+"_"+e.name:super.getPropertyName(e,t)}generatePBO(e){const{node:t,indexNode:n}=e,r=t.value;if(this.renderer.backend.has(r)){const g=this.renderer.backend.get(r);g.pbo=r.pbo}const s=this.getUniformFromNode(r.pboNode,"texture",this.shaderStage,this.context.label),a=this.getPropertyName(s);this.increaseUsage(n);const l=n.build(this,"uint"),u=this.getDataFromNode(e);let h=u.propertyName;if(h===void 0){const g=this.getVarFromNode(e);h=this.getPropertyName(g);const v=this.getDataFromNode(t);let x=v.propertySizeName;x===void 0&&(x=h+"Size",this.getVarFromNode(t,x,"uint"),this.addLineFlowCode(`${x} = uint( textureSize( ${a}, 0 ).x )`,e),v.propertySizeName=x);const{itemSize:S}=r,w="."+gA.join("").slice(0,S),R=`ivec2(${l} % ${x}, ${l} / ${x})`,C=this.generateTextureLoad(null,a,R,null,"0");let E="vec4";r.pbo.type===Rr?E="uvec4":r.pbo.type===Ns&&(E="ivec4"),this.addLineFlowCode(`${h} = ${E}(${C})${w}`,e),u.propertyName=h}return h}generateTextureLoad(e,t,n,r,s="0"){return r?`texelFetch( ${t}, ivec3( ${n}, ${r} ), ${s} )`:`texelFetch( ${t}, ${n}, ${s} )`}generateTexture(e,t,n,r){return e.isDepthTexture?`texture( ${t}, ${n} ).x`:(r&&(n=`vec3( ${n}, ${r} )`),`texture( ${t}, ${n} )`)}generateTextureLevel(e,t,n,r){return`textureLod( ${t}, ${n}, ${r} )`}generateTextureBias(e,t,n,r){return`texture( ${t}, ${n}, ${r} )`}generateTextureGrad(e,t,n,r){return`textureGrad( ${t}, ${n}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`texture( ${t}, vec3( ${n}, ${r} ) )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(`${this.getVar(r.type,r.name)};`);return t.join(`
|
|||
|
|
`)}getUniforms(e){const t=this.uniforms[e],n=[],r={};for(const a of t){let l=null,u=!1;if(a.type==="texture"){const g=a.node.value;let v="";g.isDataTexture===!0&&(g.type===Rr?v="u":g.type===Ns&&(v="i")),g.compareFunction?l=`sampler2DShadow ${a.name};`:g.isDataArrayTexture===!0||g.isCompressedArrayTexture===!0?l=`${v}sampler2DArray ${a.name};`:l=`${v}sampler2D ${a.name};`}else if(a.type==="cubeTexture")l=`samplerCube ${a.name};`;else if(a.type==="texture3D")l=`sampler3D ${a.name};`;else if(a.type==="buffer"){const g=a.node,v=this.getType(g.bufferType),x=g.bufferCount,S=x>0?x:"";l=`${g.name} {
|
|||
|
|
${v} ${a.name}[${S}];
|
|||
|
|
};
|
|||
|
|
`}else l=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const h=a.node.precision;if(h!==null&&(l=yoe[h]+" "+l),u){l=" "+l;const g=a.groupNode.name;(r[g]||(r[g]=[])).push(l)}else l="uniform "+l,n.push(l)}let s="";for(const a in r){const l=r[a];s+=this._getGLSLUniformStruct(e+"_"+a,l.join(`
|
|||
|
|
`))+`
|
|||
|
|
`}return s+=n.join(`
|
|||
|
|
`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ns){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const s of n)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};
|
|||
|
|
`}return t}getStructMembers(e){const t=[],n=e.getMemberTypes();for(let r=0;r<n.length;r++){const s=n[r];t.push(`layout( location = ${r} ) out ${s} m${r};`)}return t.join(`
|
|||
|
|
`)}getStructs(e){const t=[],n=this.structs[e];if(n.length===0)return`layout( location = 0 ) out vec4 fragColor;
|
|||
|
|
`;for(let r=0,s=n.length;r<s;r++){const a=n[r];let l=`
|
|||
|
|
`;l+=this.getStructMembers(a),l+=`
|
|||
|
|
`,t.push(l)}return t.join(`
|
|||
|
|
|
|||
|
|
`)}getVaryings(e){let t="";const n=this.varyings;if(e==="vertex"||e==="compute")for(const r of n){e==="compute"&&(r.needsInterpolation=!0);const s=this.getType(r.type),a=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${a}${r.needsInterpolation?"out":"/*out*/"} ${s} ${r.name};
|
|||
|
|
`}else if(e==="fragment"){for(const r of n)if(r.needsInterpolation){const s=this.getType(r.type),a=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${a}in ${s} ${r.name};
|
|||
|
|
`}}for(const r of this.builtins[e])t+=`${r};
|
|||
|
|
`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((n,r)=>n*r,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:s}of n.values())t.push(`#extension ${r} : ${s}`);return t.join(`
|
|||
|
|
`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=xN[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}xN[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n<e.length;n++){const r=e[n],s=this.getPropertyName(r.attributeNode);t+=`${r.varyingName} = ${s};
|
|||
|
|
`}return t}_getGLSLUniformStruct(e,t){return`
|
|||
|
|
layout( std140 ) uniform ${e} {
|
|||
|
|
${t}
|
|||
|
|
};`}_getGLSLVertexCode(e){return`#version 300 es
|
|||
|
|
|
|||
|
|
${this.getSignature()}
|
|||
|
|
|
|||
|
|
// extensions
|
|||
|
|
${e.extensions}
|
|||
|
|
|
|||
|
|
// precision
|
|||
|
|
${bN}
|
|||
|
|
|
|||
|
|
// uniforms
|
|||
|
|
${e.uniforms}
|
|||
|
|
|
|||
|
|
// varyings
|
|||
|
|
${e.varyings}
|
|||
|
|
|
|||
|
|
// attributes
|
|||
|
|
${e.attributes}
|
|||
|
|
|
|||
|
|
// codes
|
|||
|
|
${e.codes}
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
// vars
|
|||
|
|
${e.vars}
|
|||
|
|
|
|||
|
|
// transforms
|
|||
|
|
${e.transforms}
|
|||
|
|
|
|||
|
|
// flow
|
|||
|
|
${e.flow}
|
|||
|
|
|
|||
|
|
gl_PointSize = 1.0;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`}_getGLSLFragmentCode(e){return`#version 300 es
|
|||
|
|
|
|||
|
|
${this.getSignature()}
|
|||
|
|
|
|||
|
|
// precision
|
|||
|
|
${bN}
|
|||
|
|
|
|||
|
|
// uniforms
|
|||
|
|
${e.uniforms}
|
|||
|
|
|
|||
|
|
// varyings
|
|||
|
|
${e.varyings}
|
|||
|
|
|
|||
|
|
// codes
|
|||
|
|
${e.codes}
|
|||
|
|
|
|||
|
|
${e.structs}
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
// vars
|
|||
|
|
${e.vars}
|
|||
|
|
|
|||
|
|
// flow
|
|||
|
|
${e.flow}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let n=`// code
|
|||
|
|
|
|||
|
|
`;n+=this.flowCode[t];const r=this.flowNodes[t],s=r[r.length-1];for(const l of r){const u=this.getFlowData(l),h=l.name;h&&(n.length>0&&(n+=`
|
|||
|
|
`),n+=` // flow -> ${h}
|
|||
|
|
`),n+=`${u.code}
|
|||
|
|
`,l===s&&t!=="compute"&&(n+=`// result
|
|||
|
|
`,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let l=a.uniformGPU;if(l===void 0){const u=e.groupNode,h=u.name,g=this.getBindGroupArray(h,n);if(t==="texture")l=new ex(s.name,s.node,u),g.push(l);else if(t==="cubeTexture")l=new tO(s.name,s.node,u),g.push(l);else if(t==="texture3D")l=new nO(s.name,s.node,u),g.push(l);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;const v=new JB(e,u);v.name=e.name,g.push(v),l=v}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new eO(n+"_"+h,u),v[h]=x,g.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}}let _S=null,Pd=null;class iO{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return _S=_S||new pt,this.renderer.getDrawingBufferSize(_S)}setScissorTest(){}getClearColor(){const e=this.renderer;return Pd=Pd||new xE,e.getClearColor(Pd),Pd.getRGB(Pd,this.renderer.currentColorSpace),Pd}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:I7(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${V0} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let boe=0;class Soe{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class Toe{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,a=e.usage||r.STATIC_DRAW,l=e.isInterleavedBufferAttribute?e.data:e,u=n.get(l);let h=u.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,a),u.bufferGPU=h,u.bufferType=t,u.version=l.version);let g;if(s instanceof Float32Array)g=r.FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?g=r.HALF_FLOAT:g=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)g=r.SHORT;else if(s instanceof Uint32Array)g=r.UNSIGNED_INT;else if(s instanceof Int32Array)g=r.INT;else if(s instanceof Int8Array)g=r.BYTE;else if(s instanceof Uint8Array)g=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)
|
|||
|
|
`),r=[],s=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let l=s;l<a;l++){const u=l+1;r.push(`${u===t?">":" "} ${u}: ${n[l]}`)}return r.join(`
|
|||
|
|
`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const l=parseInt(a[1]);return n.toUpperCase()+`
|
|||
|
|
|
|||
|
|
`+s+`
|
|||
|
|
|
|||
|
|
`+this._handleSource(e.getShaderSource(t),l)}else return s}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,s=r.getProgramInfoLog(e).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const a=this._getShaderErrors(r,n,"vertex"),l=this._getShaderErrors(r,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+`
|
|||
|
|
|
|||
|
|
Program Info Log: `+s+`
|
|||
|
|
`+a+`
|
|||
|
|
`+l)}else s!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){const{state:n,gl:r}=this,s=this.get(t),{programGPU:a,fragmentShader:l,vertexShader:u}=s;r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,l,u),n.useProgram(a);const h=e.getBindings();this._setupBindings(h,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:r}=this,s={stage:"fragment",code:`#version 300 es
|
|||
|
|
precision highp float;
|
|||
|
|
void main() {}`};this.createProgram(s);const{computeProgram:a}=e,l=r.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU,g=a.transforms,v=[],x=[];for(let C=0;C<g.length;C++){const E=g[C];v.push(E.varyingName),x.push(E.attributeNode)}r.attachShader(l,u),r.attachShader(l,h),r.transformFeedbackVaryings(l,v,r.SEPARATE_ATTRIBS),r.linkProgram(l),r.getProgramParameter(l,r.LINK_STATUS)===!1&&this._logProgramError(l,u,h),n.useProgram(l),this._setupBindings(t,l);const S=a.attributes,w=[],R=[];for(let C=0;C<S.length;C++){const E=S[C].node.attribute;w.push(E),this.has(E)||this.attributeUtils.createAttribute(E,r.ARRAY_BUFFER)}for(let C=0;C<x.length;C++){const E=x[C].attribute;this.has(E)||this.attributeUtils.createAttribute(E,r.ARRAY_BUFFER);const B=this.get(E);R.push(B)}this.set(e,{programGPU:l,transformBuffers:R,attributes:w})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let n=0,r=0;for(const s of t){this.set(s,{textures:r,uniformBuffers:n});for(const a of s.bindings)a.isUniformBuffer&&n++,a.isSampledTexture&&r++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,n=this.get(e);let r=n.uniformBuffers,s=n.textures;for(const a of e.bindings)if(a.isUniformsGroup||a.isUniformBuffer){const l=a.buffer,u=t.createBuffer();t.bindBuffer(t.UNIFORM_BUFFER,u),t.bufferData(t.UNIFORM_BUFFER,l,t.DYNAMIC_DRAW),this.set(a,{index:r++,bufferGPU:u})}else if(a.isSampledTexture){const{textureGPU:l,glTextureType:u}=this.get(a.texture);this.set(a,{index:s++,textureGPU:l,glTextureType:u})}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const r=this.get(e).bufferGPU,s=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,r),t.bufferData(t.UNIFORM_BUFFER,s,t.DYNAMIC_DRAW)}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(MN).filter(r=>MN[r]===e),n=this.extensions;for(let r=0;r<t.length;r++)if(n.has(t[r]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,n=null,r=null,s=0){this.textureUtils.copyTextureToTexture(e,t,n,r,s)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}_setFramebuffer(e){const{gl:t,state:n}=this;let r=null;if(e.textures!==null){const s=e.renderTarget,a=this.get(s),{samples:l,depthBuffer:u,stencilBuffer:h}=s,g=s.isWebGLCubeRenderTarget===!0,v=s.isRenderTarget3D===!0,x=s.isRenderTargetArray===!0;let S=a.msaaFrameBuffer,w=a.depthRenderbuffer;const R=JU(e);let C;if(g?(a.cubeFramebuffers||(a.cubeFramebuffers={}),C=a.cubeFramebuffers[R]):(a.framebuffers||(a.framebuffers={}),C=a.framebuffers[R]),C===void 0){C=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,C);const E=e.textures;if(g){a.cubeFramebuffers[R]=C;const{textureGPU:B}=this.get(E[0]),L=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+L,B,0)}else{a.framebuffers[R]=C;for(let B=0;B<E.length;B++){const L=E[B],O=this.get(L);O.renderTarget=e.renderTarget,O.cacheKey=R;const z=t.COLOR_ATTACHMENT0+B;if(v||x){const G=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,z,O.textureGPU,0,G)}else t.framebufferTexture2D(t.FRAMEBUFFER,z,t.TEXTURE_2D,O.textureGPU,0)}n.drawBuffers(e,C)}if(e.depthTexture!==null){const B=this.get(e.depthTexture),L=h?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;B.renderTarget=e.renderTarget,B.cacheKey=R,t.framebufferTexture2D(t.FRAMEBUFFER,L,t.TEXTURE_2D,B.textureGPU,0)}}if(l>0){if(S===void 0){const E=[];S=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,S);const B=[],L=e.textures;for(let O=0;O<L.length;O++){if(B[O]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,B[O]),E.push(t.COLOR_ATTACH
|
|||
|
|
struct VarysStruct {
|
|||
|
|
@builtin( position ) Position: vec4<f32>,
|
|||
|
|
@location( 0 ) vTex : vec2<f32>
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
@vertex
|
|||
|
|
fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
|
|||
|
|
|
|||
|
|
var Varys : VarysStruct;
|
|||
|
|
|
|||
|
|
var pos = array< vec2<f32>, 4 >(
|
|||
|
|
vec2<f32>( -1.0, 1.0 ),
|
|||
|
|
vec2<f32>( 1.0, 1.0 ),
|
|||
|
|
vec2<f32>( -1.0, -1.0 ),
|
|||
|
|
vec2<f32>( 1.0, -1.0 )
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
var tex = array< vec2<f32>, 4 >(
|
|||
|
|
vec2<f32>( 0.0, 0.0 ),
|
|||
|
|
vec2<f32>( 1.0, 0.0 ),
|
|||
|
|
vec2<f32>( 0.0, 1.0 ),
|
|||
|
|
vec2<f32>( 1.0, 1.0 )
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
Varys.vTex = tex[ vertexIndex ];
|
|||
|
|
Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
|
|||
|
|
|
|||
|
|
return Varys;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,n=`
|
|||
|
|
@group( 0 ) @binding( 0 )
|
|||
|
|
var imgSampler : sampler;
|
|||
|
|
|
|||
|
|
@group( 0 ) @binding( 1 )
|
|||
|
|
var img : texture_2d<f32>;
|
|||
|
|
|
|||
|
|
@fragment
|
|||
|
|
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|||
|
|
|
|||
|
|
return textureSample( img, imgSampler, vTex );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,r=`
|
|||
|
|
@group( 0 ) @binding( 0 )
|
|||
|
|
var imgSampler : sampler;
|
|||
|
|
|
|||
|
|
@group( 0 ) @binding( 1 )
|
|||
|
|
var img : texture_2d<f32>;
|
|||
|
|
|
|||
|
|
@fragment
|
|||
|
|
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|||
|
|
|
|||
|
|
return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`;this.mipmapSampler=e.createSampler({minFilter:qf.Linear}),this.flipYSampler=e.createSampler({minFilter:qf.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Zd.TriangleStrip,stripIndexFormat:k0.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Zd.TriangleStrip,stripIndexFormat:k0.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:s,height:a}=t.size,l=this.getTransferPipeline(r),u=this.getFlipYPipeline(r),h=this.device.createTexture({size:{width:s,height:a,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),g=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:za.TwoD,baseArrayLayer:n}),v=h.createView({baseMipLevel:0,mipLevelCount:1,dimension:za.TwoD,baseArrayLayer:0}),x=this.device.createCommandEncoder({}),S=(w,R,C)=>{const E=w.getBindGroupLayout(0),B=this.device.createBindGroup({layout:E,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:R}]}),L=x.beginRenderPass({colorAttachments:[{view:C,loadOp:Wr.Clear,storeOp:ia.Store,clearValue:[0,0,0,0]}]});L.setPipeline(w),L.setBindGroup(0,B),L.draw(4,1,0,0),L.end()};S(l,g,v),S(u,v,g),this.device.queue.submit([x.finish()]),h.destroy()}generateMipmaps(e,t,n=0){const r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);const s=r.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,s),this.device.queue.submit([a.finish()]),r.useCount!==0&&(r.layers[n]=s),r.useCount++}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),s=r.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:za.TwoD,baseArrayLayer:n});const l=[];for(let u=1;u<t.mipLevelCount;u++){const h=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:a}]}),g=e.createView({baseMipLevel:u,mipLevelCount:1,dimension:za.TwoD,baseArrayLayer:n}),v={colorAttachments:[{view:g,loadOp:Wr.Clear,storeOp:ia.Store,clearValue:[0,0,0,0]}]},x=this.device.createRenderBundleEncoder({colorFormats:[t.format]});x.setPipeline(r),x.setBindGroup(0,h),x.draw(4,1,0,0),l.push({renderBundles:[x.finish()],passDescriptor:v}),a=g}return l}_mipmapRunBundles(e,t){const n=t.length;for(let r=0;r<n;r++){const s=t[r],a=e.beginRenderPass(s.passDescriptor);a.executeBundles(s.renderBundles),a.end()}}}const Foe={[Iw]:"never",[my]:"less",[Fw]:"equal",[gy]:"less-equal",[kw]:"greater",[Gw]:"greater-equal",[qw]:"always",[zw]:"not-equal"},koe=[0,1,3,2,4,5];class zoe{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new qc,this.depthTexture.name="depthBuffer"}createSampler(e){const t=this.backend,n=t.device,r=t.get(e),s={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};s.magFilter===qf.Linear&&s.minFilter===qf.Linear&&s.mipmapFilter===qf.Linear&&(s.maxAnisotropy=e.anisotropy),e.isDepth
|
|||
|
|
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|||
|
|
|
|||
|
|
let res = vec2f( iRes );
|
|||
|
|
|
|||
|
|
let uvScaled = coord * res;
|
|||
|
|
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|||
|
|
|
|||
|
|
// https://www.shadertoy.com/view/WtyXRy
|
|||
|
|
|
|||
|
|
let uv = uvWrapping - 0.5;
|
|||
|
|
let iuv = floor( uv );
|
|||
|
|
let f = fract( uv );
|
|||
|
|
|
|||
|
|
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|||
|
|
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|||
|
|
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|||
|
|
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|||
|
|
|
|||
|
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`)},Mm={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>"};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(Wo.pow_float=new rs("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),Wo.pow_vec2=new rs("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[Wo.pow_float]),Wo.pow_vec3=new rs("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[Wo.pow_float]),Wo.pow_vec4=new rs("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[Wo.pow_float]),Mm.pow_float="tsl_pow_float",Mm.pow_vec2="tsl_pow_vec2",Mm.pow_vec3="tsl_pow_vec3",Mm.pow_vec4="tsl_pow_vec4");let rO="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(rO+=`diagnostic( off, derivative_uniformity );
|
|||
|
|
`);class Yoe extends $B{constructor(e,t){super(e,t,new joe),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Co}_generateTextureSample(e,t,n,r,s=this.shaderStage){return s==="fragment"?r?`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n):this.generateTextureLod(e,t,n,r,"0")}_generateVideoSample(e,t,n=this.shaderStage){if(n==="fragment")return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2<f32>( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${n} shader.`)}_generateTextureSampleLevel(e,t,n,r,s,a=this.shaderStage){return(a==="fragment"||a==="compute")&&this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r):this.generateTextureLod(e,t,n,s,r)}generateWrapFunction(e){const t=`tsl_coord_${DN[e.wrapS]}S_${DN[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=LN[t];if(n===void 0){const r=[],s=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${s} ) -> ${s} {
|
|||
|
|
|
|||
|
|
return ${s}(
|
|||
|
|
`;const l=(u,h)=>{u===aA?(r.push(Wo.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${h} )`):u===eu?(r.push(Wo.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${h} )`):u===oA?(r.push(Wo.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${h} )`):(a+=` coord.${h}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};l(e.wrapS,"x"),a+=`,
|
|||
|
|
`,l(e.wrapT,"y"),e.isData3DTexture&&(a+=`,
|
|||
|
|
`,l(e.wrapR,"z")),a+=`
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,LN[t]=n=new rs(a,r)}return n.build(this),t}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,l;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),h=u>1;e.isData3DTexture?l="vec3<u32>":l="vec2<u32>",h||e.isVideoTexture||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,s=new Kv(new Zv(`textureDimensions( ${a} )`,l)),r.dimensionsSnippet[n]=s,(e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Kv(new Zv(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Kv(new Zv("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,r="0u"){this._include("biquadraticTexture");const s=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,r);return`tsl_biquadraticTexture( ${t}, ${s}( ${n} ), ${a}, u32( ${r} ) )`}generateTextureLod(e,t,n,r,s="0u"){const a=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,s),u=e.isData3DTexture?"vec3":"vec2",h=`${u}<u32>(${a}(${n}) * ${u}<f32>(${l}))`;return this.generateTextureLoad(e,t,h,r,s)}generateTextureLoad(e,t,n,r,s="0u"){return e.isVideoTexture===!0||e.isStorageTexture===!0?`textureLoad( ${t}, ${n} )`:r?`textureLoad( ${t}, ${n}, ${r}, u32( ${s} ) )`:`textureLoad( ${t}, ${n}, u32( ${s} ) )`}generateTextureStore(e,t,n,r){return`textureStore( ${t}, ${n}, ${r} )`}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===$r||this.isSampleCompare(e)===!1&&e.minFilter===mr&&e.magFilter===mr||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,s=this.shaderStage){let a=null;return e.isVideoTexture===!0?a=this._generateVideoSample(t,n,s):this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,r,"0",s):a=this._generateTextureSample(e,t,n,r,s),a}generateTextureGrad(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,r,s,a=this.shaderStage){let l=null;return e.isVideoTexture===!0?l=this._generateVideoSample(t,n,a):l=this._generateTextureSampleLevel(e,t,n,r,s,a),l}generateTextureBias(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?`NodeBuffer_${e.id}.${n}`:e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=$oe[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?sa.READ_ONLY:e.access}getStorageAccess(e,t){return Woe[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let l;const u=e.groupNode,h=u.name,g=this.getBindGroupArray(h,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let v=null;const x=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?v=new ex(s.name,s.node,u,x):t==="cubeTexture"?v=new tO(s.name,s.node,u,x):t==="texture3D"
|
|||
|
|
${n.vars}
|
|||
|
|
${n.code}
|
|||
|
|
`;return n.result&&(s+=` return ${n.result};
|
|||
|
|
`),s+=`
|
|||
|
|
}
|
|||
|
|
`,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);return t.join(`
|
|||
|
|
`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:s,type:a}of n.values())t.push(`@builtin( ${r} ) ${s} : ${a}`);return t.join(`,
|
|||
|
|
`)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:s,bufferCount:a}of this.scopedArrays.values()){const l=this.getType(s);t.push(`var<${r}> ${n}: array< ${l}, ${a} >;`)}return t.join(`
|
|||
|
|
`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","id","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let s=0,a=r.length;s<a;s++){const l=r[s],u=l.name,h=this.getType(l.type);t.push(`@location( ${s} ) ${u} : ${h}`)}}return t.join(`,
|
|||
|
|
`)}getStructMembers(e){const t=[],n=e.getMemberTypes();for(let s=0;s<n.length;s++){const a=n[s];t.push(` @location( ${s} ) m${s} : ${a}<f32>`)}const r=this.getBuiltins("output");return r&&t.push(" "+r),t.join(`,
|
|||
|
|
`)}getStructs(e){const t=[],n=this.structs[e];for(let r=0,s=n.length;r<s;r++){const a=n[r],l=a.name;let u=`struct ${l} {
|
|||
|
|
`;u+=this.getStructMembers(a),u+=`
|
|||
|
|
}`,t.push(u),t.push(`
|
|||
|
|
var<private> output : ${l};
|
|||
|
|
|
|||
|
|
`)}return t.join(`
|
|||
|
|
|
|||
|
|
`)}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(` ${this.getVar(r.type,r.name)};`);return`
|
|||
|
|
${t.join(`
|
|||
|
|
`)}
|
|||
|
|
`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,a=this.vars[e];for(let l=0;l<s.length;l++){const u=s[l];if(u.needsInterpolation){let h=`@location( ${l} )`;/^(int|uint|ivec|uvec)/.test(u.type)&&(h+=" @interpolate( flat )"),t.push(`${h} ${u.name} : ${this.getType(u.type)}`)}else e==="vertex"&&a.includes(u)===!1&&a.push(u)}}const n=this.getBuiltins(e);n&&t.push(n);const r=t.join(`,
|
|||
|
|
`);return e==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+r):r}getUniforms(e){const t=this.uniforms[e],n=[],r=[],s=[],a={};for(const u of t){const h=u.groupNode.name,g=this.bindingsIndexes[h];if(u.type==="texture"||u.type==="cubeTexture"||u.type==="storageTexture"||u.type==="texture3D"){const v=u.node.value;(e==="fragment"||e==="compute")&&this.isUnfilterable(v)===!1&&u.node.isStorageTextureNode!==!0&&(this.isSampleCompare(v)?n.push(`@binding( ${g.binding++} ) @group( ${g.group} ) var ${u.name}_sampler : sampler_comparison;`):n.push(`@binding( ${g.binding++} ) @group( ${g.group} ) var ${u.name}_sampler : sampler;`));let x,S="";const{primarySamples:w}=this.renderer.backend.utils.getTextureSampleData(v);if(w>1&&(S="_multisampled"),v.isCubeTexture===!0)x="texture_cube<f32>";else if(v.isDataArrayTexture===!0||v.isCompressedArrayTexture===!0)x="texture_2d_array<f32>";else if(v.isDepthTexture===!0)x=`texture_depth${S}_2d`;else if(v.isVideoTexture===!0)x="texture_external";else if(v.isData3DTexture===!0)x="texture_3d<f32>";else if(u.node.isStorageTextureNode===!0){const R=nw(v),C=this.getStorageAccess(u.node,e);x=`texture_storage_2d<${R}, ${C}>`}else{const R=this.getComponentTypeFromTexture(v).charAt(0);x=`texture${S}_2d<${R}32>`}n.push(`@binding( ${g.binding++} ) @group( ${g.group} ) var ${u.name} : ${x};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const v=u.node,x=this.getType(v.bufferType),S=v.bufferCount,w=S>0&&u.type==="buffer"?", "+S:"",R=v.isAtomic?`atomic<${x}>`:`${x}`,C=` ${u.name} : array< ${R}${w} >
|
|||
|
|
`,E=v.isStorageBufferNode?`storage, ${this.getStorageAccess(v,e)}`:"uniform";r.push(this._getWGSLStructBinding("NodeBuffer_"+v.id,C,E,g.binding++,g.group))}else{const v=this.getType(this.getVectorType(u.type)),x=u.groupNode.name;(a[x]||(a[x]={index:g.binding++,id:g.group,snippets:[]})).snippets.push(` ${u.name} : ${v}`)}}for(const u in a){const h=a[u];s.push(this._getWGSLStructBinding(u,h.snippets.join(`,
|
|||
|
|
`),"uniform",h.index,h.id))}let l=n.join(`
|
|||
|
|
`);return l+=r.join(`
|
|||
|
|
`),l+=s.join(`
|
|||
|
|
`),l}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code
|
|||
|
|
|
|||
|
|
`;r+=this.flowCode[t];const s=this.flowNodes[t],a=s[s.length-1],l=a.outputNode,u=l!==void 0&&l.isOutputStructNode===!0;for(const h of s){const g=this.getFlowData(h),v=h.name;if(v&&(r.length>0&&(r+=`
|
|||
|
|
`),r+=` // flow -> ${v}
|
|||
|
|
`),r+=`${g.code}
|
|||
|
|
`,h===a&&t!=="compute"){if(r+=`// result
|
|||
|
|
|
|||
|
|
`,t==="vertex")r+=`varyings.Vertex = ${g.result};`;else if(t==="fragment")if(u)n.returnType=l.nodeType,r+=`return ${g.result};`;else{let x=" @location(0) color: vec4<f32>";const S=this.getBuiltins("output");S&&(x+=`,
|
|||
|
|
`+S),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",x),n.structs+=`
|
|||
|
|
var<private> output : OutputStruct;
|
|||
|
|
|
|||
|
|
`,r+=`output.color = ${g.result};
|
|||
|
|
|
|||
|
|
return output;`}}}n.flow=r}this.material!==null?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getType(e){return Xoe[e]||e}isAvailable(e){let t=PN[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),PN[e]=t),t}_getWGSLMethod(e){return Wo[e]!==void 0&&this._include(e),Mm[e]}_include(e){const t=Wo[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
|
|||
|
|
// directives
|
|||
|
|
${e.directives}
|
|||
|
|
|
|||
|
|
// uniforms
|
|||
|
|
${e.uniforms}
|
|||
|
|
|
|||
|
|
// varyings
|
|||
|
|
${e.varyings}
|
|||
|
|
var<private> varyings : VaryingsStruct;
|
|||
|
|
|
|||
|
|
// codes
|
|||
|
|
${e.codes}
|
|||
|
|
|
|||
|
|
@vertex
|
|||
|
|
fn main( ${e.attributes} ) -> VaryingsStruct {
|
|||
|
|
|
|||
|
|
// vars
|
|||
|
|
${e.vars}
|
|||
|
|
|
|||
|
|
// flow
|
|||
|
|
${e.flow}
|
|||
|
|
|
|||
|
|
return varyings;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`}_getWGSLFragmentCode(e){return`${this.getSignature()}
|
|||
|
|
// global
|
|||
|
|
${rO}
|
|||
|
|
|
|||
|
|
// uniforms
|
|||
|
|
${e.uniforms}
|
|||
|
|
|
|||
|
|
// structs
|
|||
|
|
${e.structs}
|
|||
|
|
|
|||
|
|
// codes
|
|||
|
|
${e.codes}
|
|||
|
|
|
|||
|
|
@fragment
|
|||
|
|
fn main( ${e.varyings} ) -> ${e.returnType} {
|
|||
|
|
|
|||
|
|
// vars
|
|||
|
|
${e.vars}
|
|||
|
|
|
|||
|
|
// flow
|
|||
|
|
${e.flow}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`}_getWGSLComputeCode(e,t){return`${this.getSignature()}
|
|||
|
|
// directives
|
|||
|
|
${e.directives}
|
|||
|
|
|
|||
|
|
// system
|
|||
|
|
var<private> instanceIndex : u32;
|
|||
|
|
|
|||
|
|
// locals
|
|||
|
|
${e.scopedArrays}
|
|||
|
|
|
|||
|
|
// uniforms
|
|||
|
|
${e.uniforms}
|
|||
|
|
|
|||
|
|
// codes
|
|||
|
|
${e.codes}
|
|||
|
|
|
|||
|
|
@compute @workgroup_size( ${t} )
|
|||
|
|
fn main( ${e.attributes} ) {
|
|||
|
|
|
|||
|
|
// system
|
|||
|
|
instanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t});
|
|||
|
|
|
|||
|
|
// vars
|
|||
|
|
${e.vars}
|
|||
|
|
|
|||
|
|
// flow
|
|||
|
|
${e.flow}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`}_getWGSLStruct(e,t){return`
|
|||
|
|
struct ${e} {
|
|||
|
|
${t}
|
|||
|
|
};`}_getWGSLStructBinding(e,t,n,r=0,s=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)}
|
|||
|
|
@binding( ${r} ) @group( ${s} )
|
|||
|
|
var<${n}> ${e} : ${a};`}}class Qoe{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=Re.Depth24PlusStencil8:e.depth&&(t=Re.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return Zd.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Zd.LineList;if(e.isLine)return Zd.LineStrip;if(e.isMesh)return Zd.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?Re.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const Koe=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),Zoe=new Map([[z7,["float16"]]]),Joe=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class ele{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let a=s.buffer;if(a===void 0){const l=r.device;let u=n.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const g=new Uint32Array(u.length);for(let v=0;v<u.length;v++)g[v]=u[v];u=g}if(n.array=u,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){u=new u.constructor(n.count*4);for(let g=0;g<n.count;g++)u.set(n.array.subarray(g*3,g*3+3),g*4);n.itemSize=4,n.array=u}const h=u.byteLength+(4-u.byteLength%4)%4;a=l.createBuffer({label:n.name,size:h,usage:t,mappedAtCreation:!0}),new u.constructor(a.getMappedRange()).set(u),a.unmap(),s.buffer=a}}updateAttribute(e){const t=this._getBufferAttribute(e),n=this.backend,r=n.device,s=n.get(t).buffer,a=t.array,l=this._isTypedArray(a),u=t.updateRanges;if(u.length===0)r.queue.writeBuffer(s,0,a,0);else{const h=l?1:a.BYTES_PER_ELEMENT;for(let g=0,v=u.length;g<v;g++){const x=u[g],S=x.start*h,w=x.count*h;r.queue.writeBuffer(s,0,a,S,w)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),n=new Map;for(let r=0;r<t.length;r++){const s=t[r],a=s.array.BYTES_PER_ELEMENT,l=this._getBufferAttribute(s);let u=n.get(l);if(u===void 0){let v,x;s.isInterleavedBufferAttribute===!0?(v=s.data.stride*a,x=s.data.isInstancedInterleavedBuffer?Sv.Instance:Sv.Vertex):(v=s.itemSize*a,x=s.isInstancedBufferAttribute?Sv.Instance:Sv.Vertex),s.normalized===!1&&(s.array.constructor===Int16Array||s.array.constructor===Uint16Array)&&(v=4),u={arrayStride:v,attributes:[],stepMode:x},n.set(l,u)}const h=this._getVertexFormat(s),g=s.isInterleavedBufferAttribute===!0?s.offset*a:0;u.attributes.push({shaderLocation:r,offset:g,format:h})}return Array.from(n.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,n=t.device,s=t.get(this._getBufferAttribute(e)).buffer,a=s.size,l=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),u=n.createCommandEncoder({label:`readback_encoder_${e.name}`});u.copyBufferToBuffe
|
|||
|
|
* @license
|
|||
|
|
* Copyright 2010-2024 Three.js Authors
|
|||
|
|
* SPDX-License-Identifier: MIT
|
|||
|
|
*/j.BRDF_GGX;j.BRDF_Lambert;j.BasicShadowFilter;j.Break;j.Continue;j.DFGApprox;j.D_GGX;j.Discard;j.EPSILON;j.F_Schlick;const ale=j.Fn;j.INFINITY;const ole=j.If,lle=j.Loop;j.NodeShaderStage;j.NodeType;j.NodeUpdateType;j.NodeAccess;j.PCFShadowFilter;j.PCFSoftShadowFilter;j.PI;j.PI2;j.Return;j.Schlick_to_F0;j.ScriptableNodeResources;j.ShaderNode;j.TBNViewMatrix;j.VSMShadowFilter;j.V_GGX_SmithCorrelated;j.abs;j.acesFilmicToneMapping;j.acos;j.add;j.addNodeElement;j.agxToneMapping;j.all;j.alphaT;j.and;j.anisotropy;j.anisotropyB;j.anisotropyT;j.any;j.append;j.arrayBuffer;const ule=j.asin;j.assign;j.atan;j.atan2;j.atomicAdd;j.atomicAnd;j.atomicFunc;j.atomicMax;j.atomicMin;j.atomicOr;j.atomicStore;j.atomicSub;j.atomicXor;j.attenuationColor;j.attenuationDistance;j.attribute;j.attributeArray;j.backgroundBlurriness;j.backgroundIntensity;j.backgroundRotation;j.batch;j.billboarding;j.bitAnd;j.bitNot;j.bitOr;j.bitXor;j.bitangentGeometry;j.bitangentLocal;j.bitangentView;j.bitangentWorld;j.bitcast;j.blendBurn;j.blendColor;j.blendDodge;j.blendOverlay;j.blendScreen;j.blur;j.bool;j.buffer;j.bufferAttribute;j.bumpMap;j.burn;j.bvec2;j.bvec3;j.bvec4;j.bypass;j.cache;j.call;j.cameraFar;j.cameraNear;j.cameraNormalMatrix;j.cameraPosition;j.cameraProjectionMatrix;j.cameraProjectionMatrixInverse;j.cameraViewMatrix;j.cameraWorldMatrix;j.cbrt;j.cdl;j.ceil;j.checker;j.cineonToneMapping;j.clamp;j.clearcoat;j.clearcoatRoughness;j.code;j.color;j.colorSpaceToWorking;j.colorToDirection;j.compute;j.cond;j.context;j.convert;j.convertColorSpace;j.convertToTexture;const cle=j.cos;j.cross;j.cubeTexture;j.dFdx;j.dFdy;j.dashSize;j.defaultBuildStages;j.defaultShaderStages;j.defined;j.degrees;j.deltaTime;j.densityFog;j.densityFogFactor;j.depth;j.depthPass;j.difference;j.diffuseColor;j.directPointLight;j.directionToColor;j.dispersion;j.distance;j.div;j.dodge;j.dot;j.drawIndex;j.dynamicBufferAttribute;j.element;j.emissive;j.equal;j.equals;j.equirectUV;const hle=j.exp;j.exp2;j.expression;j.faceDirection;j.faceForward;j.faceforward;const fle=j.float;j.floor;j.fog;j.fract;j.frameGroup;j.frameId;j.frontFacing;j.fwidth;j.gain;j.gapSize;j.getConstNodeType;j.getCurrentStack;j.getDirection;j.getDistanceAttenuation;j.getGeometryRoughness;j.getNormalFromDepth;j.getParallaxCorrectNormal;j.getRoughness;j.getScreenPosition;j.getShIrradianceAt;j.getTextureIndex;j.getViewPosition;j.glsl;j.glslFn;j.grayscale;j.greaterThan;j.greaterThanEqual;j.hash;j.highpModelNormalViewMatrix;j.highpModelViewMatrix;j.hue;j.instance;const Ale=j.instanceIndex;j.instancedArray;j.instancedBufferAttribute;j.instancedDynamicBufferAttribute;j.instancedMesh;j.int;j.inverseSqrt;j.inversesqrt;j.invocationLocalIndex;j.invocationSubgroupIndex;j.ior;j.iridescence;j.iridescenceIOR;j.iridescenceThickness;j.ivec2;j.ivec3;j.ivec4;j.js;j.label;j.length;j.lengthSq;j.lessThan;j.lessThanEqual;j.lightPosition;j.lightTargetDirection;j.lightTargetPosition;j.lightViewPosition;j.lightingContext;j.lights;j.linearDepth;j.linearToneMapping;j.localId;j.log;j.log2;j.logarithmicDepthToViewZ;j.loop;j.luminance;j.mediumpModelViewMatrix;j.mat2;j.mat3;j.mat4;j.matcapUV;j.materialAO;j.materialAlphaTest;j.materialAnisotropy;j.materialAnisotropyVector;j.materialAttenuationColor;j.materialAttenuationDistance;j.materialClearcoat;j.materialClearcoatNormal;j.materialClearcoatRoughness;j.materialColor;j.materialDispersion;j.materialEmissive;j.materialIOR;j.materialIridescence;j.materialIridescenceIOR;j.materialIridescenceThickness;j.materialLightMap;j.materialLineDashOffset;j.materialLineDashSize;j.materialLineGapSize;j.materialLineScale;j.materialLineWidth;j.materialMetalness;j.materialNormal;j.materialOpacity;j.materialPointWidth;j.materialReference;j.materialReflectivity;j.materialRefractionRatio;j.materialRotation;j.materialRoughness;j.materialSheen;j.materialSheenRoughness;j.materialShininess;j.materialSpecular;j.materialSpecularColor;j.materialSpecularIntensity;j.materialSpecularStrength;j.materialThickness;j.materialTransmission;j.max;j.maxMipLevel;j.metalness;j.min;j.mix;j.mixElement;j.mod;j.modInt;j.modelDirection;j.modelNormalMatr
|
|||
|
|
#include <common>
|
|||
|
|
#include <color_pars_vertex>
|
|||
|
|
#include <fog_pars_vertex>
|
|||
|
|
#include <logdepthbuf_pars_vertex>
|
|||
|
|
#include <clipping_planes_pars_vertex>
|
|||
|
|
|
|||
|
|
uniform float linewidth;
|
|||
|
|
uniform vec2 resolution;
|
|||
|
|
|
|||
|
|
attribute vec3 instanceStart;
|
|||
|
|
attribute vec3 instanceEnd;
|
|||
|
|
|
|||
|
|
attribute vec3 instanceColorStart;
|
|||
|
|
attribute vec3 instanceColorEnd;
|
|||
|
|
|
|||
|
|
#ifdef WORLD_UNITS
|
|||
|
|
|
|||
|
|
varying vec4 worldPos;
|
|||
|
|
varying vec3 worldStart;
|
|||
|
|
varying vec3 worldEnd;
|
|||
|
|
|
|||
|
|
#ifdef USE_DASH
|
|||
|
|
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifdef USE_DASH
|
|||
|
|
|
|||
|
|
uniform float dashScale;
|
|||
|
|
attribute float instanceDistanceStart;
|
|||
|
|
attribute float instanceDistanceEnd;
|
|||
|
|
varying float vLineDistance;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|||
|
|
|
|||
|
|
// trim end segment so it terminates between the camera plane and the near plane
|
|||
|
|
|
|||
|
|
// conservative estimate of the near plane
|
|||
|
|
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|||
|
|
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|||
|
|
float nearEstimate = - 0.5 * b / a;
|
|||
|
|
|
|||
|
|
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|||
|
|
|
|||
|
|
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
#ifdef USE_COLOR
|
|||
|
|
|
|||
|
|
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifdef USE_DASH
|
|||
|
|
|
|||
|
|
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|||
|
|
vUv = uv;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
float aspect = resolution.x / resolution.y;
|
|||
|
|
|
|||
|
|
// camera space
|
|||
|
|
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|||
|
|
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|||
|
|
|
|||
|
|
#ifdef WORLD_UNITS
|
|||
|
|
|
|||
|
|
worldStart = start.xyz;
|
|||
|
|
worldEnd = end.xyz;
|
|||
|
|
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
vUv = uv;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|||
|
|
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|||
|
|
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|||
|
|
// perhaps there is a more elegant solution -- WestLangley
|
|||
|
|
|
|||
|
|
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|||
|
|
|
|||
|
|
if ( perspective ) {
|
|||
|
|
|
|||
|
|
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|||
|
|
|
|||
|
|
trimSegment( start, end );
|
|||
|
|
|
|||
|
|
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|||
|
|
|
|||
|
|
trimSegment( end, start );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// clip space
|
|||
|
|
vec4 clipStart = projectionMatrix * start;
|
|||
|
|
vec4 clipEnd = projectionMatrix * end;
|
|||
|
|
|
|||
|
|
// ndc space
|
|||
|
|
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|||
|
|
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|||
|
|
|
|||
|
|
// direction
|
|||
|
|
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|||
|
|
|
|||
|
|
// account for clip-space aspect ratio
|
|||
|
|
dir.x *= aspect;
|
|||
|
|
dir = normalize( dir );
|
|||
|
|
|
|||
|
|
#ifdef WORLD_UNITS
|
|||
|
|
|
|||
|
|
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|||
|
|
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|||
|
|
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|||
|
|
vec3 worldFwd = cross( worldDir, worldUp );
|
|||
|
|
worldPos = position.y < 0.5 ? start: end;
|
|||
|
|
|
|||
|
|
// height offset
|
|||
|
|
float hw = linewidth * 0.5;
|
|||
|
|
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|||
|
|
|
|||
|
|
// don't extend the line if we're rendering dashes because we
|
|||
|
|
// won't be rendering the endcaps
|
|||
|
|
#ifndef USE_DASH
|
|||
|
|
|
|||
|
|
// cap extension
|
|||
|
|
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|||
|
|
|
|||
|
|
// add width to the box
|
|||
|
|
worldPos.xyz += worldFwd * hw;
|
|||
|
|
|
|||
|
|
// endcaps
|
|||
|
|
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|||
|
|
|
|||
|
|
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
// project the worldpos
|
|||
|
|
vec4 clip = projectionMatrix * worldPos;
|
|||
|
|
|
|||
|
|
// shift the depth of the projected points so the line
|
|||
|
|
// segments overlap neatly
|
|||
|
|
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|||
|
|
clip.z = clipPose.z * clip.w;
|
|||
|
|
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
vec2 offset = vec2( dir.y, - dir.x );
|
|||
|
|
// undo aspect ratio adjustment
|
|||
|
|
dir.x /= aspect;
|
|||
|
|
offset.x /= aspect;
|
|||
|
|
|
|||
|
|
// sign flip
|
|||
|
|
if ( position.x < 0.0 ) offset *= - 1.0;
|
|||
|
|
|
|||
|
|
// endcaps
|
|||
|
|
if ( position.y < 0.0 ) {
|
|||
|
|
|
|||
|
|
offset += - dir;
|
|||
|
|
|
|||
|
|
} else if ( position.y > 1.0 ) {
|
|||
|
|
|
|||
|
|
offset += dir;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// adjust for linewidth
|
|||
|
|
offset *= linewidth;
|
|||
|
|
|
|||
|
|
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|||
|
|
offset /= resolution.y;
|
|||
|
|
|
|||
|
|
// select end
|
|||
|
|
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|||
|
|
|
|||
|
|
// back to clip space
|
|||
|
|
offset *= clip.w;
|
|||
|
|
|
|||
|
|
clip.xy += offset;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
gl_Position = clip;
|
|||
|
|
|
|||
|
|
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|||
|
|
|
|||
|
|
#include <logdepthbuf_vertex>
|
|||
|
|
#include <clipping_planes_vertex>
|
|||
|
|
#include <fog_vertex>
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`,fragmentShader:`
|
|||
|
|
uniform vec3 diffuse;
|
|||
|
|
uniform float opacity;
|
|||
|
|
uniform float linewidth;
|
|||
|
|
|
|||
|
|
#ifdef USE_DASH
|
|||
|
|
|
|||
|
|
uniform float dashOffset;
|
|||
|
|
uniform float dashSize;
|
|||
|
|
uniform float gapSize;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
varying float vLineDistance;
|
|||
|
|
|
|||
|
|
#ifdef WORLD_UNITS
|
|||
|
|
|
|||
|
|
varying vec4 worldPos;
|
|||
|
|
varying vec3 worldStart;
|
|||
|
|
varying vec3 worldEnd;
|
|||
|
|
|
|||
|
|
#ifdef USE_DASH
|
|||
|
|
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#include <common>
|
|||
|
|
#include <color_pars_fragment>
|
|||
|
|
#include <fog_pars_fragment>
|
|||
|
|
#include <logdepthbuf_pars_fragment>
|
|||
|
|
#include <clipping_planes_pars_fragment>
|
|||
|
|
|
|||
|
|
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|||
|
|
|
|||
|
|
float mua;
|
|||
|
|
float mub;
|
|||
|
|
|
|||
|
|
vec3 p13 = p1 - p3;
|
|||
|
|
vec3 p43 = p4 - p3;
|
|||
|
|
|
|||
|
|
vec3 p21 = p2 - p1;
|
|||
|
|
|
|||
|
|
float d1343 = dot( p13, p43 );
|
|||
|
|
float d4321 = dot( p43, p21 );
|
|||
|
|
float d1321 = dot( p13, p21 );
|
|||
|
|
float d4343 = dot( p43, p43 );
|
|||
|
|
float d2121 = dot( p21, p21 );
|
|||
|
|
|
|||
|
|
float denom = d2121 * d4343 - d4321 * d4321;
|
|||
|
|
|
|||
|
|
float numer = d1343 * d4321 - d1321 * d4343;
|
|||
|
|
|
|||
|
|
mua = numer / denom;
|
|||
|
|
mua = clamp( mua, 0.0, 1.0 );
|
|||
|
|
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|||
|
|
mub = clamp( mub, 0.0, 1.0 );
|
|||
|
|
|
|||
|
|
return vec2( mua, mub );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
#include <clipping_planes_fragment>
|
|||
|
|
|
|||
|
|
#ifdef USE_DASH
|
|||
|
|
|
|||
|
|
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|||
|
|
|
|||
|
|
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
float alpha = opacity;
|
|||
|
|
|
|||
|
|
#ifdef WORLD_UNITS
|
|||
|
|
|
|||
|
|
// Find the closest points on the view ray and the line segment
|
|||
|
|
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|||
|
|
vec3 lineDir = worldEnd - worldStart;
|
|||
|
|
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|||
|
|
|
|||
|
|
vec3 p1 = worldStart + lineDir * params.x;
|
|||
|
|
vec3 p2 = rayEnd * params.y;
|
|||
|
|
vec3 delta = p1 - p2;
|
|||
|
|
float len = length( delta );
|
|||
|
|
float norm = len / linewidth;
|
|||
|
|
|
|||
|
|
#ifndef USE_DASH
|
|||
|
|
|
|||
|
|
#ifdef USE_ALPHA_TO_COVERAGE
|
|||
|
|
|
|||
|
|
float dnorm = fwidth( norm );
|
|||
|
|
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|||
|
|
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
if ( norm > 0.5 ) {
|
|||
|
|
|
|||
|
|
discard;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
#ifdef USE_ALPHA_TO_COVERAGE
|
|||
|
|
|
|||
|
|
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|||
|
|
float a = vUv.x;
|
|||
|
|
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|||
|
|
float len2 = a * a + b * b;
|
|||
|
|
float dlen = fwidth( len2 );
|
|||
|
|
|
|||
|
|
if ( abs( vUv.y ) > 1.0 ) {
|
|||
|
|
|
|||
|
|
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#else
|
|||
|
|
|
|||
|
|
if ( abs( vUv.y ) > 1.0 ) {
|
|||
|
|
|
|||
|
|
float a = vUv.x;
|
|||
|
|
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|||
|
|
float len2 = a * a + b * b;
|
|||
|
|
|
|||
|
|
if ( len2 > 1.0 ) discard;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
vec4 diffuseColor = vec4( diffuse, alpha );
|
|||
|
|
|
|||
|
|
#include <logdepthbuf_fragment>
|
|||
|
|
#include <color_fragment>
|
|||
|
|
|
|||
|
|
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|||
|
|
|
|||
|
|
#include <tonemapping_fragment>
|
|||
|
|
#include <colorspace_fragment>
|
|||
|
|
#include <fog_fragment>
|
|||
|
|
#include <premultiplied_alpha_fragment>
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
`};class GE extends Ja{constructor(e){super({type:"LineMaterial",uniforms:vy.clone(Ga.line.uniforms),vertexShader:Ga.line.vertexShader,fragmentShader:Ga.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ES=new Pn,BN=new ue,ON=new ue,Os=new Pn,Is=new Pn,jl=new Pn,CS=new ue,RS=new kn,Fs=new Yz,IN=new ue,Mv=new Gc,Ev=new dA,Wl=new Pn;let Jl,rA;function FN(i,e,t){return Wl.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),Wl.multiplyScalar(1/Wl.w),Wl.x=rA/t.width,Wl.y=rA/t.height,Wl.applyMatrix4(i.projectionMatrixInverse),Wl.multiplyScalar(1/Wl.w),Math.abs(Math.max(Wl.x,Wl.y))}function _le(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let l=0,u=a;l<u;l++){Fs.start.fromBufferAttribute(r,l),Fs.end.fromBufferAttribute(s,l),Fs.applyMatrix4(t);const h=new ue,g=new ue;Jl.distanceSqToSegment(Fs.start,Fs.end,g,h),g.distanceTo(h)<rA*.5&&e.push({point:g,pointOnLine:h,distance:Jl.origin.distanceTo(g),object:i,face:null,faceIndex:l,uv:null,uv1:null})}}function yle(i,e,t){const n=e.projectionMatrix,s=i.material.resolution,a=i.matrixWorld,l=i.geometry,u=l.attributes.instanceStart,h=l.attributes.instanceEnd,g=Math.min(l.instanceCount,u.count),v=-e.near;Jl.at(1,jl),jl.w=1,jl.applyMatrix4(e.matrixWorldInverse),jl.applyMatrix4(n),jl.multiplyScalar(1/jl.w),jl.x*=s.x/2,jl.y*=s.y/2,jl.z=0,CS.copy(jl),RS.multiplyMatrices(e.matrixWorldInverse,a);for(let x=0,S=g;x<S;x++){if(Os.fromBufferAttribute(u,x),Is.fromBufferAttribute(h,x),Os.w=1,Is.w=1,Os.applyMatrix4(RS),Is.applyMatrix4(RS),Os.z>v&&Is.z>v)continue;if(Os.z>v){const L=Os.z-Is.z,O=(Os.z-v)/L;Os.lerp(Is,O)}else if(Is.z>v){const L=Is.z-Os.z,O=(Is.z-v)/L;Is.lerp(Os,O)}Os.applyMatrix4(n),Is.applyMatrix4(n),Os.multiplyScalar(1/Os.w),Is.multiplyScalar(1/Is.w),Os.x*=s.x/2,Os.y*=s.y/2,Is.x*=s.x/2,Is.y*=s.y/2,Fs.start.copy(Os),Fs.start.z=0,Fs.end.copy(Is),Fs.end.z=0;const R=Fs.closestPointToPointParameter(CS,!0);Fs.at(R,IN);const C=M0.lerp(Os.z,Is.z,R),E=C>=-1&&C<=1,B=CS.distanceTo(IN)<rA*.5;if(E&&B){Fs.start.fromBufferAttribute(u,x),Fs.end.fromBufferAttribute(h,x),Fs.start.applyMatrix4(a),Fs.end.applyMatrix4(a);const L=new ue,O=new ue;Jl.distanceSqToSegment(Fs.start,Fs.end,O,L),t.push({point:O,pointOnLine:L,distance:Jl.origin.distanceTo(O),object:i,face:null,faceIndex:x,uv:null,uv1:null})}}}class xle extends zi{constructor(e=new aO,t=new GE({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let a=0,l=0,u=t.count;a<u;a++,l+=2)BN.fromBufferAttribu
|
|||
|
|
`)l=0,u-=s;else{const v=wle(g,r,l,u,t);l+=v.offsetX,a.push(v.path)}}return a}function wle(i,e,t,n,r){const s=r.glyphs[i]||r.glyphs["?"];if(!s){console.error('THREE.Font: character "'+i+'" does not exists in font family '+r.familyName+".");return}const a=new Qz;let l,u,h,g,v,x,S,w;if(s.o){const R=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let C=0,E=R.length;C<E;)switch(R[C++]){case"m":l=R[C++]*e+t,u=R[C++]*e+n,a.moveTo(l,u);break;case"l":l=R[C++]*e+t,u=R[C++]*e+n,a.lineTo(l,u);break;case"q":h=R[C++]*e+t,g=R[C++]*e+n,v=R[C++]*e+t,x=R[C++]*e+n,a.quadraticCurveTo(v,x,h,g);break;case"b":h=R[C++]*e+t,g=R[C++]*e+n,v=R[C++]*e+t,x=R[C++]*e+n,S=R[C++]*e+t,w=R[C++]*e+n,a.bezierCurveTo(v,x,S,w,h,g);break}}return{offsetX:s.ha*e,path:a}}function iw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function Mle(i){if(Array.isArray(i))return i}function Ele(i){if(Array.isArray(i))return iw(i)}function lO(i,e,t){if(typeof i=="function"?i===e:i.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function Cle(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function zN(i,e,t,n,r,s,a){try{var l=i[s](a),u=l.value}catch(h){return void t(h)}l.done?e(u):Promise.resolve(u).then(n,r)}function Rle(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(u){zN(s,n,r,a,l,"next",u)}function l(u){zN(s,n,r,a,l,"throw",u)}a(void 0)})}}function tx(i,e,t){return e=z0(e),Fle(i,VE()?Reflect.construct(e,t||[],z0(i).constructor):e.apply(i,t))}function Nle(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function nx(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function mm(i,e){return i.get(lO(i,e))}function NS(i,e,t){Nle(i,e),e.set(i,t)}function DS(i,e,t){return i.set(lO(i,e),t),t}function qE(i,e,t){if(VE())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var r=new(i.bind.apply(i,n));return r}function Dle(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,uO(n.key),n)}}function ix(i,e,t){return e&&Dle(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function Ps(i,e,t){return(e=uO(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function rw(){return rw=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(i,e,t){var n=kle(i,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?i:t):r.value}},rw.apply(null,arguments)}function z0(i){return z0=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},z0(i)}function rx(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&aw(i,e)}function VE(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(VE=function(){return!!i})()}function Ple(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function Lle(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(g){h=!0,r=g}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function Ule(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ble(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function GN(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Hi(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?GN(Object(t),!0).forEach(function(n){Ps(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):GN(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Ole(i,e){if(i==null)return{};var t,n,r=Ile(i,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(n=0;n<s.length;n++)t=s[n],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(i,t)&&(r[t]=i[t])}return r}function Ile(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}function Fle(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Cle(i)}function sw(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var i,e,t=typeof Symbol=="function"?Symbol:{},n=t.iterator||"@@iterator",r=t.toStringTag||"@@toStringTag";function s(S,w,R,C){var E=w&&w.prototype instanceof l?w:l,B=Object.create(E.prototype);return yo(B,"_invoke",(function(L,O,z){var G,k,H,F=0,V=z||[],X=!1,ee={p:0,n:0,v:i,a:te,f:te.bind(i,4),d:function(se,ne){return G=se,k=0,H=i,ee.n=ne,a}};function te(se,ne){for(k=se,H=ne,e=0;!X&&F&&!Z&&e<V.length;e++){var Z,ae=V[e],Ae=ee.p,Se=ae[2];se>3?(Z=Se===ne)&&(H=ae[(k=ae[4])?5:(k=3,3)],ae[4]=ae[5]=i):ae[0]<=Ae&&((Z=se<2&&Ae<ae[1])?(k=0,ee.v=ne,ee.n=ae[1]):Ae<Se&&(Z=se<3||ae[0]>ne||ne>Se)&&(ae[4]=se,ae[5]=ne,ee.n=Se,k=0))}if(Z||se>1)return a;throw X=!0,ne}return function(se,ne,Z){if(F>1)throw TypeError("Generator is already running");for(X&&ne===1&&te(ne,Z),k=ne,H=Z;(e=k<2?i:H)||!X;){G||(k?k<3?(k>1&&(ee.n=-1),te(k,H)):ee.n=H:ee.v=H);try{if(F=2,G){if(k||(se="next"),e=G[se]){if(!(e=e.call(G,H)))throw TypeError("iterator result is not an object");if(!e.done)return e;H=e.value,k<2&&(k=0)}else k===1&&(e=G.return)&&e.call(G),k<2&&(H=TypeError("The iterator does not provide a '"+se+"' method"),k=1);G=i}else if((e=(X=ee.n<0)?H:L.call(O,ee))!==a)break}catch(ae){G=i,k=1,H=ae}finally{F=1}}return{value:e,done:X}}})(S,R,C),!0),B}var a={};function l(){}function u(){}function h(){}e=Object.getPrototypeOf;var g=[][n]?e(e([][n]())):(yo(e={},n,function(){return this}),e),v=h.prototype=l.prototype=Object.create(g);function x(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,yo(S,r,"GeneratorFunction")),S.prototype=Object.create(v),S}return u.prototype=h,yo(v,"constructor",h),yo(h,"constructor",u),u.displayName="GeneratorFunction",yo(h,r,"GeneratorFunction"),yo(v),yo(v,r,"Generator"),yo(v,n,function(){return this}),yo(v,"toString",function(){return"[object Generator]"}),(sw=function(){return{w:s,m:x}})()}function yo(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}yo=function(s,a,l,u){function h(g,v){yo(s,g,function(x){return this._invoke(g,v,x)})}a?r?r(s,a,{value:l,enumerable:!u,configurable:!u,writable:!u}):s[a]=l:(h("next",0),h("throw",1),h("return",2))},yo(i,e,t,n)}function aw(i,e){return aw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},aw(i,e)}function gr(i,e){return Mle(i)||Lle(i,e)||cO(i,e)||Ule()}function kle(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=z0(i))!==null;);return i}function PS(i,e,t,n){var r=rw(z0(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function Qi(i){return Ele(i)||Ple(i)||cO(i)||Ble()}function zle(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new T
|
|||
|
|
uniform float hollowRadius;
|
|||
|
|
|
|||
|
|
varying vec3 vVertexWorldPosition;
|
|||
|
|
varying vec3 vVertexNormal;
|
|||
|
|
varying float vCameraDistanceToObjCenter;
|
|||
|
|
varying float vVertexAngularDistanceToHollowRadius;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
vVertexNormal = normalize(normalMatrix * normal);
|
|||
|
|
vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|||
|
|
|
|||
|
|
vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);
|
|||
|
|
vCameraDistanceToObjCenter = length(objCenterViewPosition);
|
|||
|
|
|
|||
|
|
float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter);
|
|||
|
|
float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition)));
|
|||
|
|
vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle;
|
|||
|
|
|
|||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|||
|
|
}`,qle=`
|
|||
|
|
uniform vec3 color;
|
|||
|
|
uniform float coefficient;
|
|||
|
|
uniform float power;
|
|||
|
|
uniform float hollowRadius;
|
|||
|
|
|
|||
|
|
varying vec3 vVertexNormal;
|
|||
|
|
varying vec3 vVertexWorldPosition;
|
|||
|
|
varying float vCameraDistanceToObjCenter;
|
|||
|
|
varying float vVertexAngularDistanceToHollowRadius;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius
|
|||
|
|
if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius
|
|||
|
|
|
|||
|
|
vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition;
|
|||
|
|
vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz;
|
|||
|
|
viewCameraToVertex = normalize(viewCameraToVertex);
|
|||
|
|
float intensity = pow(
|
|||
|
|
coefficient + dot(vVertexNormal, viewCameraToVertex),
|
|||
|
|
power
|
|||
|
|
);
|
|||
|
|
gl_FragColor = vec4(color, intensity);
|
|||
|
|
}`;function Vle(i,e,t,n){return new Dg.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:Gle,fragmentShader:qle,uniforms:{coefficient:{value:i},color:{value:new Dg.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function Hle(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r<s;r++){var a=i.attributes.normal.array[r],l=i.attributes.position.array[r];n[r]=l+a*e}return t.setAttribute("position",new Dg.BufferAttribute(n,3)),t}var jle=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,a=s===void 0?"gold":s,l=r.size,u=l===void 0?2:l,h=r.coefficient,g=h===void 0?.5:h,v=r.power,x=v===void 0?1:v,S=r.hollowRadius,w=S===void 0?0:S,R=r.backside,C=R===void 0?!0:R;nx(this,e),n=tx(this,e);var E=Hle(t,u),B=Vle(g,a,x,w);return C&&(B.side=Dg.BackSide),n.geometry=E,n.material=B,n}return rx(e,i),ix(e)})(Dg.Mesh),$l=window.THREE?window.THREE:{Color:sn,Group:ja,LineBasicMaterial:$0,LineSegments:H7,Mesh:zi,MeshPhongMaterial:nD,SphereGeometry:Eu,SRGBColorSpace:_n,TextureLoader:iM},AO=xs({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){nr(e.globeObj),nr(e.tileEngine),nr(e.graticulesObj)}},stateInit:function(){var e=new $l.MeshPhongMaterial({color:0}),t=new $l.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new eY(cr),r=new $l.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new $l.LineSegments(new uP(vX(),cr,2),new $l.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){nr(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new $l.SphereGeometry(cr,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new $l.TextureLoader().load(e.globeImageUrl,function(l){l.colorSpace=$l.SRGBColorSpace,n.map=l,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new $l.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new $l.TextureLoader().load(e.bumpImageUrl,function(l){n.bumpMap=l,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),nr(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new jle(e.globeObj.geometry,{color:e.atmosphereColor,size:cr*e.atmosphereAltitude,hollowRadius:cr,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),wu=function(e){return isNaN(e)?parseInt(yn(e).toHex(),16):e},Rl=function(e){return e&&isNaN(e)?cA(e).opacity:1},jh=function(e){var t=arguments.length>1&&arg
|
|||
|
|
`.concat(Zn.common,`
|
|||
|
|
`).concat(Zn.logdepthbuf_pars_vertex,`
|
|||
|
|
|
|||
|
|
uniform float dashTranslate;
|
|||
|
|
|
|||
|
|
attribute vec4 color;
|
|||
|
|
varying vec4 vColor;
|
|||
|
|
|
|||
|
|
attribute float relDistance;
|
|||
|
|
varying float vRelDistance;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
// pass through colors and distances
|
|||
|
|
vColor = color;
|
|||
|
|
vRelDistance = relDistance + dashTranslate;
|
|||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|||
|
|
|
|||
|
|
`).concat(Zn.logdepthbuf_vertex,`
|
|||
|
|
}
|
|||
|
|
`),fragmentShader:`
|
|||
|
|
`.concat(Zn.logdepthbuf_pars_fragment,`
|
|||
|
|
|
|||
|
|
uniform float dashOffset;
|
|||
|
|
uniform float dashSize;
|
|||
|
|
uniform float gapSize;
|
|||
|
|
|
|||
|
|
varying vec4 vColor;
|
|||
|
|
varying float vRelDistance;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
// ignore pixels in the gap
|
|||
|
|
if (vRelDistance < dashOffset) discard;
|
|||
|
|
if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;
|
|||
|
|
|
|||
|
|
// set px color: [r, g, b, a], interpolated between vertices
|
|||
|
|
gl_FragColor = vColor;
|
|||
|
|
|
|||
|
|
`).concat(Zn.logdepthbuf_fragment,`
|
|||
|
|
}
|
|||
|
|
`)}},ow=function(e){return e.uniforms.uSurfaceRadius={type:"float",value:0},e.vertexShader=(`attribute float surfaceRadius;
|
|||
|
|
varying float vSurfaceRadius;
|
|||
|
|
varying vec3 vPos;
|
|||
|
|
`+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join(`
|
|||
|
|
`)),e.fragmentShader=(`uniform float uSurfaceRadius;
|
|||
|
|
varying float vSurfaceRadius;
|
|||
|
|
varying vec3 vPos;
|
|||
|
|
`+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join(`
|
|||
|
|
`)),e},Xle=function(e){return e.vertexShader=`
|
|||
|
|
attribute float r;
|
|||
|
|
|
|||
|
|
const float PI = 3.1415926535897932384626433832795;
|
|||
|
|
float toRad(in float a) {
|
|||
|
|
return a * PI / 180.0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r]
|
|||
|
|
float phi = toRad(90.0 - c.x);
|
|||
|
|
float theta = toRad(90.0 - c.y);
|
|||
|
|
float r = c.z;
|
|||
|
|
return vec3( // x,y,z
|
|||
|
|
r * sin(phi) * cos(theta),
|
|||
|
|
r * cos(phi),
|
|||
|
|
r * sin(phi) * sin(theta)
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
vec2 Cartesian2Polar(in vec3 p) {
|
|||
|
|
float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
|
|||
|
|
float phi = acos(p.y / r);
|
|||
|
|
float theta = atan(p.z, p.x);
|
|||
|
|
return vec2( // lat,lng
|
|||
|
|
90.0 - phi * 180.0 / PI,
|
|||
|
|
90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0)
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
`.concat(e.vertexShader.replace("}",`
|
|||
|
|
vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r));
|
|||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|||
|
|
}
|
|||
|
|
`),`
|
|||
|
|
`),e},jE=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},Yle=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},Qle=["stroke"],yl=window.THREE?window.THREE:{BufferGeometry:Ki,CubicBezierCurve3:$7,Curve:Pl,Group:ja,Line:xy,Mesh:zi,NormalBlending:Ka,ShaderMaterial:Ja,TubeGeometry:tM,Vector3:ue},Kle=L0.default||L0,mO=xs({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Kle,sharedMaterial:new yl.ShaderMaterial(Hi(Hi({},pO()),{},{transparent:!0,blending:yl.NormalBlending}))}},init:function(e,t){nr(e),t.scene=e,t.dataMapper=new ao(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new yl.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=gr(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r,u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l})})},update:function(e){var t=Et(e.arcStartLat),n=Et(e.arcStartLng),r=Et(e.arcStartAltitude),s=Et(e.arcEndLat),a=Et(e.arcEndLng),l=Et(e.arcEndAltitude),u=Et(e.arcAltitude),h=Et(e.arcAltitudeAutoScale),g=Et(e.arcStroke),v=Et(e.arcColor),x=Et(e.arcDashLength),S=Et(e.arcDashGap),w=Et(e.arcDashInitialGap),R=Et(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(L,O){var z=g(O),G=z!=null;if(!L.children.length||G!==(L.children[0].type==="Mesh")){nr(L);var k=G?new yl.Mesh:new yl.Line(new yl.BufferGeometry);k.material=e.sharedMaterial.clone(),L.add(k)}var H=L.children[0];Object.assign(H.material.uniforms,{dashSize:{value:x(O)},gapSize:{value:S(O)},dashOffset:{value:w(O)}});var F=R(O);H.__dashAnimateStep=F>0?1e3/F:0;var V=E(v(O),e.arcCurveResolution,G?e.arcCircularResolution+1:1),X=B(e.arcCurveResolution,G?e.arcCircularResolution+1:1,!0);H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",X);var ee=function(Z){var ae=L.__currentTargetD=Z,Ae=ae.stroke,Se=Ole(ae,Qle),xe=C(Se);G?(H.geometry&&H.geometry.dispose(),H.geometry=new yl.TubeGeometry(xe,e.arcCurveResolution,Ae/2,e.arcCircularResolution),H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",X)):H.geometry.setFromPoints(xe.getPoints(e.arcCurveResolution))},te={stroke:z,alt:u(O),altAutoScale:+h(O),startLat:+t(O),startLng:+n(O),startAlt:+r(O),endLat:+s(O),endLng:+a(O),endAlt:+l(O)},se=L.__currentTargetD||Object.assign({},te,{altAutoScale:-.001});Object.keys(te).some(function(ne){return se[ne]!==te[ne]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?ee(te):e.tweenGroup.add(new ca(se).to(te,e.arcsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(ee).start()))}).digest(e.arcsData);function C(L){var O=L.alt,z=L.altAutoScale,G=L.startLat,k=L.startLng,H=L.startAlt,F=L.endLat,V=L.endLng,X=L.endAlt,ee=function(_e){var De=gr(_e,3),Oe=De[0],tt=De[1],Je=De[2],ft=el(tt,Oe,Je),We=ft.x,rt=ft.y,ce=ft.z;return new yl.Vector3(We,rt,ce)},te=[k,G],se=[V,F],ne=O;if(ne==null&&(ne=Vh(te,se)/2*z+
|
|||
|
|
\r
|
|||
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r
|
|||
|
|
\r
|
|||
|
|
The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r
|
|||
|
|
\r
|
|||
|
|
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r
|
|||
|
|
\r
|
|||
|
|
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r
|
|||
|
|
\r
|
|||
|
|
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r
|
|||
|
|
\r
|
|||
|
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},xue=-334,bue="Helvetiker",Sue=1522,Tue=50,wue={glyphs:Aue,cssFontWeight:due,ascender:pue,underlinePosition:mue,cssFontStyle:gue,boundingBox:vue,resolution:_ue,original_font_information:yue,descender:xue,familyName:bue,lineHeight:Sue,underlineThickness:Tue},xl=Hi(Hi({},window.THREE?window.THREE:{BoxGeometry:$h,CircleGeometry:by,DoubleSide:as,Group:ja,Mesh:zi,MeshLambertMaterial:Vc,TextGeometry:kN,Vector3:ue}),{},{Font:Sle,TextGeometry:kN}),MO=xs({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:wue,onChange:function(e,t){t.font=new xl.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r;var s=new xl.CircleGeometry(1,32);t.dataMapper=new ao(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new xl.MeshLambertMaterial;a.side=as;var l=new xl.Group;l.add(new xl.Mesh(s,a));var u=new xl.Mesh(void 0,a);l.add(u);var h=new xl.Mesh;return h.visible=!1,u.add(h),l.__globeObjType="label",l})},update:function(e){var t=Et(e.labelLat),n=Et(e.labelLng),r=Et(e.labelAltitude),s=Et(e.labelText),a=Et(e.labelSize),l=Et(e.labelRotation),u=Et(e.labelColor),h=Et(e.labelIncludeDot),g=Et(e.labelDotRadius),v=Et(e.labelDotOrientation),x=new Set(["right","top","bottom"]),S=2*Math.PI*cr/360;e.dataMapper.onUpdateObj(function(w,R){var C=gr(w.children,2),E=C[0],B=C[1],L=gr(B.children,1),O=L[0],z=u(R),G=Rl(z);B.material.color.set(wu(z)),B.material.transparent=G<1,B.material.opacity=G;var k=h(R),H=v(R);!k||!x.has(H)&&(H="bottom");var F=k?+g(R)*S:1e-12;E.scale.x=E.scale.y=F;var V=+a(R)*S;if(B.geometry&&B.geometry.dispose(),B.geometry=new xl.TextGeometry(s(R),{font:e.font,size:V,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),O.geometry&&O.geometry.dispose(),B.geometry.computeBoundingBox(),O.geometry=qE(xl.BoxGeometry,Qi(new xl.Vector3().subVectors(B.geometry.boundingBox.max,B.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),H!=="right"&&B.geometry.center(),k){var X=F+V/2;H==="right"&&(B.position.x=X),B.position.y={right:-V/2,top:X+V/2,bottom:-X-V/2}[H]}var ee=function(Z){var ae=w.__currentTargetD=Z,Ae=ae.lat,Se=ae.lng,xe=ae.alt,le=ae.rot,we=ae.scale;Object.assign(w.position,el(Ae,Se,xe)),w.lookAt(e.scene.localToWorld(new xl.Vector3(0,0,0))),w.rotateY(Math.PI),w.rotateZ(-le*Math.PI/180),w.scale.x=w.scale.y=w.scale.z=we},te={lat:+t(R),lng:+n(R),alt:+r(R),rot:+l(R),scale:1},se=w.__currentTargetD||Object.assign({},te,{scale:1e-12});Object.keys(te).some(function(ne){return se[ne]!==te[ne]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?ee(te):e.tweenGroup.add(new ca(se).to(te,e.labelsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(ee).start()))}).digest(e.labelsData)}}),Mue=Hi(Hi({},window.THREE?window.THREE:{}),{},{CSS2DObject:Uj}),EO=xs({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{d
|
|||
|
|
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vUv = uv;
|
|||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|||
|
|
|
|||
|
|
}`,fragmentShader:`
|
|||
|
|
|
|||
|
|
uniform float opacity;
|
|||
|
|
|
|||
|
|
uniform sampler2D tDiffuse;
|
|||
|
|
|
|||
|
|
varying vec2 vUv;
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
|
|||
|
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|||
|
|
gl_FragColor = opacity * texel;
|
|||
|
|
|
|||
|
|
|
|||
|
|
}`};class sx{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const $ce=new kg(-1,1,1,-1,0,1);class Xce extends Ki{constructor(){super(),this.setAttribute("position",new wi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new wi([0,2,0,0,2,0],2))}}const Yce=new Xce;class Qce{constructor(e){this._mesh=new zi(Yce,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,$ce)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Kce extends sx{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof Ja?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=vy.clone(e.uniforms),this.material=new Ja({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Qce(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class i7 extends sx{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,l;this.inverse?(a=0,l=1):(a=1,l=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),s.buffers.stencil.setClear(l),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class Zce extends sx{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class Jce{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new pt);this._width=n.width,this._height=n.height,t=new qh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Kce(Wce),this.copyPass.material.blending=Qa,this.clock=new aD}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let r=0,s=this.passes.length;r<s;r++){const a=this.passes[r];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){const l=this.renderer.getContext(),u=this.renderer.state.buffers.stencil;u.setFunc(l.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function h7(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function OAe(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?h7(Object(t),!0).forEach(function(n){LAe(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):h7(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function IAe(i,e){return PAe(i)||UAe(i,e)||zAe(i,e)||BAe()}function FAe(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function kAe(i){var e=FAe(i,"string");return typeof e=="symbol"?e:e+""}function fy(i){"@babel/helpers - typeof";return fy=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fy(i)}function zAe(i,e){if(i){if(typeof i=="string")return c7(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c7(i,e):void 0}}var pw=function(e){if(fy(e)!=="object")return e;var t=aI(e);if(t.props){var n;t.props=OAe({},t.props),t!=null&&(n=t.props)!==null&&n!==void 0&&n.children&&(t.props.children=Array.isArray(t.props.children)?t.props.children.map(pw):pw(t.props.children))}return t},GAe=function(e){return QO(aI(e))},qAe=function(e,t){delete t.__k,DAe(pw(e),t)};function VAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var HAe=`.float-tooltip-kap {
|
|||
|
|
position: absolute;
|
|||
|
|
width: max-content; /* prevent shrinking near right edge */
|
|||
|
|
max-width: max(50%, 150px);
|
|||
|
|
padding: 3px 5px;
|
|||
|
|
border-radius: 3px;
|
|||
|
|
font: 12px sans-serif;
|
|||
|
|
color: #eee;
|
|||
|
|
background: rgba(0,0,0,0.6);
|
|||
|
|
pointer-events: none;
|
|||
|
|
}
|
|||
|
|
`;VAe(HAe);var jAe=xs({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,s=r===void 0?{}:r,a=!!e&&fy(e)==="object"&&!!e.node&&typeof e.node=="function",l=xAe(a?e.node():e);l.style("position")==="static"&&l.style("position","relative"),t.tooltipEl=l.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(h){var g=IAe(h,2),v=g[0],x=g[1];return t.tooltipEl.style(v,x)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,l.on("mousemove.".concat(u),function(h){t.mouseInside=!0;var g=SAe(h),v=l.node(),x=v.offsetWidth,S=v.offsetHeight,w=[t.offsetX===null||t.offsetX===void 0?"-".concat(g[0]/x*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?S>130&&S-g[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",g[0]+"px").style("top",g[1]+"px").style("transform","translate(".concat(w.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseout.".concat(u),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):GAe(e.content)?(e.tooltipEl.text(""),qAe(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function WAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var $Ae=`.scene-nav-info {
|
|||
|
|
position: absolute;
|
|||
|
|
bottom: 5px;
|
|||
|
|
width: 100%;
|
|||
|
|
text-align: center;
|
|||
|
|
color: slategrey;
|
|||
|
|
opacity: 0.7;
|
|||
|
|
font-size: 10px;
|
|||
|
|
font-family: sans-serif;
|
|||
|
|
pointer-events: none;
|
|||
|
|
user-select: none;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.scene-container canvas:focus {
|
|||
|
|
outline: none;
|
|||
|
|
}`;WAe($Ae);function mw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function XAe(i){if(Array.isArray(i))return i}function YAe(i){if(Array.isArray(i))return mw(i)}function QAe(i,e,t){return(e=ide(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function KAe(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function ZAe(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e!==0)for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(g){h=!0,r=g}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function JAe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ede(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tde(i,e){return XAe(i)||ZAe(i,e)||oI(i,e)||JAe()}function Lf(i){return YAe(i)||KAe(i)||oI(i)||ede()}function nde(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function ide(i){var e=nde(i,"string");return typeof e=="symbol"?e:e+""}function oI(i,e){if(i){if(typeof i=="string")return mw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?mw(i,e):void 0}}var br=window.THREE?window.THREE:{WebGLRenderer:Lj,Scene:Xw,PerspectiveCamera:ya,Raycaster:Xz,SRGBColorSpace:_n,TextureLoader:iM,Vector2:pt,Vector3:ue,Box3:Gc,Color:sn,Mesh:zi,SphereGeometry:Eu,MeshBasicMaterial:pA,BackSide:hr,Clock:aD},lI=xs({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},viewOffset:{default:[0,0]},backgroundColor:{default:"#000011"},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.clock.getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(a){return a.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Et(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)g(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new ca(u).to(a,r).easing(os.Quadratic.Out).onUpdate(g).start()),e.tweenGroup.add(new ca(h).to(l,r/3).easing(os.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function g(S){var w=S.x,R=S.y,C=S.z;w!==void 0&&(s.position.x=w),R!==void 0&&(s.position.y=R),C!==void 0&&(s.position.z=C)}function v(S){var w=new br.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=w:s.lookAt(w)}function x(){return Object.assign(new br.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a<r;a++)s[a-3]=arguments[a];return this.fitToBbox(this.getBbox.apply(this,s),t,n)},fitToBbox:function(e,t){var n=arguments.lengt
|
|||
|
|
cursor: pointer;
|
|||
|
|
}`;rde(sde);function gw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function ade(i){if(Array.isArray(i))return gw(i)}function r1(i,e,t){return(e=fde(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ode(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function lde(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function f7(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function jf(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?f7(Object(t),!0).forEach(function(n){r1(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):f7(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ude(i,e){if(i==null)return{};var t,n,r=cde(i,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(n=0;n<s.length;n++)t=s[n],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(i,t)&&(r[t]=i[t])}return r}function cde(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}function ux(i){return ade(i)||ode(i)||Ade(i)||lde()}function hde(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function fde(i){var e=hde(i,"string");return typeof e=="symbol"?e:e+""}function Ade(i,e){if(i){if(typeof i=="string")return gw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?gw(i,e):void 0}}function uI(i,e){var t=new e;return t._destructor&&t._destructor(),{linkProp:function(r){return{default:t[r](),onChange:function(a,l){l[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var a=s[i],l=arguments.length,u=new Array(l>1?l-1:0),h=1;h<l;h++)u[h-1]=arguments[h];var g=a[r].apply(a,u);return g===a?this:g}}}}var dde=["rendererConfig","waitForGlobeReady"],vm=jf(jf({},window.THREE?window.THREE:{AmbientLight:sD,DirectionalLight:rD,Vector2:pt,REVISION:V0}),{},{CSS2DRenderer:Bj}),cI=uI("globe",DO),pde=Object.assign.apply(Object,ux(["globeImageUrl","bumpImageUrl","globeTileEngineUrl","globeTileEngineMaxLevel","globeCurvatureResolution","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude","onGlobeReady","pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration","arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration","polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration","pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration","heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration","hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration","hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration","tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tile
|