mirror of
https://github.com/brunopostle/ifcurl.git
synced 2026-07-12 10:18:14 +00:00
4600 lines
5 MiB
JavaScript
4600 lines
5 MiB
JavaScript
|
|
var Noe=Object.create;var hW=Object.defineProperty;var Coe=Object.getOwnPropertyDescriptor;var boe=Object.getOwnPropertyNames;var Ooe=Object.getPrototypeOf,Loe=Object.prototype.hasOwnProperty;var F_=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var _oe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),fW=(e,t)=>{for(var i in t)hW(e,i,{get:t[i],enumerable:!0})},Poe=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of boe(t))!Loe.call(e,s)&&s!==i&&hW(e,s,{get:()=>t[s],enumerable:!(n=Coe(t,s))||n.enumerable});return e};var xoe=(e,t,i)=>(i=e!=null?Noe(Ooe(e)):{},Poe(t||!e||!e.__esModule?hW(i,"default",{value:e,enumerable:!0}):i,e));var gne=_oe((wne,VK)=>{(function(e){typeof wne=="object"&&typeof VK<"u"?VK.exports=e():typeof define=="function"&&define.amd?define([],e):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=e()})(function(){return(function e(t,i,n){function s(d,h){if(!i[d]){if(!t[d]){var f=typeof F_=="function"&&F_;if(!h&&f)return f(d,!0);if(l)return l(d,!0);var I=new Error("Cannot find module '"+d+"'");throw I.code="MODULE_NOT_FOUND",I}var y=i[d]={exports:{}};t[d][0].call(y.exports,function(g){var T=t[d][1][g];return s(T||g)},y,y.exports,e,t,i,n)}return i[d].exports}for(var l=typeof F_=="function"&&F_,u=0;u<n.length;u++)s(n[u]);return s})({1:[function(e,t,i){"use strict";var n=e("./utils"),s=e("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(u){for(var d,h,f,I,y,g,T,D=[],L=0,O=u.length,N=O,Y=n.getTypeOf(u)!=="string";L<u.length;)N=O-L,f=Y?(d=u[L++],h=L<O?u[L++]:0,L<O?u[L++]:0):(d=u.charCodeAt(L++),h=L<O?u.charCodeAt(L++):0,L<O?u.charCodeAt(L++):0),I=d>>2,y=(3&d)<<4|h>>4,g=1<N?(15&h)<<2|f>>6:64,T=2<N?63&f:64,D.push(l.charAt(I)+l.charAt(y)+l.charAt(g)+l.charAt(T));return D.join("")},i.decode=function(u){var d,h,f,I,y,g,T=0,D=0,L="data:";if(u.substr(0,L.length)===L)throw new Error("Invalid base64 input, it looks like a data url.");var O,N=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===l.charAt(64)&&N--,u.charAt(u.length-2)===l.charAt(64)&&N--,N%1!=0)throw new Error("Invalid base64 input, bad content length.");for(O=s.uint8array?new Uint8Array(0|N):new Array(0|N);T<u.length;)d=l.indexOf(u.charAt(T++))<<2|(I=l.indexOf(u.charAt(T++)))>>4,h=(15&I)<<4|(y=l.indexOf(u.charAt(T++)))>>2,f=(3&y)<<6|(g=l.indexOf(u.charAt(T++))),O[D++]=d,y!==64&&(O[D++]=h),g!==64&&(O[D++]=f);return O}},{"./support":30,"./utils":32}],2:[function(e,t,i){"use strict";var n=e("./external"),s=e("./stream/DataWorker"),l=e("./stream/Crc32Probe"),u=e("./stream/DataLengthProbe");function d(h,f,I,y,g){this.compressedSize=h,this.uncompressedSize=f,this.crc32=I,this.compression=y,this.compressedContent=g}d.prototype={getContentWorker:function(){var h=new s(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),f=this;return h.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new s(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(h,f,I){return h.pipe(new l).pipe(new u("uncompressedSize")).pipe(f.compressWorker(I)).pipe(new u("compressedSize")).withStreamInfo("compression",f)},t.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,i){"use strict";var n=e("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},i.DEFLATE=e("./flate")},{"./flate":7,"./stream/
|
||
|
|
\0`,mt+=n(Qe,2),mt+=$.magic,mt+=n(N,2),mt+=n(Y,2),mt+=n(At.crc32,4),mt+=n(At.compressedSize,4),mt+=n(At.uncompressedSize,4),mt+=n(pe.length,2),mt+=n(De.length,2),{fileRecord:f.LOCAL_FILE_HEADER+mt+pe+De,dirRecord:f.CENTRAL_FILE_HEADER+n(yt,2)+mt+n(le.length,2)+"\0\0\0\0"+n(ut,4)+n(D,4)+pe+De+le}}var l=e("../utils"),u=e("../stream/GenericWorker"),d=e("../utf8"),h=e("../crc32"),f=e("../signature");function I(y,g,T,D){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=T,this.encodeFileName=D,this.streamFiles=y,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(I,u),I.prototype.push=function(y){var g=y.meta.percent||0,T=this.entriesCount,D=this._sources.length;this.accumulate?this.contentBuffer.push(y):(this.bytesWritten+=y.data.length,u.prototype.push.call(this,{data:y.data,meta:{currentFile:this.currentFile,percent:T?(g+100*(T-D-1))/T:100}}))},I.prototype.openedSource=function(y){this.currentSourceOffset=this.bytesWritten,this.currentFile=y.file.name;var g=this.streamFiles&&!y.file.dir;if(g){var T=s(y,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:T.fileRecord,meta:{percent:0}})}else this.accumulate=!0},I.prototype.closedSource=function(y){this.accumulate=!1;var g=this.streamFiles&&!y.file.dir,T=s(y,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(T.dirRecord),g)this.push({data:(function(D){return f.DATA_DESCRIPTOR+n(D.crc32,4)+n(D.compressedSize,4)+n(D.uncompressedSize,4)})(y),meta:{percent:100}});else for(this.push({data:T.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},I.prototype.flush=function(){for(var y=this.bytesWritten,g=0;g<this.dirRecords.length;g++)this.push({data:this.dirRecords[g],meta:{percent:100}});var T=this.bytesWritten-y,D=(function(L,O,N,Y,V){var $=l.transformTo("string",V(Y));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(L,2)+n(L,2)+n(O,4)+n(N,4)+n($.length,2)+$})(this.dirRecords.length,T,y,this.zipComment,this.encodeFileName);this.push({data:D,meta:{percent:100}})},I.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},I.prototype.registerPrevious=function(y){this._sources.push(y);var g=this;return y.on("data",function(T){g.processChunk(T)}),y.on("end",function(){g.closedSource(g.previous.streamInfo),g._sources.length?g.prepareNextSource():g.end()}),y.on("error",function(T){g.error(T)}),this},I.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},I.prototype.error=function(y){var g=this._sources;if(!u.prototype.error.call(this,y))return!1;for(var T=0;T<g.length;T++)try{g[T].error(y)}catch{}return!0},I.prototype.lock=function(){u.prototype.lock.call(this);for(var y=this._sources,g=0;g<y.length;g++)y[g].lock()},t.exports=I},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,i){"use strict";var n=e("../compressions"),s=e("./ZipFileWorker");i.generateWorker=function(l,u,d){var h=new s(u.streamFiles,d,u.platform,u.encodeFileName),f=0;try{l.forEach(function(I,y){f++;var g=(function(O,N){var Y=O||N,V=n[Y];if(!V)throw new Error(Y+" is not a valid compression method !");return V})(y.options.compression,u.compression),T=y.options.compressionOptions||u.compressionOptions||{},D=y.dir,L=y.date;y._compressWorker(g,T).withStreamInfo("file",{name:I,dir:D,date:L,comment:y.comment||"",unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions}).pipe(h)}),h.entriesCount=f}catch(I){h.error(I)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,i){"use strict";function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with paramete
|
||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
|
|
}`,Ile=`void main() {
|
||
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
|
|
}`,$r=class extends eu{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ple,this.fragmentShader=Ile,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=eA(t.uniforms),this.uniformsGroups=fle(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let i=super.toJSON(t);i.glslVersion=this.glslVersion,i.uniforms={};for(let s in this.uniforms){let u=this.uniforms[s].value;u&&u.isTexture?i.uniforms[s]={type:"t",value:u.toJSON(t).uuid}:u&&u.isColor?i.uniforms[s]={type:"c",value:u.getHex()}:u&&u.isVector2?i.uniforms[s]={type:"v2",value:u.toArray()}:u&&u.isVector3?i.uniforms[s]={type:"v3",value:u.toArray()}:u&&u.isVector4?i.uniforms[s]={type:"v4",value:u.toArray()}:u&&u.isMatrix3?i.uniforms[s]={type:"m3",value:u.toArray()}:u&&u.isMatrix4?i.uniforms[s]={type:"m4",value:u.toArray()}:i.uniforms[s]={value:u}}Object.keys(this.defines).length>0&&(i.defines=this.defines),i.vertexShader=this.vertexShader,i.fragmentShader=this.fragmentShader,i.lights=this.lights,i.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(i.extensions=n),i}},BS=class extends jn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vi,this.projectionMatrix=new vi,this.projectionMatrixInverse=new vi,this.coordinateSystem=Op}copy(t,i){return super.copy(t,i),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,i){super.updateWorldMatrix(t,i),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Bg=new Ne,lQ=new ai,rQ=new ai,no=class extends BS{constructor(t=50,i=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=i,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,i){return super.copy(t,i),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let i=.5*this.getFilmHeight()/t;this.fov=LS*2*Math.atan(i),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(OS*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return LS*2*Math.atan(Math.tan(OS*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,i,n){Bg.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Bg.x,Bg.y).multiplyScalar(-t/Bg.z),Bg.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Bg.x,Bg.y).multiplyScalar(-t/Bg.z)}getViewSize(t,i){return this.getViewBounds(t,lQ,rQ),i.subVectors(rQ,lQ)}setViewOffset(t,i,n,s,l,u){this.aspect=t/i,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=t,this.view.fullHeight=i,this.view.offsetX=n,this.v
|
||
|
|
|
||
|
|
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 );
|
||
|
|
|
||
|
|
}
|
||
|
|
`},s=new Sl(5,5,5),l=new $r({name:"CubemapFromEquirect",uniforms:eA(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:tu,blending:h3});l.uniforms.tEquirect.value=i;let u=new Ri(s,l),d=i.minFilter;return i.minFilter===Ey&&(i.minFilter=Wa),new rP(1,10,this).update(t,u),i.minFilter=d,u.geometry.dispose(),u.material.dispose(),this}clear(t,i=!0,n=!0,s=!0){let l=t.getRenderTarget();for(let u=0;u<6;u++)t.setRenderTarget(this,u),t.clear(i,n,s);t.setRenderTarget(l)}},kd=class extends jn{constructor(){super(),this.isGroup=!0,this.type="Group"}},mle={type:"move"},US=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new kd,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new kd,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ne,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ne),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new kd,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ne,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ne),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let i=this._hand;if(i)for(let n of t.hand.values())this._getHandJoint(i,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,i,n){let s=null,l=null,u=null,d=this._targetRay,h=this._grip,f=this._hand;if(t&&i.session.visibilityState!=="visible-blurred"){if(f&&t.hand){u=!0;for(let L of t.hand.values()){let O=i.getJointPose(L,n),N=this._getHandJoint(f,L);O!==null&&(N.matrix.fromArray(O.transform.matrix),N.matrix.decompose(N.position,N.rotation,N.scale),N.matrixWorldNeedsUpdate=!0,N.jointRadius=O.radius),N.visible=O!==null}let I=f.joints["index-finger-tip"],y=f.joints["thumb-tip"],g=I.position.distanceTo(y.position),T=.02,D=.005;f.inputState.pinching&&g>T+D?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!f.inputState.pinching&&g<=T-D&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else h!==null&&t.gripSpace&&(l=i.getPose(t.gripSpace,n),l!==null&&(h.matrix.fromArray(l.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,l.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(l.linearVelocity)):h.hasLinearVelocity=!1,l.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(l.angularVelocity)):h.hasAngularVelocity=!1));d!==null&&(s=i.getPose(t.targetRaySpace,n),s===null&&l!==null&&(s=l),s!==null&&(d.matrix.fromArray(s.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,s.linearVelocity?(d.hasLinearVelocity=!0,d.linearVelocity.copy(s.linearVelocity)):d.hasLinearVelocity=!1,s.angularVelocity?(d.hasAngularVelocity=!0,d.angularVelocity.copy(s.angularVelocity)):d.hasAngularVelocity=!1,this.dispatchEvent(mle)))}return d!==null&&(d.visible=s!==null),h!==null&&(h.visible=l!==null),f!==null&&(f.visible=u!==null),this}_getHandJoint(t,i){if(t.joints[i.jointName]===void 0){let n=new kd;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[i.jointName]=n,t.add(n)}return t.joints[i.jointName]}},uP=class e{constructor(t,i=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ni(t),this.density=i}clone(){return new e(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}
|
||
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
|
|
#endif`,Are=`#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`,Dre=`#ifdef USE_ALPHAMAP
|
||
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
|
|
#endif`,Nre=`#ifdef USE_ALPHAMAP
|
||
|
|
uniform sampler2D alphaMap;
|
||
|
|
#endif`,Cre=`#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`,bre=`#ifdef USE_ALPHATEST
|
||
|
|
uniform float alphaTest;
|
||
|
|
#endif`,Ore=`#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`,Lre=`#ifdef USE_AOMAP
|
||
|
|
uniform sampler2D aoMap;
|
||
|
|
uniform float aoMapIntensity;
|
||
|
|
#endif`,_re=`#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`,Pre=`#ifdef USE_BATCHING
|
||
|
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
|
|
#endif`,xre=`vec3 transformed = vec3( position );
|
||
|
|
#ifdef USE_ALPHAHASH
|
||
|
|
vPosition = vec3( position );
|
||
|
|
#endif`,Mre=`vec3 objectNormal = vec3( normal );
|
||
|
|
#ifdef USE_TANGENT
|
||
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
||
|
|
#endif`,Bre=`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`,Ure=`#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`,Fre=`#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`,Hre=`#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`,Gre=`#if NUM_CLIPPING_PLANES > 0
|
||
|
|
varying vec3 vClipPosition;
|
||
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
|
|
#endif`,Vre=`#if NUM_CLIPPING_PLANES > 0
|
||
|
|
varying vec3 vClipPosition;
|
||
|
|
#endif`,kre=`#if NUM_CLIPPING_PLANES > 0
|
||
|
|
vClipPosition = - mvPosition.xyz;
|
||
|
|
#endif`,zre=`#if defined( USE_COLOR_ALPHA )
|
||
|
|
diffuseColor *= vColor;
|
||
|
|
#elif defined( USE_COLOR )
|
||
|
|
diffuseColor.rgb *= vColor;
|
||
|
|
#endif`,Wre=`#if defined( USE_COLOR_ALPHA )
|
||
|
|
varying vec4 vColor;
|
||
|
|
#elif defined( USE_COLOR )
|
||
|
|
varying vec3 vColor;
|
||
|
|
#endif`,Yre=`#if defined( USE_COLOR_ALPHA )
|
||
|
|
varying vec4 vColor;
|
||
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
|
|
varying vec3 vColor;
|
||
|
|
#endif`,jre=`#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`,qre=`#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`,$re=`#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`,Zre=`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`,Kre=`#ifdef USE_DISPLACEMENTMAP
|
||
|
|
uniform sampler2D displacementMap;
|
||
|
|
uniform float displacementScale;
|
||
|
|
uniform float displacementBias;
|
||
|
|
#endif`,Qre=`#ifdef USE_DISPLACEMENTMAP
|
||
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
|
|
#endif`,Jre=`#ifdef USE_EMISSIVEMAP
|
||
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
|
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
|
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
|
|
#endif
|
||
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
|
|
#endif`,Xre=`#ifdef USE_EMISSIVEMAP
|
||
|
|
uniform sampler2D emissiveMap;
|
||
|
|
#endif`,eae="gl_FragColor = linearToOutputTexel( gl_FragColor );",tae=`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 );
|
||
|
|
}`,iae=`#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`,nae=`#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`,sae=`#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`,oae=`#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`,lae=`#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`,rae=`#ifdef USE_FOG
|
||
|
|
vFogDepth = - mvPosition.z;
|
||
|
|
#endif`,aae=`#ifdef USE_FOG
|
||
|
|
varying float vFogDepth;
|
||
|
|
#endif`,uae=`#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`,dae=`#ifdef USE_FOG
|
||
|
|
uniform vec3 fogColor;
|
||
|
|
varying float vFogDepth;
|
||
|
|
#ifdef FOG_EXP2
|
||
|
|
uniform float fogDensity;
|
||
|
|
#else
|
||
|
|
uniform float fogNear;
|
||
|
|
uniform float fogFar;
|
||
|
|
#endif
|
||
|
|
#endif`,cae=`#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
|
||
|
|
}`,hae=`#ifdef USE_LIGHTMAP
|
||
|
|
uniform sampler2D lightMap;
|
||
|
|
uniform float lightMapIntensity;
|
||
|
|
#endif`,fae=`LambertMaterial material;
|
||
|
|
material.diffuseColor = diffuseColor.rgb;
|
||
|
|
material.specularStrength = specularStrength;`,pae=`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`,Iae=`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`,mae=`#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`,yae=`ToonMaterial material;
|
||
|
|
material.diffuseColor = diffuseColor.rgb;`,Eae=`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`,Tae=`BlinnPhongMaterial material;
|
||
|
|
material.diffuseColor = diffuseColor.rgb;
|
||
|
|
material.specularColor = specular;
|
||
|
|
material.specularShininess = shininess;
|
||
|
|
material.specularStrength = specularStrength;`,wae=`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`,gae=`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`,vae=`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 );
|
||
|
|
}`,Rae=`
|
||
|
|
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`,Sae=`#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`,Aae=`#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`,Dae=`#if defined( USE_LOGDEPTHBUF )
|
||
|
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
|
|
#endif`,Nae=`#if defined( USE_LOGDEPTHBUF )
|
||
|
|
uniform float logDepthBufFC;
|
||
|
|
varying float vFragDepth;
|
||
|
|
varying float vIsPerspective;
|
||
|
|
#endif`,Cae=`#ifdef USE_LOGDEPTHBUF
|
||
|
|
varying float vFragDepth;
|
||
|
|
varying float vIsPerspective;
|
||
|
|
#endif`,bae=`#ifdef USE_LOGDEPTHBUF
|
||
|
|
vFragDepth = 1.0 + gl_Position.w;
|
||
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
|
|
#endif`,Oae=`#ifdef USE_MAP
|
||
|
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
||
|
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
|
|
#endif
|
||
|
|
diffuseColor *= sampledDiffuseColor;
|
||
|
|
#endif`,Lae=`#ifdef USE_MAP
|
||
|
|
uniform sampler2D map;
|
||
|
|
#endif`,_ae=`#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`,Pae=`#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`,xae=`float metalnessFactor = metalness;
|
||
|
|
#ifdef USE_METALNESSMAP
|
||
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
|
|
metalnessFactor *= texelMetalness.b;
|
||
|
|
#endif`,Mae=`#ifdef USE_METALNESSMAP
|
||
|
|
uniform sampler2D metalnessMap;
|
||
|
|
#endif`,Bae=`#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`,Uae=`#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`,Fae=`#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`,Hae=`#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`,Gae=`#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`,Vae=`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;`,kae=`#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`,zae=`#ifndef FLAT_SHADED
|
||
|
|
varying vec3 vNormal;
|
||
|
|
#ifdef USE_TANGENT
|
||
|
|
varying vec3 vTangent;
|
||
|
|
varying vec3 vBitangent;
|
||
|
|
#endif
|
||
|
|
#endif`,Wae=`#ifndef FLAT_SHADED
|
||
|
|
varying vec3 vNormal;
|
||
|
|
#ifdef USE_TANGENT
|
||
|
|
varying vec3 vTangent;
|
||
|
|
varying vec3 vBitangent;
|
||
|
|
#endif
|
||
|
|
#endif`,Yae=`#ifndef FLAT_SHADED
|
||
|
|
vNormal = normalize( transformedNormal );
|
||
|
|
#ifdef USE_TANGENT
|
||
|
|
vTangent = normalize( transformedTangent );
|
||
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||
|
|
#endif
|
||
|
|
#endif`,jae=`#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`,qae=`#ifdef USE_CLEARCOAT
|
||
|
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
|
|
#endif`,$ae=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
|
|
#endif`,Zae=`#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`,Kae=`#ifdef USE_IRIDESCENCEMAP
|
||
|
|
uniform sampler2D iridescenceMap;
|
||
|
|
#endif
|
||
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
|
|
uniform sampler2D iridescenceThicknessMap;
|
||
|
|
#endif`,Qae=`#ifdef OPAQUE
|
||
|
|
diffuseColor.a = 1.0;
|
||
|
|
#endif
|
||
|
|
#ifdef USE_TRANSMISSION
|
||
|
|
diffuseColor.a *= material.transmissionAlpha;
|
||
|
|
#endif
|
||
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Jae=`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 );
|
||
|
|
}`,Xae=`#ifdef PREMULTIPLIED_ALPHA
|
||
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
||
|
|
#endif`,eue=`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;`,tue=`#ifdef DITHERING
|
||
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
|
|
#endif`,iue=`#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`,nue=`float roughnessFactor = roughness;
|
||
|
|
#ifdef USE_ROUGHNESSMAP
|
||
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
|
|
roughnessFactor *= texelRoughness.g;
|
||
|
|
#endif`,sue=`#ifdef USE_ROUGHNESSMAP
|
||
|
|
uniform sampler2D roughnessMap;
|
||
|
|
#endif`,oue=`#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`,lue=`#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`,rue=`#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`,aue=`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;
|
||
|
|
}`,uue=`#ifdef USE_SKINNING
|
||
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
|
|
#endif`,due=`#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`,cue=`#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`,hue=`#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`,fue=`float specularStrength;
|
||
|
|
#ifdef USE_SPECULARMAP
|
||
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
|
|
specularStrength = texelSpecular.r;
|
||
|
|
#else
|
||
|
|
specularStrength = 1.0;
|
||
|
|
#endif`,pue=`#ifdef USE_SPECULARMAP
|
||
|
|
uniform sampler2D specularMap;
|
||
|
|
#endif`,Iue=`#if defined( TONE_MAPPING )
|
||
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
|
|
#endif`,mue=`#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; }`,yue=`#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`,Eue=`#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`,Tue=`#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`,wue=`#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`,gue=`#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`,vue=`#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`,Rue=`varying vec2 vUv;
|
||
|
|
uniform mat3 uvTransform;
|
||
|
|
void main() {
|
||
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
|
|
}`,Sue=`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>
|
||
|
|
}`,Aue=`varying vec3 vWorldDirection;
|
||
|
|
#include <common>
|
||
|
|
void main() {
|
||
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
|
#include <begin_vertex>
|
||
|
|
#include <project_vertex>
|
||
|
|
gl_Position.z = gl_Position.w;
|
||
|
|
}`,Due=`#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>
|
||
|
|
}`,Nue=`varying vec3 vWorldDirection;
|
||
|
|
#include <common>
|
||
|
|
void main() {
|
||
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
|
#include <begin_vertex>
|
||
|
|
#include <project_vertex>
|
||
|
|
gl_Position.z = gl_Position.w;
|
||
|
|
}`,Cue=`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>
|
||
|
|
}`,bue=`#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;
|
||
|
|
}`,Oue=`#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
|
||
|
|
}`,Lue=`#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;
|
||
|
|
}`,_ue=`#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 );
|
||
|
|
}`,Pue=`varying vec3 vWorldDirection;
|
||
|
|
#include <common>
|
||
|
|
void main() {
|
||
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
|
#include <begin_vertex>
|
||
|
|
#include <project_vertex>
|
||
|
|
}`,xue=`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>
|
||
|
|
}`,Mue=`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>
|
||
|
|
}`,Bue=`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>
|
||
|
|
}`,Uue=`#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>
|
||
|
|
}`,Fue=`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>
|
||
|
|
}`,Hue=`#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>
|
||
|
|
}`,Gue=`#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>
|
||
|
|
}`,Vue=`#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;
|
||
|
|
}`,kue=`#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>
|
||
|
|
}`,zue=`#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
|
||
|
|
}`,Wue=`#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
|
||
|
|
}`,Yue=`#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>
|
||
|
|
}`,jue=`#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>
|
||
|
|
}`,que=`#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
|
||
|
|
}`,$ue=`#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>
|
||
|
|
}`,Zue=`#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>
|
||
|
|
}`,Kue=`#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>
|
||
|
|
}`,Que=`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>
|
||
|
|
}`,Jue=`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>
|
||
|
|
}`,Xue=`#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>
|
||
|
|
}`,ede=`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>
|
||
|
|
}`,tde=`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>
|
||
|
|
}`,ide=`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>
|
||
|
|
}`,Kn={alphahash_fragment:Sre,alphahash_pars_fragment:Are,alphamap_fragment:Dre,alphamap_pars_fragment:Nre,alphatest_fragment:Cre,alphatest_pars_fragment:bre,aomap_fragment:Ore,aomap_pars_fragment:Lre,batching_pars_vertex:_re,batching_vertex:Pre,begin_vertex:xre,beginnormal_vertex:Mre,bsdfs:Bre,iridescence_fragment:Ure,bumpmap_pars_fragment:Fre,clipping_planes_fragment:Hre,clipping_planes_pars_fragment:Gre,clipping_planes_pars_vertex:Vre,clipping_planes_vertex:kre,color_fragment:zre,color_pars_fragment:Wre,color_pars_vertex:Yre,color_vertex:jre,common:qre,cube_uv_reflection_fragment:$re,defaultnormal_vertex:Zre,displacementmap_pars_vertex:Kre,displacementmap_vertex:Qre,emissivemap_fragment:Jre,emissivemap_pars_fragment:Xre,colorspace_fragment:eae,colorspace_pars_fragment:tae,envmap_fragment:iae,envmap_common_pars_fragment:nae,envmap_pars_fragment:sae,envmap_pars_vertex:oae,envmap_physical_pars_fragment:mae,envmap_vertex:lae,fog_vertex:rae,fog_pars_vertex:aae,fog_fragment:uae,fog_pars_fragment:dae,gradientmap_pars_fragment:cae,lightmap_pars_fragment:hae,lights_lambert_fragment:fae,lights_lambert_pars_fragment:pae,lights_pars_begin:Iae,lights_toon_fragment:yae,lights_toon_pars_fragment:Eae,lights_phong_fragment:Tae,lights_phong_pars_fragment:wae,lights_physical_fragment:gae,lights_physical_pars_fragment:vae,lights_fragment_begin:Rae,lights_fragment_maps:Sae,lights_fragment_end:Aae,logdepthbuf_fragment:Dae,logdepthbuf_pars_fragment:Nae,logdepthbuf_pars_vertex:Cae,logdepthbuf_vertex:bae,map_fragment:Oae,map_pars_fragment:Lae,map_particle_fragment:_ae,map_particle_pars_fragment:Pae,metalnessmap_fragment:xae,metalnessmap_pars_fragment:Mae,morphinstance_vertex:Bae,morphcolor_vertex:Uae,morphnormal_vertex:Fae,morphtarget_pars_vertex:Hae,morphtarget_vertex:Gae,normal_fragment_begin:Vae,normal_fragment_maps:kae,normal_pars_fragment:zae,normal_pars_vertex:Wae,normal_vertex:Yae,normalmap_pars_fragment:jae,clearcoat_normal_fragment_begin:qae,clearcoat_normal_fragment_maps:$ae,clearcoat_pars_fragment:Zae,iridescence_pars_fragment:Kae,opaque_fragment:Qae,packing:Jae,premultiplied_alpha_fragment:Xae,project_vertex:eue,dithering_fragment:tue,dithering_pars_fragment:iue,roughnessmap_fragment:nue,roughnessmap_pars_fragment:sue,shadowmap_pars_fragment:oue,shadowmap_pars_vertex:lue,shadowmap_vertex:rue,shadowmask_pars_fragment:aue,skinbase_vertex:uue,skinning_pars_vertex:due,skinning_vertex:cue,skinnormal_vertex:hue,specularmap_fragment:fue,specularmap_pars_fragment:pue,tonemapping_fragment:Iue,tonemapping_pars_fragment:mue,transmission_fragment:yue,transmission_pars_fragment:Eue,uv_pars_fragment:Tue,uv_pars_vertex:wue,uv_vertex:gue,worldpos_vertex:vue,background_vert:Rue,background_frag:Sue,backgroundCube_vert:Aue,backgroundCube_frag:Due,cube_vert:Nue,cube_frag:Cue,depth_vert:bue,depth_frag:Oue,distanceRGBA_vert:Lue,distanceRGBA_frag:_ue,equirect_vert:Pue,equirect_frag:xue,linedashed_vert:Mue,linedashed_frag:Bue,meshbasic_vert:Uue,meshbasic_frag:Fue,meshlambert_vert:Hue,meshlambert_frag:Gue,meshmatcap_vert:Vue,meshmatcap_frag:kue,meshnormal_vert:zue,meshnormal_frag:Wue,meshphong_vert:Yue,meshphong_frag:jue,meshphysical_vert:que,meshphysical_frag:$ue,meshtoon_vert:Zue,meshtoon_frag:Kue,points_vert:Que,points_frag:Jue,shadow_vert:Xue,shadow_frag:ede,sprite_vert:tde,sprite_frag:ide},Gi={common:{diffuse:{value:new Ni(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Dn},alphaMap:{value:null},alphaMapTransform:{value:new Dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Dn}},envmap:{envMap:{value:null},envMapRotation:{value:new Dn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Dn},normalScale:{value:new ai(1,1)}},displac
|
||
|
|
|
||
|
|
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:h3,depthTest:!1,depthWrite:!1})}function XJ(){return new $r({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Rj(),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:h3,depthTest:!1,depthWrite:!1})}function eX(){return new $r({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Rj(),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:h3,depthTest:!1,depthWrite:!1})}function Rj(){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 fde(e){let t=new WeakMap,i=null;function n(d){if(d&&d.isTexture){let h=d.mapping,f=h===SC||h===AC,I=h===p3||h===d2;if(f||I){let y=t.get(d),g=y!==void 0?y.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g)return i===null&&(i=new Kx(e)),y=f?i.fromEquirectangular(d,y):i.fromCubemap(d,y),y.texture.pmremVersion=d.pmremVersion,t.set(d,y),y.texture;if(y!==void 0)return y.texture;{let T=d.image;return f&&T&&T.height>0||I&&T&&s(T)?(i===null&&(i=new Kx(e)),y=f?i.fromEquirectangular(d):i.fromCubemap(d),y.texture.pmremVersion=d.pmremVersion,t.set(d,y),d.addEventListener("dispose",l),y.texture):null}}}return d}function s(d){let h=0,f=6;for(let I=0;I<f;I++)d[I]!==void 0&&h++;return h===f}function l(d){let h=d.target;h.removeEventListener("dispose",l);let f=t.get(h);f!==void 0&&(t.delete(h),f.dispose())}function u(){t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:n,dispose:u}}function pde(e){let t={};function i(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=e.getExtension(n)}return t[n]=s,s}return{has:function(n){return i(n)!==null},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(n){let s=i(n);return s===null&&_S("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function Ide(e,t,i,n){let s={},l=new WeakMap;function u(y){let g=y.target;g.index!==null&&t.remove(g.index);for(let D in g.attributes)t.remove(g.attributes[D]);g.removeEventListener("dispose",u),delete s[g.id];let T=l.get(g);T&&(t.remove(T),l.delete(g)),n.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,i.memory.geometries--}function d(y,g){return s[g.id]===!0||(g.addEventListener("dispose",u),s[g.id]=!0,i.memory.geometries++),g}function h(y){let g=y.attributes;for(let T in g)t.update(g[T],e.ARRAY_BUFFER)}function f(y){let g=[],T=y.index,D=y.attributes.position,L=0;if(T!==null){let Y=T.array;L=T.version;for(let V=0,$=Y.length;V<$;V+=3){let re=Y[V+0],pe=Y[V+1],de=Y[V+2];g.push(re,pe,pe,de,de,re)}}else if(D!==void 0){let Y=D.array;L=D.version;for(let V=0,$=Y.length/3-1;V<$;V+=3){let re=V+0,pe=V+1,de=V+2;g.push(re,pe,pe,de,de,re)}}else return;let O=new(tj(g)?iC:tC)(g,1);O.version=L;let N=l.get(y);N&&t.remove(N),l.set(y,O)}function I(y){let g=l.get(y);if(g){let T=y.index;T!==null&&g.version<T.version&&f(y)}else f(y);return l.get(y)}return{get:d,update:h,getWireframeAttribute:I}}function mde(e,t,i){let n;function s(g){n=g}let l,u;function d(g){l=g.type,u=g.bytesPerElement}function h(g,T){e.drawElements(n,T,l,g*u),i.update(T,n,1)}function f(g,T,D){D!==0&&(e.drawElementsInstanced(n,T,l,g*u,D),i.update(T,n,D))}function I(g,T,D){if(D===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,T,0,l,g,0,D);let O=0;for(let N=0;N<D;N++)O+=T[N];i.update(O,n,1)}function y(g,T,D,L){if(D===0)return;let O=t.get("WEBGL_multi_draw");if(O===null)for(let N=0;N<g.length;N++)f(g[N]/u,T[N],L[N]);else{O.multiDrawElementsInstancedWEBGL(n,T,0,l,g,0,L,0,D);let N=0;for(let Y=0;Y<D;Y++)N+=T[Y]*L[Y];i.update(N,n,1)}}this.setMode=s,this.setIndex=d,this.render=h,this.renderInstances=f,this.renderMultiDraw=I,this.renderMultiDrawInstances=y}function yde(e){let t={geometries:0,textures:0},i={frame:0,calls:0,triangles:0,points:0,lines
|
||
|
|
`),n=[],s=Math.max(t-6,0),l=Math.min(t+6,i.length);for(let u=s;u<l;u++){let d=u+1;n.push(`${d===t?">":" "} ${d}: ${i[u]}`)}return n.join(`
|
||
|
|
`)}var uX=new Dn;function dce(e){ps._getMatrix(uX,ps.workingColorSpace,e);let t=`mat3( ${uX.elements.map(i=>i.toFixed(4))} )`;switch(ps.getTransfer(e)){case ZN:return[t,"LinearTransferOETF"];case Vs:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function dX(e,t,i){let n=e.getShaderParameter(t,e.COMPILE_STATUS),s=e.getShaderInfoLog(t).trim();if(n&&s==="")return"";let l=/ERROR: 0:(\d+)/.exec(s);if(l){let u=parseInt(l[1]);return i.toUpperCase()+`
|
||
|
|
|
||
|
|
`+s+`
|
||
|
|
|
||
|
|
`+uce(e.getShaderSource(t),u)}else return s}function cce(e,t){let i=dce(t);return[`vec4 ${e}( vec4 value ) {`,` return ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join(`
|
||
|
|
`)}function hce(e,t){let i;switch(t){case PY:i="Linear";break;case xY:i="Reinhard";break;case MY:i="Cineon";break;case BY:i="ACESFilmic";break;case FY:i="AgX";break;case HY:i="Neutral";break;case UY:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}var jF=new Ne;function fce(){ps.getLuminanceCoefficients(jF);let e=jF.x.toFixed(4),t=jF.y.toFixed(4),i=jF.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${i} );`," return dot( weights, rgb );","}"].join(`
|
||
|
|
`)}function pce(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zx).join(`
|
||
|
|
`)}function Ice(e){let t=[];for(let i in e){let n=e[i];n!==!1&&t.push("#define "+i+" "+n)}return t.join(`
|
||
|
|
`)}function mce(e,t){let i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let l=e.getActiveAttrib(t,s),u=l.name,d=1;l.type===e.FLOAT_MAT2&&(d=2),l.type===e.FLOAT_MAT3&&(d=3),l.type===e.FLOAT_MAT4&&(d=4),i[u]={type:l.type,location:e.getAttribLocation(t,u),locationSize:d}}return i}function Zx(e){return e!==""}function cX(e,t){let i=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function hX(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var yce=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ej(e){return e.replace(yce,Tce)}var Ece=new Map;function Tce(e,t){let i=Kn[t];if(i===void 0){let n=Ece.get(t);if(n!==void 0)i=Kn[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Ej(i)}var wce=/#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 fX(e){return e.replace(wce,gce)}function gce(e,t,i,n){let s="";for(let l=parseInt(t);l<parseInt(i);l++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+l+" ]").replace(/UNROLLED_LOOP_INDEX/g,l);return s}function pX(e){let t=`precision ${e.precision} float;
|
||
|
|
precision ${e.precision} int;
|
||
|
|
precision ${e.precision} sampler2D;
|
||
|
|
precision ${e.precision} samplerCube;
|
||
|
|
precision ${e.precision} sampler3D;
|
||
|
|
precision ${e.precision} sampler2DArray;
|
||
|
|
precision ${e.precision} sampler2DShadow;
|
||
|
|
precision ${e.precision} samplerCubeShadow;
|
||
|
|
precision ${e.precision} sampler2DArrayShadow;
|
||
|
|
precision ${e.precision} isampler2D;
|
||
|
|
precision ${e.precision} isampler3D;
|
||
|
|
precision ${e.precision} isamplerCube;
|
||
|
|
precision ${e.precision} isampler2DArray;
|
||
|
|
precision ${e.precision} usampler2D;
|
||
|
|
precision ${e.precision} usampler3D;
|
||
|
|
precision ${e.precision} usamplerCube;
|
||
|
|
precision ${e.precision} usampler2DArray;
|
||
|
|
`;return e.precision==="highp"?t+=`
|
||
|
|
#define HIGH_PRECISION`:e.precision==="mediump"?t+=`
|
||
|
|
#define MEDIUM_PRECISION`:e.precision==="lowp"&&(t+=`
|
||
|
|
#define LOW_PRECISION`),t}function vce(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===CF?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===hY?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===yy&&(t="SHADOWMAP_TYPE_VSM"),t}function Rce(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case p3:case d2:t="ENVMAP_TYPE_CUBE";break;case ZS:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Sce(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case d2:t="ENVMAP_MODE_REFRACTION";break}return t}function Ace(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case RC:t="ENVMAP_BLENDING_MULTIPLY";break;case LY:t="ENVMAP_BLENDING_MIX";break;case _Y:t="ENVMAP_BLENDING_ADD";break}return t}function Dce(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let i=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}function Nce(e,t,i,n){let s=e.getContext(),l=i.defines,u=i.vertexShader,d=i.fragmentShader,h=vce(i),f=Rce(i),I=Sce(i),y=Ace(i),g=Dce(i),T=pce(i),D=Ice(l),L=s.createProgram(),O,N,Y=i.glslVersion?"#version "+i.glslVersion+`
|
||
|
|
`:"";i.isRawShaderMaterial?(O=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,D].filter(Zx).join(`
|
||
|
|
`),O.length>0&&(O+=`
|
||
|
|
`),N=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,D].filter(Zx).join(`
|
||
|
|
`),N.length>0&&(N+=`
|
||
|
|
`)):(O=[pX(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,D,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+I:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&i.flatShading===!1?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",
|
||
|
|
`].filter(Zx).join(`
|
||
|
|
`),N=[pX(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,D,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+f:"",i.envMap?"#define "+I:"",i.envMap?"#define "+y:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&i.flatShading===!1?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor||i.batchingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==f3?"#define TONE_MAPPING":"",i.toneMapping!==f3?Kn.tonemapping_pars_fragment:"",i.toneMapping!==f3?hce("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Kn.colorspace_pars_fragment,cce("linearToOutputTexel",i.outputColorSpace),fce(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",`
|
||
|
|
`].filter(Zx).join(`
|
||
|
|
`)),u=Ej(u),u=cX(u,i),u=hX(u,i),d=Ej(d),d=cX(d,i),d=hX(d,i),u=fX(u),d=fX(d),i.isRawShaderMaterial!==!0&&(Y=`#version 300 es
|
||
|
|
`,O=[T,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
|
|
`)+`
|
||
|
|
`+O,N=["#define varying in",i.glslVersion===kF?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===kF?"":"#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(`
|
||
|
|
`)+`
|
||
|
|
`+N);let V=Y+O+u,$=Y+N+d,re=aX(s,s.VERTEX_SHADER,V),pe=aX(s,s.FRAGMENT_SHADER,$);s.attachShader(L,re),s.attachShader(L,pe),i.index0AttributeName!==void 0?s.bindAttribLocation(L,0,i.index0AttributeName):i.morphTargets===!0&&s.bindAttribLocation(L,0,"position"),s.linkProgram(L);function de(be){if(e.debug.checkShaderErrors){let ae=s.getProgramInfoLog(L).trim(),De=s.getShaderInfoLog(re).trim(),Re=s.getShaderInfoLog(pe).trim(),je=!0,pt=!0;if(s.getProgramParameter(L,s.LINK_STATUS)===!1)if(je=!1,typeof e.debug.onShaderError=="function")e.debug.onShaderError(s,L,re,pe);else{let ct=dX(s,re,"vertex"),At=dX(s,pe,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(L,s.VALIDATE_STATUS)+`
|
||
|
|
|
||
|
|
Material Name: `+be.name+`
|
||
|
|
Material Type: `+be.type+`
|
||
|
|
|
||
|
|
Program Info Log: `+ae+`
|
||
|
|
`+ct+`
|
||
|
|
`+At)}else ae!==""?console.warn("THREE.WebGLProgram: Program Info Log:",ae):(De===""||Re==="")&&(pt=!1);pt&&(be.diagnostics={runnable:je,programLog:ae,vertexShader:{log:De,prefix:O},fragmentShader:{log:Re,prefix:N}})}s.deleteShader(re),s.deleteShader(pe),ge=new MC(s,L),le=mce(s,L)}let ge;this.getUniforms=function(){return ge===void 0&&de(this),ge};let le;this.getAttributes=function(){return le===void 0&&de(this),le};let he=i.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return he===!1&&(he=s.getProgramParameter(L,rce)),he},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(L),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=ace++,this.cacheKey=t,this.usedTimes=1,this.program=L,this.vertexShader=re,this.fragmentShader=pe,this}var Cce=0,Tj=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let i=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(i),l=this._getShaderStage(n),u=this._getShaderCacheForMaterial(t);return u.has(s)===!1&&(u.add(s),s.usedTimes++),u.has(l)===!1&&(u.add(l),l.usedTimes++),this}remove(t){let i=this.materialCache.get(t);for(let n of i)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let i=this.materialCache,n=i.get(t);return n===void 0&&(n=new Set,i.set(t,n)),n}_getShaderStage(t){let i=this.shaderCache,n=i.get(t);return n===void 0&&(n=new wj(t),i.set(t,n)),n}},wj=class{constructor(t){this.id=Cce++,this.code=t,this.usedTimes=0}};function bce(e,t,i,n,s,l,u){let d=new MS,h=new Tj,f=new Set,I=[],y=s.logarithmicDepthBuffer,g=s.vertexTextures,T=s.precision,D={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 L(le){return f.add(le),le===0?"uv":`uv${le}`}function O(le,he,be,ae,De){let Re=ae.fog,je=De.geometry,pt=le.isMeshStandardMaterial?ae.environment:null,ct=(le.isMeshStandardMaterial?i:t).get(le.envMap||pt),At=ct&&ct.mapping===ZS?ct.image.height:null,Qe=D[le.type];le.precision!==null&&(T=s.getMaxPrecision(le.precision),T!==le.precision&&console.warn("THREE.WebGLProgram.getParameters:",le.precision,"not supported, using",T,"instead."));let ut=je.morphAttributes.position||je.morphAttributes.normal||je.morphAttributes.color,yt=ut!==void 0?ut.length:0,mt=0;je.morphAttributes.position!==void 0&&(mt=1),je.morphAttributes.normal!==void 0&&(mt=2),je.morphAttributes.color!==void 0&&(mt=3);let Pt,Dt,Rt,Kt;if(Qe){let _n=S0[Qe];Pt=_n.vertexShader,Dt=_n.fragmentShader}else Pt=le.vertexShader,Dt=le.fragmentShader,h.update(le),Rt=h.getVertexShaderID(le),Kt=h.getFragmentShaderID(le);let Jt=e.getRenderTarget(),Qt=e.state.buffers.depth.getReversed(),di=De.isInstancedMesh===!0,Wt=De.isBatchedMesh===!0,ci=!!le.map,Oe=!!le.matcap,xt=!!ct,ue=!!le.aoMap,He=!!le.lightMap,Le=!!le.bumpMap,_e=!!le.normalMap,Me=!!le.displacementMap,at=!!le.emissiveMap,nt=!!le.metalnessMap,vt=!!le.roughnessMap,St=le.anisotropy>0,ze=le.clearcoat>0,Be=le.dispersion>0,wt=le.iridescence>0,Lt=le.sheen>0,jt=le.transmission>0,kt=St&&!!le.anisotropyMap,mi=ze&&!!le.clearcoatMap,yi=ze&&!!le.clearcoatNormalMap,pi=ze&&!!le.clearcoatRoughnessMap,Si=wt&&!!le.iridescenceMap,ei=wt&&!!le.iridescenceThicknessMap,bi=Lt&&!!le.sheenColorMap,Qi=Lt&&!!le.sheenRoughnessMap,Bi=!!le.specularMap,Di=!!le.specularColorMap,rn=!!le.specularIntensityMap,Ft=jt&&!!le.transmissionMap,Oi=jt&&!!le.thicknessMap,ti=!!le.gradientMap,Ui=!!le.alphaMap,Ei=le.alphaTest>0,hi=!!le.alphaHash,zi=!!le.extensions,an=f3;le.toneMapped&&(Jt===n
|
||
|
|
gl_Position = vec4( position, 1.0 );
|
||
|
|
}`,Gce=`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 Vce(e,t,i){let n=new g0,s=new ai,l=new ai,u=new Yn,d=new fC({depthPacking:YY}),h=new pC,f={},I=i.maxTextureSize,y={[T0]:tu,[tu]:T0,[Zr]:Zr},g=new $r({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ai},radius:{value:4}},vertexShader:Hce,fragmentShader:Gce}),T=g.clone();T.defines.HORIZONTAL_PASS=1;let D=new mn;D.setAttribute("position",new Pn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let L=new Ri(D,g),O=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=CF;let N=this.type;this.render=function(pe,de,ge){if(O.enabled===!1||O.autoUpdate===!1&&O.needsUpdate===!1||pe.length===0)return;let le=e.getRenderTarget(),he=e.getActiveCubeFace(),be=e.getActiveMipmapLevel(),ae=e.state;ae.setBlending(h3),ae.buffers.color.setClear(1,1,1,1),ae.buffers.depth.setTest(!0),ae.setScissorTest(!1);let De=N!==yy&&this.type===yy,Re=N===yy&&this.type!==yy;for(let je=0,pt=pe.length;je<pt;je++){let ct=pe[je],At=ct.shadow;if(At===void 0){console.warn("THREE.WebGLShadowMap:",ct,"has no shadow.");continue}if(At.autoUpdate===!1&&At.needsUpdate===!1)continue;s.copy(At.mapSize);let Qe=At.getFrameExtents();if(s.multiply(Qe),l.copy(At.mapSize),(s.x>I||s.y>I)&&(s.x>I&&(l.x=Math.floor(I/Qe.x),s.x=l.x*Qe.x,At.mapSize.x=l.x),s.y>I&&(l.y=Math.floor(I/Qe.y),s.y=l.y*Qe.y,At.mapSize.y=l.y)),At.map===null||De===!0||Re===!0){let yt=this.type!==yy?{minFilter:jr,magFilter:jr}:{};At.map!==null&&At.map.dispose(),At.map=new Rc(s.x,s.y,yt),At.map.texture.name=ct.name+".shadowMap",At.camera.updateProjectionMatrix()}e.setRenderTarget(At.map),e.clear();let ut=At.getViewportCount();for(let yt=0;yt<ut;yt++){let mt=At.getViewport(yt);u.set(l.x*mt.x,l.y*mt.y,l.x*mt.z,l.y*mt.w),ae.viewport(u),At.updateMatrices(ct,yt),n=At.getFrustum(),$(de,ge,At.camera,ct,this.type)}At.isPointLightShadow!==!0&&this.type===yy&&Y(At,ge),At.needsUpdate=!1}N=this.type,O.needsUpdate=!1,e.setRenderTarget(le,he,be)};function Y(pe,de){let ge=t.update(L);g.defines.VSM_SAMPLES!==pe.blurSamples&&(g.defines.VSM_SAMPLES=pe.blurSamples,T.defines.VSM_SAMPLES=pe.blurSamples,g.needsUpdate=!0,T.needsUpdate=!0),pe.mapPass===null&&(pe.mapPass=new Rc(s.x,s.y)),g.uniforms.shadow_pass.value=pe.map.texture,g.uniforms.resolution.value=pe.mapSize,g.uniforms.radius.value=pe.radius,e.setRenderTarget(pe.mapPass),e.clear(),e.renderBufferDirect(de,null,ge,g,L,null),T.uniforms.shadow_pass.value=pe.mapPass.texture,T.uniforms.resolution.value=pe.mapSize,T.uniforms.radius.value=pe.radius,e.setRenderTarget(pe.map),e.clear(),e.renderBufferDirect(de,null,ge,T,L,null)}function V(pe,de,ge,le){let he=null,be=ge.isPointLight===!0?pe.customDistanceMaterial:pe.customDepthMaterial;if(be!==void 0)he=be;else if(he=ge.isPointLight===!0?h:d,e.localClippingEnabled&&de.clipShadows===!0&&Array.isArray(de.clippingPlanes)&&de.clippingPlanes.length!==0||de.displacementMap&&de.displacementScale!==0||de.alphaMap&&de.alphaTest>0||de.map&&de.alphaTest>0||de.alphaToCoverage===!0){let ae=he.uuid,De=de.uuid,Re=f[ae];Re===void 0&&(Re={},f[ae]=Re);let je=Re[De];je===void 0&&(je=he.clone(),Re[De]=je,de.addEventListener("dispose",re)),he=je}if(he.visible=de.visible,he.wireframe=de.wireframe,le===yy?he.side=de.shadowSide!==null?de.shadowSide:de.side:he.side=de.shadowSide!==null?de.shadowSide:y[de.side],he.alphaMap=de.alphaMap,he.alphaTest=de.alphaToCoverage===!0?.5:de.alphaTest,he.map=de.map,he.clipShadows=de.clipShadows,he.clippingPlanes=de.clippingPlanes,he.clipIntersection=de.clipIntersection,he.displacementMap=de.displacementMap,he.displacementScale=de.displacementScale,he.displacementBias=de.displacementBias,he.wireframeLinewidth=de.wireframeLinewidth,he.linewidth=de.linewidth,ge.isPointLight===!0&&he.isMeshDistanceMaterial===!0){let ae=e.properties.get(he);ae.light=ge}return he}function $(pe,de,ge,le,he){if(pe.visible===!1)return;if(pe.layers.test(de.layers)&&(pe.isMesh||pe.isLine||pe.isPoints)&&(pe.castShadow||pe.receiveShadow&&he===yy)&&(!pe.frustumCulled||n.intersectsObject(pe))){pe.modelViewMatrix.multiplyMatrices(ge.matrixWorldInverse,pe.matrixWorld);let De=t.update(pe),Re=pe.material
|
||
|
|
void main() {
|
||
|
|
|
||
|
|
gl_Position = vec4( position, 1.0 );
|
||
|
|
|
||
|
|
}`,jce=`
|
||
|
|
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;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}`,gj=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,i,n){if(this.texture===null){let s=new qr,l=t.properties.get(s);l.__webglTexture=i.texture,(i.depthNear!==n.depthNear||i.depthFar!==n.depthFar)&&(this.depthNear=i.depthNear,this.depthFar=i.depthFar),this.texture=s}}getMesh(t){if(this.texture!==null&&this.mesh===null){let i=t.cameras[0].viewport,n=new $r({vertexShader:Yce,fragmentShader:jce,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new Ri(new Mp(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},vj=class extends Pp{constructor(t,i){super();let n=this,s=null,l=1,u=null,d="local-floor",h=1,f=null,I=null,y=null,g=null,T=null,D=null,L=new gj,O=i.getContextAttributes(),N=null,Y=null,V=[],$=[],re=new ai,pe=null,de=new no;de.viewport=new Yn;let ge=new no;ge.viewport=new Yn;let le=[de,ge],he=new sx,be=null,ae=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Dt){let Rt=V[Dt];return Rt===void 0&&(Rt=new US,V[Dt]=Rt),Rt.getTargetRaySpace()},this.getControllerGrip=function(Dt){let Rt=V[Dt];return Rt===void 0&&(Rt=new US,V[Dt]=Rt),Rt.getGripSpace()},this.getHand=function(Dt){let Rt=V[Dt];return Rt===void 0&&(Rt=new US,V[Dt]=Rt),Rt.getHandSpace()};function De(Dt){let Rt=$.indexOf(Dt.inputSource);if(Rt===-1)return;let Kt=V[Rt];Kt!==void 0&&(Kt.update(Dt.inputSource,Dt.frame,f||u),Kt.dispatchEvent({type:Dt.type,data:Dt.inputSource}))}function Re(){s.removeEventListener("select",De),s.removeEventListener("selectstart",De),s.removeEventListener("selectend",De),s.removeEventListener("squeeze",De),s.removeEventListener("squeezestart",De),s.removeEventListener("squeezeend",De),s.removeEventListener("end",Re),s.removeEventListener("inputsourceschange",je);for(let Dt=0;Dt<V.length;Dt++){let Rt=$[Dt];Rt!==null&&($[Dt]=null,V[Dt].disconnect(Rt))}be=null,ae=null,L.reset(),t.setRenderTarget(N),T=null,g=null,y=null,s=null,Y=null,Pt.stop(),n.isPresenting=!1,t.setPixelRatio(pe),t.setSize(re.width,re.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Dt){l=Dt,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Dt){d=Dt,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return f||u},this.setReferenceSpace=function(Dt){f=Dt},this.getBaseLayer=function(){return g!==null?g:T},this.getBinding=function(){return y},this.getFrame=function(){return D},this.getSession=function(){return s},this.setSession=async function(Dt){if(s=Dt,s!==null){if(N=t.getRenderTarget(),s.addEventListener("select",De),s.addEventListener("selectstart",De),s.addEventListener("selectend",De),s.addEventListener("squeeze",De),s.addEventListener("squeezestart",De),s.addEventListener("squeezeend",De),s.addEventListener("end",Re),s.addEventListener("inputsourceschange",je),O.xrCompatible!==!0&&await i.makeXRCompatible(),pe=t.getPixelRatio(),t.getSize(re),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let Kt=null,Jt=null,Qt=null;O.depth&&(Qt=O.stencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24,Kt=O.stencil?XS:l2,Jt=O.stencil?JS:I3);let di={colorFormat:i.RGBA8,depthFormat:Qt,scaleFactor:l};y=new XRWebGLBinding(s,i),g=y.createProjectionLayer(di),s.updateRenderState({layers:[g]}),t.setPixelRatio(1),t.setSize(g.textureWidth,g.textureHeight,!1),Y=new Rc(g.textureWidth,g.textureHeight,{format:zd,type:zf,depthTexture:new qg(g.textureWidth,g.textureHeight,Jt,void 0,void 0,void 0,void 0,void 0,void 0,Kt),stencilBuffer:O.stencil,colorSpace:t.outputColorSpace,samples:O.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{let Kt={antialias:O.antialias,alpha:!0,depth:O.depth,stencil:O.stencil,framebufferScaleFactor:l};T=new XRWebGLLayer(s,i,Kt),s.updateRenderState({baseLayer:T}),t.setPixelRatio
|
||
|
|
`;ke&&(oi+=`var destructors = [];
|
||
|
|
`);var Ii=ke?"destructors":"null",ki=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];Q&&(oi+=`var thisWired = toClassParamWire(${Ii}, this);
|
||
|
|
`);for(var Ut=0;Ut<dt;++Ut){var Li=`toArg${Ut}Wire`;oi+=`var arg${Ut}Wired = ${Li}(${Ii}, arg${Ut});
|
||
|
|
`,ki.push(Li)}if(oi+=(Ee||Ce?"var rv = ":"")+`invoker(${gt});
|
||
|
|
`,ke)oi+=`runDestructors(destructors);
|
||
|
|
`;else for(var Ut=Q?1:2;Ut<H.length;++Ut){var gi=Ut===1?"thisWired":"arg"+(Ut-2)+"Wired";H[Ut].destructorFunction!==null&&(oi+=`${gi}_dtor(${gi});
|
||
|
|
`,ki.push(`${gi}_dtor`))}return Ee&&(oi+=`var ret = fromRetWire(rv);
|
||
|
|
return ret;
|
||
|
|
`),oi+=`}
|
||
|
|
`,new Function(ki,oi)}function Mi(H,Q,Ee,Ce,ke,dt){var It=Q.length;It<2&&ri("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var gt=Q[1]!==null&&Ee!==null,Ut=Yt(Q),oi=!Q[0].isVoid,Ii=Q[0],ki=Q[1],Li=[H,ri,Ce,ke,El,Ii.fromWireType.bind(Ii),ki?.toWireType.bind(ki)],gi=2;gi<It;++gi){var In=Q[gi];Li.push(In.toWireType.bind(In))}if(!Ut)for(var gi=gt?1:2;gi<Q.length;++gi)Q[gi].destructorFunction!==null&&Li.push(Q[gi].destructorFunction);var fs=Ci(Q,gt,oi,dt)(...Li);return tr(H,fs)}var sn=function(H,Q,Ee,Ce,ke,dt){H>>>=0,Ee>>>=0,Ce>>>=0,ke>>>=0,dt>>>=0;var It=Ct(Q,Ee);ke=eo(Ce,ke),Tl([],[H],gt=>{gt=gt[0];var Ut=`constructor ${gt.name}`;if(gt.registeredClass.constructor_body===void 0&&(gt.registeredClass.constructor_body=[]),gt.registeredClass.constructor_body[Q-1]!==void 0)throw new Vt(`Cannot register multiple constructors with identical number of parameters (${Q-1}) for class '${gt.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return gt.registeredClass.constructor_body[Q-1]=()=>{ms(`Cannot construct ${gt.name} due to unbound types`,It)},Tl([],It,oi=>(oi.splice(1,0,null),gt.registeredClass.constructor_body[Q-1]=Mi(Ut,oi,null,ke,dt),[])),[]})},on=H=>{H=H.trim();let Q=H.indexOf("(");return Q===-1?H:H.slice(0,Q)},Bn=function(H,Q,Ee,Ce,ke,dt,It,gt,Ut,oi){H>>>=0,Q>>>=0,Ce>>>=0,ke>>>=0,dt>>>=0,It>>>=0;var Ii=Ct(Ee,Ce);Q=qt(Q),Q=on(Q),dt=eo(ke,dt,Ut),Tl([],[H],ki=>{ki=ki[0];var Li=`${ki.name}.${Q}`;Q.startsWith("@@")&&(Q=Symbol[Q.substring(2)]),gt&&ki.registeredClass.pureVirtualFunctions.push(Q);function gi(){ms(`Cannot call ${Li} due to unbound types`,Ii)}var In=ki.registeredClass.instancePrototype,Ln=In[Q];return Ln===void 0||Ln.overloadTable===void 0&&Ln.className!==ki.name&&Ln.argCount===Ee-2?(gi.argCount=Ee-2,gi.className=ki.name,In[Q]=gi):(js(In,Q,Li),In[Q].overloadTable[Ee-2]=gi),Tl([],Ii,fs=>{var Ls=Mi(Li,fs,ki,dt,It,Ut);return In[Q].overloadTable===void 0?(Ls.argCount=Ee-2,In[Q]=Ls):In[Q].overloadTable[Ee-2]=Ls,[]}),[]})},ss=[],Un=[0,1,,1,null,1,!0,1,!1,1];function ws(H){H>>>=0,H>9&&--Un[H+1]===0&&(Un[H]=void 0,ss.push(H))}var On={toValue:H=>(H||ri(`Cannot use deleted val. handle = ${H}`),Un[H]),toHandle:H=>{switch(H){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let Q=ss.pop()||Un.length;return Un[Q]=H,Un[Q+1]=1,Q}}}},ir={name:"emscripten::val",fromWireType:H=>{var Q=On.toValue(H);return ws(H),Q},toWireType:(H,Q)=>On.toHandle(Q),readValueFromPointer:Gr,destructorFunction:null};function J0(H){return H>>>=0,Pi(H,ir)}var lc=(H,Q)=>{switch(Q){case 4:return function(Ee){return this.fromWireType((le(),yt)[Ee>>>2>>>0])};case 8:return function(Ee){return this.fromWireType((le(),mt)[Ee>>>3>>>0])};default:throw new TypeError(`invalid float width (${Q}): ${H}`)}},pf=function(H,Q,Ee){H>>>=0,Q>>>=0,Ee>>>=0,Q=qt(Q),Pi(H,{name:Q,fromWireType:Ce=>Ce,toWireType:(Ce,ke)=>ke,readValueFromPointer:lc(Q,Ee),destructorFunction:null})};function HI(H,Q,Ee,Ce,ke,dt,It,gt){H>>>=0,Ee>>>=0,Ce>>>=0,ke>>>=0,dt>>>=0;var Ut=Ct(Q,Ee);H=qt(H),H=on(H),ke=eo(Ce,ke,It),qs(H,function(){ms(`Cannot call ${H} due to unbound types`,Ut)},Q-1),Tl([],Ut,oi=>{var Ii=[oi[0],null].concat(oi.slice(1));return FI(H,Mi(H,Ii,null,ke,dt,It),Q-1),[]})}var op=function(H,Q,Ee,Ce,ke){H>>>=0,Q>>>=0,Ee>>>=0,Q=qt(Q);let dt=Ce===0,It=Ut=>Ut;if(dt){var gt=32-8*Ee;It=Ut=>Ut<<gt>>>gt,ke=It(ke)}Pi(H,{name:Q,fromWireType:It,toWireType:(Ut,oi)=>oi,readValueFromPointer:Yi(Q,Ee,Ce!==0),destructorFunction:null})};function lp(H,Q,Ee){H>>>=0,Ee>>>=0;var Ce=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],ke=Ce[Q];function dt(It){var gt=(le(),ut)[It>>>2>>>0],Ut=(le(),ut)[It+4>>>2>>>0];return new ke((le(),je).buffer,Ut,gt)}Ee=qt(Ee),Pi(H,{name:Ee,fromWireType:dt,readValueFromPointer:dt},{ignoreDuplicateRegistrations:!0})}var rp=Object.assign({optional:!0},ir);function GI(H,Q){H>>>=0,Q>>>=0,Pi(H,rp)}var If=(H,Q,Ee,Ce)=>{if(Ee>>>=0,!(Ce>0))return 0;for(var ke=Ee,dt=Ee+Ce-1,It=0;It<H.length;++It)
|
||
|
|
${Ii}
|
||
|
|
}`;var ki=new Function(Object.keys(Ut),Ii)(...Object.values(Ut)),Li=`methodCaller<(${dt.map(gi=>gi.name)}) => ${ke.name}>`;return GT(tr(Li,ki))};function zT(H){return H>>>=0,H?(H=WI(H),On.toHandle(globalThis[H])):On.toHandle(globalThis)}function WT(H,Q){return H>>>=0,Q>>>=0,H=On.toValue(H),Q=On.toValue(Q),On.toHandle(H[Q])}function YT(H){H>>>=0,H>9&&(Un[H+1]+=1)}function uE(H,Q){return H>>>=0,Q>>>=0,H=On.toValue(H),Q=On.toValue(Q),H instanceof Q}function jT(H,Q,Ee,Ce,ke){return H>>>=0,Q>>>=0,Ee>>>=0,Ce>>>=0,ke>>>=0,vm[H](Q,Ee,Ce,ke)}function qT(H){return H>>>=0,H=On.toValue(H),typeof H=="number"}function $T(H){return H>>>=0,H=On.toValue(H),typeof H=="string"}function ZT(){return On.toHandle([])}function KT(H){return H>>>=0,On.toHandle(WI(H))}function QT(){return On.toHandle({})}function JT(H){H>>>=0;var Q=On.toValue(H);El(Q),ws(H)}function XT(H,Q,Ee){H>>>=0,Q>>>=0,Ee>>>=0,H=On.toValue(H),Q=On.toValue(Q),Ee=On.toValue(Ee),H[Q]=Ee}function ew(H,Q){H=Rn(H),Q>>>=0;var Ee=new Date(H*1e3);(le(),Qe)[Q>>>2>>>0]=Ee.getUTCSeconds(),(le(),Qe)[Q+4>>>2>>>0]=Ee.getUTCMinutes(),(le(),Qe)[Q+8>>>2>>>0]=Ee.getUTCHours(),(le(),Qe)[Q+12>>>2>>>0]=Ee.getUTCDate(),(le(),Qe)[Q+16>>>2>>>0]=Ee.getUTCMonth(),(le(),Qe)[Q+20>>>2>>>0]=Ee.getUTCFullYear()-1900,(le(),Qe)[Q+24>>>2>>>0]=Ee.getUTCDay();var Ce=Date.UTC(Ee.getUTCFullYear(),0,1,0,0,0,0),ke=(Ee.getTime()-Ce)/(1e3*60*60*24)|0;(le(),Qe)[Q+28>>>2>>>0]=ke}var tw=H=>H%4===0&&(H%100!==0||H%400===0),Sm=[0,31,60,91,121,152,182,213,244,274,305,335],iw=[0,31,59,90,120,151,181,212,243,273,304,334],cp=H=>{var Q=tw(H.getFullYear()),Ee=Q?Sm:iw,Ce=Ee[H.getMonth()]+H.getDate()-1;return Ce};function nw(H,Q){H=Rn(H),Q>>>=0;var Ee=new Date(H*1e3);(le(),Qe)[Q>>>2>>>0]=Ee.getSeconds(),(le(),Qe)[Q+4>>>2>>>0]=Ee.getMinutes(),(le(),Qe)[Q+8>>>2>>>0]=Ee.getHours(),(le(),Qe)[Q+12>>>2>>>0]=Ee.getDate(),(le(),Qe)[Q+16>>>2>>>0]=Ee.getMonth(),(le(),Qe)[Q+20>>>2>>>0]=Ee.getFullYear()-1900,(le(),Qe)[Q+24>>>2>>>0]=Ee.getDay();var Ce=cp(Ee)|0;(le(),Qe)[Q+28>>>2>>>0]=Ce,(le(),Qe)[Q+36>>>2>>>0]=-(Ee.getTimezoneOffset()*60);var ke=new Date(Ee.getFullYear(),0,1),dt=new Date(Ee.getFullYear(),6,1).getTimezoneOffset(),It=ke.getTimezoneOffset(),gt=(dt!=It&&Ee.getTimezoneOffset()==Math.min(It,dt))|0;(le(),Qe)[Q+32>>>2>>>0]=gt}var hp={},as=()=>performance.timeOrigin+performance.now();function dE(H,Q){if(y)return Bi(2,0,1,H,Q);if(hp[H]&&(clearTimeout(hp[H].id),delete hp[H]),!Q)return 0;var Ee=setTimeout(()=>{delete hp[H],hc(()=>Fm(H,as()))},Q);return hp[H]={id:Ee,timeout_ms:Q},0}var Am=function(H,Q,Ee,Ce){H>>>=0,Q>>>=0,Ee>>>=0,Ce>>>=0;var ke=new Date().getFullYear(),dt=new Date(ke,0,1),It=new Date(ke,6,1),gt=dt.getTimezoneOffset(),Ut=It.getTimezoneOffset(),oi=Math.max(gt,Ut);(le(),ut)[H>>>2>>>0]=oi*60,(le(),Qe)[Q>>>2>>>0]=+(gt!=Ut);var Ii=gi=>{var In=gi>=0?"-":"+",Ln=Math.abs(gi),fs=String(Math.floor(Ln/60)).padStart(2,"0"),Ls=String(Ln%60).padStart(2,"0");return`UTC${In}${fs}${Ls}`},ki=Ii(gt),Li=Ii(Ut);Ut<gt?(Fa(ki,Ee,17),Fa(Li,Ce,17)):(Fa(ki,Ce,17),Fa(Li,Ee,17))},wf=()=>Date.now(),Dm=1,Nm=H=>H>=0&&H<=3;function sw(H,Q,Ee){if(Q=Rn(Q),Ee>>>=0,!Nm(H))return 28;var Ce;if(H===0)Ce=wf();else if(Dm)Ce=as();else return 52;var ke=Math.round(Ce*1e3*1e3);return(le(),Pt)[Ee>>>3>>>0]=BigInt(ke),0}var pc=()=>{},cE=()=>{pi+=1},An=()=>{throw cE(),"unwind"},ow=()=>4294901760,Cm=(H,Q)=>Math.ceil(H/Q)*Q,lw=H=>{var Q=rs.buffer.byteLength,Ee=(H-Q+65535)/65536|0;try{return rs.grow(Ee),Kt(),1}catch{}};function hE(H){H>>>=0;var Q=(le(),pt).length;if(H<=Q)return!1;var Ee=ow();if(H>Ee)return!1;for(var Ce=1;Ce<=4;Ce*=2){var ke=Q*(1+.2/Ce);ke=Math.min(ke,H+100663296);var dt=Math.min(Ee,Cm(Math.max(H,ke),65536)),It=lw(dt);if(It)return!0}return!1}var bm={},rw=()=>T||"./this.program",fp=()=>{if(!fp.strings){var H=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",Q={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:H,_:rw()};for(var Ee in bm)bm[Ee]===void 0?delete Q[Ee]:Q[Ee]=bm[Ee];var Ce=[];for(var Ee in Q)Ce.push(`${Ee}=${Q[Ee]}`);fp.strings=Ce}return fp.strings};function o0(H,Q){if(y)return Bi(3,0,1,H,Q);H>>>=0,Q>>>=0
|
||
|
|
`)),!H)return null;YI=Lm(H,!0)}return YI.shift()},l0={ttys:[],init(){},shutdown(){},register(H,Q){l0.ttys[H]={input:[],output:[],ops:Q},et.registerDevice(H,l0.stream_ops)},stream_ops:{open(H){var Q=l0.ttys[H.node.rdev];if(!Q)throw new et.ErrnoError(43);H.tty=Q,H.seekable=!1},close(H){H.tty.ops.fsync(H.tty)},fsync(H){H.tty.ops.fsync(H.tty)},read(H,Q,Ee,Ce,ke){if(!H.tty||!H.tty.ops.get_char)throw new et.ErrnoError(60);for(var dt=0,It=0;It<Ce;It++){var gt;try{gt=H.tty.ops.get_char(H.tty)}catch{throw new et.ErrnoError(29)}if(gt===void 0&&dt===0)throw new et.ErrnoError(6);if(gt==null)break;dt++,Q[Ee+It]=gt}return dt&&(H.node.atime=Date.now()),dt},write(H,Q,Ee,Ce,ke){if(!H.tty||!H.tty.ops.put_char)throw new et.ErrnoError(60);try{for(var dt=0;dt<Ce;dt++)H.tty.ops.put_char(H.tty,Q[Ee+dt])}catch{throw new et.ErrnoError(29)}return Ce&&(H.node.mtime=H.node.ctime=Date.now()),dt}},default_tty_ops:{get_char(H){return fE()},put_char(H,Q){Q===null||Q===10?(V(Pd(H.output)),H.output=[]):Q!=0&&H.output.push(Q)},fsync(H){H.output?.length>0&&(V(Pd(H.output)),H.output=[])},ioctl_tcgets(H){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(H,Q,Ee){return 0},ioctl_tiocgwinsz(H){return[24,80]}},default_tty1_ops:{put_char(H,Q){Q===null||Q===10?($(Pd(H.output)),H.output=[]):Q!=0&&H.output.push(Q)},fsync(H){H.output?.length>0&&($(Pd(H.output)),H.output=[])}}},Xe=H=>{ci()},hn={ops_table:null,mount(H){return hn.createNode(null,"/",16895,0)},createNode(H,Q,Ee,Ce){if(et.isBlkdev(Ee)||et.isFIFO(Ee))throw new et.ErrnoError(63);hn.ops_table||={dir:{node:{getattr:hn.node_ops.getattr,setattr:hn.node_ops.setattr,lookup:hn.node_ops.lookup,mknod:hn.node_ops.mknod,rename:hn.node_ops.rename,unlink:hn.node_ops.unlink,rmdir:hn.node_ops.rmdir,readdir:hn.node_ops.readdir,symlink:hn.node_ops.symlink},stream:{llseek:hn.stream_ops.llseek}},file:{node:{getattr:hn.node_ops.getattr,setattr:hn.node_ops.setattr},stream:{llseek:hn.stream_ops.llseek,read:hn.stream_ops.read,write:hn.stream_ops.write,mmap:hn.stream_ops.mmap,msync:hn.stream_ops.msync}},link:{node:{getattr:hn.node_ops.getattr,setattr:hn.node_ops.setattr,readlink:hn.node_ops.readlink},stream:{}},chrdev:{node:{getattr:hn.node_ops.getattr,setattr:hn.node_ops.setattr},stream:et.chrdev_stream_ops}};var ke=et.createNode(H,Q,Ee,Ce);return et.isDir(ke.mode)?(ke.node_ops=hn.ops_table.dir.node,ke.stream_ops=hn.ops_table.dir.stream,ke.contents={}):et.isFile(ke.mode)?(ke.node_ops=hn.ops_table.file.node,ke.stream_ops=hn.ops_table.file.stream,ke.usedBytes=0,ke.contents=null):et.isLink(ke.mode)?(ke.node_ops=hn.ops_table.link.node,ke.stream_ops=hn.ops_table.link.stream):et.isChrdev(ke.mode)&&(ke.node_ops=hn.ops_table.chrdev.node,ke.stream_ops=hn.ops_table.chrdev.stream),ke.atime=ke.mtime=ke.ctime=Date.now(),H&&(H.contents[Q]=ke,H.atime=H.mtime=H.ctime=ke.atime),ke},getFileDataAsTypedArray(H){return H.contents?H.contents.subarray?H.contents.subarray(0,H.usedBytes):new Uint8Array(H.contents):new Uint8Array(0)},expandFileStorage(H,Q){var Ee=H.contents?H.contents.length:0;if(!(Ee>=Q)){var Ce=1024*1024;Q=Math.max(Q,Ee*(Ee<Ce?2:1.125)>>>0),Ee!=0&&(Q=Math.max(Q,256));var ke=H.contents;H.contents=new Uint8Array(Q),H.usedBytes>0&&H.contents.set(ke.subarray(0,H.usedBytes),0)}},resizeFileStorage(H,Q){if(H.usedBytes!=Q)if(Q==0)H.contents=null,H.usedBytes=0;else{var Ee=H.contents;H.contents=new Uint8Array(Q),Ee&&H.contents.set(Ee.subarray(0,Math.min(Q,H.usedBytes))),H.usedBytes=Q}},node_ops:{getattr(H){var Q={};return Q.dev=et.isChrdev(H.mode)?H.id:1,Q.ino=H.id,Q.mode=H.mode,Q.nlink=1,Q.uid=0,Q.gid=0,Q.rdev=H.rdev,et.isDir(H.mode)?Q.size=4096:et.isFile(H.mode)?Q.size=H.usedBytes:et.isLink(H.mode)?Q.size=H.link.length:Q.size=0,Q.atime=new Date(H.atime),Q.mtime=new Date(H.mtime),Q.ctime=new Date(H.ctime),Q.blksize=4096,Q.blocks=Math.ceil(Q.size/Q.blksize),Q},setattr(H,Q){for(let Ee of["mode","atime","mtime","ctime"])Q[Ee]!=null&&(H[Ee]=Q[Ee]);Q.size!==void 0&&hn.resizeFileStorage(H,Q.size)},lookup(H,Q){throw hn.doesNotExistError||(hn.doesNot
|
||
|
|
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
||
|
|
Make sure to invoke .delete() manually once you're done with the instance instead.
|
||
|
|
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(Nt,Yi),Ke.leakWarning=Nt.stack.replace(/^Error: /,""),Ld.register(te,Ke,te)}return te},Tl=te=>Ld.unregister(te),en(k)):(en=te=>te,k),cn=[],tn=()=>{for(;cn.length;){var k=cn.pop();k.$$.deleteScheduled=!1,k.delete()}},Sn,Gn=()=>{let k=ns.prototype;Object.assign(k,{isAliasOf(ve){if(!(this instanceof ns)||!(ve instanceof ns))return!1;var Ue=this.$$.ptrType.registeredClass,Ke=this.$$.ptr;ve.$$=ve.$$;for(var Et=ve.$$.ptrType.registeredClass,Nt=ve.$$.ptr;Ue.baseClass;)Ke=Ue.upcast(Ke),Ue=Ue.baseClass;for(;Et.baseClass;)Nt=Et.upcast(Nt),Et=Et.baseClass;return Ue===Et&&Ke===Nt},clone(){if(this.$$.ptr||Od(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var ve=en(Object.create(Object.getPrototypeOf(this),{$$:{value:e0(this.$$)}}));return ve.$$.count.value+=1,ve.$$.deleteScheduled=!1,ve},delete(){this.$$.ptr||Od(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Rn("Object already scheduled for deletion"),Tl(this),Gt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Od(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Rn("Object already scheduled for deletion"),cn.push(this),cn.length===1&&Sn&&Sn(tn),this.$$.deleteScheduled=!0,this}});let te=Symbol.dispose;te&&(k[te]=k.delete)};function ns(){}var cs=(k,te)=>Object.defineProperty(te,"name",{value:k}),bn=(k,te,ve)=>{if(k[te].overloadTable===void 0){var Ue=k[te];k[te]=function(...Ke){return k[te].overloadTable.hasOwnProperty(Ke.length)||Rn(`Function '${ve}' called with an invalid number of arguments (${Ke.length}) - expects one of (${k[te].overloadTable})!`),k[te].overloadTable[Ke.length].apply(this,Ke)},k[te].overloadTable=[],k[te].overloadTable[Ue.argCount]=Ue}},Ji=(k,te,ve)=>{u.hasOwnProperty(k)?((ve===void 0||u[k].overloadTable!==void 0&&u[k].overloadTable[ve]!==void 0)&&Rn(`Cannot register public name '${k}' twice`),bn(u,k,k),u[k].overloadTable.hasOwnProperty(ve)&&Rn(`Cannot register multiple overloads of a function with the same number of arguments (${ve})!`),u[k].overloadTable[ve]=te):(u[k]=te,u[k].argCount=ve)},bs=48,zn=57,Xs=k=>{de(typeof k=="string"),k=k.replace(/[^a-zA-Z0-9_]/g,"$");var te=k.charCodeAt(0);return te>=bs&&te<=zn?`_${k}`:k};function _d(k,te,ve,Ue,Ke,Et,Nt,Ot){this.name=k,this.constructor=te,this.instancePrototype=ve,this.rawDestructor=Ue,this.baseClass=Ke,this.getActualType=Et,this.upcast=Nt,this.downcast=Ot,this.pureVirtualFunctions=[]}var Os=(k,te,ve)=>{for(;te!==ve;)te.upcast||Rn(`Expected null or instance of ${ve.name}, got an instance of ${te.name}`),k=te.upcast(k),te=te.baseClass;return k};function tr(k,te){if(te===null)return this.isReference&&Rn(`null is not a valid ${this.name}`),0;te.$$||Rn(`Cannot pass "${El(te)}" as a ${this.name}`),te.$$.ptr||Rn(`Cannot pass deleted object as a pointer of type ${this.name}`);var ve=te.$$.ptrType.registeredClass,Ue=Os(te.$$.ptr,ve,this.registeredClass);return Ue}function Xn(k,te){var ve;if(te===null)return this.isReference&&Rn(`null is not a valid ${this.name}`),this.isSmartPointer?(ve=this.rawConstructor(),k!==null&&k.push(this.rawDestructor,ve),ve):0;(!te||!te.$$)&&Rn(`Cannot pass "${El(te)}" as a ${this.name}`),te.$$.ptr||Rn(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&te.$$.ptrType.isConst&&Rn(`Cannot convert argument of type ${te.$$.smartPtrType?te.$$.smartPtrType.name:te.$$.ptrType.name} to parameter type ${this.name}`);var Ue=te.$$.ptrType.registeredClass;if(ve=Os(te.$$.ptr,Ue,this.registeredClass),this.isSmartPointer)switch(te.$$.smartPtr===void 0&&Rn("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:te.$$.smartPtrType===this?ve=te.$$.smartPtr:Rn(`Cannot convert argument of type ${te.$$.smartPtrType?te.$$.smartPtrType.name:te.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:ve=te.$$.smartPtr;break;case 2:if(te.$$.smartPtrType===this)ve=te.$$.smartPtr;else{var Ke=te.clone();ve=this.rawShare(ve,ms.toHandl
|
||
|
|
`;H+=`checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);
|
||
|
|
`,Ke&&(H+=`var destructors = [];
|
||
|
|
`);var Q=Ke?"destructors":"null",Ee=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];te&&(H+=`var thisWired = toClassParamWire(${Q}, this);
|
||
|
|
`);for(var Ht=0;Ht<Et;++Ht){var Ce=`toArg${Ht}Wire`;H+=`var arg${Ht}Wired = ${Ce}(${Q}, arg${Ht});
|
||
|
|
`,Ee.push(Ce)}if(H+=(ve||Ue?"var rv = ":"")+`invoker(${Ot});
|
||
|
|
`,Ke)H+=`runDestructors(destructors);
|
||
|
|
`;else for(var Ht=te?1:2;Ht<k.length;++Ht){var ke=Ht===1?"thisWired":"arg"+(Ht-2)+"Wired";k[Ht].destructorFunction!==null&&(H+=`${ke}_dtor(${ke});
|
||
|
|
`,Ee.push(`${ke}_dtor`))}return ve&&(H+=`var ret = fromRetWire(rv);
|
||
|
|
return ret;
|
||
|
|
`),H+=`}
|
||
|
|
`,Ee.push("checkArgCount","minArgs","maxArgs"),H=`if (arguments.length !== ${Ee.length}){ throw new Error(humanName + "Expected ${Ee.length} closure arguments " + arguments.length + " given."); }
|
||
|
|
${H}`,new Function(Ee,H)}function Tm(k){for(var te=k.length-2,ve=k.length-1;ve>=2&&k[ve].optional;--ve)te--;return te}function i0(k,te,ve,Ue,Ke,Et){var Nt=te.length;Nt<2&&Rn("argTypes array size mismatch! Must at least get return value and 'this' types!"),de(!Et,"Async bindings are only supported with JSPI.");for(var Ot=te[1]!==null&&ve!==null,Ht=UI(te),H=!te[0].isVoid,Q=Nt-2,Ee=Tm(te),Ce=te[0],ke=te[1],dt=[k,Rn,Ue,Ke,Ei,Ce.fromWireType.bind(Ce),ke?.toWireType.bind(ke)],It=2;It<Nt;++It){var gt=te[It];dt.push(gt.toWireType.bind(gt))}if(!Ht)for(var It=Ot?1:2;It<te.length;++It)te[It].destructorFunction!==null&&dt.push(te[It].destructorFunction);dt.push(Z0,Ee,Q);var oi=Em(te,Ot,H,Et)(...dt);return cs(k,oi)}var FI=function(k,te,ve,Ue,Ke,Et){k>>>=0,ve>>>=0,Ue>>>=0,Ke>>>=0,Et>>>=0,de(te>0);var Nt=$0(te,ve);Ke=uo(Ue,Ke),rs([],[k],Ot=>{Ot=Ot[0];var Ht=`constructor ${Ot.name}`;if(Ot.registeredClass.constructor_body===void 0&&(Ot.registeredClass.constructor_body=[]),Ot.registeredClass.constructor_body[te-1]!==void 0)throw new Ba(`Cannot register multiple constructors with identical number of parameters (${te-1}) for class '${Ot.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return Ot.registeredClass.constructor_body[te-1]=()=>{t0(`Cannot construct ${Ot.name} due to unbound types`,Nt)},rs([],Nt,H=>(H.splice(1,0,null),Ot.registeredClass.constructor_body[te-1]=i0(Ht,H,null,Ke,Et),[])),[]})},K0=k=>{k=k.trim();let te=k.indexOf("(");return te===-1?k:(de(k.endsWith(")"),"Parentheses for argument names should match."),k.slice(0,te))},wm=function(k,te,ve,Ue,Ke,Et,Nt,Ot,Ht,H){k>>>=0,te>>>=0,Ue>>>=0,Ke>>>=0,Et>>>=0,Nt>>>=0;var Q=$0(ve,Ue);te=Is(te),te=K0(te),Et=uo(Ke,Et,Ht),rs([],[k],Ee=>{Ee=Ee[0];var Ce=`${Ee.name}.${te}`;te.startsWith("@@")&&(te=Symbol[te.substring(2)]),Ot&&Ee.registeredClass.pureVirtualFunctions.push(te);function ke(){t0(`Cannot call ${Ce} due to unbound types`,Q)}var dt=Ee.registeredClass.instancePrototype,It=dt[te];return It===void 0||It.overloadTable===void 0&&It.className!==Ee.name&&It.argCount===ve-2?(ke.argCount=ve-2,ke.className=Ee.name,dt[te]=ke):(bn(dt,te,Ce),dt[te].overloadTable[ve-2]=ke),rs([],Q,gt=>{var Ut=i0(Ce,gt,Ee,Et,Nt,Ht);return dt[te].overloadTable===void 0?(Ut.argCount=ve-2,dt[te]=Ut):dt[te].overloadTable[ve-2]=Ut,[]}),[]})},eo=[],Ua=[0,1,,1,null,1,!0,1,!1,1];function Q0(k){k>>>=0,k>9&&--Ua[k+1]===0&&(de(Ua[k]!==void 0,"Decref for unallocated handle."),Ua[k]=void 0,eo.push(k))}var ms={toValue:k=>(k||Rn(`Cannot use deleted val. handle = ${k}`),de(k===2||Ua[k]!==void 0&&k%2===0,`invalid handle: ${k}`),Ua[k]),toHandle:k=>{switch(k){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let te=eo.pop()||Ua.length;return Ua[te]=k,Ua[te+1]=1,te}}}},sp={name:"emscripten::val",fromWireType:k=>{var te=ms.toValue(k);return Q0(k),te},toWireType:(k,te)=>ms.toHandle(te),readValueFromPointer:hi,destructorFunction:null};function Ct(k){return k>>>=0,ao(k,sp)}var Yt=(k,te)=>{switch(te){case 4:return function(ve){return this.fromWireType(Kt[ve>>>2>>>0])};case 8:return function(ve){return this.fromWireType(Jt[ve>>>3>>>0])};default:throw new TypeError(`invalid float width (${te}): ${k}`)}},Ci=function(k,te,ve){k>>>=0,te>>>=0,ve>>>=0,te=Is(te),ao(k,{name:te,fromWireType:Ue=>Ue,toWireType:(Ue,Ke)=>{if(typeof Ke!="number"&&typeof Ke!="boolean")throw new TypeError(`Cannot convert ${El(Ke)} to ${this.name}`);return Ke},readValueFromPointer:Yt(te,ve),destructorFunction:null})};function Mi(k,te,ve,Ue,Ke,Et,Nt,Ot){k>>>=0,ve>>>=0,Ue>>>=0,Ke>>>=0,Et>>>=0;var Ht=$0(te,ve);k=Is(k),k=K0(k),Ke=uo(Ue,Ke,Nt),Ji(k,function(){t0(`Cannot call ${k} due to unbound types`,Ht)},te-1),rs([],Ht,H=>{var Q=[H[0],null].concat(H.slice(1));return Zs(k,i0(k,Q,null,Ke,Et,Nt),te-1),[]})}var sn=function(k,te,ve,Ue,Ke){k>>>=0,te>>>=0,ve>>>=0,te=Is(te);let Et=Ue===0,Nt=Ht=>Ht;if(Et){var Ot=32-8*ve;Nt=Ht=>Ht<<Ot>>>Ot,Ke=Nt(Ke)}ao(k,{name:te,fromWireType:Nt,toWireType:(Ht,H)=>{if(typeof H!="number"&&typeof H!="boolean")throw new TypeError(`Cannot convert "${El(H)}" to ${te}`
|
||
|
|
${Q}
|
||
|
|
}`;var Ee=new Function(Object.keys(Ht),Q)(...Object.values(Ht)),Ce=`methodCaller<(${Et.map(ke=>ke.name)}) => ${Ke.name}>`;return VI(cs(Ce,Ee))};function cc(k){return k>>>=0,k?(k=Ai(k),ms.toHandle(globalThis[k])):ms.toHandle(globalThis)}function yf(k,te){return k>>>=0,te>>>=0,k=ms.toValue(k),te=ms.toValue(te),ms.toHandle(k[te])}function up(k){k>>>=0,k>9&&(Ua[k+1]+=1)}function Ef(k,te){return k>>>=0,te>>>=0,k=ms.toValue(k),te=ms.toValue(te),k instanceof te}function dp(k,te,ve,Ue,Ke){return k>>>=0,te>>>=0,ve>>>=0,Ue>>>=0,Ke>>>=0,uc[k](te,ve,Ue,Ke)}function hc(k){return k>>>=0,k=ms.toValue(k),typeof k=="number"}function th(k){return k>>>=0,k=ms.toValue(k),typeof k=="string"}function fc(){return ms.toHandle([])}function xd(k){return k>>>=0,ms.toHandle(Ai(k))}function ih(){return ms.toHandle({})}function nh(k){k>>>=0;var te=ms.toValue(k);Ei(te),Q0(k)}function BT(k,te,ve){k>>>=0,te>>>=0,ve>>>=0,k=ms.toValue(k),te=ms.toValue(te),ve=ms.toValue(ve),k[te]=ve}function UT(k,te){k=Ft(k),te>>>=0;var ve=new Date(k*1e3);Dt[te>>>2>>>0]=ve.getUTCSeconds(),Dt[te+4>>>2>>>0]=ve.getUTCMinutes(),Dt[te+8>>>2>>>0]=ve.getUTCHours(),Dt[te+12>>>2>>>0]=ve.getUTCDate(),Dt[te+16>>>2>>>0]=ve.getUTCMonth(),Dt[te+20>>>2>>>0]=ve.getUTCFullYear()-1900,Dt[te+24>>>2>>>0]=ve.getUTCDay();var Ue=Date.UTC(ve.getUTCFullYear(),0,1,0,0,0,0),Ke=(ve.getTime()-Ue)/(1e3*60*60*24)|0;Dt[te+28>>>2>>>0]=Ke}var FT=k=>k%4===0&&(k%100!==0||k%400===0),HT=[0,31,60,91,121,152,182,213,244,274,305,335],vm=[0,31,59,90,120,151,181,212,243,273,304,334],GT=k=>{var te=FT(k.getFullYear()),ve=te?HT:vm,Ue=ve[k.getMonth()]+k.getDate()-1;return Ue};function VT(k,te){k=Ft(k),te>>>=0;var ve=new Date(k*1e3);Dt[te>>>2>>>0]=ve.getSeconds(),Dt[te+4>>>2>>>0]=ve.getMinutes(),Dt[te+8>>>2>>>0]=ve.getHours(),Dt[te+12>>>2>>>0]=ve.getDate(),Dt[te+16>>>2>>>0]=ve.getMonth(),Dt[te+20>>>2>>>0]=ve.getFullYear()-1900,Dt[te+24>>>2>>>0]=ve.getDay();var Ue=GT(ve)|0;Dt[te+28>>>2>>>0]=Ue,Dt[te+36>>>2>>>0]=-(ve.getTimezoneOffset()*60);var Ke=new Date(ve.getFullYear(),0,1),Et=new Date(ve.getFullYear(),6,1).getTimezoneOffset(),Nt=Ke.getTimezoneOffset(),Ot=(Et!=Nt&&ve.getTimezoneOffset()==Math.min(Nt,Et))|0;Dt[te+32>>>2>>>0]=Ot}var Tf={},aE=k=>{if(k instanceof wt||k=="unwind")return pe;he(),k instanceof WebAssembly.RuntimeError&&ZI()<=0&&V("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 5242880)"),T(1,k)},Rm=()=>pi||ac>0,WI=k=>{pe=k,Rm()||(u.onExit?.(k),re=!0),T(k,new wt(k))},kT=(k,te)=>{if(pe=k,wE(),Rm()&&!te){var ve=`program exited (with status: ${k}), but keepRuntimeAlive() is set (counter=${ac}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;Qe?.(ve),V(ve)}WI(k)},zT=kT,WT=()=>{if(!Rm())try{zT(pe)}catch(k){aE(k)}},YT=k=>{if(re){V("user callback triggered after runtime exited or application aborted. Ignoring.");return}try{k(),WT()}catch(te){aE(te)}},uE=()=>performance.now(),jT=(k,te)=>{if(Tf[k]&&(clearTimeout(Tf[k].id),delete Tf[k]),!te)return 0;var ve=setTimeout(()=>{de(k in Tf),delete Tf[k],YT(()=>pp(k,uE()))},te);return Tf[k]={id:ve,timeout_ms:te},0},qT=function(k,te,ve,Ue){k>>>=0,te>>>=0,ve>>>=0,Ue>>>=0;var Ke=new Date().getFullYear(),Et=new Date(Ke,0,1),Nt=new Date(Ke,6,1),Ot=Et.getTimezoneOffset(),Ht=Nt.getTimezoneOffset(),H=Math.max(Ot,Ht);Rt[k>>>2>>>0]=H*60,Dt[te>>>2>>>0]=+(Ot!=Ht);var Q=ke=>{var dt=ke>=0?"-":"+",It=Math.abs(ke),gt=String(Math.floor(It/60)).padStart(2,"0"),Ut=String(It%60).padStart(2,"0");return`UTC${dt}${gt}${Ut}`},Ee=Q(Ot),Ce=Q(Ht);de(Ee),de(Ce),de(On(Ee)<=16,`timezone name truncated to fit in TZNAME_MAX (${Ee})`),de(On(Ce)<=16,`timezone name truncated to fit in TZNAME_MAX (${Ce})`),Ht<Ot?(ws(Ee,ve,17),ws(Ce,Ue,17)):(ws(Ee,Ue,17),ws(Ce,ve,17))},$T=()=>Date.now(),ZT=1,KT=k=>k>=0&&k<=3;function QT(k,te,ve){if(te=Ft(te),ve>>>=0,!KT(k))return 28;var Ue;if(k===0)Ue=$T();else if(ZT)Ue=uE();else return 52;var Ke=Math.round(Ue*1e3*1e3);return Qt[ve>>>3>>>0]=BigInt(Ke),0}var JT=()=>4294901760,XT=(k,te)=>(de(te,"alignment ar
|
||
|
|
`)),!k)return null;Dm=Nm(k,!0)}return Dm.shift()},pc={ttys:[],init(){},shutdown(){},register(k,te){pc.ttys[k]={input:[],output:[],ops:te},Xe.registerDevice(k,pc.stream_ops)},stream_ops:{open(k){var te=pc.ttys[k.node.rdev];if(!te)throw new Xe.ErrnoError(43);k.tty=te,k.seekable=!1},close(k){k.tty.ops.fsync(k.tty)},fsync(k){k.tty.ops.fsync(k.tty)},read(k,te,ve,Ue,Ke){if(!k.tty||!k.tty.ops.get_char)throw new Xe.ErrnoError(60);for(var Et=0,Nt=0;Nt<Ue;Nt++){var Ot;try{Ot=k.tty.ops.get_char(k.tty)}catch{throw new Xe.ErrnoError(29)}if(Ot===void 0&&Et===0)throw new Xe.ErrnoError(6);if(Ot==null)break;Et++,te[ve+Nt]=Ot}return Et&&(k.node.atime=Date.now()),Et},write(k,te,ve,Ue,Ke){if(!k.tty||!k.tty.ops.put_char)throw new Xe.ErrnoError(60);try{for(var Et=0;Et<Ue;Et++)k.tty.ops.put_char(k.tty,te[ve+Et])}catch{throw new Xe.ErrnoError(29)}return Ue&&(k.node.mtime=k.node.ctime=Date.now()),Et}},default_tty_ops:{get_char(k){return sw()},put_char(k,te){te===null||te===10?(Y(lc(k.output)),k.output=[]):te!=0&&k.output.push(te)},fsync(k){k.output?.length>0&&(Y(lc(k.output)),k.output=[])},ioctl_tcgets(k){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(k,te,ve){return 0},ioctl_tiocgwinsz(k){return[24,80]}},default_tty1_ops:{put_char(k,te){te===null||te===10?(V(lc(k.output)),k.output=[]):te!=0&&k.output.push(te)},fsync(k){k.output?.length>0&&(V(lc(k.output)),k.output=[])}}},cE=k=>{He("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},An={ops_table:null,mount(k){return An.createNode(null,"/",16895,0)},createNode(k,te,ve,Ue){if(Xe.isBlkdev(ve)||Xe.isFIFO(ve))throw new Xe.ErrnoError(63);An.ops_table||={dir:{node:{getattr:An.node_ops.getattr,setattr:An.node_ops.setattr,lookup:An.node_ops.lookup,mknod:An.node_ops.mknod,rename:An.node_ops.rename,unlink:An.node_ops.unlink,rmdir:An.node_ops.rmdir,readdir:An.node_ops.readdir,symlink:An.node_ops.symlink},stream:{llseek:An.stream_ops.llseek}},file:{node:{getattr:An.node_ops.getattr,setattr:An.node_ops.setattr},stream:{llseek:An.stream_ops.llseek,read:An.stream_ops.read,write:An.stream_ops.write,mmap:An.stream_ops.mmap,msync:An.stream_ops.msync}},link:{node:{getattr:An.node_ops.getattr,setattr:An.node_ops.setattr,readlink:An.node_ops.readlink},stream:{}},chrdev:{node:{getattr:An.node_ops.getattr,setattr:An.node_ops.setattr},stream:Xe.chrdev_stream_ops}};var Ke=Xe.createNode(k,te,ve,Ue);return Xe.isDir(Ke.mode)?(Ke.node_ops=An.ops_table.dir.node,Ke.stream_ops=An.ops_table.dir.stream,Ke.contents={}):Xe.isFile(Ke.mode)?(Ke.node_ops=An.ops_table.file.node,Ke.stream_ops=An.ops_table.file.stream,Ke.usedBytes=0,Ke.contents=null):Xe.isLink(Ke.mode)?(Ke.node_ops=An.ops_table.link.node,Ke.stream_ops=An.ops_table.link.stream):Xe.isChrdev(Ke.mode)&&(Ke.node_ops=An.ops_table.chrdev.node,Ke.stream_ops=An.ops_table.chrdev.stream),Ke.atime=Ke.mtime=Ke.ctime=Date.now(),k&&(k.contents[te]=Ke,k.atime=k.mtime=k.ctime=Ke.atime),Ke},getFileDataAsTypedArray(k){return k.contents?k.contents.subarray?k.contents.subarray(0,k.usedBytes):new Uint8Array(k.contents):new Uint8Array(0)},expandFileStorage(k,te){var ve=k.contents?k.contents.length:0;if(!(ve>=te)){var Ue=1024*1024;te=Math.max(te,ve*(ve<Ue?2:1.125)>>>0),ve!=0&&(te=Math.max(te,256));var Ke=k.contents;k.contents=new Uint8Array(te),k.usedBytes>0&&k.contents.set(Ke.subarray(0,k.usedBytes),0)}},resizeFileStorage(k,te){if(k.usedBytes!=te)if(te==0)k.contents=null,k.usedBytes=0;else{var ve=k.contents;k.contents=new Uint8Array(te),ve&&k.contents.set(ve.subarray(0,Math.min(te,k.usedBytes))),k.usedBytes=te}},node_ops:{getattr(k){var te={};return te.dev=Xe.isChrdev(k.mode)?k.id:1,te.ino=k.id,te.mode=k.mode,te.nlink=1,te.uid=0,te.gid=0,te.rdev=k.rdev,Xe.isDir(k.mode)?te.size=4096:Xe.isFile(k.mode)?te.size=k.usedBytes:Xe.isLink(k.mode)?te.size=k.link.length:te.size=0,te.atime=new Date(k.atime),te.mtime=new Date(k.mtime),te.ctime=new Date(k.ctime),te.blksize=4096,te.blocks=Math.ceil(te.size/te.blksize),te},setattr(k,te){for(let ve of["mode",
|
||
|
|
#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>
|
||
|
|
|
||
|
|
}
|
||
|
|
`};var E5=class extends $r{constructor(t){super({type:"LineMaterial",uniforms:nv.clone(S0.line.uniforms),vertexShader:S0.line.vertexShader,fragmentShader:S0.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){t===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){t===!0!==this.dashed&&(this.needsUpdate=!0),t===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(t===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),t===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}},Gq=new Yn,Hee=new Ne,Gee=new Ne,Wc=new Yn,Yc=new Yn,mT=new Yn,Vq=new Ne,kq=new vi,jc=new ks,Vee=new Ne,wG=new un,gG=new Rs,yT=new Yn,ET,w6;function kee(e,t,i){return yT.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),yT.multiplyScalar(1/yT.w),yT.x=w6/i.width,yT.y=w6/i.height,yT.applyMatrix4(e.projectionMatrixInverse),yT.multiplyScalar(1/yT.w),Math.abs(Math.max(yT.x,yT.y))}var d$=class extends Ri{constructor(t=new KG,i=new E5({color:16777215*Math.random()})){super(t,i),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){let t=this.geometry,i=t.attributes.instanceStart,n=t.attributes.instanceEnd,s=new Float32Array(2*i.count);for(let u=0,d=0,h=i.count;u<h;u++,d+=2)Hee.fromBufferAttribute(i,u),Gee.fromBufferAttribute(n,u),s[d]=d===0?0:s[d-1],s[d+1]=s[d]+Hee.distanceTo(Gee);let l=new c3(s,2,1);return t.setAttribute("instanceDistanceStart",new Yd(l,1,0)),t.setAttribute("instanceDistanceEnd",new Yd(l,1,1)),this}raycast(t,i){let n=this.material.worldUnits,s=t.camera;s!==null||n||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');let l=t.params.Line2!==void 0&&t.params.Line2.threshold||0;ET=t.ray;let u=this.matrixWorld,d=this.geometry,h=this.material,f,I;w6=h.linewidth+l,d.boundingSphere===null&&d.computeBoundingSphere(),gG.copy(d.boundingSphere).applyMatrix4(u),n?f=.5*w6:f=kee(s,Math.max(s.near,gG.distanceToPoint(ET.origin)),h.resolution),gG.radius+=f,ET.intersectsSphere(gG)!==!1&&(d.boundingBox===null&&d.computeBoundingBox(),wG.copy(d.boundingBox).applyMatrix4(u),n?I=.5*w6:I=kee(s,Math.max(s.near,wG.distanceToPoint(ET.origin)),h.resolution),wG.expandByScalar(I),ET.intersectsBox(wG)!==!1&&(n?(function(y,g){let T=y.matrixWorld,D=y.geometry,L=D.attributes.instanceStart,O=D.attributes.instanceEnd;for(let N=0,Y=Math.min(D.instanceCount,L.count);N<Y;N++){jc.start.fromBufferAttribute(L,N),jc.end.fromBufferAttribute(O,N),jc.applyMatrix4(T);let V=new Ne,$=new Ne;ET.distanceSqToSegment(jc.start,jc.end,$,V),$.distanceTo(V)<.5*w6&&g.push({point:$,pointOnLine:V,distance:ET.origin.distanceTo($),object:y,face:null,faceIndex:N,uv:null,uv1:null})}})(this,i):(function(y,g,T){let D=g.projectionMatrix,L=y.material.resolution,O=y.matrixWorld,N=y.geometry,Y=N.attributes.instanceStart,V=N.attributes.instanceEnd,$=Math.min(N.instanceCount,Y.count),re=-g.near;ET.at(1,mT),mT.w=1,mT.applyMatrix4(g.matrixWorldInverse),mT.applyMatrix4(D),mT.multiplySca
|
||
|
|
#include <common>
|
||
|
|
#include <clipping_planes_pars_vertex>
|
||
|
|
|
||
|
|
attribute float itemFilter;
|
||
|
|
uniform vec2 lodSize;
|
||
|
|
attribute vec3 itemFirst;
|
||
|
|
attribute vec3 itemLast;
|
||
|
|
|
||
|
|
float lodWidth = 2.0;
|
||
|
|
|
||
|
|
void cutLodLine(const in vec4 first, inout vec4 second ) {
|
||
|
|
float projValue1 = projectionMatrix[2][2];
|
||
|
|
float projValue2 = projectionMatrix[3][2];
|
||
|
|
float approxResult = -(projValue2 / projValue1) / 2.0;
|
||
|
|
float diff1 = approxResult - first.z;
|
||
|
|
float diff2 = second.z - first.z;
|
||
|
|
float cutFilter = diff1 / diff2;
|
||
|
|
second.xyz = mix(first.xyz, second.xyz, cutFilter);
|
||
|
|
}
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
if (itemFilter == 0.0) {
|
||
|
|
gl_Position = vec4(0,0,0,0);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
vec4 rawFirst = vec4(itemFirst, 1.0);
|
||
|
|
vec4 rawLast = vec4(itemLast, 1.0);
|
||
|
|
vec4 first = modelViewMatrix * rawFirst;
|
||
|
|
vec4 last = modelViewMatrix * rawLast;
|
||
|
|
|
||
|
|
bool lodPerspective = projectionMatrix[2][3] == -1.0;
|
||
|
|
if (lodPerspective) {
|
||
|
|
bool firstCut = first.z < 0.0 && last.z >= 0.0;
|
||
|
|
bool lastCut = last.z < 0.0 && first.z >= 0.0;
|
||
|
|
if (firstCut) {
|
||
|
|
cutLodLine( first, last );
|
||
|
|
} else if (lastCut) {
|
||
|
|
cutLodLine( last, first );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
vec4 firstCut = projectionMatrix * first;
|
||
|
|
vec4 lastCut = projectionMatrix * last;
|
||
|
|
vec3 firstNdc = firstCut.xyz / firstCut.w;
|
||
|
|
vec3 lastNdc = lastCut.xyz / lastCut.w;
|
||
|
|
|
||
|
|
vec2 lodOrientation = lastNdc.xy - firstNdc.xy;
|
||
|
|
|
||
|
|
float lodRatio = lodSize.x / lodSize.y;
|
||
|
|
lodOrientation.x *= lodRatio;
|
||
|
|
lodOrientation = normalize(lodOrientation);
|
||
|
|
|
||
|
|
vec2 lodDistance = vec2(lodOrientation.y, - lodOrientation.x);
|
||
|
|
lodOrientation.x /= lodRatio;
|
||
|
|
lodDistance.x /= lodRatio;
|
||
|
|
|
||
|
|
if (position.x < 0.0) {
|
||
|
|
lodDistance *= - 1.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (position.y < 0.0) {
|
||
|
|
lodDistance += -lodOrientation;
|
||
|
|
} else if (position.y > 1.0) {
|
||
|
|
lodDistance += lodOrientation;
|
||
|
|
}
|
||
|
|
|
||
|
|
lodDistance *= lodWidth;
|
||
|
|
lodDistance /= lodSize.y;
|
||
|
|
|
||
|
|
bool isFirst = position.y < 0.5;
|
||
|
|
vec4 lodPosition = isFirst ? firstCut : lastCut;
|
||
|
|
lodDistance *= lodPosition.w;
|
||
|
|
lodPosition.xy += lodDistance;
|
||
|
|
gl_Position = lodPosition;
|
||
|
|
|
||
|
|
vec4 mvPosition = isFirst ? first : last;
|
||
|
|
#include <clipping_planes_vertex>
|
||
|
|
}
|
||
|
|
`),Se(Qb,"fragment",`
|
||
|
|
#include <common>
|
||
|
|
#include <clipping_planes_pars_fragment>
|
||
|
|
|
||
|
|
uniform vec3 lodColor;
|
||
|
|
uniform float lodOpacity;
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
#include <clipping_planes_fragment>
|
||
|
|
gl_FragColor = vec4(lodColor, lodOpacity);
|
||
|
|
#include <colorspace_fragment>
|
||
|
|
}
|
||
|
|
`);var E9=class xv{static setupLodMeshResize(t){t.onBeforeRender=i=>{i.getSize(t.material[0].lodSize)}}static setupLodAttributes(t){t.setIndex(xv.indices),t.setAttribute("position",xv.vertices)}static setLodBuffer(t,i,n){let s=t.getItemFirst(),l=t.getItemLast(),u=this.setItemFirst(t,s,i,l);({itemFirst:s,dataBuffer:u,itemLast:l}=this.resetAttributes(s,u,i,l)),this.setupFinish(n,u),t.setAttribute("itemFirst",s),t.setAttribute("itemLast",l)}static setLodVisibility(t,i){let n=this.setupItemFilter(t);this.applyVisibilityState(t,i,n),n.needsUpdate=!0}static getInterAttribute(t,i){return t.getAttribute(i)}static computeLodSphere(t){if(!t.boundingSphere)return;let i=t.getItemFirst();if(i){let n=xv.getLodMidPoint(t,i),s=xv.getLodRadius(n,i);t.boundingSphere.radius=s}}static newLodMaterialParams(t){let i={lodColor:{value:new Ni(t.color)},lodSize:{value:new ai(1,1)},lodOpacity:{value:t.opacity??1}};return{uniforms:nv.merge([Gi.common,i]),transparent:t.transparent??!1,vertexShader:Qb.vertex,fragmentShader:Qb.fragment}}static setLodFilter(t,i){let n=t.getItemFilter(),s=n.array;for(let l=0;l<i.position.length;++l){let u=i.position[l]/2,d=i.size[l]/2;d===4294967295?s.fill(1,u):s.fill(1,u,u+d)}n.needsUpdate=!0}static getInstancedAttribute(t,i){return t.getAttribute(i)}static computeLodBox(t){if(!t.boundingBox)return;let i=t.getItemFirst();if(i){let n=i.data.array;t.boundingBox.setFromArray(n)}else t.boundingBox.makeEmpty()}static setDataBuffer(t,i,n){return(t=i.data).array=n,t.needsUpdate=!0,t}static disposeAllData(t){delete t.attributes.itemFilter,delete t.attributes.position,t.index=null,t.dispose(),xv.setupLodAttributes(t)}static setItemFirst(t,i,n,s){let l=null;return i&&(n.length===i.data.array.length?l=this.setDataBuffer(l,i,n):(i=void 0,this.disposeAllData(t))),l}static setupFinish(t,i){t&&(i.onUploadCallback=t)}static resetAttributes(t,i,n,s){return t||(i=new c3(n,6,1),t=new Yd(i,3,0),s=new Yd(i,3,3)),{itemFirst:t,dataBuffer:i,itemLast:s}}static setupItemFilter(t){let i=t.getItemFirst().count,n=t.getItemFilter();return n?n.array.fill(0):(n=new hy(new Uint8Array(i),1),t.setAttribute("itemFilter",n)),n}static applyVisibilityState(t,i,n){i!==!0?i&&this.setLodFilter(t,i):n.array.fill(1)}static getLodMidPoint(t,i){let n=t.boundingSphere.center;return this.tempBox.setFromArray(i.data.array),this.tempBox.getCenter(n),n}static getLodRadius(t,i){let n=0,s=i.data.array.length;for(let l=0;l<s;l+=3){let u=i.data.array;xv.tempVec.fromArray(u,l);let d=t.distanceToSquared(xv.tempVec);n=Math.max(n,d)}return Math.sqrt(n)}};Se(E9,"tempVec",new Ne),Se(E9,"tempBox",new un),Se(E9,"vertices",new $i([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),Se(E9,"indices",new eC([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5],1));var tE=E9,JG=class extends Ri{constructor(t,i){super(t,i),Se(this,"geometry"),Se(this,"material"),this.geometry=t,this.material=i,tE.setupLodMeshResize(this)}},S$=class extends u2{constructor(){super(),Se(this,"isLODGeometry",!0),tE.setupLodAttributes(this)}isFiltered(){return!!this.getItemFilter()}computeBoundingBox(){this.boundingBox||(this.boundingBox=new un),tE.computeLodBox(this)}applyMatrix4(t){return this.applyTransformToBuffers(t),this.updateBounds(),this}computeBoundingSphere(){this.boundingSphere||(this.boundingSphere=new Rs),tE.computeLodSphere(this)}getItemFilter(){return tE.getInstancedAttribute(this,"itemFilter")}getItemLast(){return tE.getInterAttribute(this,"itemLast")}getItemFirst(){return tE.getInterAttribute(this,"itemFirst")}applyTransformToBuffers(t){this.getItemFirst().applyMatrix4(t),this.getItemLast().applyMatrix4(t)}updateBounds(){this.boundingBox&&this.computeBoundingBox(),this.boundingSphere&&this.computeBoundingSphere()}},A$=class extends $r{constructor(t){super(tE.newLodMaterialParams(t)),Se(this,"isLodMaterial",!0),Se(this,"isLineMaterial",!0),this.clipping=!0,this.lights=!1,this.needsUpdate=!0}get lodSize(){return this.uniforms.lodSize.value}set lodColor(t){this.uniforms.lodColor.value=t}set lodSize(t){this.uniforms.lodSize.value.copy(t)}get lodColor(){return this.uniforms.lodColor.value}},Y9=class
|
||
|
|
|
||
|
|
- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.
|
||
|
|
|
||
|
|
- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};Ye(OK,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/);Ye(OK,"_lut",["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"]);var hf=OK,lV=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function D1e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var LK={},nk={};(function(e){let t=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",i=t+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",n="["+t+"]["+i+"]*",s=new RegExp("^"+n+"$"),l=function(d,h){let f=[],I=h.exec(d);for(;I;){let y=[];y.startIndex=h.lastIndex-I[0].length;let g=I.length;for(let T=0;T<g;T++)y.push(I[T]);f.push(y),I=h.exec(d)}return f},u=function(d){let h=s.exec(d);return!(h===null||typeof h>"u")};e.isExist=function(d){return typeof d<"u"},e.isEmptyObject=function(d){return Object.keys(d).length===0},e.merge=function(d,h,f){if(h){let I=Object.keys(h),y=I.length;for(let g=0;g<y;g++)f==="strict"?d[I[g]]=[h[I[g]]]:d[I[g]]=h[I[g]]}},e.getValue=function(d){return e.isExist(d)?d:""},e.isName=u,e.getAllMatches=l,e.nameRegexp=n})(nk);var _K=nk,N1e={allowBooleanAttributes:!1,unpairedTags:[]};LK.validate=function(e,t){t=Object.assign({},N1e,t);let i=[],n=!1,s=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let l=0;l<e.length;l++)if(e[l]==="<"&&e[l+1]==="?"){if(l+=2,l=Bte(e,l),l.err)return l}else if(e[l]==="<"){let u=l;if(l++,e[l]==="!"){l=Ute(e,l);continue}else{let d=!1;e[l]==="/"&&(d=!0,l++);let h="";for(;l<e.length&&e[l]!==">"&&e[l]!==" "&&e[l]!==" "&&e[l]!==`
|
||
|
|
`&&e[l]!=="\r";l++)h+=e[l];if(h=h.trim(),h[h.length-1]==="/"&&(h=h.substring(0,h.length-1),l--),!M1e(h)){let y;return h.trim().length===0?y="Invalid space after '<'.":y="Tag '"+h+"' is an invalid name.",Ma("InvalidTag",y,df(e,l))}let f=O1e(e,l);if(f===!1)return Ma("InvalidAttr","Attributes for '"+h+"' have open quote.",df(e,l));let I=f.value;if(l=f.index,I[I.length-1]==="/"){let y=l-I.length;I=I.substring(0,I.length-1);let g=Fte(I,t);if(g===!0)n=!0;else return Ma(g.err.code,g.err.msg,df(e,y+g.err.line))}else if(d)if(f.tagClosed){if(I.trim().length>0)return Ma("InvalidTag","Closing tag '"+h+"' can't have attributes or invalid starting.",df(e,u));if(i.length===0)return Ma("InvalidTag","Closing tag '"+h+"' has not been opened.",df(e,u));{let y=i.pop();if(h!==y.tagName){let g=df(e,y.tagStartPos);return Ma("InvalidTag","Expected closing tag '"+y.tagName+"' (opened in line "+g.line+", col "+g.col+") instead of closing tag '"+h+"'.",df(e,u))}i.length==0&&(s=!0)}}else return Ma("InvalidTag","Closing tag '"+h+"' doesn't have proper closing.",df(e,l));else{let y=Fte(I,t);if(y!==!0)return Ma(y.err.code,y.err.msg,df(e,l-I.length+y.err.line));if(s===!0)return Ma("InvalidXml","Multiple possible root nodes found.",df(e,l));t.unpairedTags.indexOf(h)!==-1||i.push({tagName:h,tagStartPos:u}),n=!0}for(l++;l<e.length;l++)if(e[l]==="<")if(e[l+1]==="!"){l++,l=Ute(e,l);continue}else if(e[l+1]==="?"){if(l=Bte(e,++l),l.err)return l}else break;else if(e[l]==="&"){let y=P1e(e,l);if(y==-1)return Ma("InvalidChar","char '&' is not expected.",df(e,l));l=y}else if(s===!0&&!Mte(e[l]))return Ma("InvalidXml","Extra text at the end",df(e,l));e[l]==="<"&&l--}}else{if(Mte(e[l]))continue;return Ma("InvalidChar","char '"+e[l]+"' is not expected.",df(e,l))}if(n){if(i.length==1)return Ma("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",df(e,i[0].tagStartPos));if(i.length>0)return Ma("InvalidXml","Invalid '"+JSON.stringify(i.map(l=>l.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return Ma("InvalidXml","Start tag expected.",1);return!0};function Mte(e){return e===" "||e===" "||e===`
|
||
|
|
`||e==="\r"}function Bte(e,t){let i=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let n=e.substr(i,t-i);if(t>5&&n==="xml")return Ma("InvalidXml","XML declaration allowed only at the start of the document.",df(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function Ute(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let i=1;for(t+=8;t<e.length;t++)if(e[t]==="<")i++;else if(e[t]===">"&&(i--,i===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var C1e='"',b1e="'";function O1e(e,t){let i="",n="",s=!1;for(;t<e.length;t++){if(e[t]===C1e||e[t]===b1e)n===""?n=e[t]:n!==e[t]||(n="");else if(e[t]===">"&&n===""){s=!0;break}i+=e[t]}return n!==""?!1:{value:i,index:t,tagClosed:s}}var L1e=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Fte(e,t){let i=_K.getAllMatches(e,L1e),n={};for(let s=0;s<i.length;s++){if(i[s][1].length===0)return Ma("InvalidAttr","Attribute '"+i[s][2]+"' has no space in starting.",Q9(i[s]));if(i[s][3]!==void 0&&i[s][4]===void 0)return Ma("InvalidAttr","Attribute '"+i[s][2]+"' is without value.",Q9(i[s]));if(i[s][3]===void 0&&!t.allowBooleanAttributes)return Ma("InvalidAttr","boolean attribute '"+i[s][2]+"' is not allowed.",Q9(i[s]));let l=i[s][2];if(!x1e(l))return Ma("InvalidAttr","Attribute '"+l+"' is an invalid name.",Q9(i[s]));if(!n.hasOwnProperty(l))n[l]=1;else return Ma("InvalidAttr","Attribute '"+l+"' is repeated.",Q9(i[s]))}return!0}function _1e(e,t){let i=/\d/;for(e[t]==="x"&&(t++,i=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(i))break}return-1}function P1e(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,_1e(e,t);let i=0;for(;t<e.length;t++,i++)if(!(e[t].match(/\w/)&&i<20)){if(e[t]===";")break;return-1}return t}function Ma(e,t,i){return{err:{code:e,msg:t,line:i.line||i,col:i.col}}}function x1e(e){return _K.isName(e)}function M1e(e){return _K.isName(e)}function df(e,t){let i=e.substring(0,t).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function Q9(e){return e.startIndex+e[1].length}var PK={},Nie={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,i){return e}},B1e=function(e){return Object.assign({},Nie,e)};PK.buildOptions=B1e;PK.defaultOptions=Nie;var QZ=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,i){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:i})}addChild(t){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child})}},U1e=QZ,F1e=nk;function H1e(e,t){let i={};if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let n=1,s=!1,l=!1,u="";for(;t<e.length;t++)if(e[t]==="<"&&!l){if(s&&k1e(e,t))t+=7,[entityName,val,t]=G1e(e,t+1),val.indexOf("&")===-1&&(i[j1e(entityName)]={regx:RegExp(`&${entityName};`,"g"),val});else if(s&&z1e(e,t))t+=8;else if(s&&W1e(e,t))t+=8;else if(s&&Y1e(e,t))t+=9;else if(V1e)l=!0;else throw new Error("Invalid DOCTYPE");n++,u=""}else if(e[t]===">"){if(l?e[t-1]==="-"&&e[t-2]==="-"&&(l=!1,n--):n--,n===0)break}else e[t]==="["?s=!0:u+=e[t];if(n!==0)throw new Error("Unclosed DOCTYPE")}else throw new Erro
|
||
|
|
`);let t=new J9("!xml"),i=t,n="",s="";for(let l=0;l<e.length;l++)if(e[l]==="<")if(e[l+1]==="/"){let d=B6(e,">",l,"Closing Tag is not closed."),h=e.substring(l+2,d).trim();if(this.options.removeNSPrefix){let y=h.indexOf(":");y!==-1&&(h=h.substr(y+1))}this.options.transformTagName&&(h=this.options.transformTagName(h)),i&&(n=this.saveTextToParentTag(n,i,s));let f=s.substring(s.lastIndexOf(".")+1);if(h&&this.options.unpairedTags.indexOf(h)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${h}>`);let I=0;f&&this.options.unpairedTags.indexOf(f)!==-1?(I=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):I=s.lastIndexOf("."),s=s.substring(0,I),i=this.tagsNodeStack.pop(),n="",l=d}else if(e[l+1]==="?"){let d=JZ(e,l,!1,"?>");if(!d)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,i,s),!(this.options.ignoreDeclaration&&d.tagName==="?xml"||this.options.ignorePiTags)){let h=new J9(d.tagName);h.add(this.options.textNodeName,""),d.tagName!==d.tagExp&&d.attrExpPresent&&(h[":@"]=this.buildAttributesMap(d.tagExp,s,d.tagName)),this.addChild(i,h,s)}l=d.closeIndex+1}else if(e.substr(l+1,3)==="!--"){let d=B6(e,"-->",l+4,"Comment is not closed.");if(this.options.commentPropName){let h=e.substring(l+4,d-2);n=this.saveTextToParentTag(n,i,s),i.add(this.options.commentPropName,[{[this.options.textNodeName]:h}])}l=d}else if(e.substr(l+1,2)==="!D"){let d=tme(e,l);this.docTypeEntities=d.entities,l=d.i}else if(e.substr(l+1,2)==="!["){let d=B6(e,"]]>",l,"CDATA is not closed.")-2,h=e.substring(l+9,d);n=this.saveTextToParentTag(n,i,s);let f=this.parseTextData(h,i.tagname,s,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?i.add(this.options.cdataPropName,[{[this.options.textNodeName]:h}]):i.add(this.options.textNodeName,f),l=d+2}else{let d=JZ(e,l,this.options.removeNSPrefix),h=d.tagName,f=d.rawTagName,I=d.tagExp,y=d.attrExpPresent,g=d.closeIndex;this.options.transformTagName&&(h=this.options.transformTagName(h)),i&&n&&i.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,i,s,!1));let T=i;if(T&&this.options.unpairedTags.indexOf(T.tagname)!==-1&&(i=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),h!==t.tagname&&(s+=s?"."+h:h),this.isItStopNode(this.options.stopNodes,s,h)){let D="";if(I.length>0&&I.lastIndexOf("/")===I.length-1)h[h.length-1]==="/"?(h=h.substr(0,h.length-1),s=s.substr(0,s.length-1),I=h):I=I.substr(0,I.length-1),l=d.closeIndex;else if(this.options.unpairedTags.indexOf(h)!==-1)l=d.closeIndex;else{let O=this.readStopNodeData(e,f,g+1);if(!O)throw new Error(`Unexpected end of ${f}`);l=O.i,D=O.tagContent}let L=new J9(h);h!==I&&y&&(L[":@"]=this.buildAttributesMap(I,s,h)),D&&(D=this.parseTextData(D,h,s,!0,y,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),L.add(this.options.textNodeName,D),this.addChild(i,L,s)}else{if(I.length>0&&I.lastIndexOf("/")===I.length-1){h[h.length-1]==="/"?(h=h.substr(0,h.length-1),s=s.substr(0,s.length-1),I=h):I=I.substr(0,I.length-1),this.options.transformTagName&&(h=this.options.transformTagName(h));let D=new J9(h);h!==I&&y&&(D[":@"]=this.buildAttributesMap(I,s,h)),this.addChild(i,D,s),s=s.substr(0,s.lastIndexOf("."))}else{let D=new J9(h);this.tagsNodeStack.push(i),h!==I&&y&&(D[":@"]=this.buildAttributesMap(I,s,h)),this.addChild(i,D,s),i=D}n="",l=g}}else n+=e[l];return t.child};function dme(e,t,i){let n=this.options.updateTag(t.tagname,i,t[":@"]);n===!1||(typeof n=="string"&&(t.tagname=n),e.addChild(t))}var cme=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let i=this.docTypeEntities[t];e=e.replace(i.regx,i.val)}for(let t in this.lastEntities){let i=this.lastEntities[t];e=e.replace(i.regex,i.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let i=this.htmlEntities[t];e=e.replace(i.regex,i.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function hme(e,t,i,n){return e&&(n===void 0&&(n=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,i,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,n),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function fme(e,t,i){let n="*."
|
||
|
|
`;function Cme(e,t){let i="";return t.format&&t.indentBy.length>0&&(i=Nme),Lie(e,t,"",i)}function Lie(e,t,i,n){let s="",l=!1;for(let u=0;u<e.length;u++){let d=e[u],h=bme(d);if(h===void 0)continue;let f="";if(i.length===0?f=h:f=`${i}.${h}`,h===t.textNodeName){let D=d[h];Ome(f,t)||(D=t.tagValueProcessor(h,D),D=_ie(D,t)),l&&(s+=n),s+=D,l=!1;continue}else if(h===t.cdataPropName){l&&(s+=n),s+=`<![CDATA[${d[h][0][t.textNodeName]}]]>`,l=!1;continue}else if(h===t.commentPropName){s+=n+`<!--${d[h][0][t.textNodeName]}-->`,l=!0;continue}else if(h[0]==="?"){let D=Hte(d[":@"],t),L=h==="?xml"?"":n,O=d[h][0][t.textNodeName];O=O.length!==0?" "+O:"",s+=L+`<${h}${O}${D}?>`,l=!0;continue}let I=n;I!==""&&(I+=t.indentBy);let y=Hte(d[":@"],t),g=n+`<${h}${y}`,T=Lie(d[h],t,f,I);t.unpairedTags.indexOf(h)!==-1?t.suppressUnpairedNode?s+=g+">":s+=g+"/>":(!T||T.length===0)&&t.suppressEmptyNode?s+=g+"/>":T&&T.endsWith(">")?s+=g+`>${T}${n}</${h}>`:(s+=g+">",T&&n!==""&&(T.includes("/>")||T.includes("</"))?s+=n+t.indentBy+T+n:s+=T,s+=`</${h}>`),l=!0}return s}function bme(e){let t=Object.keys(e);for(let i=0;i<t.length;i++){let n=t[i];if(e.hasOwnProperty(n)&&n!==":@")return n}}function Hte(e,t){let i="";if(e&&!t.ignoreAttributes)for(let n in e){if(!e.hasOwnProperty(n))continue;let s=t.attributeValueProcessor(n,e[n]);s=_ie(s,t),s===!0&&t.suppressBooleanAttributes?i+=` ${n.substr(t.attributeNamePrefix.length)}`:i+=` ${n.substr(t.attributeNamePrefix.length)}="${s}"`}return i}function Ome(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let i=e.substr(e.lastIndexOf(".")+1);for(let n in t.stopNodes)if(t.stopNodes[n]===e||t.stopNodes[n]==="*."+i)return!0;return!1}function _ie(e,t){if(e&&e.length>0&&t.processEntities)for(let i=0;i<t.entities.length;i++){let n=t.entities[i];e=e.replace(n.regex,n.val)}return e}var Lme=Cme,_me=Lme,Pme={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function nR(e){this.options=Object.assign({},Pme,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Bme),this.processTextOrObjNode=xme,this.options.format?(this.indentate=Mme,this.tagEndChar=`>
|
||
|
|
`,this.newLine=`
|
||
|
|
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}nR.prototype.build=function(e){return this.options.preserveOrder?_me(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};nR.prototype.j2x=function(e,t){let i="",n="";for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s))if(typeof e[s]>"u")this.isAttribute(s)&&(n+="");else if(e[s]===null)this.isAttribute(s)?n+="":s[0]==="?"?n+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(e[s]instanceof Date)n+=this.buildTextValNode(e[s],s,"",t);else if(typeof e[s]!="object"){let l=this.isAttribute(s);if(l)i+=this.buildAttrPairStr(l,""+e[s]);else if(s===this.options.textNodeName){let u=this.options.tagValueProcessor(s,""+e[s]);n+=this.replaceEntitiesValue(u)}else n+=this.buildTextValNode(e[s],s,"",t)}else if(Array.isArray(e[s])){let l=e[s].length,u="",d="";for(let h=0;h<l;h++){let f=e[s][h];if(!(typeof f>"u"))if(f===null)s[0]==="?"?n+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(typeof f=="object")if(this.options.oneListGroup){let I=this.j2x(f,t+1);u+=I.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(d+=I.attrStr)}else u+=this.processTextOrObjNode(f,s,t);else if(this.options.oneListGroup){let I=this.options.tagValueProcessor(s,f);I=this.replaceEntitiesValue(I),u+=I}else u+=this.buildTextValNode(f,s,"",t)}this.options.oneListGroup&&(u=this.buildObjectNode(u,s,d,t)),n+=u}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName){let l=Object.keys(e[s]),u=l.length;for(let d=0;d<u;d++)i+=this.buildAttrPairStr(l[d],""+e[s][l[d]])}else n+=this.processTextOrObjNode(e[s],s,t);return{attrStr:i,val:n}};nR.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t==="true"?" "+e:" "+e+'="'+t+'"'};function xme(e,t,i){let n=this.j2x(e,i+1);return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,n.attrStr,i):this.buildObjectNode(n.val,t,n.attrStr,i)}nR.prototype.buildObjectNode=function(e,t,i,n){if(e==="")return t[0]==="?"?this.indentate(n)+"<"+t+i+"?"+this.tagEndChar:this.indentate(n)+"<"+t+i+this.closeTag(t)+this.tagEndChar;{let s="</"+t+this.tagEndChar,l="";return t[0]==="?"&&(l="?",s=""),(i||i==="")&&e.indexOf("<")===-1?this.indentate(n)+"<"+t+i+l+">"+e+s:this.options.commentPropName!==!1&&t===this.options.commentPropName&&l.length===0?this.indentate(n)+`<!--${e}-->`+this.newLine:this.indentate(n)+"<"+t+i+l+this.tagEndChar+e+this.indentate(n)+s}};nR.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};nR.prototype.buildTextValNode=function(e,t,i,n){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(n)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(n)+`<!--${e}-->`+this.newLine;if(t[0]==="?")return this.indentate(n)+"<"+t+i+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(t,e);return s=this.replaceEntitiesValue(s),s===""?this.indentate(n)+"<"+t+i+this.closeTag(t)+this.tagEndChar:this.indentate(n)+"<"+t+i+">"+s+"</"+t+this.tagEndChar}};nR.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let i=this.options.entities[t];e=e.replace(i.regex,i.val)}return e};function Mme(e){return this.options.indentBy.repeat(e)}function Bme(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}var Ume=nR,Fme=LK,Hme=Dme,Gme=Ume,sk={XMLParser:Hme,XMLValidator:Fme,XMLBuilder:Gme},U6=class{};Ye(U6,"parser",new sk.XMLParser({allowBooleanAttribut
|
||
|
|
|
||
|
|
varying vec3 worldPosition;
|
||
|
|
|
||
|
|
uniform float uDistance;
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
|
||
|
|
vec3 pos = position.xzy * uDistance;
|
||
|
|
pos.xz += cameraPosition.xz;
|
||
|
|
|
||
|
|
worldPosition = pos;
|
||
|
|
|
||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
||
|
|
|
||
|
|
}
|
||
|
|
`,fragmentShader:`
|
||
|
|
|
||
|
|
varying vec3 worldPosition;
|
||
|
|
|
||
|
|
uniform float uZoom;
|
||
|
|
uniform float uFade;
|
||
|
|
uniform float uSize1;
|
||
|
|
uniform float uSize2;
|
||
|
|
uniform vec3 uColor;
|
||
|
|
uniform float uDistance;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
float getGrid(float size) {
|
||
|
|
|
||
|
|
vec2 r = worldPosition.xz / size;
|
||
|
|
|
||
|
|
|
||
|
|
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
||
|
|
float line = min(grid.x, grid.y);
|
||
|
|
|
||
|
|
|
||
|
|
return 1.0 - min(line, 1.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
|
||
|
|
|
||
|
|
float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / uDistance, 1.0);
|
||
|
|
|
||
|
|
float g1 = getGrid(uSize1);
|
||
|
|
float g2 = getGrid(uSize2);
|
||
|
|
|
||
|
|
// Ortho camera fades the grid away when zooming out
|
||
|
|
float minZoom = step(0.2, uZoom);
|
||
|
|
float zoomFactor = pow(min(uZoom, 1.), 2.) * minZoom;
|
||
|
|
|
||
|
|
gl_FragColor = vec4(uColor.rgb, mix(g2, g1, g1) * pow(d, uFade));
|
||
|
|
gl_FragColor.a = mix(0.5 * gl_FragColor.a, gl_FragColor.a, g2) * zoomFactor;
|
||
|
|
|
||
|
|
if ( gl_FragColor.a <= 0.0 ) discard;
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
`,extensions:{derivatives:!0}});this.three=new Ri(d,h),this.three.frustumCulled=!1,i.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(t){this.three.visible=t,t?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return this._fade===3}set fade(t){this._fade=t?3:0,this.material.uniforms.uFade.value=this._fade}setup(t){let i={...this._defaultConfig,...t};this.config.visible=!0,this.config.color=i.color,this.config.primarySize=i.primarySize,this.config.secondarySize=i.secondarySize,this.config.distance=i.distance,this.isSetup=!0,this.onSetup.trigger()}dispose(){this.setupEvents(!1),this.components.get(RB).list.delete(this.config.uuid),this.components.get(vB).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(t){if(this.world.isDisposing||!(this.world.camera instanceof T7))return;let i=this.world.camera.controls;t?i.addEventListener("update",this.updateZoom):i.removeEventListener("update",this.updateZoom)}},tne=class ine extends Br{constructor(t){super(t),Ye(this,"list",new Map),Ye(this,"onDisposed",new Wi),Ye(this,"enabled",!0),t.add(ine.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");let i=new zV(this.components,t);return this.list.set(t.uuid,i),t.onDisposed.add(()=>{this.delete(t)}),i}delete(t){let i=this.list.get(t.uuid);i&&i.dispose(),this.list.delete(t.uuid)}dispose(){for(let[t,i]of this.list)i.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}};Ye(tne,"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");var Yme=tne,nne=0,jme=1,qme=2,$te=2,MZ=1.25,Zte=1,bV=32,ok=65535,$me=Math.pow(2,-24),BZ=Symbol("SKIP_GENERATION");function Zme(e){return e.index?e.index.count:e.attributes.position.count}function v7(e){return Zme(e)/3}function Kme(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}function Qme(e,t){if(!e.index){let i=e.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Kme(i,n);e.setIndex(new Pn(s,1));for(let l=0;l<i;l++)s[l]=l}}function sne(e){let t=v7(e),i=e.drawRange,n=i.start/3,s=(i.start+i.count)/3,l=Math.max(0,n),u=Math.min(t,s)-l;return[{offset:Math.floor(l),count:Math.floor(u)}]}function one(e){if(!e.groups||!e.groups.length)return sne(e);let t=[],i=new Set,n=e.drawRange,s=n.start/3,l=(n.start+n.count)/3;for(let d of e.groups){let h=d.start/3,f=(d.start+d.count)/3;i.add(Math.max(s,h)),i.add(Math.min(l,f))}let u=Array.from(i.values()).sort((d,h)=>d-h);for(let d=0;d<u.length-1;d++){let h=u[d],f=u[d+1];t.push({offset:Math.floor(h),count:Math.floor(f-h)})}return t}function Jme(e){if(e.groups.length===0)return!1;let t=v7(e),i=one(e).sort((l,u)=>l.offset-u.offset),n=i[i.length-1];n.count=Math.min(t-n.offset,n.count);let s=0;return i.forEach(({count:l})=>s+=l),t!==s}function Xl(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function Xme(e){e[0]=e[1]=e[2]=1/0,e[3]=e[4]=e[5]=-1/0}function Kte(e){let t=-1,i=-1/0;for(let n=0;n<3;n++){let s=e[n+3]-e[n];s>i&&(i=s,t=n)}return t}function Qte(e,t){t.set(e)}function Jte(e,t,i){let n,s;for(let l=0;l<3;l++){let u=l+3;n=e[l],s=t[l],i[l]=n<s?n:s,n=e[u],s=t[u],i[u]=n>s?n:s}}function cV(e,t,i){for(let n=0;n<3;n++){let s=t[e+2*n],l=t[e+2*n+1],u=s-l,d=s+l;u<i[n]&&(i[n]=u),d>i[n+3]&&(i[n+3]=d)}}function sB(e){let t=e[3]-e[0],i=e[4]-e[1],n=e[5]-e[2];return 2*(t*i+i*n+n*t)}function UZ(e,t,i,n,s=null){let l=1/0,u=1/0,d=1/0,h=-1/0,f=-1/0,I=-1/0,y=1/0,g=1/0,T=1/0,D=-1/0,L=-1/0,O=-1/0,N=s!==null;for(let Y=t*6,V=(t+i)*6;Y<V;Y+=6){let $=e[Y+0],re=e[Y+1],pe=$-re,de=$+re;pe<l&&(l=pe),de>h&&(h=de),N&&$<y&&(y=$),N&&$>D&&(D=$);let ge=e[Y+2],le=e[Y+3],he=ge-le,be=ge+le;he<u&&(u=he),be>f&&(f=be),N&&ge<g&&(g=ge),N&&ge>L&&(L=ge);let ae=e[Y+4],De=e[Y+5],Re=ae-De,je=ae+De;Re<d&&(d=Re),je>I&&(I=je),N&&ae<T&&(T=ae),N&&ae>O&&(O=ae)}n[0]=l,n[1]=u,n[2]=d,n[3]=h,n[4]=f,n[5]=I,N&&(s[0]=y,s[1]=g,s[2]=T,s[3]=D,s[4]=L,s[5]=O
|
||
|
|
\0`,Dt+=l(yt,2),Dt+=pe.magic,Dt+=l(V,2),Dt+=l($,2),Dt+=l(ut.crc32,4),Dt+=l(ut.compressedSize,4),Dt+=l(ut.uncompressedSize,4),Dt+=l(ge.length,2),Dt+=l(je.length,2),{fileRecord:y.LOCAL_FILE_HEADER+Dt+ge+je,dirRecord:y.CENTRAL_FILE_HEADER+l(Pt,2)+Dt+l(be.length,2)+"\0\0\0\0"+l(mt,4)+l(O,4)+ge+je+be}}var d=i("../utils"),h=i("../stream/GenericWorker"),f=i("../utf8"),I=i("../crc32"),y=i("../signature");function g(T,D,L,O){h.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=D,this.zipPlatform=L,this.encodeFileName=O,this.streamFiles=T,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}d.inherits(g,h),g.prototype.push=function(T){var D=T.meta.percent||0,L=this.entriesCount,O=this._sources.length;this.accumulate?this.contentBuffer.push(T):(this.bytesWritten+=T.data.length,h.prototype.push.call(this,{data:T.data,meta:{currentFile:this.currentFile,percent:L?(D+100*(L-O-1))/L:100}}))},g.prototype.openedSource=function(T){this.currentSourceOffset=this.bytesWritten,this.currentFile=T.file.name;var D=this.streamFiles&&!T.file.dir;if(D){var L=u(T,D,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:L.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(T){this.accumulate=!1;var D=this.streamFiles&&!T.file.dir,L=u(T,D,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(L.dirRecord),D)this.push({data:(function(O){return y.DATA_DESCRIPTOR+l(O.crc32,4)+l(O.compressedSize,4)+l(O.uncompressedSize,4)})(T),meta:{percent:100}});else for(this.push({data:L.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var T=this.bytesWritten,D=0;D<this.dirRecords.length;D++)this.push({data:this.dirRecords[D],meta:{percent:100}});var L=this.bytesWritten-T,O=(function(N,Y,V,$,re){var pe=d.transformTo("string",re($));return y.CENTRAL_DIRECTORY_END+"\0\0\0\0"+l(N,2)+l(N,2)+l(Y,4)+l(V,4)+l(pe.length,2)+pe})(this.dirRecords.length,L,T,this.zipComment,this.encodeFileName);this.push({data:O,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(T){this._sources.push(T);var D=this;return T.on("data",function(L){D.processChunk(L)}),T.on("end",function(){D.closedSource(D.previous.streamInfo),D._sources.length?D.prepareNextSource():D.end()}),T.on("error",function(L){D.error(L)}),this},g.prototype.resume=function(){return!!h.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(T){var D=this._sources;if(!h.prototype.error.call(this,T))return!1;for(var L=0;L<D.length;L++)try{D[L].error(T)}catch{}return!0},g.prototype.lock=function(){h.prototype.lock.call(this);for(var T=this._sources,D=0;D<T.length;D++)T[D].lock()},n.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(i,n,s){var l=i("../compressions"),u=i("./ZipFileWorker");s.generateWorker=function(d,h,f){var I=new u(h.streamFiles,f,h.platform,h.encodeFileName),y=0;try{d.forEach(function(g,T){y++;var D=(function(Y,V){var $=Y||V,re=l[$];if(!re)throw new Error($+" is not a valid compression method !");return re})(T.options.compression,h.compression),L=T.options.compressionOptions||h.compressionOptions||{},O=T.dir,N=T.date;T._compressWorker(D,L).withStreamInfo("file",{name:g,dir:O,date:N,comment:T.comment||"",unixPermissions:T.unixPermissions,dosPermissions:T.dosPermissions}).pipe(I)}),I.entriesCount=y}catch(g){I.error(g)}return I}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(i,n,s){function l(){if(!(this instanceof l))return new l;if(arguments.length)throw new Error("The constructor with parameters has been remov
|
||
|
|
${U6.builder.build(l)}`}};Ye(dne,"default",{title:"BCF Topic",type:"Issue",status:"Active"});var TK=dne,cne=(e,t)=>{if(t.trim()==="")return;let i=bd.xmlParser.parse(t).Extensions;if(!i)return;let{Priorities:n,TopicStatuses:s,TopicTypes:l,Users:u}=i;if(n&&n.Priority){let d=Array.isArray(n.Priority)?n.Priority:[n.Priority];for(let h of d)e.config.priorities.add(h)}if(s&&s.TopicStatus){let d=Array.isArray(s.TopicStatus)?s.TopicStatus:[s.TopicStatus];for(let h of d)e.config.statuses.add(h)}if(l&&l.TopicType){let d=Array.isArray(l.TopicType)?l.TopicType:[l.TopicType];for(let h of d)e.config.types.add(h)}if(u&&u.User){let d=Array.isArray(u.User)?u.User:[u.User];for(let h of d)e.config.users.add(h)}},ZV=class extends tR{constructor(){super(...arguments),Ye(this,"_config",{version:{type:"Select",options:new Set(["2.1","3"]),multiple:!1,value:""},author:{type:"Text",value:""},types:{type:"TextSet",value:new Set},statuses:{type:"TextSet",value:new Set},priorities:{type:"TextSet",value:new Set},labels:{type:"TextSet",value:new Set},stages:{type:"TextSet",value:new Set},users:{type:"TextSet",value:new Set},includeSelectionTag:{type:"Boolean",value:!1},updateExtensionsOnImport:{type:"Boolean",value:!1},strict:{type:"Boolean",value:!1},includeAllExtensionsOnExport:{type:"Boolean",value:!1},fallbackVersionOnImport:{type:"Select",multiple:!1,options:new Set(["2.1","3"]),value:""},ignoreIncompleteTopicsOnImport:{type:"Boolean",value:!1},exportCustomDataAsLabels:{type:"Boolean",value:!1}})}get version(){return this._config.version.value}set version(t){this._config.version.value=t}get author(){return this._config.author.value}set author(t){this._config.author.value=t}get types(){return this._config.types.value}set types(t){this._config.types.value=t}get statuses(){return this._config.statuses.value}set statuses(t){this._config.statuses.value=t}get priorities(){return this._config.priorities.value}set priorities(t){this._config.priorities.value=t}get labels(){return this._config.labels.value}set labels(t){this._config.labels.value=t}get stages(){return this._config.stages.value}set stages(t){this._config.stages.value=t}get users(){return this._config.users.value}set users(t){this._config.users.value=t}get includeSelectionTag(){return this._config.includeSelectionTag.value}set includeSelectionTag(t){this._config.includeSelectionTag.value=t}get updateExtensionsOnImport(){return this._config.updateExtensionsOnImport.value}set updateExtensionsOnImport(t){this._config.updateExtensionsOnImport.value=t}get strict(){return this._config.strict.value}set strict(t){this._config.strict.value=t}get includeAllExtensionsOnExport(){return this._config.includeAllExtensionsOnExport.value}set includeAllExtensionsOnExport(t){this._config.includeAllExtensionsOnExport.value=t}get fallbackVersionOnImport(){return this._config.fallbackVersionOnImport.value}set fallbackVersionOnImport(t){this._config.fallbackVersionOnImport.value=t}get ignoreIncompleteTopicsOnImport(){return this._config.ignoreIncompleteTopicsOnImport.value}set ignoreIncompleteTopicsOnImport(t){this._config.ignoreIncompleteTopicsOnImport.value=t}get exportCustomDataAsLabels(){return this._config.exportCustomDataAsLabels.value}set exportCustomDataAsLabels(t){this._config.exportCustomDataAsLabels.value=t}},FK=class hB extends Br{constructor(){super(...arguments),Ye(this,"enabled",!1),Ye(this,"_defaultConfig",{author:"jhon.doe@example.com",version:"2.1",types:new Set(["Clash","Failure","Fault","Inquiry","Issue","Remark","Request"]),statuses:new Set(["Active","In Progress","Done","In Review","Closed"]),priorities:new Set(["On hold","Minor","Normal","Major","Critical"]),labels:new Set,stages:new Set,users:new Set,includeSelectionTag:!1,updateExtensionsOnImport:!0,strict:!1,includeAllExtensionsOnExport:!0,fallbackVersionOnImport:"2.1",ignoreIncompleteTopicsOnImport:!1,exportCustomDataAsLabels:!1}),Ye(this,"config",new ZV(this,this.components,"BCF Topics",hB.uuid)),Ye(this,"list",new ml),Ye(this,"documents",new ml),Ye(this,"onSetup",new Wi),Ye(this,"isSetup",!1),Ye(this,"onBCFImported",new Wi),Ye(thi
|
||
|
|
<Version VersionId="${this.config.version}" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_3_0/Schemas/version.xsd"
|
||
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||
|
|
</Version>`);for(let[l,u]of this.documents.entries())u.type!=="external"&&i.file(this.config.version==="2.1"?u.fileName:`documents/${l}`,u.data);if(this.config.version==="3"){let l=[];for(let[u,d]of this.documents.entries()){let{type:h,description:f}=d;h!=="external"&&l.push(`<Document Guid="${u}">
|
||
|
|
<Filename>${d.fileName}</Filename>
|
||
|
|
${f?`<Description>${f}</Description>`:""}
|
||
|
|
</Document>`)}l.length>0&&i.file("documents.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||
|
|
<DocumentInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="documents.xsd">
|
||
|
|
<Documents>
|
||
|
|
${l.join(`
|
||
|
|
`)}
|
||
|
|
</Documents>
|
||
|
|
</DocumentInfo>`)}i.file("bcf.extensions",this.serializeExtensions());let n=this.components.get(xT);for(let l of t){let u=i.folder(l.guid);u.file("markup.bcf",l.serialize());for(let d of l.viewpoints){let h=n.list.get(d);if(!h)continue;let f=h.title??h.guid;u.file(`${f}.bcfv`,await h.serialize());let I=n.snapshots.get(h.snapshot);if(!I)continue;let y=I?h.snapshot:h.guid,g=n.getSnapshotExtension(h.snapshot);u.file(`${y}.${g}`,I,{binary:!0})}}return await i.generateAsync({type:"blob"})}serializeExtensions(){let t=[...this.config.types].map(d=>`<TopicType>${d}</TopicType>`).join(`
|
||
|
|
`),i=[...this.config.statuses].map(d=>`<TopicStatus>${d}</TopicStatus>`).join(`
|
||
|
|
`),n=[...this.config.priorities].map(d=>`<Priority>${d}</Priority>`).join(`
|
||
|
|
`),s=[...this.config.labels].map(d=>`<TopicLabel>${d}</TopicLabel>`).join(`
|
||
|
|
`),l=[...this.config.stages].map(d=>`<Stage>${d}</Stage>`).join(`
|
||
|
|
`),u=[...this.config.users].map(d=>`<User>${d}</User>`).join(`
|
||
|
|
`);return`
|
||
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
<Extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="your-schema-location.xsd">
|
||
|
|
${t.length!==0?`<TopicTypes>
|
||
|
|
${t}
|
||
|
|
</TopicTypes>`:""}
|
||
|
|
${i.length!==0?`<TopicStatuses>
|
||
|
|
${i}
|
||
|
|
</TopicStatuses>`:""}
|
||
|
|
${n.length!==0?`<Priorities>
|
||
|
|
${n}
|
||
|
|
</Priorities>`:""}
|
||
|
|
${s.length!==0?`<TopicLabels>
|
||
|
|
${s}
|
||
|
|
</TopicLabels>`:""}
|
||
|
|
${l.length!==0?`<Stages>
|
||
|
|
${l}
|
||
|
|
</Stages>`:""}
|
||
|
|
${u.length!==0?`<Users>
|
||
|
|
${u}
|
||
|
|
</Users>`:""}
|
||
|
|
</Extensions>
|
||
|
|
`}processMarkupComment(t){let{Guid:i,Date:n,Author:s,Comment:l,Viewpoint:u}=t;if(!(i&&n&&s&&(w7||u)))return null;let d=new w7(this.components,l??"");return d.guid=i,d.date=new Date(n),d.author=s,d.viewpoint=u?.Guid,d.modifiedAuthor=t.ModifiedAuthor,d.modifiedDate=t.ModifiedDate?new Date(t.ModifiedDate):void 0,d}getMarkupComments(t,i){var n;let s;if(i==="2.1"&&(s=t.Comment),i==="3"&&(s=(n=t.Topic.Comments)==null?void 0:n.Comment),!s)return[];s=Array.isArray(s)?s:[s];let l=s.map(d=>this.processMarkupComment(d)).filter(d=>d);return Array.isArray(l)?l:[l]}getMarkupLabels(t,i){var n;let s;return i==="2.1"&&(s=t.Topic.Labels),i==="3"&&(s=(n=t.Topic.Labels)==null?void 0:n.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(t,i){var n;let s;return i==="2.1"&&(s=t.Viewpoints),i==="3"&&(s=(n=t.Topic.Viewpoints)==null?void 0:n.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(t,i){var n;let s;return i==="2.1"&&(s=t.Topic.RelatedTopic),i==="3"&&(s=(n=t.Topic.RelatedTopics)==null?void 0:n.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(u=>u.Guid):[]}getMarkupDocumentReferences(t,i){var n;let s;return i==="2.1"&&(s=t.Topic.DocumentReference),i==="3"&&(s=(n=t.Topic.DocumentReferences)==null?void 0:n.DocumentReference),s?Array.isArray(s)?s:[s]:[]}async load(t){var i,n,s;let{fallbackVersionOnImport:l,ignoreIncompleteTopicsOnImport:u,updateExtensionsOnImport:d}=this.config,h=new hie;await h.loadAsync(t);let f=Object.values(h.files),I=l,y=f.find(V=>V.name.endsWith(".version"));if(y){let V=await y.async("string"),$=hB.xmlParser.parse(V).Version.VersionId;I=String($)}if(!(I&&(I==="2.1"||I==="3")))throw new Error(`BCFTopics: ${I} is not supported.`);let g=f.find(V=>V.name.endsWith(".extensions"));if(d&&g){let V=await g.async("string");cne(this,V)}let T=[],D=this.components.get(xT),L=f.filter(V=>V.name.endsWith(".bcfv"));for(let V of L){let $=await V.async("string"),re=hB.xmlParser.parse($).VisualizationInfo;if(!re){console.warn("Missing VisualizationInfo in Viewpoint");continue}let pe={},{Guid:de,ClippingPlanes:ge,Components:le,OrthogonalCamera:he,PerspectiveCamera:be}=re;if(de&&(pe.guid=de),le){let De={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};pe.components=De;let{Selection:Re,Visibility:je}=le;if(Re&&Re.Component){let At=Array.isArray(Re.Component)?Re.Component:[Re.Component];De.selection=At.map(Qe=>Qe.IfcGuid?{ifc_guid:Qe.IfcGuid}:null).filter(Qe=>Qe!==null)}if(je&&"DefaultVisibility"in je&&(De.visibility.default_visibility=je.DefaultVisibility),je&&je.Exceptions&&"Component"in je.Exceptions){let{Component:At}=je.Exceptions,Qe=Array.isArray(At)?At:[At];De.visibility.exceptions=Qe.map(ut=>ut.IfcGuid?{ifc_guid:ut.IfcGuid}:null).filter(ut=>ut!==null)}let pt;I==="2.1"&&(pt=le.ViewSetupHints),I==="3"&&(pt=(i=le.Visibility)==null?void 0:i.ViewSetupHints),pt&&("OpeningsVisible"in pt&&(De.visibility.view_setup_hints.openings_visible=pt.OpeningsVisible),"SpacesVisible"in pt&&(De.visibility.view_setup_hints.spaces_visible=pt.SpacesVisible),"SpaceBoundariesVisible"in pt&&(De.visibility.view_setup_hints.space_boundaries_visible=pt.SpaceBoundariesVisible));let{Coloring:ct}=le;if(ct&&ct.Color){let At=Array.isArray(ct.Color)?ct.Color:[ct.Color];for(let Qe of At){let{Color:ut,Component:yt}=Qe;if(!(ut.length===6||ut.length===8))continue;let mt=ut.length===6?ut:ut.slice(2),Dt=(Array.isArray(yt)?yt:[yt]).map(Rt=>Rt.IfcGuid?{ifc_guid:Rt.IfcGuid}:null).filter(Rt=>Rt!==null);De.coloring.push({color:mt,components:Dt})}}}if(he||be){let De=re.PerspectiveCamera??re.OrthogonalCamera,{CameraViewPoint:Re,CameraDirection:je}=De,pt=new Ne(Number(Re.X),Number(Re.Z),Number(-Re.Y)),ct=new Ne(Number(je.X),Number(je.Z),Number(-je.Y)),At={camera_view_point:{x:pt.x,y:pt.y,z:pt.z},camera_direction:{x:ct.x,y:ct.y,z:ct.z},aspect_ratio:"AspectRatio"in De?De.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in De&&(pe.orthogonal_camera={...At,view_to_world_scale:De.ViewToWorldScale}),"FieldOfView"in De&&(pe.perspective_camera={..
|
||
|
|
<Component IfcGuid="${g}" ${D??""} />`}}}else l=[...this.selectionComponents].map(u=>`<Component IfcGuid="${u}" />`).join(`
|
||
|
|
`);return l}createColorTags(){let t="";for(let[i,n]of this.componentColors.entries()){let s=n.map(l=>`
|
||
|
|
<Component IfcGuid="${l}" />`).join(`
|
||
|
|
`);t+=`<Color Color="${i}">
|
||
|
|
${s}
|
||
|
|
</Color>`}return t.length!==0?`<Coloring>
|
||
|
|
${t}
|
||
|
|
</Coloring>`:"<Coloring />"}toJSON(){let t=this._components.get(M6),i={guid:this.guid,components:{selection:[...this.selectionComponents].map(l=>({ifc_guid:l,authoring_tool_id:null})),coloring:[...this.componentColors].map(([l,u])=>({color:l,components:u.map(d=>({ifc_guid:d,authoring_tool_id:null}))})),visibility:{default_visibility:this.defaultVisibility,exceptions:[...this.exceptionComponents].map(l=>({ifc_guid:l,authoring_tool_id:null})),view_setup_hints:{spaces_visible:this.spacesVisible,space_boundaries_visible:this.spaceBoundariesVisible,openings_visible:this.openingsVisible}}},clipping_planes:[...this.clippingPlanes].map(l=>{let u=t.list.get(l);if(!u)return null;let d=u._controls.worldPosition??u.origin,{normal:h}=u;return{location:{x:d.x,y:-d.z,z:d.y},direction:{x:h.x,y:-h.z,z:h.y}}}).filter(l=>l!==null)};"field_of_view"in this.camera?i.perspective_camera=this.camera:i.orthogonal_camera=this.camera;let n=this._components.get(xT),s=n.snapshots.get(this.snapshot);if(s){let l=s.toString(),u=btoa(l),d=n.getSnapshotExtension(this.snapshot);i.snapshot={snapshot_type:d,snapshot_data:u}}return i}async serialize(t=this._managerVersion){let i=this._components.get($n),n=this.position;n.applyMatrix4(i.baseCoordinationMatrix.clone().invert());let s=this.direction;s.normalize();let l=new vi().makeRotationX(Math.PI/2),u=s.clone().applyMatrix4(l);u.normalize();let d=`<CameraViewPoint>
|
||
|
|
<X>${n.x}</X>
|
||
|
|
<Y>${-n.z}</Y>
|
||
|
|
<Z>${n.y}</Z>
|
||
|
|
</CameraViewPoint>`,h=`<CameraDirection>
|
||
|
|
<X>${s.x}</X>
|
||
|
|
<Y>${-s.z}</Y>
|
||
|
|
<Z>${s.y}</Z>
|
||
|
|
</CameraDirection>`,f=`<CameraUpVector>
|
||
|
|
<X>${u.x}</X>
|
||
|
|
<Y>${-u.z}</Y>
|
||
|
|
<Z>${u.y}</Z>
|
||
|
|
</CameraUpVector>`,I=`<AspectRatio>${this.camera.aspect_ratio}</AspectRatio>`,y="";"view_to_world_scale"in this.camera?y=`<OrthogonalCamera>
|
||
|
|
${d}
|
||
|
|
${h}
|
||
|
|
${f}
|
||
|
|
${I}
|
||
|
|
<ViewToWorldScale>${this.camera.view_to_world_scale}</ViewToWorldScale>
|
||
|
|
</OrthogonalCamera>`:"field_of_view"in this.camera&&(y=`<PerspectiveCamera>
|
||
|
|
${d}
|
||
|
|
${h}
|
||
|
|
${f}
|
||
|
|
${I}
|
||
|
|
<FieldOfView>${this.camera.field_of_view}</FieldOfView>
|
||
|
|
</PerspectiveCamera>`);let g=`<ViewSetupHints SpacesVisible="${this.spacesVisible??!1}" SpaceBoundariesVisible="${this.spaceBoundariesVisible??!1}" OpeningsVisible="${this.openingsVisible??!1}" />`,T=(await this.createComponentTags("selection")).trim(),D=(await this.createComponentTags("exception")).trim(),L=this.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
<VisualizationInfo Guid="${this.guid}">
|
||
|
|
<Components>
|
||
|
|
${t==="2.1"?g:""}
|
||
|
|
${T.length!==0?`<Selection>${T}</Selection>`:""}
|
||
|
|
<Visibility DefaultVisibility="${this.defaultVisibility}">
|
||
|
|
${t==="3"?g:""}
|
||
|
|
${D.length!==0?`<Exceptions>${D}</Exceptions>`:""}
|
||
|
|
</Visibility>
|
||
|
|
${L}
|
||
|
|
</Components>
|
||
|
|
${y}
|
||
|
|
</VisualizationInfo>`}},AK=class extends tR{constructor(){super(...arguments),Ye(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(t){this._config.overwriteColors.value=t}},fne=class DK extends Br{constructor(t){super(t),Ye(this,"enabled",!0),Ye(this,"world",null),Ye(this,"list",new ml),Ye(this,"snapshots",new ml),Ye(this,"isSetup",!1),Ye(this,"onSetup",new Wi),Ye(this,"config",new AK(this,this.components,"Viewpoints",DK.uuid)),Ye(this,"onDisposed",new Wi),t.add(DK.uuid,this)}create(t){let i=new wB(this.components,t);return i.world=this.world,t||this.list.set(i.guid,i),i}getSnapshotExtension(t){let i="jpeg",n=this.snapshots.get(t);if(!n)return i;let s=n.subarray(0,4),l="";for(let u=0;u<s.length;u++)l+=s[u].toString(16);return l.startsWith("89504e47")&&(i="png"),l.startsWith("ffd8ffe")&&(i="jpeg"),i}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};Ye(fne,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");var xT=fne,gB=class{constructor(t,i){Ye(this,"_components"),Ye(this,"_cameraOffset",10),Ye(this,"_planeHelper"),Ye(this,"_farPlaneHelper"),Ye(this,"_cameraHelper"),Ye(this,"onStateChanged",new Wi),Ye(this,"onUpdated",new Wi),Ye(this,"onDisposed",new Wi),Ye(this,"camera"),Ye(this,"plane",new es),Ye(this,"farPlane",new es),Ye(this,"id",hf.create()),Ye(this,"_open",!1),Ye(this,"_range",Ine.defaultRange),Ye(this,"_world",null),Ye(this,"_helpersVisible",!1),Ye(this,"_planesEnabled",!1),this._components=t,this.camera=new TB(this._components);let{threeOrtho:n}=this.camera;if(i?.id&&(this.id=i.id),i?.normal&&i?.point){let{normal:s,point:l}=i;this.plane.setFromNormalAndCoplanarPoint(s,l)}this._cameraHelper=new gC(n),this._planeHelper=new $S(this.plane,50),this._farPlaneHelper=new $S(this.farPlane,50),this.farPlaneHelperColor=new Ni("blue"),this.update()}get _planeNormalOpposite(){return this.plane.normal.clone().negate()}get _planePosition(){return this.plane.normal.clone().multiplyScalar(-this.plane.constant)}get _cameraPosition(){return this._planePosition.addScaledVector(this._planeNormalOpposite,this._cameraOffset)}set open(t){this._open=t,this.onStateChanged.trigger(["open"])}get open(){return this._open}set planeHelperColor(t){!Array.isArray(this._planeHelper.material)&&"color"in this._planeHelper.material&&this._planeHelper.material.color instanceof Ni&&(this._planeHelper.material.color=t)}set farPlaneHelperColor(t){!Array.isArray(this._farPlaneHelper.material)&&"color"in this._farPlaneHelper.material&&this._farPlaneHelper.material.color instanceof Ni&&(this._farPlaneHelper.material.color=t)}set range(t){this._range=t,this.update()}get range(){return this._range}set distance(t){this.plane.constant=t,this.update()}get distance(){return this.plane.constant}set world(t){this._world=t,this.camera.currentWorld=t,t&&(this.camera.projection.set("Orthographic"),this.camera.set("Plan"),this.camera.controls.dollySpeed=6,this.camera.controls.restThreshold=.005,this.update())}get world(){return this._world}set helpersVisible(t){if(!t){this._helpersVisible=t,this._planeHelper.removeFromParent(),this._farPlaneHelper.removeFromParent(),this._cameraHelper.removeFromParent();return}this.world&&(this._helpersVisible=t,this.world.scene.three.add(this._planeHelper,this._farPlaneHelper))}get helpersVisible(){return this._helpersVisible}set planesEnabled(t){let{world:i}=this;if(!i)return;let{renderer:n}=i;n&&(n.setPlane(t,this.plane),n.setPlane(t,this.farPlane),this._planesEnabled=t)}get planesEnabled(){return this._planesEnabled}dispose(){this.helpersVisible=!1;let t=this._components.get(vB);t.destroy(this._planeHelper),t.destroy(this._farPlaneHelper),t.destroy(this._cameraHelper),this.camera.dispose(),this.onDisposed.trigger()}update(){if(this.world){let t=this._cameraPosition,i=this._planePosition;this.camera.controls.setLookAt(t.x,t.y,t.z,i.x,i.y,i.z,!1)}this.farPlane.normal.copy(this._planeNormalOpposite),this.farPlane.constant=this.range-this.plane.constant,this.onUpdated.trigger()}flip(){this.plane.norma
|
||
|
|
varying vec2 vUv;
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
vUv = uv;
|
||
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
|
|
}
|
||
|
|
`,fragmentShader:`
|
||
|
|
#include <packing>
|
||
|
|
|
||
|
|
varying vec2 vUv;
|
||
|
|
uniform sampler2D tDiffuse;
|
||
|
|
uniform sampler2D tDepth;
|
||
|
|
uniform float cameraNear;
|
||
|
|
uniform float cameraFar;
|
||
|
|
|
||
|
|
|
||
|
|
float readDepth( sampler2D depthSampler, vec2 coord ) {
|
||
|
|
float fragCoordZ = texture2D( depthSampler, coord ).x;
|
||
|
|
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
||
|
|
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
||
|
|
}
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
//vec3 diffuse = texture2D( tDiffuse, vUv ).rgb;
|
||
|
|
float depth = readDepth( tDepth, vUv );
|
||
|
|
|
||
|
|
gl_FragColor.rgb = 1.0 - vec3( depth );
|
||
|
|
gl_FragColor.a = 1.0;
|
||
|
|
}
|
||
|
|
`,uniforms:{cameraNear:{value:n.near},cameraFar:{value:n.far},tDiffuse:{value:null},tDepth:{value:null}}});let s=new Mp(2,2);this._postQuad=new Ri(s,this.depthMaterial),this.scene.add(this._postQuad);let l=`
|
||
|
|
addEventListener("message", (event) => {
|
||
|
|
const { buffer } = event.data;
|
||
|
|
const colors = new Set();
|
||
|
|
for (let i = 0; i < buffer.length; i += 4) {
|
||
|
|
const r = buffer[i];
|
||
|
|
colors.add(r);
|
||
|
|
}
|
||
|
|
postMessage({ colors });
|
||
|
|
});
|
||
|
|
`,u=new Blob([l],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(u)),this.worker.addEventListener("message",this.handleWorkerMessage)}dispose(){this.enabled=!1,this.onDistanceComputed.reset(),this.worker.terminate(),this.tempRT.dispose(),this.resultRT.dispose();let t=[...this.scene.children];this.excludedObjects.clear();for(let i of t)i.removeFromParent();this._postQuad.geometry.dispose(),this._postQuad.removeFromParent(),this._buffer=null,this.onDisposed.reset()}},CK=class extends VV{constructor(){super(...arguments),Ye(this,"_distanceRenderer"),Ye(this,"autoBias",!0),Ye(this,"_defaultShadowConfig",{cascade:1,resolution:512}),Ye(this,"_lightsWithShadow",new Map),Ye(this,"_isComputingShadows",!1),Ye(this,"_shadowsEnabled",!0),Ye(this,"_bias",0),Ye(this,"recomputeShadows",t=>{if(!this._shadowsEnabled)return;if(this.autoBias&&(this.bias=-.005),t*=1.5,!this.currentWorld)throw new Error("A world needs to be assigned to the scene before computing shadows!");if(!this._lightsWithShadow.size)throw new Error("No shadows found!");let n=this.currentWorld.camera.three;if(!(n instanceof no)&&!(n instanceof v0))throw new Error("Invalid camera type!");let s=new Ne;n.getWorldDirection(s);let l=t,u=new Ne;u.copy(this.config.directionalLight.position),u.normalize();for(let[d,h]of this._lightsWithShadow){let f=this.directionalLights.get(h);if(!f)throw new Error("Light not found.");let I=new Ne;I.copy(s);let y=d===this._lightsWithShadow.size-1,g=y?l/2:l*2/3;I.multiplyScalar(g),I.add(n.position);let T=l-g,D=new Ne;D.copy(u),D.multiplyScalar(T),f.target.position.copy(I),f.position.copy(I),f.position.add(D),f.shadow.camera.right=T,f.shadow.camera.left=-T,f.shadow.camera.top=T,f.shadow.camera.bottom=-T,f.shadow.camera.far=T*2,f.shadow.camera.updateProjectionMatrix(),f.shadow.camera.updateMatrix(),y||(l/=3)}this._isComputingShadows=!1})}get bias(){return this._bias}set bias(t){this._bias=t;for(let[,i]of this._lightsWithShadow){let n=this.directionalLights.get(i);n&&(n.shadow.bias=t)}}get shadowsEnabled(){return this._shadowsEnabled}set shadowsEnabled(t){this._shadowsEnabled=t;for(let[,i]of this.directionalLights)i.castShadow=t}get distanceRenderer(){if(!this._distanceRenderer)throw new Error("You must set up this component before accessing the distance renderer!");return this._distanceRenderer}setup(t){super.setup(t);let i={...this._defaultConfig,...this._defaultShadowConfig,...t};if(i.cascade<=0)throw new Error("Config.shadows.cascade must be a natural number greater than 0!");if(i.cascade>1)throw new Error("Multiple shadows not supported yet!");if(!this.currentWorld)throw new Error("A world needs to be assigned to the scene before setting it up!");for(let[,n]of this.directionalLights)n.target.removeFromParent(),n.removeFromParent(),n.dispose();this.directionalLights.clear(),this._distanceRenderer||(this._distanceRenderer=new NK(this.components,this.currentWorld),this._distanceRenderer.onDistanceComputed.add(this.recomputeShadows)),this._lightsWithShadow.clear();for(let n=0;n<i.cascade;n++){let s=new iv;s.intensity=this.config.directionalLight.intensity,s.color=this.config.directionalLight.color,s.position.copy(this.config.directionalLight.position),s.shadow.mapSize.width=i.resolution,s.shadow.mapSize.height=i.resolution,this.three.add(s,s.target),this.directionalLights.set(s.uuid,s),this._lightsWithShadow.set(n,s.uuid),s.castShadow=!0,s.shadow.bias=this._bias}}dispose(){super.dispose(),this._distanceRenderer&&this._distanceRenderer.dispose(),this._lightsWithShadow.clear()}async updateShadows(){this._isComputingShadows||!this._shadowsEnabled||(this._isComputingShadows=!0,await this.distanceRenderer.compute())}},R5=class{constructor(t){Ye(this,"cardinality","required"),Ye(this,"instructions"),Ye(this,"evalRequirement",(i,n,s,l)=>{let u={parameter:s,currentValue:i,requiredValue:n,pass:!1};l&&this.addCheckResult(u,l);let d=!1;if(n.type==="simple"&&(d=i===n.parameter),n.type==="enumeration"&&(d=n.parameter.includes(i)),n.type==="pattern"&&(d=new RegExp(n.parameter).test(String(i))),n.type==="length"){let{min:h,lengt
|
||
|
|
${t.parameter.map(l=>`<xs:enumeration value="${l}" />`).join(`
|
||
|
|
`)}
|
||
|
|
</xs:restriction>`),t.type==="pattern"&&(i=`<xs:restriction base="xs:string">
|
||
|
|
<xs:pattern value="${t.parameter}" />
|
||
|
|
</xs:restriction>`),t.type==="bounds"){let{min:s,minInclusive:l,max:u,maxInclusive:d}=t.parameter,h="";s!==void 0&&(h=`<xs:min${l?"Inclusive":"Exclusive"} value="${s}">`);let f="";u!==void 0&&(f=`<xs:max${d?"Inclusive":"Exclusive"} value="${u}">`),i=`<xs:restriction base="xs:double">
|
||
|
|
${h}
|
||
|
|
${f}
|
||
|
|
</xs:restriction>`}if(t.type==="length"){let{length:s,min:l,max:u}=t.parameter,d="";s!==void 0&&l===void 0&&u===void 0&&(d=`<xs:length value="${s}" />`);let h="";l!==void 0&&s===void 0&&(h=`<xs:minLength value="${l}" />`);let f="";u!==void 0&&s===void 0&&(f=`<xs:maxLength value="${u}" />`),i=`<xs:restriction base="xs:string">
|
||
|
|
${d}
|
||
|
|
${h}
|
||
|
|
${f}
|
||
|
|
</xs:restriction>`}return`<${e[0].toLowerCase()+e.slice(1)}>
|
||
|
|
${i}
|
||
|
|
</${e[0].toLowerCase()+e.slice(1)}>`},QV=class extends R5{constructor(t,i){super(t),Ye(this,"facetType","Attribute"),Ye(this,"name"),Ye(this,"value"),this.name=i}serialize(t){let i=MT("Name",this.name),n=MT("Value",this.value),s="";return t==="requirement"&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<attribute ${s}>
|
||
|
|
${i}
|
||
|
|
${n}
|
||
|
|
</attribute>`}async getEntities(){}async test(t,i,n={skipIfFails:!0}){let s=this._components.get($n);for(let[l,u]of Object.entries(t)){let d=s.list.get(l);if(!d)continue;let h=await d.getItemsData([...u]);for(let f of h){let I=this.getItemChecks(i,l,f,n.skipIfFails);if(!I)continue;let g=Object.keys(f).filter(D=>{let L=this.evalRequirement(D,this.name,"Name");if(!L)return!1;let O=f[D];return Array.isArray(O)?!0:O===null||O.value===null?this.cardinality==="optional"||this.cardinality==="prohibited":Array.isArray(O.value)&&O.value.length===0||typeof O.value=="string"&&O.value.trim()===""?!1:L}),T=g.length>0;if(I.push({parameter:"Name",currentValue:T?g[0]:null,requiredValue:this.name,pass:this.cardinality==="prohibited"?!T:T}),this.value)if(g[0]){let D=f[g[0]];Array.isArray(D)?I.push({parameter:"Value",currentValue:null,requiredValue:this.value,pass:this.cardinality==="prohibited"}):Array.isArray(D.value)?I.push({parameter:"Value",currentValue:null,requiredValue:this.value,pass:this.cardinality==="prohibited"}):this.evalRequirement(D.value,this.value,"Value",I)}else I.push({parameter:"Value",currentValue:null,requiredValue:this.value,pass:this.cardinality==="prohibited"})}}}},JV=class extends R5{constructor(t,i){super(t),Ye(this,"facetType","Classification"),Ye(this,"system"),Ye(this,"value"),Ye(this,"uri"),this.system=i}serialize(t){let i=MT("System",this.system),n=MT("Value",this.value),s="";return t==="requirement"&&(s+=`cardinality="${this.cardinality}"`,s+=this.uri?`uri=${this.uri}`:"",s+=this.instructions?`instructions="${this.instructions}"`:""),`<classification ${s}>
|
||
|
|
${i}
|
||
|
|
${n}
|
||
|
|
</classification>`}async getEntities(t,i){}async test(t,i){}},g7=class extends R5{constructor(t,i){super(t),Ye(this,"facetType","Entity"),Ye(this,"name"),Ye(this,"predefinedType"),this.name=i}serialize(t){let i=MT("Name",this.name),n=MT("Name",this.predefinedType),s="";return t==="requirement"&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<entity ${s}>
|
||
|
|
${i}
|
||
|
|
${n}
|
||
|
|
</entity>`}async getEntities(t,i){let n=this._components.get($n),s=new Map;for(let[u,d]of n.list){if(!t.find(I=>I.test(u)))continue;let f=await d.getCategories();for(let I of f){if(!await this.evalName(I))continue;let g=s.get(u);g||(g=[],s.set(u,g)),g.push(I)}}let l={};if(await Promise.all(Array.from(s.entries()).map(async([u,d])=>{let h=n.list.get(u);if(!h)return;let f=d.map(g=>new RegExp(`^${g}$`)),I=await h.getItemsOfCategories(f),y=Object.values(I).flat();l[u]=new Set(y)})),!this.predefinedType){Qc.add(i,l);return}for(let[u,d]of Object.entries(l)){let h=n.list.get(u);if(!h)continue;let f=await h.getItemsData([...d]);for(let I of f){if(!("value"in I._localId))continue;await this.evalPredefinedType(u,I)&&Qc.append(i,u,I._localId.value)}}}async test(t,i,n){let s=this._components.get($n);for(let[l,u]of Object.entries(t)){let d=s.list.get(l);if(!d)continue;let h=await d.getItemsData([...u]);for(let f of h){if(!("value"in f._category))continue;let I=this.getItemChecks(i,l,f,n.skipIfFails);I&&(await this.evalName(f._category.value,I),await this.evalPredefinedType(l,f,I))}}}async evalName(t,i){return this.evalRequirement(t,this.name,"Name",i)}async evalPredefinedType(t,i,n){if(!this.predefinedType||!("value"in i.PredefinedType))return null;let s=typeof this.predefinedType.parameter=="string"&&this.predefinedType.parameter==="USERDEFINED",l=i.PredefinedType.value;if(l==="USERDEFINED"&&!s){let h=Object.keys(i).find(f=>/^((?!Predefined).)*Type$/.test(f));if(h){let f=i[h];"value"in f&&(l=f.value)}else l="USERDEFINED"}if(!l){let h=this._components.get($n).list.get(t);if(h&&"value"in i._localId){let[f]=await h.getItemsData([i._localId.value],{relations:{IsTypedBy:{attributes:!0,relations:!1}}});if(Array.isArray(f.IsTypedBy)){let I=f.IsTypedBy[0];if(I&&"value"in I.PredefinedType&&(l=I.PredefinedType.value,l==="USERDEFINED"&&!s)){let g=Object.keys(I).find(T=>/^((?!Predefined).)*Type$/.test(T));if(g){let T=I[g];"value"in T&&(l=T.value)}else l="USERDEFINED"}}}}return this.evalRequirement(l,this.predefinedType,"PredefinedType",n)}},XV=class extends R5{constructor(t,i,n){super(t),Ye(this,"facetType","Property"),Ye(this,"propertySet"),Ye(this,"baseName"),Ye(this,"value"),Ye(this,"dataType"),Ye(this,"uri"),Ye(this,"_unsupportedTypes",["IFCCOMPLEXPROPERTY","IFCPHYSICALCOMPLEXQUANTITY"]),this.propertySet=i,this.baseName=n}serialize(t){let i=MT("PropertySet",this.propertySet),n=MT("BaseName",this.baseName),s=MT("Value",this.value),l=this.dataType?`dataType=${this.dataType}`:"",u="";return t==="requirement"&&(u+=`cardinality="${this.cardinality}"`,u+=this.uri?`uri=${this.uri}`:"",u+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${l} ${u}>
|
||
|
|
${i}
|
||
|
|
${n}
|
||
|
|
${s}
|
||
|
|
</property>`}async getEntities(t,i){let n=this._components.get($n);for(let[s,l]of n.list){if(!t.find(I=>I.test(s)))continue;let d=await l.getItemsOfCategories([/PROPERTYSET/,/ELEMENTQUANTITY/]),h=Object.values(d).flat();if(h.length===0)continue;let f=await l.getItemsData(h,{relations:{HasProperties:{attributes:!0,relations:!1},DefinesOcurrence:{attributes:!0,relations:!1}}});for(let I of f){if(!("value"in I._localId&&"value"in I._category&&"value"in I.Name&&Array.isArray(I.DefinesOcurrence))||!this.evalRequirement(I.Name.value,this.propertySet,"PropertySet"))continue;let g;if(I._category.value==="IFCPROPERTYSET"&&(g="HasProperties"),I._category.value==="IFCELEMENTQUANTITY"&&(g="Quantities"),!g)continue;let T=I[g];if(Array.isArray(T))for(let D of T){let L=Object.keys(D),O=L.find($=>/Name/.test($));if(!(O&&"value"in D[O]))continue;let N=D[O];if(!("value"in N)||!this.evalRequirement(N.value,this.baseName,"BaseName"))continue;if(this.value){let $=L.find(de=>/Value/.test(de));if(!$)continue;let re=D[$];if(!("value"in re)||!this.evalRequirement(re.value,this.value,"Value"))continue}let V=I.DefinesOcurrence.map($=>"value"in $._localId&&typeof $._localId.value=="number"?$._localId.value:null).filter($=>$!==null);Qc.append(i,s,...V)}}}}async test(t,i,n={skipIfFails:!0}){let s=this._components.get($n);for(let[l,u]of Object.entries(t)){let d=s.list.get(l);if(!d)continue;let h=await d.getItemsData([...u],{relations:{IsDefinedBy:{attributes:!0,relations:!0},IsTypedBy:{attributes:!0,relations:!1},HasPropertySets:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});for(let f of h){let I=this.getItemChecks(i,l,f,n.skipIfFails);if(!I)continue;let g=(await this.getPsets(f)).filter(T=>!("value"in T.Name)||!this.evalRequirement(T.Name.value,this.propertySet,"PropertySet")?!1:(I.push({currentValue:T.Name.value,parameter:"PropertySet",pass:!0,requiredValue:this.propertySet}),!0));if(g.length===0){I.push({currentValue:null,parameter:"PropertySet",pass:!1,requiredValue:this.propertySet});continue}for(let T of g){let D=this.getPropertyListName(T);if(!D)continue;let L=T[D];if(!Array.isArray(L)){I.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:this.baseName});continue}let O=L.filter(N=>!("value"in N._category&&"value"in N.Name)||this._unsupportedTypes.includes(N._category.value)||!this.evalRequirement(N.Name.value,this.baseName,"BaseName")?!1:(I.push({currentValue:N.Name.value,parameter:"BaseName",pass:!0,requiredValue:this.baseName}),!0));if(O.length===0){I.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:this.baseName});continue}for(let N of O)this.evalValue(N,I),this.evalDataType(N,I),this.evalURI()}}}}getPropertyListName(t){let i;return"value"in t._category&&(t._category.value==="IFCPROPERTYSET"&&(i="HasProperties"),t._category.value==="IFCELEMENTQUANTITY"&&(i="Quantities")),i}getValueKey(t){return Object.keys(t).find(i=>/Value/.test(i)||/Values/.test(i))}getTypePsets(t){if(!Array.isArray(t.IsTypedBy))return[];let[i]=t.IsTypedBy;return i&&Array.isArray(i.HasPropertySets)?i.HasPropertySets:[]}async getPsets(t){let i=this.getTypePsets(t);if(!Array.isArray(t.IsDefinedBy))return i;let n=[];for(let s of t.IsDefinedBy){if(!("value"in s.Name))continue;let l=s.Name.value,u=this.getPropertyListName(s);if(!(l&&u))continue;let d=i.find(h=>"value"in h.Name?h.Name.value===l:!1);if(d&&Array.isArray(d.HasProperties)&&Array.isArray(s.HasProperties))for(let h of d.HasProperties){if(!("value"in h.Name))continue;let f=h.Name.value;s.HasProperties.find(y=>"value"in y.Name?y.Name.value===f:!1)||s.HasProperties.push(h)}n.push(s)}return n}evalValue(t,i){let n=this.getValueKey(t),s=t[n];if(!("value"in s))return!1;if(this.value){if(!n)return i?.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:this.value}),!1;let l=structuredClone(this.value);return s.type==="IFCLABEL"&&l.type==="simple"&&(l.parameter=String(l.parameter)),this.evalRequirement(s.value,l,"Value",i)}return n&&typeof s.value=="string"&&s.value.trim()===""?(i?.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:this.val
|
||
|
|
${i}
|
||
|
|
</material>`}async getEntities(t,i){let n=this._components.get($n);for(let[s,l]of n.list){if(!t.find(I=>I.test(s)))continue;let d=await l.getItemsOfCategories(this._ifcMaterialEntities),h=Object.values(d).flat();if(h.length===0)continue;let f=await l.getItemsData(h,{relations:{AssociatedTo:{attributes:!0,relations:!1},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(let I of f){if(!("value"in I._localId&&"value"in I._category&&Array.isArray(I.AssociatedTo))||!this.hasValidMaterial(I))continue;let g=I.AssociatedTo.map(T=>"value"in T._localId&&T._localId.value?T._localId.value:null).filter(T=>T!==null);Qc.append(i,s,...g)}}}async test(t,i,n={skipIfFails:!0}){let s=this._components.get($n);for(let[l,u]of Object.entries(t)){let d=s.list.get(l);if(!d)continue;let h=await d.getItemsData([[...u][0]],{relations:{AssociatedTo:{attributes:!1,relations:!1},HasAssociations:{attributes:!0,relations:!0},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(let f of h){let I=this.getItemChecks(i,l,f,n.skipIfFails);if(I){if(!Array.isArray(f.HasAssociations)){I.push({parameter:null,currentValue:null,requiredValue:this.value,pass:!1});continue}for(let y of f.HasAssociations){if(!this._ifcMaterialEntities.some(T=>"value"in y._category?T.test(y._category.value):!1))continue;if(this.hasValidMaterial(y,I))break}}}}}hasValidMaterial(t,i){let n=!1;if("value"in t._category&&t._category.value==="IFCMATERIAL")this.evalValue(t,i)&&(n=!0);else for(let[s,l]of Object.entries(t))if(["ForLayerSet","MaterialLayers","Material","MaterialConstituents","Materials"].includes(s)&&Array.isArray(l)){for(let u of l)if("value"in u._category&&u._category.value==="IFCMATERIAL"){if(this.evalValue(u,i)){n=!0;break}}else if(this.hasValidMaterial(u)){n=!0;break}}return n}evalValue(t,i){if(!this.value)return i?.push({parameter:null,currentValue:t.Name&&"value"in t.Name?t.Name.value:null,pass:!0}),!0;if(!("value"in t._category&&t._category.value==="IFCMATERIAL"))return null;let n=!1;return t.Name&&"value"in t.Name&&(n=this.evalRequirement(t.Name.value,this.value,"Value",i)),n||(t.Category&&"value"in t.Category&&(n=this.evalRequirement(t.Category.value,this.value,"Value",i)),n)}},tk=class extends R5{constructor(t,i){super(t),Ye(this,"facetType","PartOf"),Ye(this,"_entityFacet"),Ye(this,"_entity"),Ye(this,"relation"),Ye(this,"cardinality","required"),this._entity=i,this._entityFacet=new g7(t,i.name),this._entityFacet.predefinedType=i.predefinedType}set entity(t){this._entity=t;let{name:i,predefinedType:n}=t;this._entityFacet=new g7(this._components,i),this._entityFacet.predefinedType=n}get entity(){return this._entity}serialize(){return""}async getEntities(t,i){}async test(t){}},ik=class{constructor(t,i,n){Ye(this,"name"),Ye(this,"ifcVersion",new Set),Ye(this,"identifier",hf.create()),Ye(this,"description"),Ye(this,"instructions"),Ye(this,"requirementsDescription"),Ye(this,"applicability",new uf),Ye(this,"requirements",new uf),Ye(this,"components"),this.components=t,this.name=i;for(let s of n)this.ifcVersion.add(s)}set(t){let i=t,n=this;for(let l in t){if(l==="identifier")continue;let u=i[l];l in this&&(n[l]=u)}return this.components.get(mne).list.set(this.identifier,this),this}async test(t,i={skipIfFails:!0}){let n=new ml;if(this.requirements.size===0)return n;let s={},l=[];for(let d of this.applicability)l.push(d.getEntities(t,s));await Promise.all(l);let u=[];for(let d of this.requirements)u.push(d.test(s,n,i));return await Promise.all(u),n}serialize(){let t=`name="${this.name}"`,i=this.identifier?`identifier="${this.identifier}"`:"",n=this.description?`description="${this.description}"`:"",s=this.instructions?`instructions="${this.instructions}"`:"";return`<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${t} ${i} ${n} ${s}>
|
||
|
|
<applicability minOccurs="1" maxOccurs="unbounded">
|
||
|
|
${[...this.applicability].map(u=>u.serialize("applicability")).join(`
|
||
|
|
`)}
|
||
|
|
</applicability>
|
||
|
|
<requirements>
|
||
|
|
${[...this.requirements].map(u=>u.serialize("requirement")).join(`
|
||
|
|
`)}
|
||
|
|
</requirements>
|
||
|
|
</specification>`}},mm=e=>{if(!e)return;let t={};if("simpleValue"in e&&(t.type="simple",t.parameter=e.simpleValue),"restriction"in e){let i=e.restriction,n=Object.keys(i);if("pattern"in i&&(t.type="pattern",t.parameter=i.pattern.value),"enumeration"in i){t.type="enumeration";let s=i.enumeration.map(({value:l})=>i.base.includes("string")?String(l):i.base.includes("integer")||i.base.includes("double")?Number(l):l);t.parameter=s}if(n.some(s=>["minInclusive","minExclusive","maxInclusive","maxExclusive"].includes(s))){t.type="bounds";let s={},l=n.find(d=>d.includes("min")),u=n.find(d=>d.includes("max"));l&&(s.minInclusive=l==="minInclusive",s.min=i[l].value),u&&(s.maxInclusive=u==="maxInclusive",s.max=i[u].value),t.parameter=s}if(n.some(s=>["minLength","length","maxLength"].includes(s))){t.type="length";let s={};i.length!==void 0&&(s.length=i.length.value),i.minLength!==void 0&&(s.min=i.minLength.value),i.maxLength!==void 0&&(s.max=i.maxLength.value),t.parameter=s}}if(t.parameter!==void 0)return t},wie=(e,t)=>{let i=[];for(let n of t){let s=n.name,l=mm(s);if(!l)continue;let u=new g7(e,l);n.cardinality&&(u.cardinality=n.cardinality),u.predefinedType=mm(n.predefinedType),u.instructions=n.instructions,i.push(u)}return i},gie=(e,t)=>{let i=[];for(let n of t){let s=n.name,l=mm(s);if(!l)continue;let u=new QV(e,l);n.cardinality&&(u.cardinality=n.cardinality),u.value=mm(n.value),u.instructions=n.instructions,i.push(u)}return i},vie=(e,t)=>{let i=[];for(let n of t){let s=new ek(e);n.cardinality&&(s.cardinality=n.cardinality);let l=mm(n.value);l?.type==="enumeration"&&Array.isArray(l.parameter)&&(l.parameter=l.parameter.map(String)),s.value=l,s.uri=n.uri,s.instructions=n.instructions,i.push(s)}return i},Rie=(e,t)=>{let i=[];for(let n of t){let s=n.propertySet,l=n.baseName,u=mm(s),d=mm(l);if(!(d&&u))continue;let h=new XV(e,u,d);n.cardinality&&(h.cardinality=n.cardinality);let f=mm(n.value);h.value=f,h.dataType=n.dataType,h.uri=n.uri,h.instructions=n.instructions,i.push(h)}return i},Sie=(e,t)=>{let i=[];for(let n of t){let s=n.system,l=mm(s);if(!l)continue;let u=new JV(e,l);n.cardinality&&(u.cardinality=n.cardinality);let d=mm(n.value);d?.type==="simple"&&(d.parameter=String(d.parameter)),d?.type==="enumeration"&&Array.isArray(d.parameter)&&(d.parameter=d.parameter.map(String)),u.value=d,u.uri=n.uri,u.instructions=n.instructions,i.push(u)}return i},Aie=(e,t)=>{let i=[];for(let n of t){let s=mm(n.entity.name);if(!s)continue;let l=mm(n.entity.predefinedType),u=new tk(e,{name:s,predefinedType:l});u.relation=n.relation,n.cardinality&&(u.cardinality=n.cardinality),u.instructions=n.instructions,i.push(u)}return i},GK=class bK extends Br{constructor(t){super(t),Ye(this,"enabled",!0),Ye(this,"IDSInfo"),Ye(this,"list",new ml),t.add(bK.uuid,this)}getModelIdMap(t){let i={},n={};for(let[s,l]of t){let d=[...l].filter(([,I])=>I.pass).map(([I])=>I);Qc.append(i,s,...d);let f=[...l].filter(([,I])=>!I.pass).map(([I])=>I);Qc.append(n,s,...f)}return{pass:i,fail:n}}create(t,i,n){let s=new ik(this.components,t,i);return n&&(s.identifier=n),this.list.set(s.identifier,s),s}load(t){let i=[],n=bK.xmlParser.parse(t).ids,{specifications:s,info:l}=n;if(this.IDSInfo={...l},s&&s.specification){let u=Array.isArray(s.specification)?s.specification:[s.specification];for(let d of u){let{name:h,ifcVersion:f,description:I,instructions:y,identifier:g}=d;if(!(h&&f))continue;let T=[],D=[],{applicability:L,requirements:O}=d;if(L){let{maxOccurs:V,...$}=L,re=Array.isArray($)?$:[$];for(let pe of re)for(let de in pe){let ge=Array.isArray(pe[de])?pe[de]:[pe[de]];if(de==="entity"){let le=wie(this.components,ge);T.push(...le)}if(de==="attribute"){let le=gie(this.components,ge);T.push(...le)}if(de==="material"){let le=vie(this.components,ge);T.push(...le)}if(de==="classification"){let le=Sie(this.components,ge);T.push(...le)}if(de==="property"){let le=Rie(this.components,ge);T.push(...le)}if(de==="partOf"){let le=Aie(this.components,ge);T.push(...le)}}}let N;if(O){let{maxOccurs:V,...$}=O;N=O.description;let re=Array.isArray($)?$:[$];for(let pe of re)for(let de in pe){let ge=Array.
|
||
|
|
<!-- Made with That Open Engine ${UK.release} (https://github.com/thatopen/engine_components) -->
|
||
|
|
<info>
|
||
|
|
<title>${t.title}</title>
|
||
|
|
${t.copyright?`<copyright>${t.copyright}</copyright>`:""}
|
||
|
|
${t.version?`<version>${t.version}</version>`:""}
|
||
|
|
${t.description?`<description>${t.description}</description>`:""}
|
||
|
|
${t.author?`<author>${t.author}</author>`:""}
|
||
|
|
${t.date?`<date>${t.date.toISOString().split("T")[0]}</date>`:""}
|
||
|
|
${t.purpose?`<purpose>${t.purpose}</purpose>`:""}
|
||
|
|
${t.milestone?`<milestone>${t.milestone}</milestone>`:""}
|
||
|
|
</info>
|
||
|
|
<specifications>
|
||
|
|
${[...n].map(l=>l.serialize()).join(`
|
||
|
|
`)}
|
||
|
|
</specifications>
|
||
|
|
</ids>`}};Ye(GK,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c");Ye(GK,"xmlParser",new sk.XMLParser({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));var mne=GK,yne=class Ene extends Br{constructor(t){super(t),Ye(this,"enabled",!0),t.add(Ene.uuid,this)}static distanceFromPointToLine(t,i,n,s=!1){let l=new ks,u=new Ne;return l.set(i,n),l.closestPointToPoint(t,s,u),u.distanceTo(t)}round(t){t.x=Math.trunc(t.x*1e3)/1e3,t.y=Math.trunc(t.y*1e3)/1e3,t.z=Math.trunc(t.z*1e3)/1e3}async getVolumeFromFragments(t){return console.warn("getVolumeFromFragments is deprecated. Use getItemsVolume instead."),this.getItemsVolume(t)}async getItemsVolume(t){let i=0,n=this.components.get($n);for(let[s,l]of Object.entries(t)){let u=n.list.get(s);u&&(i+=await u.getItemsVolume([...l]))}return i}static convertUnits(t,i,n,s=2){let l={m:1,cm:.01,mm:.001,km:1e3,m2:1,cm2:1e-4,mm2:1e-6,km2:1e6,m3:1,cm3:1e-6,mm3:1e-9,km3:1e9};if(!l[i]||!l[n])throw new Error("Invalid units provided for conversion.");if(!Number.isInteger(s)||s<0||s>5)throw new Error("Precision must be an integer between 0 and 5.");let u=l[i]/l[n],d=t*u,h=10**s;return Math.round(d*h)/h}};Ye(yne,"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");var sEe=yne;var oEe=xoe(gne(),1);var export_JSZip=oEe.default;export{export_JSZip as JSZip,Tne as OBC,$F as THREE};
|
||
|
|
/*! Bundled license information:
|
||
|
|
|
||
|
|
jszip/dist/jszip.min.js:
|
||
|
|
@thatopen/components/dist/index.mjs:
|
||
|
|
(*!
|
||
|
|
|
||
|
|
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
||
|
|
<http://stuartk.com/jszip>
|
||
|
|
|
||
|
|
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
||
|
|
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
|
||
|
|
|
||
|
|
JSZip uses the library pako released under the MIT license :
|
||
|
|
https://github.com/nodeca/pako/blob/main/LICENSE
|
||
|
|
*)
|
||
|
|
|
||
|
|
three/build/three.core.js:
|
||
|
|
three/build/three.module.js:
|
||
|
|
(**
|
||
|
|
* @license
|
||
|
|
* Copyright 2010-2025 Three.js Authors
|
||
|
|
* SPDX-License-Identifier: MIT
|
||
|
|
*)
|
||
|
|
|
||
|
|
@thatopen/fragments/dist/index.mjs:
|
||
|
|
(*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
|
||
|
|
|
||
|
|
@thatopen/components/dist/index.mjs:
|
||
|
|
(*!
|
||
|
|
* camera-controls
|
||
|
|
* https://github.com/yomotsu/camera-controls
|
||
|
|
* (c) 2017 @yomotsu
|
||
|
|
* Released under the MIT License.
|
||
|
|
*)
|
||
|
|
*/
|