2026-04-25 18:59:02 +01:00
var vRe = Object . create ; var gee = Object . defineProperty ; var RRe = Object . getOwnPropertyDescriptor ; var SRe = Object . getOwnPropertyNames ; var ARe = Object . getPrototypeOf , bRe = Object . prototype . hasOwnProperty ; var qU = ( 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 NRe = ( e , t ) => ( ) => ( t || e ( ( t = { exports : { } } ) . exports , t ) , t . exports ) , wee = ( e , t ) => { for ( var i in t ) gee ( e , i , { get : t [ i ] , enumerable : ! 0 } ) } , _Re = ( e , t , i , n ) => { if ( t && typeof t == "object" || typeof t == "function" ) for ( let s of SRe ( t ) ) ! bRe . call ( e , s ) && s !== i && gee ( e , s , { get : ( ) => t [ s ] , enumerable : ! ( n = RRe ( t , s ) ) || n . enumerable } ) ; return e } ; var DRe = ( e , t , i ) => ( i = e != null ? vRe ( ARe ( e ) ) : { } , _Re ( t || ! e || ! e . _ _esModule ? gee ( i , "default" , { value : e , enumerable : ! 0 } ) : i , e ) ) ; var m4e = NRe ( ( I4e , V0e ) => { ( function ( e ) { typeof I4e == "object" && typeof V0e < "u" ? V0e . 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 ( l , d ) { if ( ! i [ l ] ) { if ( ! t [ l ] ) { var h = typeof qU == "function" && qU ; if ( ! d && h ) return h ( l , ! 0 ) ; if ( o ) return o ( l , ! 0 ) ; var p = new Error ( "Cannot find module '" + l + "'" ) ; throw p . code = "MODULE_NOT_FOUND" , p } var I = i [ l ] = { exports : { } } ; t [ l ] [ 0 ] . call ( I . exports , function ( m ) { var y = t [ l ] [ 1 ] [ m ] ; return s ( y || m ) } , I , I . exports , e , t , i , n ) } return i [ l ] . exports } for ( var o = typeof qU == "function" && qU , r = 0 ; r < n . length ; r ++ ) s ( n [ r ] ) ; return s } ) ( { 1 : [ function ( e , t , i ) { "use strict" ; var n = e ( "./utils" ) , s = e ( "./support" ) , o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ; i . encode = function ( r ) { for ( var l , d , h , p , I , m , y , T = [ ] , R = 0 , b = r . length , A = b , O = n . getTypeOf ( r ) !== "string" ; R < r . length ; ) A = b - R , h = O ? ( l = r [ R ++ ] , d = R < b ? r [ R ++ ] : 0 , R < b ? r [ R ++ ] : 0 ) : ( l = r . charCodeAt ( R ++ ) , d = R < b ? r . charCodeAt ( R ++ ) : 0 , R < b ? r . charCodeAt ( R ++ ) : 0 ) , p = l >> 2 , I = ( 3 & l ) << 4 | d >> 4 , m = 1 < A ? ( 15 & d ) << 2 | h >> 6 : 64 , y = 2 < A ? 63 & h : 64 , T . push ( o . charAt ( p ) + o . charAt ( I ) + o . charAt ( m ) + o . charAt ( y ) ) ; return T . join ( "" ) } , i . decode = function ( r ) { var l , d , h , p , I , m , y = 0 , T = 0 , R = "data:" ; if ( r . substr ( 0 , R . length ) === R ) throw new Error ( "Invalid base64 input, it looks like a data url." ) ; var b , A = 3 * ( r = r . replace ( /[^A-Za-z0-9+/=]/g , "" ) ) . length / 4 ; if ( r . charAt ( r . length - 1 ) === o . charAt ( 64 ) && A -- , r . charAt ( r . length - 2 ) === o . charAt ( 64 ) && A -- , A % 1 != 0 ) throw new Error ( "Invalid base64 input, bad content length." ) ; for ( b = s . uint8array ? new Uint8Array ( 0 | A ) : new Array ( 0 | A ) ; y < r . length ; ) l = o . indexOf ( r . charAt ( y ++ ) ) << 2 | ( p = o . indexOf ( r . charAt ( y ++ ) ) ) >> 4 , d = ( 15 & p ) << 4 | ( I = o . indexOf ( r . charAt ( y ++ ) ) ) >> 2 , h = ( 3 & I ) << 6 | ( m = o . indexOf ( r . charAt ( y ++ ) ) ) , b [ T ++ ] = l , I !== 64 && ( b [ T ++ ] = d ) , m !== 64 && ( b [ T ++ ] = h ) ; return b } } , { "./support" : 30 , "./utils" : 32 } ] , 2 : [ function ( e , t , i ) { "use strict" ; var n = e ( "./external" ) , s = e ( "./stream/DataWorker" ) , o = e ( "./stream/Crc32Probe" ) , r = e ( "./stream/DataLengthProbe" ) ; function l ( d , h , p , I , m ) { this . compressedSize = d , this . uncompressedSize = h , this . crc32 = p , this . compression = I , this . compressedContent = m } l . prototype = { getContentWorker : function ( ) { var d = new s ( n . Promise . resolve ( this . compressedContent ) ) . pipe ( this . compression . uncompressWorker ( ) ) . pipe ( new r ( "data_length" ) ) , h = this ; return d . on ( "end" , function ( ) { if ( this . streamInfo . data _length !== h . uncompressedSize ) throw new Error ( "Bug : uncompressed data size mismatch" ) } ) , d } , 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 ) } } , l . createWorkerFrom = function ( d , h , p ) { return d . pipe ( new o ) . pipe ( new r ( "uncompressedSize" ) ) . pipe ( h . compressWorker ( p ) ) . pipe ( new r ( "compressedSize" ) ) . withStreamInfo ( "compression" , h ) } , t . exports = l } , { "./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 , " .
\ 0 ` ,ft+=n( $ e,2),ft+=U.magic,ft+=n(A,2),ft+=n(O,2),ft+=n(St.crc32,4),ft+=n(St.compressedSize,4),ft+=n(St.uncompressedSize,4),ft+=n(ne.length,2),ft+=n(Ae.length,2),{fileRecord:h.LOCAL_FILE_HEADER+ft+ne+Ae,dirRecord:h.CENTRAL_FILE_HEADER+n(It,2)+ft+n(se.length,2)+" \0 \0 \0 \0 "+n(ke,4)+n(T,4)+ne+Ae+se}}var o=e("../utils"),r=e("../stream/GenericWorker"),l=e("../utf8"),d=e("../crc32"),h=e("../signature");function p(I,m,y,T){r.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=y,this.encodeFileName=T,this.streamFiles=I,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,r),p.prototype.push=function(I){var m=I.meta.percent||0,y=this.entriesCount,T=this._sources.length;this.accumulate?this.contentBuffer.push(I):(this.bytesWritten+=I.data.length,r.prototype.push.call(this,{data:I.data,meta:{currentFile:this.currentFile,percent:y?(m+100*(y-T-1))/y:100}}))},p.prototype.openedSource=function(I){this.currentSourceOffset=this.bytesWritten,this.currentFile=I.file.name;var m=this.streamFiles&&!I.file.dir;if(m){var y=s(I,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(I){this.accumulate=!1;var m=this.streamFiles&&!I.file.dir,y=s(I,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),m)this.push({data:(function(T){return h.DATA_DESCRIPTOR+n(T.crc32,4)+n(T.compressedSize,4)+n(T.uncompressedSize,4)})(I),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var I=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var y=this.bytesWritten-I,T=(function(R,b,A,O,P){var U=o.transformTo("string",P(O));return h.CENTRAL_DIRECTORY_END+" \0 \0 \0 \0 "+n(R,2)+n(R,2)+n(b,4)+n(A,4)+n(U.length,2)+U})(this.dirRecords.length,y,I,this.zipComment,this.encodeFileName);this.push({data:T,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(I){this._sources.push(I);var m=this;return I.on("data",function(y){m.processChunk(y)}),I.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),I.on("error",function(y){m.error(y)}),this},p.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(I){var m=this._sources;if(!r.prototype.error.call(this,I))return!1;for(var y=0;y<m.length;y++)try{m[y].error(I)}catch{}return!0},p.prototype.lock=function(){r.prototype.lock.call(this);for(var I=this._sources,m=0;m<I.length;m++)I[m].lock()},t.exports=p},{"../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(o,r,l){var d=new s(r.streamFiles,l,r.platform,r.encodeFileName),h=0;try{o.forEach(function(p,I){h++;var m=(function(b,A){var O=b||A,P=n[O];if(!P)throw new Error(O+" is not a valid compression method !");return P})(I.options.compression,r.compression),y=I.options.compressionOptions||r.compressionOptions||{},T=I.dir,R=I.date;I._compressWorker(m,y).withStreamInfo("file",{name:p,dir:T,date:R,comment:I.comment||"",unixPermissions:I.unixPermissions,dosPermissions:I.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(p){d.error(p)}return d}},{"../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
2026-04-25 18:24:50 +01:00
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
2026-04-25 18:59:02 +01:00
} ` ,Q5e= ` void main ( ) {
2026-04-25 18:24:50 +01:00
gl _FragColor = vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
2026-04-25 18:59:02 +01:00
} ` ,Kl=class extends za{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=K5e,this.fragmentShader=Q5e,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=PC(t.uniforms),this.uniformsGroups=Z5e(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.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){let i=super.toJSON(t);i.glslVersion=this.glslVersion,i.uniforms={};for(let s in this.uniforms){let r=this.uniforms[s].value;r&&r.isTexture?i.uniforms[s]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?i.uniforms[s]={type:"c",value:r.getHex()}:r&&r.isVector2?i.uniforms[s]={type:"v2",value:r.toArray()}:r&&r.isVector3?i.uniforms[s]={type:"v3",value:r.toArray()}:r&&r.isVector4?i.uniforms[s]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?i.uniforms[s]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?i.uniforms[s]={type:"m4",value:r.toArray()}:i.uniforms[s]={value:r}}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}},yP=class extends Kl{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Fb=class extends za{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oi(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kI,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new UI,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},IC=class extends Fb{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={
2026-04-25 18:24:50 +01:00
if ( diffuseColor . a < getAlphaHashThreshold ( vPosition ) ) discard ;
2026-04-25 18:59:02 +01:00
# endif ` ,ASe= ` # ifdef USE _ALPHAHASH
2026-04-25 18:24:50 +01:00
const float ALPHA _HASH _SCALE = 0.05 ;
float hash2D ( vec2 value ) {
return fract ( 1.0 e4 * 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.0 e - 6 , 1.0 ) ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,bSe= ` # ifdef USE _ALPHAMAP
2026-04-25 18:24:50 +01:00
diffuseColor . a *= texture2D ( alphaMap , vAlphaMapUv ) . g ;
2026-04-25 18:59:02 +01:00
# endif ` ,NSe= ` # ifdef USE _ALPHAMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D alphaMap ;
2026-04-25 18:59:02 +01:00
# endif ` ,_Se= ` # ifdef USE _ALPHATEST
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
# endif ` ,DSe= ` # ifdef USE _ALPHATEST
2026-04-25 18:24:50 +01:00
uniform float alphaTest ;
2026-04-25 18:59:02 +01:00
# endif ` ,CSe= ` # ifdef USE _AOMAP
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# endif ` ,xSe= ` # ifdef USE _AOMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D aoMap ;
uniform float aoMapIntensity ;
2026-04-25 18:59:02 +01:00
# endif ` ,OSe= ` # ifdef USE _BATCHING
2026-04-25 18:24:50 +01:00
# 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 ;
2026-04-25 18:59:02 +01:00
vec4 getBatchingColor ( const in float i ) {
2026-04-25 18:24:50 +01:00
int size = textureSize ( batchingColorTexture , 0 ) . x ;
int j = int ( i ) ;
int x = j % size ;
int y = j / size ;
2026-04-25 18:59:02 +01:00
return texelFetch ( batchingColorTexture , ivec2 ( x , y ) , 0 ) ;
2026-04-25 18:24:50 +01:00
}
2026-04-25 18:59:02 +01:00
# endif ` ,LSe= ` # ifdef USE _BATCHING
2026-04-25 18:24:50 +01:00
mat4 batchingMatrix = getBatchingMatrix ( getIndirectIndex ( gl _DrawID ) ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,PSe= ` vec3 transformed = vec3 ( position ) ;
2026-04-25 18:24:50 +01:00
# ifdef USE _ALPHAHASH
vPosition = vec3 ( position ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,MSe= ` vec3 objectNormal = vec3 ( normal ) ;
2026-04-25 18:24:50 +01:00
# ifdef USE _TANGENT
vec3 objectTangent = vec3 ( tangent . xyz ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,BSe= ` float G _BlinnPhong _Implicit ( ) {
2026-04-25 18:24:50 +01:00
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 ) ;
2026-04-25 18:59:02 +01:00
} // validated`,FSe=`#ifdef USE_IRIDESCENCE
2026-04-25 18:24:50 +01:00
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.0 e - 9 ;
vec3 val = vec3 ( 5.4856 e - 13 , 4.4201 e - 13 , 5.2481 e - 13 ) ;
vec3 pos = vec3 ( 1.6810 e + 06 , 1.7953 e + 06 , 2.2084 e + 06 ) ;
vec3 var = vec3 ( 4.3278 e + 09 , 9.3046 e + 09 , 6.6121 e + 09 ) ;
vec3 xyz = val * sqrt ( 2.0 * PI * var ) * cos ( pos * phase + shift ) * exp ( - pow2 ( phase ) * var ) ;
xyz . x += 9.7470 e - 14 * sqrt ( 2.0 * PI * 4.5282 e + 09 ) * cos ( 2.2399 e + 06 * phase + shift [ 0 ] ) * exp ( - 4.5282 e + 09 * pow2 ( phase ) ) ;
xyz /= 1.0685 e - 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 R s = 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 ) ) ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,USe= ` # ifdef USE _BUMPMAP
2026-04-25 18:24:50 +01:00
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 ) ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,HSe= ` # if NUM _CLIPPING _PLANES > 0
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# endif ` ,GSe= ` # if NUM _CLIPPING _PLANES > 0
2026-04-25 18:24:50 +01:00
varying vec3 vClipPosition ;
uniform vec4 clippingPlanes [ NUM _CLIPPING _PLANES ] ;
2026-04-25 18:59:02 +01:00
# endif ` ,VSe= ` # if NUM _CLIPPING _PLANES > 0
2026-04-25 18:24:50 +01:00
varying vec3 vClipPosition ;
2026-04-25 18:59:02 +01:00
# endif ` ,kSe= ` # if NUM _CLIPPING _PLANES > 0
2026-04-25 18:24:50 +01:00
vClipPosition = - mvPosition . xyz ;
2026-04-25 18:59:02 +01:00
# endif ` ,zSe= ` # if defined ( USE _COLOR ) || defined ( USE _COLOR _ALPHA )
2026-04-25 18:24:50 +01:00
diffuseColor *= vColor ;
2026-04-25 18:59:02 +01:00
# endif ` ,WSe= ` # if defined ( USE _COLOR ) || defined ( USE _COLOR _ALPHA )
2026-04-25 18:24:50 +01:00
varying vec4 vColor ;
2026-04-25 18:59:02 +01:00
# endif ` ,YSe= ` # if defined ( USE _COLOR ) || defined ( USE _COLOR _ALPHA ) || defined ( USE _INSTANCING _COLOR ) || defined ( USE _BATCHING _COLOR )
2026-04-25 18:24:50 +01:00
varying vec4 vColor ;
2026-04-25 18:59:02 +01:00
# endif ` ,jSe= ` # if defined ( USE _COLOR ) || defined ( USE _COLOR _ALPHA ) || defined ( USE _INSTANCING _COLOR ) || defined ( USE _BATCHING _COLOR )
2026-04-25 18:24:50 +01:00
vColor = vec4 ( 1.0 ) ;
# endif
2026-04-25 18:59:02 +01:00
# ifdef USE _COLOR _ALPHA
2026-04-25 18:24:50 +01:00
vColor *= color ;
2026-04-25 18:59:02 +01:00
# elif defined ( USE _COLOR )
vColor . rgb *= color ;
2026-04-25 18:24:50 +01:00
# endif
# ifdef USE _INSTANCING _COLOR
2026-04-25 18:59:02 +01:00
vColor . rgb *= instanceColor . rgb ;
2026-04-25 18:24:50 +01:00
# endif
# ifdef USE _BATCHING _COLOR
2026-04-25 18:59:02 +01:00
vColor *= getBatchingColor ( getIndirectIndex ( gl _DrawID ) ) ;
# endif ` ,qSe= ` # define PI 3.141592653589793
2026-04-25 18:24:50 +01:00
# 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 ) ;
}
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 ) ;
2026-04-25 18:59:02 +01:00
} // validated`,$Se=`#ifdef ENVMAP_TYPE_CUBE_UV
2026-04-25 18:24:50 +01:00
# 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 ) ;
}
}
2026-04-25 18:59:02 +01:00
# endif ` ,ZSe= ` vec3 transformedNormal = objectNormal ;
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
# endif ` ,KSe= ` # ifdef USE _DISPLACEMENTMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D displacementMap ;
uniform float displacementScale ;
uniform float displacementBias ;
2026-04-25 18:59:02 +01:00
# endif ` ,QSe= ` # ifdef USE _DISPLACEMENTMAP
2026-04-25 18:24:50 +01:00
transformed += normalize ( objectNormal ) * ( texture2D ( displacementMap , vDisplacementMapUv ) . x * displacementScale + displacementBias ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,JSe= ` # ifdef USE _EMISSIVEMAP
2026-04-25 18:24:50 +01:00
vec4 emissiveColor = texture2D ( emissiveMap , vEmissiveMapUv ) ;
# ifdef DECODE _VIDEO _TEXTURE _EMISSIVE
emissiveColor = sRGBTransferEOTF ( emissiveColor ) ;
# endif
totalEmissiveRadiance *= emissiveColor . rgb ;
2026-04-25 18:59:02 +01:00
# endif ` ,XSe= ` # ifdef USE _EMISSIVEMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D emissiveMap ;
2026-04-25 18:59:02 +01:00
# endif ` ,eAe="gl_FragColor = linearToOutputTexel( gl_FragColor );",tAe= ` vec4 LinearTransferOETF ( in vec4 value ) {
2026-04-25 18:24:50 +01:00
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 ) ;
2026-04-25 18:59:02 +01:00
} ` ,iAe= ` # ifdef USE _ENVMAP
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
vec4 envColor = textureCube ( envMap , envMapRotation * reflectVec ) ;
# 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
2026-04-25 18:24:50 +01:00
# endif
2026-04-25 18:59:02 +01:00
# endif ` ,nAe= ` # ifdef USE _ENVMAP
2026-04-25 18:24:50 +01:00
uniform float envMapIntensity ;
uniform mat3 envMapRotation ;
# ifdef ENVMAP _TYPE _CUBE
uniform samplerCube envMap ;
# else
uniform sampler2D envMap ;
# endif
2026-04-25 18:59:02 +01:00
# endif ` ,sAe= ` # ifdef USE _ENVMAP
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# endif ` ,oAe= ` # ifdef USE _ENVMAP
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
# endif ` ,rAe= ` # ifdef USE _ENVMAP
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
# endif ` ,lAe= ` # ifdef USE _FOG
2026-04-25 18:24:50 +01:00
vFogDepth = - mvPosition . z ;
2026-04-25 18:59:02 +01:00
# endif ` ,aAe= ` # ifdef USE _FOG
2026-04-25 18:24:50 +01:00
varying float vFogDepth ;
2026-04-25 18:59:02 +01:00
# endif ` ,uAe= ` # ifdef USE _FOG
2026-04-25 18:24:50 +01:00
# 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 ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,cAe= ` # ifdef USE _FOG
2026-04-25 18:24:50 +01:00
uniform vec3 fogColor ;
varying float vFogDepth ;
# ifdef FOG _EXP2
uniform float fogDensity ;
# else
uniform float fogNear ;
uniform float fogFar ;
# endif
2026-04-25 18:59:02 +01:00
# endif ` ,dAe= ` # ifdef USE _GRADIENTMAP
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
} ` ,hAe= ` # ifdef USE _LIGHTMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D lightMap ;
uniform float lightMapIntensity ;
2026-04-25 18:59:02 +01:00
# endif ` ,fAe= ` LambertMaterial material ;
2026-04-25 18:24:50 +01:00
material . diffuseColor = diffuseColor . rgb ;
2026-04-25 18:59:02 +01:00
material . specularStrength = specularStrength ; ` ,pAe= ` varying vec3 vViewPosition ;
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# define RE _IndirectDiffuse RE _IndirectDiffuse _Lambert ` ,IAe= ` uniform bool receiveShadow ;
2026-04-25 18:24:50 +01:00
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 ;
}
2026-04-25 18:59:02 +01:00
# endif
# include < lightprobes _pars _fragment > ` ,mAe= ` # ifdef USE _ENVMAP
2026-04-25 18:24:50 +01:00
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 ) ;
2026-04-25 18:59:02 +01:00
reflectVec = normalize ( mix ( reflectVec , normal , pow4 ( roughness ) ) ) ;
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# endif ` ,yAe= ` ToonMaterial material ;
material . diffuseColor = diffuseColor . rgb ; ` ,EAe= ` varying vec3 vViewPosition ;
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# define RE _IndirectDiffuse RE _IndirectDiffuse _Toon ` ,TAe= ` BlinnPhongMaterial material ;
2026-04-25 18:24:50 +01:00
material . diffuseColor = diffuseColor . rgb ;
material . specularColor = specular ;
material . specularShininess = shininess ;
2026-04-25 18:59:02 +01:00
material . specularStrength = specularStrength ; ` ,gAe= ` varying vec3 vViewPosition ;
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# define RE _IndirectDiffuse RE _IndirectDiffuse _BlinnPhong ` ,wAe= ` PhysicalMaterial material ;
material . diffuseColor = diffuseColor . rgb ;
material . diffuseContribution = diffuseColor . rgb * ( 1.0 - metalnessFactor ) ;
material . metalness = metalnessFactor ;
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
material . specularColor = min ( pow2 ( ( material . ior - 1.0 ) / ( material . ior + 1.0 ) ) * specularColorFactor , vec3 ( 1.0 ) ) * specularIntensityFactor ;
material . specularColorBlended = mix ( material . specularColor , diffuseColor . rgb , metalnessFactor ) ;
2026-04-25 18:24:50 +01:00
# else
2026-04-25 18:59:02 +01:00
material . specularColor = vec3 ( 0.04 ) ;
material . specularColorBlended = mix ( material . specularColor , diffuseColor . rgb , metalnessFactor ) ;
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
material . sheenRoughness = clamp ( sheenRoughness , 0.0001 , 1.0 ) ;
2026-04-25 18:24:50 +01:00
# 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 ;
2026-04-25 18:59:02 +01:00
# endif ` ,vAe= ` uniform sampler2D dfgLUT ;
struct PhysicalMaterial {
2026-04-25 18:24:50 +01:00
vec3 diffuseColor ;
2026-04-25 18:59:02 +01:00
vec3 diffuseContribution ;
2026-04-25 18:24:50 +01:00
vec3 specularColor ;
2026-04-25 18:59:02 +01:00
vec3 specularColorBlended ;
float roughness ;
float metalness ;
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
vec3 iridescenceFresnelDielectric ;
vec3 iridescenceFresnelMetallic ;
2026-04-25 18:24:50 +01:00
# 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 ) ) ;
2026-04-25 18:59:02 +01:00
return 0.5 / max ( gv + gl , EPSILON ) ;
2026-04-25 18:24:50 +01:00
}
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 ) {
2026-04-25 18:59:02 +01:00
vec3 f0 = material . specularColorBlended ;
2026-04-25 18:24:50 +01:00
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 ) ;
2026-04-25 18:59:02 +01:00
mat3 mat = mInv * transpose ( mat3 ( T1 , T2 , N ) ) ;
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
float rInv = 1.0 / ( roughness + 0.1 ) ;
float a = - 1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv ;
float b = - 0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv ;
float DG = exp ( a * dotNV + b ) ;
return saturate ( DG ) ;
2026-04-25 18:24:50 +01:00
}
vec3 EnvironmentBRDF ( const in vec3 normal , const in vec3 viewDir , const in vec3 specularColor , const in float specularF90 , const in float roughness ) {
2026-04-25 18:59:02 +01:00
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
vec2 fab = texture2D ( dfgLUT , vec2 ( roughness , dotNV ) ) . rg ;
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
vec2 fab = texture2D ( dfgLUT , vec2 ( roughness , dotNV ) ) . rg ;
2026-04-25 18:24:50 +01:00
# 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 ;
}
2026-04-25 18:59:02 +01:00
vec3 BRDF _GGX _Multiscatter ( const in vec3 lightDir , const in vec3 viewDir , const in vec3 normal , const in PhysicalMaterial material ) {
vec3 singleScatter = BRDF _GGX ( lightDir , viewDir , normal , material ) ;
float dotNL = saturate ( dot ( normal , lightDir ) ) ;
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
vec2 dfgV = texture2D ( dfgLUT , vec2 ( material . roughness , dotNV ) ) . rg ;
vec2 dfgL = texture2D ( dfgLUT , vec2 ( material . roughness , dotNL ) ) . rg ;
vec3 FssEss _V = material . specularColorBlended * dfgV . x + material . specularF90 * dfgV . y ;
vec3 FssEss _L = material . specularColorBlended * dfgL . x + material . specularF90 * dfgL . y ;
float Ess _V = dfgV . x + dfgV . y ;
float Ess _L = dfgL . x + dfgL . y ;
float Ems _V = 1.0 - Ess _V ;
float Ems _L = 1.0 - Ess _L ;
vec3 Favg = material . specularColorBlended + ( 1.0 - material . specularColorBlended ) * 0.047619 ;
vec3 Fms = FssEss _V * FssEss _L * Favg / ( 1.0 - Ems _V * Ems _L * Favg + EPSILON ) ;
float compensationFactor = Ems _V * Ems _L ;
vec3 multiScatter = Fms * compensationFactor ;
return singleScatter + multiScatter ;
}
2026-04-25 18:24:50 +01:00
# 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 )
) ;
2026-04-25 18:59:02 +01:00
vec3 fresnel = ( material . specularColorBlended * t2 . x + ( material . specularF90 - material . specularColorBlended ) * t2 . y ) ;
2026-04-25 18:24:50 +01:00
reflectedLight . directSpecular += lightColor * fresnel * LTC _Evaluate ( normal , viewDir , position , mInv , rectCoords ) ;
2026-04-25 18:59:02 +01:00
reflectedLight . directDiffuse += lightColor * material . diffuseContribution * LTC _Evaluate ( normal , viewDir , position , mat3 ( 1.0 ) , rectCoords ) ;
# ifdef USE _CLEARCOAT
vec3 Ncc = geometryClearcoatNormal ;
vec2 uvClearcoat = LTC _Uv ( Ncc , viewDir , material . clearcoatRoughness ) ;
vec4 t1Clearcoat = texture2D ( ltc _1 , uvClearcoat ) ;
vec4 t2Clearcoat = texture2D ( ltc _2 , uvClearcoat ) ;
mat3 mInvClearcoat = mat3 (
vec3 ( t1Clearcoat . x , 0 , t1Clearcoat . y ) ,
vec3 ( 0 , 1 , 0 ) ,
vec3 ( t1Clearcoat . z , 0 , t1Clearcoat . w )
) ;
vec3 fresnelClearcoat = material . clearcoatF0 * t2Clearcoat . x + ( material . clearcoatF90 - material . clearcoatF0 ) * t2Clearcoat . y ;
clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC _Evaluate ( Ncc , viewDir , position , mInvClearcoat , rectCoords ) ;
# endif
2026-04-25 18:24:50 +01:00
}
# 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
2026-04-25 18:59:02 +01:00
sheenSpecularDirect += irradiance * BRDF _Sheen ( directLight . direction , geometryViewDir , geometryNormal , material . sheenColor , material . sheenRoughness ) ;
float sheenAlbedoV = IBLSheenBRDF ( geometryNormal , geometryViewDir , material . sheenRoughness ) ;
float sheenAlbedoL = IBLSheenBRDF ( geometryNormal , directLight . direction , material . sheenRoughness ) ;
float sheenEnergyComp = 1.0 - max3 ( material . sheenColor ) * max ( sheenAlbedoV , sheenAlbedoL ) ;
irradiance *= sheenEnergyComp ;
# endif
reflectedLight . directSpecular += irradiance * BRDF _GGX _Multiscatter ( directLight . direction , geometryViewDir , geometryNormal , material ) ;
reflectedLight . directDiffuse += irradiance * BRDF _Lambert ( material . diffuseContribution ) ;
2026-04-25 18:24:50 +01:00
}
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 ) {
2026-04-25 18:59:02 +01:00
vec3 diffuse = irradiance * BRDF _Lambert ( material . diffuseContribution ) ;
# ifdef USE _SHEEN
float sheenAlbedo = IBLSheenBRDF ( geometryNormal , geometryViewDir , material . sheenRoughness ) ;
float sheenEnergyComp = 1.0 - max3 ( material . sheenColor ) * sheenAlbedo ;
diffuse *= sheenEnergyComp ;
# endif
reflectedLight . indirectDiffuse += diffuse ;
2026-04-25 18:24:50 +01:00
}
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
2026-04-25 18:59:02 +01:00
sheenSpecularIndirect += irradiance * material . sheenColor * IBLSheenBRDF ( geometryNormal , geometryViewDir , material . sheenRoughness ) * RECIPROCAL _PI ;
# endif
vec3 singleScatteringDielectric = vec3 ( 0.0 ) ;
vec3 multiScatteringDielectric = vec3 ( 0.0 ) ;
vec3 singleScatteringMetallic = vec3 ( 0.0 ) ;
vec3 multiScatteringMetallic = vec3 ( 0.0 ) ;
2026-04-25 18:24:50 +01:00
# ifdef USE _IRIDESCENCE
2026-04-25 18:59:02 +01:00
computeMultiscatteringIridescence ( geometryNormal , geometryViewDir , material . specularColor , material . specularF90 , material . iridescence , material . iridescenceFresnelDielectric , material . roughness , singleScatteringDielectric , multiScatteringDielectric ) ;
computeMultiscatteringIridescence ( geometryNormal , geometryViewDir , material . diffuseColor , material . specularF90 , material . iridescence , material . iridescenceFresnelMetallic , material . roughness , singleScatteringMetallic , multiScatteringMetallic ) ;
2026-04-25 18:24:50 +01:00
# else
2026-04-25 18:59:02 +01:00
computeMultiscattering ( geometryNormal , geometryViewDir , material . specularColor , material . specularF90 , material . roughness , singleScatteringDielectric , multiScatteringDielectric ) ;
computeMultiscattering ( geometryNormal , geometryViewDir , material . diffuseColor , material . specularF90 , material . roughness , singleScatteringMetallic , multiScatteringMetallic ) ;
# endif
vec3 singleScattering = mix ( singleScatteringDielectric , singleScatteringMetallic , material . metalness ) ;
vec3 multiScattering = mix ( multiScatteringDielectric , multiScatteringMetallic , material . metalness ) ;
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric ;
vec3 diffuse = material . diffuseContribution * ( 1.0 - totalScatteringDielectric ) ;
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL _PI ;
vec3 indirectSpecular = radiance * singleScattering ;
indirectSpecular += multiScattering * cosineWeightedIrradiance ;
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance ;
# ifdef USE _SHEEN
float sheenAlbedo = IBLSheenBRDF ( geometryNormal , geometryViewDir , material . sheenRoughness ) ;
float sheenEnergyComp = 1.0 - max3 ( material . sheenColor ) * sheenAlbedo ;
indirectSpecular *= sheenEnergyComp ;
indirectDiffuse *= sheenEnergyComp ;
2026-04-25 18:24:50 +01:00
# endif
2026-04-25 18:59:02 +01:00
reflectedLight . indirectSpecular += indirectSpecular ;
reflectedLight . indirectDiffuse += indirectDiffuse ;
2026-04-25 18:24:50 +01:00
}
# 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 ) ;
2026-04-25 18:59:02 +01:00
} ` ,RAe= `
2026-04-25 18:24:50 +01:00
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 ) {
2026-04-25 18:59:02 +01:00
material . iridescenceFresnelDielectric = evalIridescence ( 1.0 , material . iridescenceIOR , dotNVi , material . iridescenceThickness , material . specularColor ) ;
material . iridescenceFresnelMetallic = evalIridescence ( 1.0 , material . iridescenceIOR , dotNVi , material . iridescenceThickness , material . diffuseColor ) ;
material . iridescenceFresnel = mix ( material . iridescenceFresnelDielectric , material . iridescenceFresnelMetallic , material . metalness ) ;
2026-04-25 18:24:50 +01:00
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 ) ;
2026-04-25 18:59:02 +01:00
# if defined ( USE _SHADOWMAP ) && ( UNROLLED _LOOP _INDEX < NUM _POINT _LIGHT _SHADOWS ) && ( defined ( SHADOWMAP _TYPE _PCF ) || defined ( SHADOWMAP _TYPE _BASIC ) )
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# ifdef USE _LIGHT _PROBES _GRID
vec3 probeWorldPos = ( ( vec4 ( geometryPosition , 1.0 ) - viewMatrix [ 3 ] ) * viewMatrix ) . xyz ;
vec3 probeWorldNormal = inverseTransformDirection ( geometryNormal , viewMatrix ) ;
irradiance += getLightProbeGridIrradiance ( probeWorldPos , probeWorldNormal ) ;
# endif
2026-04-25 18:24:50 +01:00
# endif
# if defined ( RE _IndirectSpecular )
vec3 radiance = vec3 ( 0.0 ) ;
vec3 clearcoatRadiance = vec3 ( 0.0 ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,SAe= ` # if defined ( RE _IndirectDiffuse )
2026-04-25 18:24:50 +01:00
# ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vLightMapUv ) ;
vec3 lightMapIrradiance = lightMapTexel . rgb * lightMapIntensity ;
irradiance += lightMapIrradiance ;
# endif
2026-04-25 18:59:02 +01:00
# if defined ( USE _ENVMAP ) && defined ( ENVMAP _TYPE _CUBE _UV )
# if defined ( STANDARD ) || defined ( LAMBERT ) || defined ( PHONG )
iblIrradiance += getIBLIrradiance ( geometryNormal ) ;
# endif
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
# endif ` ,AAe= ` # if defined ( RE _IndirectDiffuse )
# if defined ( LAMBERT ) || defined ( PHONG )
irradiance += iblIrradiance ;
# endif
2026-04-25 18:24:50 +01:00
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 ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,bAe= ` # ifdef USE _LIGHT _PROBES _GRID
uniform highp sampler3D probesSH ;
uniform vec3 probesMin ;
uniform vec3 probesMax ;
uniform vec3 probesResolution ;
vec3 getLightProbeGridIrradiance ( vec3 worldPos , vec3 worldNormal ) {
vec3 res = probesResolution ;
vec3 gridRange = probesMax - probesMin ;
vec3 resMinusOne = res - 1.0 ;
vec3 probeSpacing = gridRange / resMinusOne ;
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5 ;
vec3 uvw = clamp ( ( samplePos - probesMin ) / gridRange , 0.0 , 1.0 ) ;
uvw = uvw * resMinusOne / res + 0.5 / res ;
float nz = res . z ;
float paddedSlices = nz + 2.0 ;
float atlasDepth = 7.0 * paddedSlices ;
float uvZBase = uvw . z * nz + 1.0 ;
vec4 s0 = texture ( probesSH , vec3 ( uvw . xy , ( uvZBase ) / atlasDepth ) ) ;
vec4 s1 = texture ( probesSH , vec3 ( uvw . xy , ( uvZBase + paddedSlices ) / atlasDepth ) ) ;
vec4 s2 = texture ( probesSH , vec3 ( uvw . xy , ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ) ;
vec4 s3 = texture ( probesSH , vec3 ( uvw . xy , ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ) ;
vec4 s4 = texture ( probesSH , vec3 ( uvw . xy , ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ) ;
vec4 s5 = texture ( probesSH , vec3 ( uvw . xy , ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ) ;
vec4 s6 = texture ( probesSH , vec3 ( uvw . xy , ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ) ;
vec3 c0 = s0 . xyz ;
vec3 c1 = vec3 ( s0 . w , s1 . xy ) ;
vec3 c2 = vec3 ( s1 . zw , s2 . x ) ;
vec3 c3 = s2 . yzw ;
vec3 c4 = s3 . xyz ;
vec3 c5 = vec3 ( s3 . w , s4 . xy ) ;
vec3 c6 = vec3 ( s4 . zw , s5 . x ) ;
vec3 c7 = s5 . yzw ;
vec3 c8 = s6 . xyz ;
float x = worldNormal . x , y = worldNormal . y , z = worldNormal . z ;
vec3 result = c0 * 0.886227 ;
result += c1 * 2.0 * 0.511664 * y ;
result += c2 * 2.0 * 0.511664 * z ;
result += c3 * 2.0 * 0.511664 * x ;
result += c4 * 2.0 * 0.429043 * x * y ;
result += c5 * 2.0 * 0.429043 * y * z ;
result += c6 * ( 0.743125 * z * z - 0.247708 ) ;
result += c7 * 2.0 * 0.429043 * x * z ;
result += c8 * 0.429043 * ( x * x - y * y ) ;
return max ( result , vec3 ( 0.0 ) ) ;
}
# endif ` ,NAe= ` # if defined ( USE _LOGARITHMIC _DEPTH _BUFFER )
2026-04-25 18:24:50 +01:00
gl _FragDepth = vIsPerspective == 0.0 ? gl _FragCoord . z : log2 ( vFragDepth ) * logDepthBufFC * 0.5 ;
2026-04-25 18:59:02 +01:00
# endif ` ,_Ae= ` # if defined ( USE _LOGARITHMIC _DEPTH _BUFFER )
2026-04-25 18:24:50 +01:00
uniform float logDepthBufFC ;
varying float vFragDepth ;
varying float vIsPerspective ;
2026-04-25 18:59:02 +01:00
# endif ` ,DAe= ` # ifdef USE _LOGARITHMIC _DEPTH _BUFFER
2026-04-25 18:24:50 +01:00
varying float vFragDepth ;
varying float vIsPerspective ;
2026-04-25 18:59:02 +01:00
# endif ` ,CAe= ` # ifdef USE _LOGARITHMIC _DEPTH _BUFFER
2026-04-25 18:24:50 +01:00
vFragDepth = 1.0 + gl _Position . w ;
vIsPerspective = float ( isPerspectiveMatrix ( projectionMatrix ) ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,xAe= ` # ifdef USE _MAP
2026-04-25 18:24:50 +01:00
vec4 sampledDiffuseColor = texture2D ( map , vMapUv ) ;
# ifdef DECODE _VIDEO _TEXTURE
sampledDiffuseColor = sRGBTransferEOTF ( sampledDiffuseColor ) ;
# endif
diffuseColor *= sampledDiffuseColor ;
2026-04-25 18:59:02 +01:00
# endif ` ,OAe= ` # ifdef USE _MAP
2026-04-25 18:24:50 +01:00
uniform sampler2D map ;
2026-04-25 18:59:02 +01:00
# endif ` ,LAe= ` # if defined ( USE _MAP ) || defined ( USE _ALPHAMAP )
2026-04-25 18:24:50 +01:00
# 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 ;
2026-04-25 18:59:02 +01:00
# endif ` ,PAe= ` # if defined ( USE _POINTS _UV )
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
# endif ` ,MAe= ` float metalnessFactor = metalness ;
2026-04-25 18:24:50 +01:00
# ifdef USE _METALNESSMAP
vec4 texelMetalness = texture2D ( metalnessMap , vMetalnessMapUv ) ;
metalnessFactor *= texelMetalness . b ;
2026-04-25 18:59:02 +01:00
# endif ` ,BAe= ` # ifdef USE _METALNESSMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D metalnessMap ;
2026-04-25 18:59:02 +01:00
# endif ` ,FAe= ` # ifdef USE _INSTANCING _MORPH
2026-04-25 18:24:50 +01:00
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 ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,UAe= ` # if defined ( USE _MORPHCOLORS )
2026-04-25 18:24:50 +01:00
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
}
2026-04-25 18:59:02 +01:00
# endif ` ,HAe= ` # ifdef USE _MORPHNORMALS
2026-04-25 18:24:50 +01:00
objectNormal *= morphTargetBaseInfluence ;
for ( int i = 0 ; i < MORPHTARGETS _COUNT ; i ++ ) {
if ( morphTargetInfluences [ i ] != 0.0 ) objectNormal += getMorph ( gl _VertexID , i , 1 ) . xyz * morphTargetInfluences [ i ] ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,GAe= ` # ifdef USE _MORPHTARGETS
2026-04-25 18:24:50 +01:00
# 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 ) ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,VAe= ` # ifdef USE _MORPHTARGETS
2026-04-25 18:24:50 +01:00
transformed *= morphTargetBaseInfluence ;
for ( int i = 0 ; i < MORPHTARGETS _COUNT ; i ++ ) {
if ( morphTargetInfluences [ i ] != 0.0 ) transformed += getMorph ( gl _VertexID , i , 0 ) . xyz * morphTargetInfluences [ i ] ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,kAe= ` float faceDirection = gl _FrontFacing ? 1.0 : - 1.0 ;
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
vec3 nonPerturbedNormal = normal ; ` ,zAe= ` # ifdef USE _NORMALMAP _OBJECTSPACE
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
# if defined ( USE _PACKED _NORMALMAP )
mapN = vec3 ( mapN . xy , sqrt ( saturate ( 1.0 - dot ( mapN . xy , mapN . xy ) ) ) ) ;
# endif
2026-04-25 18:24:50 +01:00
mapN . xy *= normalScale ;
normal = normalize ( tbn * mapN ) ;
# elif defined ( USE _BUMPMAP )
normal = perturbNormalArb ( - vViewPosition , normal , dHdxy _fwd ( ) , faceDirection ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,WAe= ` # ifndef FLAT _SHADED
2026-04-25 18:24:50 +01:00
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
2026-04-25 18:59:02 +01:00
# endif ` ,YAe= ` # ifndef FLAT _SHADED
2026-04-25 18:24:50 +01:00
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
2026-04-25 18:59:02 +01:00
# endif ` ,jAe= ` # ifndef FLAT _SHADED
2026-04-25 18:24:50 +01:00
vNormal = normalize ( transformedNormal ) ;
# ifdef USE _TANGENT
vTangent = normalize ( transformedTangent ) ;
vBitangent = normalize ( cross ( vNormal , vTangent ) * tangent . w ) ;
# endif
2026-04-25 18:59:02 +01:00
# endif ` ,qAe= ` # ifdef USE _NORMALMAP
2026-04-25 18:24:50 +01:00
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 ) ;
}
2026-04-25 18:59:02 +01:00
# endif ` , $ Ae= ` # ifdef USE _CLEARCOAT
2026-04-25 18:24:50 +01:00
vec3 clearcoatNormal = nonPerturbedNormal ;
2026-04-25 18:59:02 +01:00
# endif ` ,ZAe= ` # ifdef USE _CLEARCOAT _NORMALMAP
2026-04-25 18:24:50 +01:00
vec3 clearcoatMapN = texture2D ( clearcoatNormalMap , vClearcoatNormalMapUv ) . xyz * 2.0 - 1.0 ;
clearcoatMapN . xy *= clearcoatNormalScale ;
clearcoatNormal = normalize ( tbn2 * clearcoatMapN ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,KAe= ` # ifdef USE _CLEARCOATMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D clearcoatMap ;
# endif
# ifdef USE _CLEARCOAT _NORMALMAP
uniform sampler2D clearcoatNormalMap ;
uniform vec2 clearcoatNormalScale ;
# endif
# ifdef USE _CLEARCOAT _ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap ;
2026-04-25 18:59:02 +01:00
# endif ` ,QAe= ` # ifdef USE _IRIDESCENCEMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D iridescenceMap ;
# endif
# ifdef USE _IRIDESCENCE _THICKNESSMAP
uniform sampler2D iridescenceThicknessMap ;
2026-04-25 18:59:02 +01:00
# endif ` ,JAe= ` # ifdef OPAQUE
2026-04-25 18:24:50 +01:00
diffuseColor . a = 1.0 ;
# endif
# ifdef USE _TRANSMISSION
diffuseColor . a *= material . transmissionAlpha ;
# endif
2026-04-25 18:59:02 +01:00
gl _FragColor = vec4 ( outgoingLight , diffuseColor . a ) ; ` ,XAe= ` vec3 packNormalToRGB ( const in vec3 normal ) {
2026-04-25 18:24:50 +01:00
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 ) {
2026-04-25 18:59:02 +01:00
# ifdef USE _REVERSED _DEPTH _BUFFER
return depth * ( far - near ) - far ;
# else
return depth * ( near - far ) - near ;
# endif
2026-04-25 18:24:50 +01:00
}
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 ) {
2026-04-25 18:59:02 +01:00
# ifdef USE _REVERSED _DEPTH _BUFFER
return ( near * far ) / ( ( near - far ) * depth - near ) ;
# else
return ( near * far ) / ( ( far - near ) * depth - far ) ;
# endif
} ` ,ebe= ` # ifdef PREMULTIPLIED _ALPHA
2026-04-25 18:24:50 +01:00
gl _FragColor . rgb *= gl _FragColor . a ;
2026-04-25 18:59:02 +01:00
# endif ` ,tbe= ` vec4 mvPosition = vec4 ( transformed , 1.0 ) ;
2026-04-25 18:24:50 +01:00
# ifdef USE _BATCHING
mvPosition = batchingMatrix * mvPosition ;
# endif
# ifdef USE _INSTANCING
mvPosition = instanceMatrix * mvPosition ;
# endif
mvPosition = modelViewMatrix * mvPosition ;
2026-04-25 18:59:02 +01:00
gl _Position = projectionMatrix * mvPosition ; ` ,ibe= ` # ifdef DITHERING
2026-04-25 18:24:50 +01:00
gl _FragColor . rgb = dithering ( gl _FragColor . rgb ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,nbe= ` # ifdef DITHERING
2026-04-25 18:24:50 +01:00
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 ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,sbe= ` float roughnessFactor = roughness ;
2026-04-25 18:24:50 +01:00
# ifdef USE _ROUGHNESSMAP
vec4 texelRoughness = texture2D ( roughnessMap , vRoughnessMapUv ) ;
roughnessFactor *= texelRoughness . g ;
2026-04-25 18:59:02 +01:00
# endif ` ,obe= ` # ifdef USE _ROUGHNESSMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D roughnessMap ;
2026-04-25 18:59:02 +01:00
# endif ` ,rbe= ` # if NUM _SPOT _LIGHT _COORDS > 0
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# if defined ( SHADOWMAP _TYPE _PCF )
uniform sampler2DShadow directionalShadowMap [ NUM _DIR _LIGHT _SHADOWS ] ;
# else
uniform sampler2D directionalShadowMap [ NUM _DIR _LIGHT _SHADOWS ] ;
# endif
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# if defined ( SHADOWMAP _TYPE _PCF )
uniform sampler2DShadow spotShadowMap [ NUM _SPOT _LIGHT _SHADOWS ] ;
# else
uniform sampler2D spotShadowMap [ NUM _SPOT _LIGHT _SHADOWS ] ;
# endif
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# if defined ( SHADOWMAP _TYPE _PCF )
uniform samplerCubeShadow pointShadowMap [ NUM _POINT _LIGHT _SHADOWS ] ;
# elif defined ( SHADOWMAP _TYPE _BASIC )
uniform samplerCube pointShadowMap [ NUM _POINT _LIGHT _SHADOWS ] ;
# endif
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# if defined ( SHADOWMAP _TYPE _PCF )
float interleavedGradientNoise ( vec2 position ) {
return fract ( 52.9829189 * fract ( dot ( position , vec2 ( 0.06711056 , 0.00583715 ) ) ) ) ;
2026-04-25 18:24:50 +01:00
}
2026-04-25 18:59:02 +01:00
vec2 vogelDiskSample ( int sampleIndex , int samplesCount , float phi ) {
const float goldenAngle = 2.399963229728653 ;
float r = sqrt ( ( float ( sampleIndex ) + 0.5 ) / float ( samplesCount ) ) ;
float theta = float ( sampleIndex ) * goldenAngle + phi ;
return vec2 ( cos ( theta ) , sin ( theta ) ) * r ;
}
# endif
# if defined ( SHADOWMAP _TYPE _PCF )
float getShadow ( sampler2DShadow 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 ) {
vec2 texelSize = vec2 ( 1.0 ) / shadowMapSize ;
float radius = shadowRadius * texelSize . x ;
float phi = interleavedGradientNoise ( gl _FragCoord . xy ) * PI2 ;
shadow = (
texture ( shadowMap , vec3 ( shadowCoord . xy + vogelDiskSample ( 0 , 5 , phi ) * radius , shadowCoord . z ) ) +
texture ( shadowMap , vec3 ( shadowCoord . xy + vogelDiskSample ( 1 , 5 , phi ) * radius , shadowCoord . z ) ) +
texture ( shadowMap , vec3 ( shadowCoord . xy + vogelDiskSample ( 2 , 5 , phi ) * radius , shadowCoord . z ) ) +
texture ( shadowMap , vec3 ( shadowCoord . xy + vogelDiskSample ( 3 , 5 , phi ) * radius , shadowCoord . z ) ) +
texture ( shadowMap , vec3 ( shadowCoord . xy + vogelDiskSample ( 4 , 5 , phi ) * radius , shadowCoord . z ) )
) * 0.2 ;
}
return mix ( 1.0 , shadow , shadowIntensity ) ;
}
# elif defined ( SHADOWMAP _TYPE _VSM )
float getShadow ( sampler2D shadowMap , vec2 shadowMapSize , float shadowIntensity , float shadowBias , float shadowRadius , vec4 shadowCoord ) {
float shadow = 1.0 ;
shadowCoord . xyz /= shadowCoord . w ;
# ifdef USE _REVERSED _DEPTH _BUFFER
shadowCoord . z -= shadowBias ;
# else
shadowCoord . z += shadowBias ;
# endif
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 ) {
vec2 distribution = texture2D ( shadowMap , shadowCoord . xy ) . rg ;
float mean = distribution . x ;
float variance = distribution . y * distribution . y ;
# ifdef USE _REVERSED _DEPTH _BUFFER
float hard _shadow = step ( mean , shadowCoord . z ) ;
# else
float hard _shadow = step ( shadowCoord . z , mean ) ;
# endif
if ( hard _shadow == 1.0 ) {
shadow = 1.0 ;
} else {
variance = max ( variance , 0.0000001 ) ;
float d = shadowCoord . z - mean ;
float p _max = variance / ( variance + d * d ) ;
p _max = clamp ( ( p _max - 0.3 ) / 0.65 , 0.0 , 1.0 ) ;
shadow = max ( hard _shadow , p _max ) ;
}
}
return mix ( 1.0 , shadow , shadowIntensity ) ;
}
# else
float getShadow ( sampler2D shadowMap , vec2 shadowMapSize , float shadowIntensity , float shadowBias , float shadowRadius , vec4 shadowCoord ) {
float shadow = 1.0 ;
shadowCoord . xyz /= shadowCoord . w ;
# ifdef USE _REVERSED _DEPTH _BUFFER
shadowCoord . z -= shadowBias ;
# else
shadowCoord . z += shadowBias ;
# endif
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 ) {
float depth = texture2D ( shadowMap , shadowCoord . xy ) . r ;
# ifdef USE _REVERSED _DEPTH _BUFFER
shadow = step ( depth , shadowCoord . z ) ;
# else
shadow = step ( shadowCoord . z , depth ) ;
# endif
}
return mix ( 1.0 , shadow , shadowIntensity ) ;
}
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
# if defined ( SHADOWMAP _TYPE _PCF )
float getPointShadow ( samplerCubeShadow shadowMap , vec2 shadowMapSize , float shadowIntensity , float shadowBias , float shadowRadius , vec4 shadowCoord , float shadowCameraNear , float shadowCameraFar ) {
2026-04-25 18:24:50 +01:00
float shadow = 1.0 ;
2026-04-25 18:59:02 +01:00
vec3 lightToPosition = shadowCoord . xyz ;
vec3 bd3D = normalize ( lightToPosition ) ;
vec3 absVec = abs ( lightToPosition ) ;
float viewSpaceZ = max ( max ( absVec . x , absVec . y ) , absVec . z ) ;
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
# ifdef USE _REVERSED _DEPTH _BUFFER
float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ) ;
dp -= shadowBias ;
# else
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ) ;
dp += shadowBias ;
# endif
float texelSize = shadowRadius / shadowMapSize . x ;
vec3 absDir = abs ( bd3D ) ;
vec3 tangent = absDir . x > absDir . z ? vec3 ( 0.0 , 1.0 , 0.0 ) : vec3 ( 1.0 , 0.0 , 0.0 ) ;
tangent = normalize ( cross ( bd3D , tangent ) ) ;
vec3 bitangent = cross ( bd3D , tangent ) ;
float phi = interleavedGradientNoise ( gl _FragCoord . xy ) * PI2 ;
vec2 sample0 = vogelDiskSample ( 0 , 5 , phi ) ;
vec2 sample1 = vogelDiskSample ( 1 , 5 , phi ) ;
vec2 sample2 = vogelDiskSample ( 2 , 5 , phi ) ;
vec2 sample3 = vogelDiskSample ( 3 , 5 , phi ) ;
vec2 sample4 = vogelDiskSample ( 4 , 5 , phi ) ;
2026-04-25 18:24:50 +01:00
shadow = (
2026-04-25 18:59:02 +01:00
texture ( shadowMap , vec4 ( bd3D + ( tangent * sample0 . x + bitangent * sample0 . y ) * texelSize , dp ) ) +
texture ( shadowMap , vec4 ( bd3D + ( tangent * sample1 . x + bitangent * sample1 . y ) * texelSize , dp ) ) +
texture ( shadowMap , vec4 ( bd3D + ( tangent * sample2 . x + bitangent * sample2 . y ) * texelSize , dp ) ) +
texture ( shadowMap , vec4 ( bd3D + ( tangent * sample3 . x + bitangent * sample3 . y ) * texelSize , dp ) ) +
texture ( shadowMap , vec4 ( bd3D + ( tangent * sample4 . x + bitangent * sample4 . y ) * texelSize , dp ) )
) * 0.2 ;
2026-04-25 18:24:50 +01:00
}
return mix ( 1.0 , shadow , shadowIntensity ) ;
}
2026-04-25 18:59:02 +01:00
# elif defined ( SHADOWMAP _TYPE _BASIC )
float getPointShadow ( samplerCube shadowMap , vec2 shadowMapSize , float shadowIntensity , float shadowBias , float shadowRadius , vec4 shadowCoord , float shadowCameraNear , float shadowCameraFar ) {
2026-04-25 18:24:50 +01:00
float shadow = 1.0 ;
vec3 lightToPosition = shadowCoord . xyz ;
2026-04-25 18:59:02 +01:00
vec3 absVec = abs ( lightToPosition ) ;
float viewSpaceZ = max ( max ( absVec . x , absVec . y ) , absVec . z ) ;
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ) ;
dp += shadowBias ;
2026-04-25 18:24:50 +01:00
vec3 bd3D = normalize ( lightToPosition ) ;
2026-04-25 18:59:02 +01:00
float depth = textureCube ( shadowMap , bd3D ) . r ;
# ifdef USE _REVERSED _DEPTH _BUFFER
depth = 1.0 - depth ;
2026-04-25 18:24:50 +01:00
# endif
2026-04-25 18:59:02 +01:00
shadow = step ( dp , depth ) ;
2026-04-25 18:24:50 +01:00
}
return mix ( 1.0 , shadow , shadowIntensity ) ;
}
2026-04-25 18:59:02 +01:00
# endif
# endif
# endif ` ,lbe= ` # if NUM _SPOT _LIGHT _COORDS > 0
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# endif ` ,abe= ` # if ( defined ( USE _SHADOWMAP ) && ( NUM _DIR _LIGHT _SHADOWS > 0 || NUM _POINT _LIGHT _SHADOWS > 0 ) ) || ( NUM _SPOT _LIGHT _COORDS > 0 )
# ifdef HAS _NORMAL
vec3 shadowWorldNormal = inverseTransformDirection ( transformedNormal , viewMatrix ) ;
# else
vec3 shadowWorldNormal = vec3 ( 0.0 ) ;
# endif
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# endif ` ,ube= ` float getShadowMask ( ) {
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# if NUM _POINT _LIGHT _SHADOWS > 0 && ( defined ( SHADOWMAP _TYPE _PCF ) || defined ( SHADOWMAP _TYPE _BASIC ) )
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
} ` ,cbe= ` # ifdef USE _SKINNING
2026-04-25 18:24:50 +01:00
mat4 boneMatX = getBoneMatrix ( skinIndex . x ) ;
mat4 boneMatY = getBoneMatrix ( skinIndex . y ) ;
mat4 boneMatZ = getBoneMatrix ( skinIndex . z ) ;
mat4 boneMatW = getBoneMatrix ( skinIndex . w ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,dbe= ` # ifdef USE _SKINNING
2026-04-25 18:24:50 +01:00
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 ) ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,hbe= ` # ifdef USE _SKINNING
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
# endif ` ,fbe= ` # ifdef USE _SKINNING
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
# endif ` ,pbe= ` float specularStrength ;
2026-04-25 18:24:50 +01:00
# ifdef USE _SPECULARMAP
vec4 texelSpecular = texture2D ( specularMap , vSpecularMapUv ) ;
specularStrength = texelSpecular . r ;
# else
specularStrength = 1.0 ;
2026-04-25 18:59:02 +01:00
# endif ` ,Ibe= ` # ifdef USE _SPECULARMAP
2026-04-25 18:24:50 +01:00
uniform sampler2D specularMap ;
2026-04-25 18:59:02 +01:00
# endif ` ,mbe= ` # if defined ( TONE _MAPPING )
2026-04-25 18:24:50 +01:00
gl _FragColor . rgb = toneMapping ( gl _FragColor . rgb ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,ybe= ` # ifndef saturate
2026-04-25 18:24:50 +01:00
# 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 ) ;
}
2026-04-25 18:59:02 +01:00
vec3 CustomToneMapping ( vec3 color ) { return color ; } ` ,Ebe= ` # ifdef USE _TRANSMISSION
2026-04-25 18:24:50 +01:00
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 (
2026-04-25 18:59:02 +01:00
n , v , material . roughness , material . diffuseContribution , material . specularColorBlended , material . specularF90 ,
2026-04-25 18:24:50 +01:00
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 ) ;
2026-04-25 18:59:02 +01:00
# endif ` ,Tbe= ` # ifdef USE _TRANSMISSION
2026-04-25 18:24:50 +01:00
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 ) ;
}
2026-04-25 18:59:02 +01:00
# endif ` ,gbe= ` # if defined ( USE _UV ) || defined ( USE _ANISOTROPY )
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
# endif ` ,wbe= ` # if defined ( USE _UV ) || defined ( USE _ANISOTROPY )
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
# endif ` ,vbe= ` # if defined ( USE _UV ) || defined ( USE _ANISOTROPY )
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
# endif ` ,Rbe= ` # if defined ( USE _ENVMAP ) || defined ( DISTANCE ) || defined ( USE _SHADOWMAP ) || defined ( USE _TRANSMISSION ) || NUM _SPOT _LIGHT _COORDS > 0
2026-04-25 18:24:50 +01:00
vec4 worldPosition = vec4 ( transformed , 1.0 ) ;
# ifdef USE _BATCHING
worldPosition = batchingMatrix * worldPosition ;
# endif
# ifdef USE _INSTANCING
worldPosition = instanceMatrix * worldPosition ;
# endif
worldPosition = modelMatrix * worldPosition ;
2026-04-25 18:59:02 +01:00
# endif ` ,Sbe= ` varying vec2 vUv ;
2026-04-25 18:24:50 +01:00
uniform mat3 uvTransform ;
void main ( ) {
vUv = ( uvTransform * vec3 ( uv , 1 ) ) . xy ;
gl _Position = vec4 ( position . xy , 1.0 , 1.0 ) ;
2026-04-25 18:59:02 +01:00
} ` ,Abe= ` uniform sampler2D t2D ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,bbe= ` varying vec3 vWorldDirection ;
2026-04-25 18:24:50 +01:00
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
gl _Position . z = gl _Position . w ;
2026-04-25 18:59:02 +01:00
} ` ,Nbe= ` # ifdef ENVMAP _TYPE _CUBE
2026-04-25 18:24:50 +01:00
uniform samplerCube envMap ;
# elif defined ( ENVMAP _TYPE _CUBE _UV )
uniform sampler2D envMap ;
# endif
uniform float backgroundBlurriness ;
uniform float backgroundIntensity ;
uniform mat3 backgroundRotation ;
varying vec3 vWorldDirection ;
# include < cube _uv _reflection _fragment >
void main ( ) {
# ifdef ENVMAP _TYPE _CUBE
2026-04-25 18:59:02 +01:00
vec4 texColor = textureCube ( envMap , backgroundRotation * vWorldDirection ) ;
2026-04-25 18:24:50 +01:00
# 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 >
2026-04-25 18:59:02 +01:00
} ` ,_be= ` varying vec3 vWorldDirection ;
2026-04-25 18:24:50 +01:00
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
gl _Position . z = gl _Position . w ;
2026-04-25 18:59:02 +01:00
} ` ,Dbe= ` uniform samplerCube tCube ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Cbe= ` # include < common >
2026-04-25 18:24:50 +01:00
# 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 ;
2026-04-25 18:59:02 +01:00
} ` ,xbe= ` # if DEPTH _PACKING == 3200
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
# ifdef USE _REVERSED _DEPTH _BUFFER
float fragCoordZ = vHighPrecisionZW [ 0 ] / vHighPrecisionZW [ 1 ] ;
# else
float fragCoordZ = 0.5 * vHighPrecisionZW [ 0 ] / vHighPrecisionZW [ 1 ] + 0.5 ;
# endif
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
} ` ,Obe= ` # define DISTANCE
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
} ` ,Lbe= ` # define DISTANCE
2026-04-25 18:24:50 +01:00
uniform vec3 referencePosition ;
uniform float nearDistance ;
uniform float farDistance ;
varying vec3 vWorldPosition ;
# include < common >
# 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 ) ;
2026-04-25 18:59:02 +01:00
gl _FragColor = vec4 ( dist , 0.0 , 0.0 , 1.0 ) ;
} ` ,Pbe= ` varying vec3 vWorldDirection ;
2026-04-25 18:24:50 +01:00
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
2026-04-25 18:59:02 +01:00
} ` ,Mbe= ` uniform sampler2D tEquirect ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Bbe= ` uniform float scale ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Fbe= ` uniform vec3 diffuse ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Ube= ` # include < common >
2026-04-25 18:24:50 +01:00
# 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 >
2026-04-25 18:59:02 +01:00
} ` ,Hbe= ` uniform vec3 diffuse ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Gbe= ` # define LAMBERT
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Vbe= ` # define LAMBERT
2026-04-25 18:24:50 +01:00
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float opacity ;
# 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 < emissivemap _pars _fragment >
2026-04-25 18:59:02 +01:00
# include < cube _uv _reflection _fragment >
2026-04-25 18:24:50 +01:00
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
2026-04-25 18:59:02 +01:00
# include < envmap _physical _pars _fragment >
2026-04-25 18:24:50 +01:00
# 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 >
2026-04-25 18:59:02 +01:00
} ` ,kbe= ` # define MATCAP
2026-04-25 18:24:50 +01:00
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 ;
2026-04-25 18:59:02 +01:00
} ` ,zbe= ` # define MATCAP
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Wbe= ` # define NORMAL
2026-04-25 18:24:50 +01:00
# 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
2026-04-25 18:59:02 +01:00
} ` ,Ybe= ` # define NORMAL
2026-04-25 18:24:50 +01:00
uniform float opacity ;
# if defined ( FLAT _SHADED ) || defined ( USE _BUMPMAP ) || defined ( USE _NORMALMAP _TANGENTSPACE )
varying vec3 vViewPosition ;
# endif
# 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 >
2026-04-25 18:59:02 +01:00
gl _FragColor = vec4 ( normalize ( normal ) * 0.5 + 0.5 , diffuseColor . a ) ;
2026-04-25 18:24:50 +01:00
# ifdef OPAQUE
gl _FragColor . a = 1.0 ;
# endif
2026-04-25 18:59:02 +01:00
} ` ,jbe= ` # define PHONG
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,qbe= ` # define PHONG
2026-04-25 18:24:50 +01:00
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform vec3 specular ;
uniform float shininess ;
uniform float opacity ;
# 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 < emissivemap _pars _fragment >
2026-04-25 18:59:02 +01:00
# include < cube _uv _reflection _fragment >
2026-04-25 18:24:50 +01:00
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
2026-04-25 18:59:02 +01:00
# include < envmap _physical _pars _fragment >
2026-04-25 18:24:50 +01:00
# 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 >
2026-04-25 18:59:02 +01:00
} ` , $ be= ` # define STANDARD
2026-04-25 18:24:50 +01:00
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
2026-04-25 18:59:02 +01:00
} ` ,Zbe= ` # define STANDARD
2026-04-25 18:24:50 +01:00
# 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 < 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
2026-04-25 18:59:02 +01:00
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect ;
# endif
2026-04-25 18:24:50 +01:00
# 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 >
2026-04-25 18:59:02 +01:00
} ` ,Kbe= ` # define TOON
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Qbe= ` # define TOON
2026-04-25 18:24:50 +01:00
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float opacity ;
# 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 < 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 >
2026-04-25 18:59:02 +01:00
} ` ,Jbe= ` uniform float size ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Xbe= ` uniform vec3 diffuse ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,eNe= ` # include < common >
2026-04-25 18:24:50 +01:00
# 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 >
2026-04-25 18:59:02 +01:00
} ` ,tNe= ` uniform vec3 color ;
2026-04-25 18:24:50 +01:00
uniform float opacity ;
# include < common >
# 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 >
2026-04-25 18:59:02 +01:00
# include < premultiplied _alpha _fragment >
} ` ,iNe= ` uniform float rotation ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,nNe= ` uniform vec3 diffuse ;
2026-04-25 18:24:50 +01:00
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 >
2026-04-25 18:59:02 +01:00
} ` ,Ps={alphahash_fragment:SSe,alphahash_pars_fragment:ASe,alphamap_fragment:bSe,alphamap_pars_fragment:NSe,alphatest_fragment:_Se,alphatest_pars_fragment:DSe,aomap_fragment:CSe,aomap_pars_fragment:xSe,batching_pars_vertex:OSe,batching_vertex:LSe,begin_vertex:PSe,beginnormal_vertex:MSe,bsdfs:BSe,iridescence_fragment:FSe,bumpmap_pars_fragment:USe,clipping_planes_fragment:HSe,clipping_planes_pars_fragment:GSe,clipping_planes_pars_vertex:VSe,clipping_planes_vertex:kSe,color_fragment:zSe,color_pars_fragment:WSe,color_pars_vertex:YSe,color_vertex:jSe,common:qSe,cube_uv_reflection_fragment: $ Se,defaultnormal_vertex:ZSe,displacementmap_pars_vertex:KSe,displacementmap_vertex:QSe,emissivemap_fragment:JSe,emissivemap_pars_fragment:XSe,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:rAe,fog_vertex:lAe,fog_pars_vertex:aAe,fog_fragment:uAe,fog_pars_fragment:cAe,gradientmap_pars_fragment:dAe,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:gAe,lights_physical_fragment:wAe,lights_physical_pars_fragment:vAe,lights_fragment_begin:RAe,lights_fragment_maps:SAe,lights_fragment_end:AAe,lightprobes_pars_fragment:bAe,logdepthbuf_fragment:NAe,logdepthbuf_pars_fragment:_Ae,logdepthbuf_pars_vertex:DAe,logdepthbuf_vertex:CAe,map_fragment:xAe,map_pars_fragment:OAe,map_particle_fragment:LAe,map_particle_pars_fragment:PAe,metalnessmap_fragment:MAe,metalnessmap_pars_fragment:BAe,morphinstance_vertex:FAe,morphcolor_vertex:UAe,morphnormal_vertex:HAe,morphtarget_pars_vertex:GAe,morphtarget_vertex:VAe,normal_fragment_begin:kAe,normal_fragment_maps:zAe,normal_pars_fragment:WAe,normal_pars_vertex:YAe,normal_vertex:jAe,normalmap_pars_fragment:qAe,clearcoat_normal_fragment_begin: $ Ae,clearcoat_normal_fragment_maps:ZAe,clearcoat_pars_fragment:KAe,iridescence_pars_fragment:QAe,opaque_fragment:JAe,packing:XAe,premultiplied_alpha_fragment:ebe,project_vertex:tbe,dithering_fragment:ibe,dithering_pars_fragment:nbe,roughnessmap_fragment:sbe,roughnessmap_pars_fragment:obe,shadowmap_pars_fragment:rbe,shadowmap_pars_vertex:lbe,shadowmap_vertex:abe,shadowmask_pars_fragment:ube,skinbase_vertex:cbe,skinning_pars_vertex:dbe,skinning_vertex:hbe,skinnormal_vertex:fbe,specularmap_fragment:pbe,specularmap_pars_fragment:Ibe,tonemapping_fragment:mbe,tonemapping_pars_fragment:ybe,transmission_fragment:Ebe,transmission_pars_fragment:Tbe,uv_pars_fragment:gbe,uv_pars_vertex:wbe,uv_vertex:vbe,worldpos_vertex:Rbe,background_vert:Sbe,background_frag:Abe,backgroundCube_vert:bbe,backgroundCube_frag:Nbe,cube_vert:_be,cube_frag:Dbe,depth_vert:Cbe,depth_frag:xbe,distance_vert:Obe,distance_frag:Lbe,equirect_vert:Pbe,equirect_frag:Mbe,linedashed_vert:Bbe,linedashed_frag:Fbe,meshbasic_vert:Ube,meshbasic_frag:Hbe,meshlambert_vert:Gbe,meshlambert_frag:Vbe,meshmatcap_vert:kbe,meshmatcap_frag:zbe,meshnormal_vert:Wbe,meshnormal_frag:Ybe,meshphong_vert:jbe,meshphong_frag:qbe,meshphysical_vert: $ be,meshphysical_frag:Zbe,meshtoon_vert:Kbe,meshtoon_frag:Qbe,points_vert:Jbe,points_frag:Xbe,shadow_vert:eNe,shadow_frag:tNe,sprite_vert:iNe,sprite_frag:nNe},an={common:{diffuse:{value:new Oi(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Qn},alphaMap:{value:null},alphaMapTransform:{value:new Qn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Qn}},envmap:{envMap:{value:null},envMapRotation:{value:new Qn},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Qn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Qn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Qn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Qn},normalScale:{value:n
precision highp float ;
precision highp int ;
varying vec3 vOutputDirection ;
uniform sampler2D envMap ;
uniform float roughness ;
uniform float mipInt ;
# define ENVMAP _TYPE _CUBE _UV
# include < cube _uv _reflection _fragment >
# define PI 3.14159265359
// Van der Corput radical inverse
float radicalInverse _VdC ( uint bits ) {
bits = ( bits << 16 u ) | ( bits >> 16 u ) ;
bits = ( ( bits & 0x55555555 u ) << 1 u ) | ( ( bits & 0xAAAAAAAA u ) >> 1 u ) ;
bits = ( ( bits & 0x33333333 u ) << 2 u ) | ( ( bits & 0xCCCCCCCC u ) >> 2 u ) ;
bits = ( ( bits & 0x0F0F0F0F u ) << 4 u ) | ( ( bits & 0xF0F0F0F0 u ) >> 4 u ) ;
bits = ( ( bits & 0x00FF00FF u ) << 8 u ) | ( ( bits & 0xFF00FF00 u ) >> 8 u ) ;
return float ( bits ) * 2.3283064365386963 e - 10 ; // / 0x100000000
}
// Hammersley sequence
vec2 hammersley ( uint i , uint N ) {
return vec2 ( float ( i ) / float ( N ) , radicalInverse _VdC ( i ) ) ;
}
// GGX VNDF importance sampling (Eric Heitz 2018)
// "Sampling the GGX Distribution of Visible Normals"
// https://jcgt.org/published/0007/04/01/
vec3 importanceSampleGGX _VNDF ( vec2 Xi , vec3 V , float roughness ) {
float alpha = roughness * roughness ;
// Section 4.1: Orthonormal basis
vec3 T1 = vec3 ( 1.0 , 0.0 , 0.0 ) ;
vec3 T2 = cross ( V , T1 ) ;
// Section 4.2: Parameterization of projected area
float r = sqrt ( Xi . x ) ;
float phi = 2.0 * PI * Xi . y ;
float t1 = r * cos ( phi ) ;
float t2 = r * sin ( phi ) ;
float s = 0.5 * ( 1.0 + V . z ) ;
t2 = ( 1.0 - s ) * sqrt ( 1.0 - t1 * t1 ) + s * t2 ;
// Section 4.3: Reprojection onto hemisphere
vec3 Nh = t1 * T1 + t2 * T2 + sqrt ( max ( 0.0 , 1.0 - t1 * t1 - t2 * t2 ) ) * V ;
// Section 3.4: Transform back to ellipsoid configuration
return normalize ( vec3 ( alpha * Nh . x , alpha * Nh . y , max ( 0.0 , Nh . z ) ) ) ;
}
void main ( ) {
vec3 N = normalize ( vOutputDirection ) ;
vec3 V = N ; // Assume view direction equals normal for pre-filtering
vec3 prefilteredColor = vec3 ( 0.0 ) ;
float totalWeight = 0.0 ;
// For very low roughness, just sample the environment directly
if ( roughness < 0.001 ) {
gl _FragColor = vec4 ( bilinearCubeUV ( envMap , N , mipInt ) , 1.0 ) ;
return ;
}
// Tangent space basis for VNDF sampling
vec3 up = abs ( N . z ) < 0.999 ? vec3 ( 0.0 , 0.0 , 1.0 ) : vec3 ( 1.0 , 0.0 , 0.0 ) ;
vec3 tangent = normalize ( cross ( up , N ) ) ;
vec3 bitangent = cross ( N , tangent ) ;
for ( uint i = 0 u ; i < uint ( GGX _SAMPLES ) ; i ++ ) {
vec2 Xi = hammersley ( i , uint ( GGX _SAMPLES ) ) ;
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
vec3 H _tangent = importanceSampleGGX _VNDF ( Xi , vec3 ( 0.0 , 0.0 , 1.0 ) , roughness ) ;
// Transform H back to world space
vec3 H = normalize ( tangent * H _tangent . x + bitangent * H _tangent . y + N * H _tangent . z ) ;
vec3 L = normalize ( 2.0 * dot ( V , H ) * H - V ) ;
float NdotL = max ( dot ( N , L ) , 0.0 ) ;
if ( NdotL > 0.0 ) {
// Sample environment at fixed mip level
// VNDF importance sampling handles the distribution filtering
vec3 sampleColor = bilinearCubeUV ( envMap , L , mipInt ) ;
// Weight by NdotL for the split-sum approximation
// VNDF PDF naturally accounts for the visible microfacet distribution
prefilteredColor += sampleColor * NdotL ;
totalWeight += NdotL ;
}
}
if ( totalWeight > 0.0 ) {
prefilteredColor = prefilteredColor / totalWeight ;
}
gl _FragColor = vec4 ( prefilteredColor , 1.0 ) ;
}
` ,blending:Na,depthTest:!1,depthWrite:!1})}function pNe(e,t,i){let n=new Float32Array(MC),s=new ye(0,1,0);return new Kl({name:"SphericalGaussianBlur",defines:{n:MC,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP: ` $ { e } . 0 ` },uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:dj(),fragmentShader: `
2026-04-25 18:24:50 +01:00
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 ) ;
}
}
2026-04-25 18:59:02 +01:00
` ,blending:Na,depthTest:!1,depthWrite:!1})}function Mfe(){return new Kl({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:dj(),fragmentShader: `
2026-04-25 18:24:50 +01:00
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 ) ;
}
2026-04-25 18:59:02 +01:00
` ,blending:Na,depthTest:!1,depthWrite:!1})}function Bfe(){return new Kl({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:dj(),fragmentShader: `
2026-04-25 18:24:50 +01:00
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 ) ) ;
}
2026-04-25 18:59:02 +01:00
` ,blending:Na,depthTest:!1,depthWrite:!1})}function dj(){return `
2026-04-25 18:24:50 +01:00
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 ) ;
}
2026-04-25 18:59:02 +01:00
` }var yG=class extends ka{constructor(t=1,i={}){super(t,t,i),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new Nm(s),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,i){this.texture.type=i.type,this.texture.colorSpace=i.colorSpace,this.texture.generateMipmaps=i.generateMipmaps,this.texture.minFilter=i.minFilter,this.texture.magFilter=i.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader: `
varying vec3 vWorldDirection ;
2026-04-25 18:24:50 +01:00
2026-04-25 18:59:02 +01:00
vec3 transformDirection ( in vec3 dir , in mat4 matrix ) {
return normalize ( ( matrix * vec4 ( dir , 0.0 ) ) . xyz ) ;
2026-04-25 18:24:50 +01:00
2026-04-25 18:59:02 +01:00
}
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 pr(5,5,5),o=new Kl({name:"CubemapFromEquirect",uniforms:PC(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Js,blending:Na});o.uniforms.tEquirect.value=i;let r=new _i(s,o),l=i.minFilter;return i.minFilter===qc&&(i.minFilter=Us),new AC(1,10,this).update(t,r),i.minFilter=l,r.geometry.dispose(),r.material.dispose(),this}clear(t,i=!0,n=!0,s=!0){let o=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(i,n,s);t.setRenderTarget(o)}};function INe(e){let t=new WeakMap,i=new WeakMap,n=null;function s(m,y=!1){return m==null?null:y?r(m):o(m)}function o(m){if(m&&m.isTexture){let y=m.mapping;if(y===rw||y===lw)if(t.has(m)){let T=t.get(m).texture;return l(T,m.mapping)}else{let T=m.image;if(T&&T.height>0){let R=new yG(T.height);return R.fromEquirectangularTexture(e,m),t.set(m,R),m.addEventListener("dispose",h),l(R.texture,m.mapping)}else return null}}return m}function r(m){if(m&&m.isTexture){let y=m.mapping,T=y===rw||y===lw,R=y===Ef||y===VI;if(T||R){let b=i.get(m),A=b!==void 0?b.texture.pmremVersion:0;if(m.isRenderTargetTexture&&m.pmremVersion!==A)return n===null&&(n=new mG(e)),b=T?n.fromEquirectangular(m,b):n.fromCubemap(m,b),b.texture.pmremVersion=m.pmremVersion,i.set(m,b),b.texture;if(b!==void 0)return b.texture;{let O=m.image;return T&&O&&O.height>0||R&&O&&d(O)?(n===null&&(n=new mG(e)),b=T?n.fromEquirectangular(m):n.fromCubemap(m),b.texture.pmremVersion=m.pmremVersion,i.set(m,b),m.addEventListener("dispose",p),b.texture):null}}}return m}function l(m,y){return y===rw?m.mapping=Ef:y===lw&&(m.mapping=VI),m}function d(m){let y=0,T=6;for(let R=0;R<T;R++)m[R]!==void 0&&y++;return y===T}function h(m){let y=m.target;y.removeEventListener("dispose",h);let T=t.get(y);T!==void 0&&(t.delete(y),T.dispose())}function p(m){let y=m.target;y.removeEventListener("dispose",p);let T=i.get(y);T!==void 0&&(i.delete(y),T.dispose())}function I(){t=new WeakMap,i=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:I}}function mNe(e){let t={};function i(n){if(t[n]!==void 0)return t[n];let 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&&Oo("WebGLRenderer: "+n+" extension not supported."),s}}}function yNe(e,t,i,n){let s={},o=new WeakMap;function r(I){let m=I.target;m.index!==null&&t.remove(m.index);for(let T in m.attributes)t.remove(m.attributes[T]);m.removeEventListener("dispose",r),delete s[m.id];let y=o.get(m);y&&(t.remove(y),o.delete(m)),n.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,i.memory.geometries--}function l(I,m){return s[m.id]===!0||(m.addEventListener("dispose",r),s[m.id]=!0,i.memory.geometries++),m}function d(I){let m=I.attributes;for(let y in m)t.update(m[y],e.ARRAY_BUFFER)}function h(I){let m=[],y=I.index,T=I.attributes.position,R=0;if(T===void 0)return;if(y!==null){let O=y.array;R=y.version;for(let P=0,U=O.length;P<U;P+=3){let Z=O[P+0],ne=O[P+1],K=O[P+2];m.push(Z,ne,ne,K,K,Z)}}else{let O=T.array;R=T.version;for(let P=0,U=O.length/3-1;P<U;P+=3){let Z=P+0,ne=P+1,K=P+2;m.push(Z,ne,ne,K,K,Z)}}let b=new(T.count>=65535?Ob:xb)(m,1);b.version=R;let A=o.get(I);A&&t.remove(A),o.set(I,b)}function p(I){let m=o.get(I);if(m){let y=I.index;y!==null&&m.version<y.version&&h(I)}else h(I);return o.get(I)}return{get:l,update:d,getWireframeAttribute:p}}function ENe(e,t,i){let n;function s(I){n=I}let o,r;function l(I){o=I.type,r=I.bytesPerElement}function d(I,m){e.drawElements(n,m,o,I*r),i.update(m,n,1)}function h(I,m,y){y!==0&&(e.drawElementsInstanced(n,m,o,I*r,y),i.update(m,n,y))}function p(I,m,y){if(y===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,o,I,0,y);let R=0;for(let b=0;b<y;b++)R+=m[b];i.update(R,n,1)}this.setMode=s,this.setIndex=l,this.render=d,this.renderInstances=h,this.renderMultiDraw=p}function TNe(e){let t={geometries:0,textures:0},
precision highp float ;
uniform mat4 modelViewMatrix ;
uniform mat4 projectionMatrix ;
attribute vec3 position ;
attribute vec2 uv ;
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
precision highp float ;
uniform sampler2D tDiffuse ;
varying vec2 vUv ;
# include < tonemapping _pars _fragment >
# include < colorspace _pars _fragment >
void main ( ) {
gl _FragColor = texture2D ( tDiffuse , vUv ) ;
# ifdef LINEAR _TONE _MAPPING
gl _FragColor . rgb = LinearToneMapping ( gl _FragColor . rgb ) ;
# elif defined ( REINHARD _TONE _MAPPING )
gl _FragColor . rgb = ReinhardToneMapping ( gl _FragColor . rgb ) ;
# elif defined ( CINEON _TONE _MAPPING )
gl _FragColor . rgb = CineonToneMapping ( gl _FragColor . rgb ) ;
# elif defined ( ACES _FILMIC _TONE _MAPPING )
gl _FragColor . rgb = ACESFilmicToneMapping ( gl _FragColor . rgb ) ;
# elif defined ( AGX _TONE _MAPPING )
gl _FragColor . rgb = AgXToneMapping ( gl _FragColor . rgb ) ;
# elif defined ( NEUTRAL _TONE _MAPPING )
gl _FragColor . rgb = NeutralToneMapping ( gl _FragColor . rgb ) ;
# elif defined ( CUSTOM _TONE _MAPPING )
gl _FragColor . rgb = CustomToneMapping ( gl _FragColor . rgb ) ;
# endif
# ifdef SRGB _TRANSFER
gl _FragColor = sRGBTransferOETF ( gl _FragColor ) ;
# endif
} ` ,depthTest:!1,depthWrite:!1}),h=new _i(l,d),p=new ba(-1,1,1,-1,0,1),I=null,m=null,y=!1,T,R=null,b=[],A=!1;this.setSize=function(O,P){o.setSize(O,P),r.setSize(O,P);for(let U=0;U<b.length;U++){let Z=b[U];Z.setSize&&Z.setSize(O,P)}},this.setEffects=function(O){b=O,A=b.length>0&&b[0].isRenderPass===!0;let P=o.width,U=o.height;for(let Z=0;Z<b.length;Z++){let ne=b[Z];ne.setSize&&ne.setSize(P,U)}},this.begin=function(O,P){if(y||O.toneMapping===_c&&b.length===0)return!1;if(R=P,P!==null){let U=P.width,Z=P.height;(o.width!==U||o.height!==Z)&&this.setSize(U,Z)}return A===!1&&O.setRenderTarget(o),T=O.toneMapping,O.toneMapping=_c,!0},this.hasRenderPass=function(){return A},this.end=function(O,P){O.toneMapping=T,y=!0;let U=o,Z=r;for(let ne=0;ne<b.length;ne++){let K=b[ne];if(K.enabled!==!1&&(K.render(O,Z,U,P),K.needsSwap!==!1)){let oe=U;U=Z,Z=oe}}if(I!==O.outputColorSpace||m!==O.toneMapping){I=O.outputColorSpace,m=O.toneMapping,d.defines={},Hn.getTransfer(I)===pn&&(d.defines.SRGB_TRANSFER="");let ne=vNe[m];ne&&(d.defines[ne]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=U.texture,O.setRenderTarget(R),O.render(h,p),R=null,y=!1},this.isCompositing=function(){return y},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),r.dispose(),l.dispose(),d.dispose()}}var ipe=new wr,Vte=new Zl(1,1),npe=new Yv,spe=new sC,ope=new Nm,Ffe=[],Ufe=[],Hfe=new Float32Array(16),Gfe=new Float32Array(9),Vfe=new Float32Array(4);function o7(e,t,i){let n=e[0];if(n<=0||n>0)return e;let s=t*i,o=Ffe[s];if(o===void 0&&(o=new Float32Array(s),Ffe[s]=o),t!==0){n.toArray(o,0);for(let r=1,l=0;r!==t;++r)l+=i,e[r].toArray(o,l)}return o}function Zc(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function Kc(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function hj(e,t){let i=Ufe[t];i===void 0&&(i=new Int32Array(t),Ufe[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function SNe(e,t){let i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function ANe(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Zc(i,t))return;e.uniform2fv(this.addr,t),Kc(i,t)}}function bNe(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(t.r!==void 0)(i[0]!==t.r||i[1]!==t.g||i[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(Zc(i,t))return;e.uniform3fv(this.addr,t),Kc(i,t)}}function NNe(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Zc(i,t))return;e.uniform4fv(this.addr,t),Kc(i,t)}}function _Ne(e,t){let i=this.cache,n=t.elements;if(n===void 0){if(Zc(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),Kc(i,t)}else{if(Zc(i,n))return;Vfe.set(n),e.uniformMatrix2fv(this.addr,!1,Vfe),Kc(i,n)}}function DNe(e,t){let i=this.cache,n=t.elements;if(n===void 0){if(Zc(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),Kc(i,t)}else{if(Zc(i,n))return;Gfe.set(n),e.uniformMatrix3fv(this.addr,!1,Gfe),Kc(i,n)}}function CNe(e,t){let i=this.cache,n=t.elements;if(n===void 0){if(Zc(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),Kc(i,t)}else{if(Zc(i,n))return;Hfe.set(n),e.uniformMatrix4fv(this.addr,!1,Hfe),Kc(i,n)}}function xNe(e,t){let i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function ONe(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Zc(i,t))return;e.uniform2iv(this.addr,t),Kc(i,t)}}function LNe(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(Zc(i,t))return;e.uniform3iv(this.addr,t),Kc(i,t)}}function PNe(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Zc(i,t))return;e.uniform4iv(this.addr,t),K
` ),n=[],s=Math.max(t-6,0),o=Math.min(t+6,i.length);for(let r=s;r<o;r++){let l=r+1;n.push( ` $ { l === t ? ">" : " " } $ { l } : $ { i [ r ] } ` )}return n.join( `
` )}var Wfe=new Qn;function p_e(e){Hn._getMatrix(Wfe,Hn.workingColorSpace,e);let t= ` mat3 ( $ { Wfe . elements . map ( i => i . toFixed ( 4 ) ) } ) ` ;switch(Hn.getTransfer(e)){case zv:return[t,"LinearTransferOETF"];case pn:return[t,"sRGBTransferOETF"];default:return ci("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Yfe(e,t,i){let n=e.getShaderParameter(t,e.COMPILE_STATUS),o=(e.getShaderInfoLog(t)||"").trim();if(n&&o==="")return"";let r=/ERROR: 0:( \d +)/.exec(o);if(r){let l=parseInt(r[1]);return i.toUpperCase()+ `
` +o+ `
` +f_e(e.getShaderSource(t),l)}else return o}function I_e(e,t){let i=p_e(t);return[ ` vec4 $ { e } ( vec4 value ) { ` , ` return $ { i [ 1 ] } ( vec4 ( value . rgb * $ { i [ 0 ] } , value . a ) ) ; ` ,"}"].join( `
` )}var m_e={[zP]:"Linear",[WP]:"Reinhard",[YP]:"Cineon",[jP]:"ACESFilmic",[qP]:"AgX",[ $ P]:"Neutral",[YY]:"Custom"};function y_e(e,t){let i=m_e[t];return i===void 0?(ci("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}var cj=new ye;function E_e(){Hn.getLuminanceCoefficients(cj);let e=cj.x.toFixed(4),t=cj.y.toFixed(4),i=cj.z.toFixed(4);return["float luminance( const in vec3 rgb ) {", ` const vec3 weights = vec3 ( $ { e } , $ { t } , $ { i } ) ; ` ," return dot( weights, rgb );","}"].join( `
` )}function T_e(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(IG).join( `
` )}function g_e(e){let t=[];for(let i in e){let n=e[i];n!==!1&&t.push("#define "+i+" "+n)}return t.join( `
` )}function w_e(e,t){let i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let o=e.getActiveAttrib(t,s),r=o.name,l=1;o.type===e.FLOAT_MAT2&&(l=2),o.type===e.FLOAT_MAT3&&(l=3),o.type===e.FLOAT_MAT4&&(l=4),i[r]={type:o.type,location:e.getAttribLocation(t,r),locationSize:l}}return i}function IG(e){return e!==""}function jfe(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 qfe(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var v_e=/^[ \t ]*#include +<([ \w \d ./]+)>/gm;function Yte(e){return e.replace(v_e,S_e)}var R_e=new Map;function S_e(e,t){let i=Ps[t];if(i===void 0){let n=R_e.get(t);if(n!==void 0)i=Ps[n],ci('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Yte(i)}var A_e=/#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 $ fe(e){return e.replace(A_e,b_e)}function b_e(e,t,i,n){let s="";for(let o=parseInt(t);o<parseInt(i);o++)s+=n.replace(/ \[ \s *i \s * \] /g,"[ "+o+" ]").replace(/UNROLLED_LOOP_INDEX/g,o);return s}function Zfe(e){let t= ` precision $ { e . precision } float ;
2026-04-25 18:24:50 +01:00
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+= `
2026-04-25 18:59:02 +01:00
# define LOW _PRECISION ` ),t}var N_e={[eR]:"SHADOWMAP_TYPE_PCF",[xm]:"SHADOWMAP_TYPE_VSM"};function __e(e){return N_e[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var D_e={[Ef]:"ENVMAP_TYPE_CUBE",[VI]:"ENVMAP_TYPE_CUBE",[BT]:"ENVMAP_TYPE_CUBE_UV"};function C_e(e){return e.envMap===!1?"ENVMAP_TYPE_CUBE":D_e[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var x_e={[VI]:"ENVMAP_MODE_REFRACTION"};function O_e(e){return e.envMap===!1?"ENVMAP_MODE_REFLECTION":x_e[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var L_e={[zb]:"ENVMAP_BLENDING_MULTIPLY",[nG]:"ENVMAP_BLENDING_MIX",[sG]:"ENVMAP_BLENDING_ADD"};function P_e(e){return e.envMap===!1?"ENVMAP_BLENDING_NONE":L_e[e.combine]||"ENVMAP_BLENDING_NONE"}function M_e(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 B_e(e,t,i,n){let s=e.getContext(),o=i.defines,r=i.vertexShader,l=i.fragmentShader,d=__e(i),h=C_e(i),p=O_e(i),I=P_e(i),m=M_e(i),y=T_e(i),T=g_e(o),R=s.createProgram(),b,A,O=i.glslVersion?"#version "+i.glslVersion+ `
` :"";i.isRawShaderMaterial?(b=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T].filter(IG).join( `
` ),b.length>0&&(b+= `
` ),A=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T].filter(IG).join( `
` ),A.length>0&&(A+= `
` )):(b=[Zfe(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T,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 "+p:"",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.vertexNormals?"#define HAS_NORMAL":"",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:""
` ].filter(IG).join( `
` ),A=[Zfe(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T,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 "+h:"",i.envMap?"#define "+p:"",i.envMap?"#define "+I:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",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?"#define USE_COLOR":"",i.vertexAlphas||i.batchingColor?"#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 "+d:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==_c?"#define TONE_MAPPING":"",i.toneMapping!==_c?Ps.tonemapping_pars_fragment:"",i.toneMapping!==_c?y_e("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Ps.colorspace_pars_fragment,I_e("linearToOutputTexel",i.outputColorSpace),E_e(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"", `
` ].filter(IG).join( `
` )),r=Yte(r),r=jfe(r,i),r=qfe(r,i),l=Yte(l),l=jfe(l,i),l=qfe(l,i),r= $ fe(r),l= $ fe(l),i.isRawShaderMaterial!==!0&&(O= ` # version 300 es
` ,b=[y,"#define attribute in","#define varying out","#define texture2D texture"].join( `
2026-04-25 18:24:50 +01:00
` )+ `
2026-04-25 18:59:02 +01:00
` +b,A=["#define varying in",i.glslVersion===e7?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===e7?"":"#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( `
2026-04-25 18:24:50 +01:00
` )+ `
2026-04-25 18:59:02 +01:00
` +A);let P=O+b+r,U=O+A+l,Z=zfe(s,s.VERTEX_SHADER,P),ne=zfe(s,s.FRAGMENT_SHADER,U);s.attachShader(R,Z),s.attachShader(R,ne),i.index0AttributeName!==void 0?s.bindAttribLocation(R,0,i.index0AttributeName):i.morphTargets===!0&&s.bindAttribLocation(R,0,"position"),s.linkProgram(R);function K(Re){if(e.debug.checkShaderErrors){let ee=s.getProgramInfoLog(R)||"",Ae=s.getShaderInfoLog(Z)||"",Ee=s.getShaderInfoLog(ne)||"",Ce=ee.trim(),Qe=Ae.trim(),qe=Ee.trim(),St=!0, $ e=!0;if(s.getProgramParameter(R,s.LINK_STATUS)===!1)if(St=!1,typeof e.debug.onShaderError=="function")e.debug.onShaderError(s,R,Z,ne);else{let ke=Yfe(s,Z,"vertex"),It=Yfe(s,ne,"fragment");yi("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(R,s.VALIDATE_STATUS)+ `
2026-04-25 18:24:50 +01:00
2026-04-25 18:59:02 +01:00
Material Name : ` +Re.name+ `
Material Type : ` +Re.type+ `
2026-04-25 18:24:50 +01:00
2026-04-25 18:59:02 +01:00
Program Info Log : ` +Ce+ `
` +ke+ `
` +It)}else Ce!==""?ci("WebGLProgram: Program Info Log:",Ce):(Qe===""||qe==="")&&( $ e=!1); $ e&&(Re.diagnostics={runnable:St,programLog:Ce,vertexShader:{log:Qe,prefix:b},fragmentShader:{log:qe,prefix:A}})}s.deleteShader(Z),s.deleteShader(ne),oe=new n7(s,R),se=w_e(s,R)}let oe;this.getUniforms=function(){return oe===void 0&&K(this),oe};let se;this.getAttributes=function(){return se===void 0&&K(this),se};let he=i.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return he===!1&&(he=s.getProgramParameter(R,d_e)),he},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(R),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=h_e++,this.cacheKey=t,this.usedTimes=1,this.program=R,this.vertexShader=Z,this.fragmentShader=ne,this}var F_e=0,jte=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let i=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(i),o=this._getShaderStage(n),r=this._getShaderCacheForMaterial(t);return r.has(s)===!1&&(r.add(s),s.usedTimes++),r.has(o)===!1&&(r.add(o),o.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 qte(t),i.set(t,n)),n}},qte=class{constructor(t){this.id=F_e++,this.code=t,this.usedTimes=0}};function U_e(e){return e===Dc||e===WT||e===YT}function H_e(e,t,i,n,s,o){let r=new oC,l=new jte,d=new Set,h=[],p=new Map,I=n.logarithmicDepthBuffer,m=n.precision,y={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 T(oe){return d.add(oe),oe===0?"uv": ` uv$ { oe } ` }function R(oe,se,he,Re,ee,Ae){let Ee=Re.fog,Ce=ee.geometry,Qe=oe.isMeshStandardMaterial||oe.isMeshLambertMaterial||oe.isMeshPhongMaterial?Re.environment:null,qe=oe.isMeshStandardMaterial||oe.isMeshLambertMaterial&&!oe.envMap||oe.isMeshPhongMaterial&&!oe.envMap,St=t.get(oe.envMap||Qe,qe), $ e=St&&St.mapping===BT?St.image.height:null,ke=y[oe.type];oe.precision!==null&&(m=n.getMaxPrecision(oe.precision),m!==oe.precision&&ci("WebGLProgram.getParameters:",oe.precision,"not supported, using",m,"instead."));let It=Ce.morphAttributes.position||Ce.morphAttributes.normal||Ce.morphAttributes.color,ft=It!==void 0?It.length:0,Dt=0;Ce.morphAttributes.position!==void 0&&(Dt=1),Ce.morphAttributes.normal!==void 0&&(Dt=2),Ce.morphAttributes.color!==void 0&&(Dt=3);let Zt,Ct,Ut,ii;if(ke){let Un=gf[ke];Zt=Un.vertexShader,Ct=Un.fragmentShader}else Zt=oe.vertexShader,Ct=oe.fragmentShader,l.update(oe),Ut=l.getVertexShaderID(oe),ii=l.getFragmentShaderID(oe);let Vt=e.getRenderTarget(),Kt=e.state.buffers.depth.getReversed(),ui=ee.isInstancedMesh===!0,jt=ee.isBatchedMesh===!0,Oe=!!oe.map,Ft=!!oe.matcap,ge=!!St,Ue=!!oe.aoMap,Pe=!!oe.lightMap,Me=!!oe.bumpMap,ze=!!oe.normalMap,pt=!!oe.displacementMap,He=!!oe.emissiveMap,At=!!oe.metalnessMap,Tt=!!oe.roughnessMap,Lt=oe.anisotropy>0,Ht=oe.clearcoat>0,ri=oe.dispersion>0,Xe=oe.iridescence>0,We=oe.sheen>0,Mt=oe.transmission>0,si=Lt&&!!oe.anisotropyMap,gi=Ht&&!!oe.clearcoatMap,mi=Ht&&!!oe.clearcoatNormalMap,bi=Ht&&!!oe.clearcoatRoughnessMap,Qt=Xe&&!!oe.iridescenceMap,di=Xe&&!!oe.iridescenceThicknessMap,Wi=We&&!!oe.sheenColorMap,ki=We&&!!oe.sheenRoughnessMap,Pi=!!oe.specularMap,Di=!!oe.specularColorMap,dn=!!oe.specularIntensityMap,Ln=Mt&&!!oe.transmissionMap,Zi=Mt&&!!oe.thick
2026-04-25 18:24:50 +01:00
gl _Position = vec4 ( position , 1.0 ) ;
2026-04-25 18:59:02 +01:00
} ` ,K_e= ` uniform sampler2D shadow _pass ;
2026-04-25 18:24:50 +01:00
uniform vec2 resolution ;
uniform float radius ;
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
2026-04-25 18:59:02 +01:00
vec2 distribution = texture2D ( shadow _pass , ( gl _FragCoord . xy + vec2 ( uvOffset , 0.0 ) * radius ) / resolution ) . rg ;
2026-04-25 18:24:50 +01:00
mean += distribution . x ;
squared _mean += distribution . y * distribution . y + distribution . x * distribution . x ;
# else
2026-04-25 18:59:02 +01:00
float depth = texture2D ( shadow _pass , ( gl _FragCoord . xy + vec2 ( 0.0 , uvOffset ) * radius ) / resolution ) . r ;
2026-04-25 18:24:50 +01:00
mean += depth ;
squared _mean += depth * depth ;
# endif
}
mean = mean / samples ;
squared _mean = squared _mean / samples ;
2026-04-25 18:59:02 +01:00
float std _dev = sqrt ( max ( 0.0 , squared _mean - mean * mean ) ) ;
gl _FragColor = vec4 ( mean , std _dev , 0.0 , 1.0 ) ;
} ` ,Q_e=[new ye(1,0,0),new ye(-1,0,0),new ye(0,1,0),new ye(0,-1,0),new ye(0,0,1),new ye(0,0,-1)],J_e=[new ye(0,-1,0),new ye(0,-1,0),new ye(0,0,1),new ye(0,0,-1),new ye(0,-1,0),new ye(0,-1,0)],Xfe=new Ai,pG=new ye,Gte=new ye;function X_e(e,t,i){let n=new F0,s=new hi,o=new hi,r=new xn,l=new EP,d=new TP,h={},p=i.maxTextureSize,I={[ $ l]:Js,[Js]: $ l,[so]:so},m=new Kl({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new hi},radius:{value:4}},vertexShader:Z_e,fragmentShader:K_e}),y=m.clone();y.defines.HORIZONTAL_PASS=1;let T=new nn;T.setAttribute("position",new Tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let R=new _i(T,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=eR;let A=this.type;this.render=function(ne,K,oe){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||ne.length===0)return;this.type===eG&&(ci("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=eR);let se=e.getRenderTarget(),he=e.getActiveCubeFace(),Re=e.getActiveMipmapLevel(),ee=e.state;ee.setBlending(Na),ee.buffers.depth.getReversed()===!0?ee.buffers.color.setClear(0,0,0,0):ee.buffers.color.setClear(1,1,1,1),ee.buffers.depth.setTest(!0),ee.setScissorTest(!1);let Ae=A!==this.type;Ae&&K.traverse(function(Ee){Ee.material&&(Array.isArray(Ee.material)?Ee.material.forEach(Ce=>Ce.needsUpdate=!0):Ee.material.needsUpdate=!0)});for(let Ee=0,Ce=ne.length;Ee<Ce;Ee++){let Qe=ne[Ee],qe=Qe.shadow;if(qe===void 0){ci("WebGLShadowMap:",Qe,"has no shadow.");continue}if(qe.autoUpdate===!1&&qe.needsUpdate===!1)continue;s.copy(qe.mapSize);let St=qe.getFrameExtents();s.multiply(St),o.copy(qe.mapSize),(s.x>p||s.y>p)&&(s.x>p&&(o.x=Math.floor(p/St.x),s.x=o.x*St.x,qe.mapSize.x=o.x),s.y>p&&(o.y=Math.floor(p/St.y),s.y=o.y*St.y,qe.mapSize.y=o.y));let $ e=e.state.buffers.depth.getReversed();if(qe.camera._reversedDepth= $ e,qe.map===null||Ae===!0){if(qe.map!==null&&(qe.map.depthTexture!==null&&(qe.map.depthTexture.dispose(),qe.map.depthTexture=null),qe.map.dispose()),this.type===xm){if(Qe.isPointLight){ci("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}qe.map=new ka(s.x,s.y,{format:Dc,type:sr,minFilter:Us,magFilter:Us,generateMipmaps:!1}),qe.map.texture.name=Qe.name+".shadowMap",qe.map.depthTexture=new Zl(s.x,s.y,Ro),qe.map.depthTexture.name=Qe.name+".shadowMapDepth",qe.map.depthTexture.format=Aa,qe.map.depthTexture.compareFunction=null,qe.map.depthTexture.minFilter=Vs,qe.map.depthTexture.magFilter=Vs}else Qe.isPointLight?(qe.map=new yG(s.x),qe.map.depthTexture=new uC(s.x,co)):(qe.map=new ka(s.x,s.y),qe.map.depthTexture=new Zl(s.x,s.y,co)),qe.map.depthTexture.name=Qe.name+".shadowMap",qe.map.depthTexture.format=Aa,this.type===eR?(qe.map.depthTexture.compareFunction= $ e?Ty:jT,qe.map.depthTexture.minFilter=Us,qe.map.depthTexture.magFilter=Us):(qe.map.depthTexture.compareFunction=null,qe.map.depthTexture.minFilter=Vs,qe.map.depthTexture.magFilter=Vs);qe.camera.updateProjectionMatrix()}let ke=qe.map.isWebGLCubeRenderTarget?6:1;for(let It=0;It<ke;It++){if(qe.map.isWebGLCubeRenderTarget)e.setRenderTarget(qe.map,It),e.clear();else{It===0&&(e.setRenderTarget(qe.map),e.clear());let ft=qe.getViewport(It);r.set(o.x*ft.x,o.y*ft.y,o.x*ft.z,o.y*ft.w),ee.viewport(r)}if(Qe.isPointLight){let ft=qe.camera,Dt=qe.matrix,Zt=Qe.distance||ft.far;Zt!==ft.far&&(ft.far=Zt,ft.updateProjectionMatrix()),pG.setFromMatrixPosition(Qe.matrixWorld),ft.position.copy(pG),Gte.copy(ft.position),Gte.add(Q_e[It]),ft.up.copy(J_e[It]),ft.lookAt(Gte),ft.updateMatrixWorld(),Dt.makeTranslation(-pG.x,-pG.y,-pG.z),Xfe.multiplyMatrices(ft.projectionMatrix,ft.matrixWorldInverse),qe._frustum.setFromProjectionMatrix(Xfe,ft.coordinateSystem,ft.reversedDepth)}else qe.updateMatrices(Qe);n=qe.getFrustum(),U(K,oe,qe.camera,Qe,this.type)}qe.isPointLightShadow!==!0&&this.type===xm&&O(qe,oe),qe.needsUpdate=!1}A=this.type,b.needsUpdate=!1,e.setRenderTarget(se,he,Re)};function O(ne,K){let oe=t.update(R);m.defines.VSM_SAMPLES!==ne.blurSamples&&(m.defines.VSM_SAMPLES=ne.blurSamples,y.def
2026-04-25 18:24:50 +01:00
void main ( ) {
gl _Position = vec4 ( position , 1.0 ) ;
2026-04-25 18:59:02 +01:00
} ` ,nDe= `
2026-04-25 18:24:50 +01:00
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 ;
}
2026-04-25 18:59:02 +01:00
} ` , $ te=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,i){if(this.texture===null){let n=new cP(t.texture);(t.depthNear!==i.depthNear||t.depthFar!==i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let i=t.cameras[0].viewport,n=new Kl({vertexShader:iDe,fragmentShader:nDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new _i(new dp(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Zte=class extends jc{constructor(t,i){super();let n=this,s=null,o=1,r=null,l="local-floor",d=1,h=null,p=null,I=null,m=null,y=null,T=null,R=typeof XRWebGLBinding<"u",b=new $ te,A={},O=i.getContextAttributes(),P=null,U=null,Z=[],ne=[],K=new hi,oe=null,se=new xo;se.viewport=new xn;let he=new xo;he.viewport=new xn;let Re=[se,he],ee=new bC,Ae=null,Ee=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ut){let ii=Z[Ut];return ii===void 0&&(ii=new jv,Z[Ut]=ii),ii.getTargetRaySpace()},this.getControllerGrip=function(Ut){let ii=Z[Ut];return ii===void 0&&(ii=new jv,Z[Ut]=ii),ii.getGripSpace()},this.getHand=function(Ut){let ii=Z[Ut];return ii===void 0&&(ii=new jv,Z[Ut]=ii),ii.getHandSpace()};function Ce(Ut){let ii=ne.indexOf(Ut.inputSource);if(ii===-1)return;let Vt=Z[ii];Vt!==void 0&&(Vt.update(Ut.inputSource,Ut.frame,h||r),Vt.dispatchEvent({type:Ut.type,data:Ut.inputSource}))}function Qe(){s.removeEventListener("select",Ce),s.removeEventListener("selectstart",Ce),s.removeEventListener("selectend",Ce),s.removeEventListener("squeeze",Ce),s.removeEventListener("squeezestart",Ce),s.removeEventListener("squeezeend",Ce),s.removeEventListener("end",Qe),s.removeEventListener("inputsourceschange",qe);for(let Ut=0;Ut<Z.length;Ut++){let ii=ne[Ut];ii!==null&&(ne[Ut]=null,Z[Ut].disconnect(ii))}Ae=null,Ee=null,b.reset();for(let Ut in A)delete A[Ut];t.setRenderTarget(P),y=null,m=null,I=null,s=null,U=null,Ct.stop(),n.isPresenting=!1,t.setPixelRatio(oe),t.setSize(K.width,K.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Ut){o=Ut,n.isPresenting===!0&&ci("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Ut){l=Ut,n.isPresenting===!0&&ci("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||r},this.setReferenceSpace=function(Ut){h=Ut},this.getBaseLayer=function(){return m!==null?m:y},this.getBinding=function(){return I===null&&R&&(I=new XRWebGLBinding(s,i)),I},this.getFrame=function(){return T},this.getSession=function(){return s},this.setSession=async function(Ut){if(s=Ut,s!==null){if(P=t.getRenderTarget(),s.addEventListener("select",Ce),s.addEventListener("selectstart",Ce),s.addEventListener("selectend",Ce),s.addEventListener("squeeze",Ce),s.addEventListener("squeezestart",Ce),s.addEventListener("squeezeend",Ce),s.addEventListener("end",Qe),s.addEventListener("inputsourceschange",qe),O.xrCompatible!==!0&&await i.makeXRCompatible(),oe=t.getPixelRatio(),t.getSize(K),R&&"createProjectionLayer"in XRWebGLBinding.prototype){let Vt=null,Kt=null,ui=null;O.depth&&(ui=O.stencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24,Vt=O.stencil? $ c:Aa,Kt=O.stencil?yh:co);let jt={colorFormat:i.RGBA8,depthFormat:ui,scaleFactor:o};I=this.getBinding(),m=I.createProjectionLayer(jt),s.updateRenderState({layers:[m]}),t.setPixelRatio(1),t.setSize(m.textureWidth,m.textureHeight,!1),U=new ka(m.textureWidth,m.textureHeight,{format:Ko,type:Lo,depthTexture:new Zl(m.textureWidth,m.textureHeight,Kt,void 0,void 0,void 0,void 0,void 0,void 0,Vt),stencilBuffer:O.stencil,colorSpace:t.outputColorSpace,samples:O.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{let Vt={antialias:O.antialias,alpha:!0,depth:O.depth,stencil:O.stencil,framebufferScaleFactor:o};y=new XRWebGLLayer(s,i,Vt),s.updateRenderState({baseLayer:y}),t.setPixelR
` )),!k)return null;k1=WE(k,!0)}return k1.shift()},nf={ttys:[],init(){},shutdown(){},register(k,X){nf.ttys[k]={input:[],output:[],ops:X},ot.registerDevice(k,nf.stream_ops)},stream_ops:{open(k){var X=nf.ttys[k.node.rdev];if(!X)throw new ot.ErrnoError(43);k.tty=X,k.seekable=!1},close(k){k.tty.ops.fsync(k.tty)},fsync(k){k.tty.ops.fsync(k.tty)},read(k,X,we,xe,Ke){if(!k.tty||!k.tty.ops.get_char)throw new ot.ErrnoError(60);for(var yt=0,gt=0;gt<xe;gt++){var Rt;try{Rt=k.tty.ops.get_char(k.tty)}catch{throw new ot.ErrnoError(29)}if(Rt===void 0&&yt===0)throw new ot.ErrnoError(6);if(Rt==null)break;yt++,X[we+gt]=Rt}return yt&&(k.node.atime=Date.now()),yt},write(k,X,we,xe,Ke){if(!k.tty||!k.tty.ops.put_char)throw new ot.ErrnoError(60);try{for(var yt=0;yt<xe;yt++)k.tty.ops.put_char(k.tty,X[we+yt])}catch{throw new ot.ErrnoError(29)}return xe&&(k.node.mtime=k.node.ctime=Date.now()),yt}},default_tty_ops:{get_char(k){return ig()},put_char(k,X){X===null||X===10?(P(II(k.output)),k.output=[]):X!=0&&k.output.push(X)},fsync(k){k.output?.length>0&&(P(II(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,X,we){return 0},ioctl_tiocgwinsz(k){return[24,80]}},default_tty1_ops:{put_char(k,X){X===null||X===10?(U(II(k.output)),k.output=[]):X!=0&&k.output.push(X)},fsync(k){k.output?.length>0&&(U(II(k.output)),k.output=[])}}},st=k=>{jt()},jn={ops_table:null,mount(k){return jn.createNode(null,"/",16895,0)},createNode(k,X,we,xe){if(ot.isBlkdev(we)||ot.isFIFO(we))throw new ot.ErrnoError(63);jn.ops_table||={dir:{node:{getattr:jn.node_ops.getattr,setattr:jn.node_ops.setattr,lookup:jn.node_ops.lookup,mknod:jn.node_ops.mknod,rename:jn.node_ops.rename,unlink:jn.node_ops.unlink,rmdir:jn.node_ops.rmdir,readdir:jn.node_ops.readdir,symlink:jn.node_ops.symlink},stream:{llseek:jn.stream_ops.llseek}},file:{node:{getattr:jn.node_ops.getattr,setattr:jn.node_ops.setattr},stream:{llseek:jn.stream_ops.llseek,read:jn.stream_ops.read,write:jn.stream_ops.write,mmap:jn.stream_ops.mmap,msync:jn.stream_ops.msync}},link:{node:{getattr:jn.node_ops.getattr,setattr:jn.node_ops.setattr,readlink:jn.node_ops.readlink},stream:{}},chrdev:{node:{getattr:jn.node_ops.getattr,setattr:jn.node_ops.setattr},stream:ot.chrdev_stream_ops}};var Ke=ot.createNode(k,X,we,xe);return ot.isDir(Ke.mode)?(Ke.node_ops=jn.ops_table.dir.node,Ke.stream_ops=jn.ops_table.dir.stream,Ke.contents={}):ot.isFile(Ke.mode)?(Ke.node_ops=jn.ops_table.file.node,Ke.stream_ops=jn.ops_table.file.stream,Ke.usedBytes=0,Ke.contents=null):ot.isLink(Ke.mode)?(Ke.node_ops=jn.ops_table.link.node,Ke.stream_ops=jn.ops_table.link.stream):ot.isChrdev(Ke.mode)&&(Ke.node_ops=jn.ops_table.chrdev.node,Ke.stream_ops=jn.ops_table.chrdev.stream),Ke.atime=Ke.mtime=Ke.ctime=Date.now(),k&&(k.contents[X]=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,X){var we=k.contents?k.contents.length:0;if(!(we>=X)){var xe=1024*1024;X=Math.max(X,we*(we<xe?2:1.125)>>>0),we!=0&&(X=Math.max(X,256));var Ke=k.contents;k.contents=new Uint8Array(X),k.usedBytes>0&&k.contents.set(Ke.subarray(0,k.usedBytes),0)}},resizeFileStorage(k,X){if(k.usedBytes!=X)if(X==0)k.contents=null,k.usedBytes=0;else{var we=k.contents;k.contents=new Uint8Array(X),we&&k.contents.set(we.subarray(0,Math.min(X,k.usedBytes))),k.usedBytes=X}},node_ops:{getattr(k){var X={};return X.dev=ot.isChrdev(k.mode)?k.id:1,X.ino=k.id,X.mode=k.mode,X.nlink=1,X.uid=0,X.gid=0,X.rdev=k.rdev,ot.isDir(k.mode)?X.size=4096:ot.isFile(k.mode)?X.size=k.usedBytes:ot.isLink(k.mode)?X.size=k.link.length:X.size=0,X.atime=new Date(k.atime),X.mtime=new Date(k.mtime),X.ctime=new Date(k.ctime),X.blksize=4096,X.blocks=Math.ceil(X.size/X.blksize),X},setattr(k,X){for(let we of["mode","atime","mtime","ctime"])X[we]!=null&&(k[we]=X[we]);X.size!==void 0&&jn.resizeFileStorage(k,X.size)},lookup(k,X){throw jn.doesNotExistError||(jn.doesNot
2026-04-25 18:24:50 +01:00
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 .
2026-04-25 18:59:02 +01:00
Originally allocated ` );"captureStackTrace"in Error&&Error.captureStackTrace(Nt,ni),nt.leakWarning=Nt.stack.replace(/^Error: /,""),Dr.register(le,nt,le)}return le},ma=le=>Dr.unregister(le),ei(W)):(ei=le=>le,W),Xt=[],ji=()=>{for(;Xt.length;){var W=Xt.pop();W. $ $ .deleteScheduled=!1,W.delete()}},rn,Ki=()=>{let W=fn.prototype;Object.assign(W,{isAliasOf(be){if(!(this instanceof fn)||!(be instanceof fn))return!1;var Ve=this. $ $ .ptrType.registeredClass,nt=this. $ $ .ptr;be. $ $ =be. $ $ ;for(var vt=be. $ $ .ptrType.registeredClass,Nt=be. $ $ .ptr;Ve.baseClass;)nt=Ve.upcast(nt),Ve=Ve.baseClass;for(;vt.baseClass;)Nt=vt.upcast(Nt),vt=vt.baseClass;return Ve===vt&&nt===Nt},clone(){if(this. $ $ .ptr||Hc(this),this. $ $ .preservePointerOnDelete)return this. $ $ .count.value+=1,this;var be=ei(Object.create(Object.getPrototypeOf(this),{ $ $ :{value:_r(this. $ $ )}}));return be. $ $ .count.value+=1,be. $ $ .deleteScheduled=!1,be},delete(){this. $ $ .ptr||Hc(this),this. $ $ .deleteScheduled&&!this. $ $ .preservePointerOnDelete&&Yn("Object already scheduled for deletion"),ma(this),Gc(this. $ $ ),this. $ $ .preservePointerOnDelete||(this. $ $ .smartPtr=void 0,this. $ $ .ptr=void 0)},isDeleted(){return!this. $ $ .ptr},deleteLater(){return this. $ $ .ptr||Hc(this),this. $ $ .deleteScheduled&&!this. $ $ .preservePointerOnDelete&&Yn("Object already scheduled for deletion"),Xt.push(this),Xt.length===1&&rn&&rn(ji),this. $ $ .deleteScheduled=!0,this}});let le=Symbol.dispose;le&&(W[le]=W.delete)};function fn(){}var En=(W,le)=>Object.defineProperty(le,"name",{value:W}),zn=(W,le,be)=>{if(W[le].overloadTable===void 0){var Ve=W[le];W[le]=function(...nt){return W[le].overloadTable.hasOwnProperty(nt.length)||Yn( ` Function '${be}' called with an invalid number of arguments ( $ { nt . length } ) - expects one of ( $ { W [ le ] . overloadTable } ) ! ` ),W[le].overloadTable[nt.length].apply(this,nt)},W[le].overloadTable=[],W[le].overloadTable[Ve.argCount]=Ve}},Vn=(W,le,be)=>{r.hasOwnProperty(W)?((be===void 0||r[W].overloadTable!==void 0&&r[W].overloadTable[be]!==void 0)&&Yn( ` Cannot register public name '${W}' twice ` ),zn(r,W,W),r[W].overloadTable.hasOwnProperty(be)&&Yn( ` Cannot register multiple overloads of a function with the same number of arguments ( $ { be } ) ! ` ),r[W].overloadTable[be]=le):(r[W]=le,r[W].argCount=be)},wn=48,Ds=57,Ws=W=>{K(typeof W=="string"),W=W.replace(/[^a-zA-Z0-9_]/g," $ ");var le=W.charCodeAt(0);return le>=wn&&le<=Ds? ` _$ { W } ` :W};function Ys(W,le,be,Ve,nt,vt,Nt,xt){this.name=W,this.constructor=le,this.instancePrototype=be,this.rawDestructor=Ve,this.baseClass=nt,this.getActualType=vt,this.upcast=Nt,this.downcast=xt,this.pureVirtualFunctions=[]}var hs=(W,le,be)=>{for(;le!==be;)le.upcast||Yn( ` Expected null or instance of $ { be . name } , got an instance of $ { le . name } ` ),W=le.upcast(W),le=le.baseClass;return W};function uo(W,le){if(le===null)return this.isReference&&Yn( ` null is not a valid $ { this . name } ` ),0;le. $ $ ||Yn( ` Cannot pass "${Er(le)}" as a $ { this . name } ` ),le. $ $ .ptr||Yn( ` Cannot pass deleted object as a pointer of type $ { this . name } ` );var be=le. $ $ .ptrType.registeredClass,Ve=hs(le. $ $ .ptr,be,this.registeredClass);return Ve}function sn(W,le){var be;if(le===null)return this.isReference&&Yn( ` null is not a valid $ { this . name } ` ),this.isSmartPointer?(be=this.rawConstructor(),W!==null&&W.push(this.rawDestructor,be),be):0;(!le||!le. $ $ )&&Yn( ` Cannot pass "${Er(le)}" as a $ { this . name } ` ),le. $ $ .ptr||Yn( ` Cannot pass deleted object as a pointer of type $ { this . name } ` ),!this.isConst&&le. $ $ .ptrType.isConst&&Yn( ` Cannot convert argument of type $ { le . $$ . smartPtrType ? le . $$ . smartPtrType . name : le . $$ . ptrType . name } to parameter type $ { this . name } ` );var Ve=le. $ $ .ptrType.registeredClass;if(be=hs(le. $ $ .ptr,Ve,this.registeredClass),this.isSmartPointer)switch(le. $ $ .smartPtr===void 0&&Yn("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:le. $ $ .smartPtrType===this?be=le. $ $ .smartPtr:Yn( ` Cannot convert argument of type $ { le . $$ . smartPtrType ? le . $$ . smartPtrType . name : le . $$ . ptrType . name } to parameter type $ { this . name } ` );break;case 1:be=le. $ $ .smartPtr;break;case 2:if(le. $ $ .smartPtrType===this)be=le. $ $ .smartPtr;else{var nt=le.clone();be=this.rawShare(be,io.toHandle
` )),!W)return null;HE=GE(W,!0)}return HE.shift()},oh={ttys:[],init(){},shutdown(){},register(W,le){oh.ttys[W]={input:[],output:[],ops:le},st.registerDevice(W,oh.stream_ops)},stream_ops:{open(W){var le=oh.ttys[W.node.rdev];if(!le)throw new st.ErrnoError(43);W.tty=le,W.seekable=!1},close(W){W.tty.ops.fsync(W.tty)},fsync(W){W.tty.ops.fsync(W.tty)},read(W,le,be,Ve,nt){if(!W.tty||!W.tty.ops.get_char)throw new st.ErrnoError(60);for(var vt=0,Nt=0;Nt<Ve;Nt++){var xt;try{xt=W.tty.ops.get_char(W.tty)}catch{throw new st.ErrnoError(29)}if(xt===void 0&&vt===0)throw new st.ErrnoError(6);if(xt==null)break;vt++,le[be+Nt]=xt}return vt&&(W.node.atime=Date.now()),vt},write(W,le,be,Ve,nt){if(!W.tty||!W.tty.ops.put_char)throw new st.ErrnoError(60);try{for(var vt=0;vt<Ve;vt++)W.tty.ops.put_char(W.tty,le[be+vt])}catch{throw new st.ErrnoError(29)}return Ve&&(W.node.mtime=W.node.ctime=Date.now()),vt}},default_tty_ops:{get_char(W){return U4()},put_char(W,le){le===null||le===10?(O(Yo(W.output)),W.output=[]):le!=0&&W.output.push(le)},fsync(W){W.output?.length>0&&(O(Yo(W.output)),W.output=[])},ioctl_tcgets(W){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(W,le,be){return 0},ioctl_tiocgwinsz(W){return[24,80]}},default_tty1_ops:{put_char(W,le){le===null||le===10?(P(Yo(W.output)),W.output=[]):le!=0&&W.output.push(le)},fsync(W){W.output?.length>0&&(P(Yo(W.output)),W.output=[])}}},eg=W=>{Ue("internal error: mmapAlloc called but ` emscripten _builtin _memalign ` native symbol not exported")},fs={ops_table:null,mount(W){return fs.createNode(null,"/",16895,0)},createNode(W,le,be,Ve){if(st.isBlkdev(be)||st.isFIFO(be))throw new st.ErrnoError(63);fs.ops_table||={dir:{node:{getattr:fs.node_ops.getattr,setattr:fs.node_ops.setattr,lookup:fs.node_ops.lookup,mknod:fs.node_ops.mknod,rename:fs.node_ops.rename,unlink:fs.node_ops.unlink,rmdir:fs.node_ops.rmdir,readdir:fs.node_ops.readdir,symlink:fs.node_ops.symlink},stream:{llseek:fs.stream_ops.llseek}},file:{node:{getattr:fs.node_ops.getattr,setattr:fs.node_ops.setattr},stream:{llseek:fs.stream_ops.llseek,read:fs.stream_ops.read,write:fs.stream_ops.write,mmap:fs.stream_ops.mmap,msync:fs.stream_ops.msync}},link:{node:{getattr:fs.node_ops.getattr,setattr:fs.node_ops.setattr,readlink:fs.node_ops.readlink},stream:{}},chrdev:{node:{getattr:fs.node_ops.getattr,setattr:fs.node_ops.setattr},stream:st.chrdev_stream_ops}};var nt=st.createNode(W,le,be,Ve);return st.isDir(nt.mode)?(nt.node_ops=fs.ops_table.dir.node,nt.stream_ops=fs.ops_table.dir.stream,nt.contents={}):st.isFile(nt.mode)?(nt.node_ops=fs.ops_table.file.node,nt.stream_ops=fs.ops_table.file.stream,nt.usedBytes=0,nt.contents=null):st.isLink(nt.mode)?(nt.node_ops=fs.ops_table.link.node,nt.stream_ops=fs.ops_table.link.stream):st.isChrdev(nt.mode)&&(nt.node_ops=fs.ops_table.chrdev.node,nt.stream_ops=fs.ops_table.chrdev.stream),nt.atime=nt.mtime=nt.ctime=Date.now(),W&&(W.contents[le]=nt,W.atime=W.mtime=W.ctime=nt.atime),nt},getFileDataAsTypedArray(W){return W.contents?W.contents.subarray?W.contents.subarray(0,W.usedBytes):new Uint8Array(W.contents):new Uint8Array(0)},expandFileStorage(W,le){var be=W.contents?W.contents.length:0;if(!(be>=le)){var Ve=1024*1024;le=Math.max(le,be*(be<Ve?2:1.125)>>>0),be!=0&&(le=Math.max(le,256));var nt=W.contents;W.contents=new Uint8Array(le),W.usedBytes>0&&W.contents.set(nt.subarray(0,W.usedBytes),0)}},resizeFileStorage(W,le){if(W.usedBytes!=le)if(le==0)W.contents=null,W.usedBytes=0;else{var be=W.contents;W.contents=new Uint8Array(le),be&&W.contents.set(be.subarray(0,Math.min(le,W.usedBytes))),W.usedBytes=le}},node_ops:{getattr(W){var le={};return le.dev=st.isChrdev(W.mode)?W.id:1,le.ino=W.id,le.mode=W.mode,le.nlink=1,le.uid=0,le.gid=0,le.rdev=W.rdev,st.isDir(W.mode)?le.size=4096:st.isFile(W.mode)?le.size=W.usedBytes:st.isLink(W.mode)?le.size=W.link.length:le.size=0,le.atime=new Date(W.atime),le.mtime=new Date(W.mtime),le.ctime=new Date(W.ctime),le.blksize=4096,le.blocks=Math.ceil(le.size/le.blksize),le},setattr(W,le){for(let be of["mode",
2026-04-25 18:24:50 +01:00
# 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 ( ) {
2026-04-25 18:59:02 +01:00
float alpha = opacity ;
vec4 diffuseColor = vec4 ( diffuse , alpha ) ;
2026-04-25 18:24:50 +01:00
# 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
# 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
# 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 >
}
2026-04-25 18:59:02 +01:00
` };var iE=class extends Kl{constructor(t){super({type:"LineMaterial",uniforms:eN.clone(gf.line.uniforms),vertexShader:gf.line.vertexShader,fragmentShader:gf.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.worldUnits&&(this.needsUpdate=!0),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)}};var kie=new xn,Ype=new ye,jpe=new ye,Hh=new xn,Gh=new xn,c2=new xn,zie=new ye,Wie=new Ai,Vh=new ds,qpe=new ye,bq=new kn,Nq=new no,d2=new xn,h2, $ 6;function $ pe(e,t,i){return d2.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),d2.multiplyScalar(1/d2.w),d2.x= $ 6/i.width,d2.y= $ 6/i.height,d2.applyMatrix4(e.projectionMatrixInverse),d2.multiplyScalar(1/d2.w),Math.abs(Math.max(d2.x,d2.y))}function Yxe(e,t){let i=e.matrixWorld,n=e.geometry,s=n.attributes.instanceStart,o=n.attributes.instanceEnd,r=Math.min(n.instanceCount,s.count);for(let l=0,d=r;l<d;l++){Vh.start.fromBufferAttribute(s,l),Vh.end.fromBufferAttribute(o,l),Vh.applyMatrix4(i);let h=new ye,p=new ye;h2.distanceSqToSegment(Vh.start,Vh.end,p,h),p.distanceTo(h)< $ 6*.5&&t.push({point:p,pointOnLine:h,distance:h2.origin.distanceTo(p),object:e,face:null,faceIndex:l,uv:null,uv1:null})}}function jxe(e,t,i){let n=t.projectionMatrix,o=e.material.resolution,r=e.matrixWorld,l=e.geometry,d=l.attributes.instanceStart,h=l.attributes.instanceEnd,p=Math.min(l.instanceCount,d.count),I=-t.near;h2.at(1,c2),c2.w=1,c2.applyMatrix4(t.matrixWorldInverse),c2.applyMatrix4(n),c2.multiplyScalar(1/c2.w),c2.x*=o.x/2,c2.y*=o.y/2,c2.z=0,zie.copy(c2),Wie.multiplyMatrices(t.matrixWorldInverse,r);for(let m=0,y=p;m<y;m++){if(Hh.fromBufferAttribute(d,m),Gh.fromBufferAttribute(h,m),Hh.w=1,Gh.w=1,Hh.applyMatrix4(Wie),Gh.applyMatrix4(Wie),Hh.z>I&&Gh.z>I)continue;if(Hh.z>I){let P=Hh.z-Gh.z,U=(Hh.z-I)/P;Hh.lerp(Gh,U)}else if(Gh.z>I){let P=Gh.z-Hh.z,U=(Gh.z-I)/P;Gh.lerp(Hh,U)}Hh.applyMatrix4(n),Gh.applyMatrix4(n),Hh.multiplyScalar(1/Hh.w),Gh.multiplyScalar(1/Gh.w),Hh.x*=o.x/2,Hh.y*=o.y/2,Gh.x*=o.x/2,Gh.y*=o.y/2,Vh.start.copy(Hh),Vh.start.z=0,Vh.end.copy(Gh),Vh.end.z=0;let R=Vh.closestPointToPointParameter(zie,!0);Vh.at(R,qpe);let b=cr.lerp(Hh.z,Gh.z,R),A=b>=-1&&b<=1,O=zie.distanceTo(qpe)< $ 6*.5;if(A&&O){Vh.start.fromBufferAttribute(d,m),Vh.end.fromBufferAttribute(h,m),Vh.start.applyMatrix4(r),Vh.end.applyMatrix4(r);let P=new ye,U=new ye;h2.distanceSqToSegment(Vh.start,Vh.end,U,P),i.push({point:U,pointOnLine:P,distance:h2.origin.distanceTo(U),object:e,face:null,faceIndex:m,uv:null,uv1:null})}}}var _q=class extends _i{constructor(t=new s8,i=new iE({color:Math.random()*16777215})){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 r=0,
2026-04-25 18:24:50 +01:00
# 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 ) ;
}
2026-04-25 18:59:02 +01:00
varying float vHighlight ;
2026-04-25 18:24:50 +01:00
void main ( ) {
if ( itemFilter == 0.0 ) {
gl _Position = vec4 ( 0 , 0 , 0 , 0 ) ;
return ;
}
2026-04-25 18:59:02 +01:00
vHighlight = itemFilter > 1.5 ? 1.0 : 0.0 ;
2026-04-25 18:24:50 +01:00
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 >
}
2026-04-25 18:59:02 +01:00
` );Ne(R8,"fragment", `
2026-04-25 18:24:50 +01:00
# include < common >
# include < clipping _planes _pars _fragment >
uniform vec3 lodColor ;
uniform float lodOpacity ;
2026-04-25 18:59:02 +01:00
uniform vec3 highlightColor ;
uniform float highlightOpacity ;
varying float vHighlight ;
2026-04-25 18:24:50 +01:00
void main ( ) {
# include < clipping _planes _fragment >
2026-04-25 18:59:02 +01:00
vec3 color = mix ( lodColor , highlightColor , vHighlight ) ;
float alpha = mix ( lodOpacity , highlightOpacity , vHighlight ) ;
gl _FragColor = vec4 ( color , alpha ) ;
2026-04-25 18:24:50 +01:00
# include < colorspace _fragment >
}
2026-04-25 18:59:02 +01:00
` );var Ik=class ON{static setupLodMeshResize(t){t.onBeforeRender=i=>{i.getSize(t.material[0].lodSize)}}static setupLodAttributes(t){t.setIndex(ON.indices),t.setAttribute("position",ON.vertices)}static setLodBuffer(t,i,n){let s=t.getItemFirst(),o=t.getItemLast(),r=this.setItemFirst(t,s,i,o);({itemFirst:s,dataBuffer:r,itemLast:o}=this.resetAttributes(s,r,i,o)),this.setupFinish(n,r),t.setAttribute("itemFirst",s),t.setAttribute("itemLast",o)}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=ON.getLodMidPoint(t,i),s=ON.getLodRadius(n,i);t.boundingSphere.radius=s}}static newLodMaterialParams(t){let i={lodColor:{value:new Oi(t.color)},lodSize:{value:new hi(1,1)},lodOpacity:{value:t.opacity??1},highlightColor:{value:new Oi(1,1,1)},highlightOpacity:{value:1}},n=eN.merge([an.common,i]),s=t.transparent??!1;return{uniforms:n,transparent:s,vertexShader:R8.vertex,fragmentShader:R8.fragment}}static setLodFilter(t,i){let n=t.getItemFilter(),s=n.array;for(let o=0;o<i.position.length;++o){let r=i.position[o]/2,l=i.size[o]/2;l===4294967295?s.fill(1,r):s.fill(1,r,r+l)}n.needsUpdate=!0}static setLodHighlight(t,i){let n=t.getItemFilter(),s=n.array;for(let o=0;o<i.position.length;++o){let r=i.position[o]/2,l=i.size[o]/2;l===4294967295?s.fill(2,r):s.fill(2,r,r+l)}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);return}t.boundingBox.makeEmpty()}static setDataBuffer(t,i,n){return t=i.data,t.array=n,t.needsUpdate=!0,t}static disposeAllData(t){delete t.attributes.itemFilter,delete t.attributes.position,t.index=null,t.dispose(),ON.setupLodAttributes(t)}static setItemFirst(t,i,n,s){let o=null;return i&&(n.length===i.data.array.length?o=this.setDataBuffer(o,i,n):(i=void 0,this.disposeAllData(t))),o}static setupFinish(t,i){t&&(i.onUploadCallback=t)}static resetAttributes(t,i,n,s){return t||(i=new Dm(n,6,1),t=new Du(i,3,0),s=new Du(i,3,3)),{itemFirst:t,dataBuffer:i,itemLast:s}}static setupItemFilter(t){let n=t.getItemFirst().count,s=t.getItemFilter();return s?s.array.fill(0):(s=new B0(new Uint8Array(n),1),t.setAttribute("itemFilter",s)),s}static applyVisibilityState(t,i,n){if(i===!0){n.array.fill(1);return}i&&this.setLodFilter(t,i)}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 o=0;o<s;o+=3){let r=i.data.array;ON.tempVec.fromArray(r,o);let l=t.distanceToSquared(ON.tempVec);n=Math.max(n,l)}return Math.sqrt(n)}};Ne(Ik,"tempVec",new ye);Ne(Ik,"tempBox",new kn);Ne(Ik,"vertices",new ln([-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));Ne(Ik,"indices",new aP([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5],1));var D3=Ik,d $ =class extends _i{constructor(t,i){super(t,i),Ne(this,"geometry"),Ne(this,"material"),this.geometry=t,this.material=i,D3.setupLodMeshResize(this)}},qne=class extends Xv{constructor(){super(),Ne(this,"isLODGeometry",!0),D3.setupLodAttributes(this)}isFiltered(){return!!this.getItemFilter()}computeBoundingBox(){this.boundingBox||(this.boundingBox=new kn),D3.computeLodBox(this)}applyMatrix4(t){return this.applyTransformToBuffers(t),this.updateBounds(),this}computeBoundingSphere(){this.boundingSphere||(this.boundingSphere=new no),D3.computeLodSphere(this)}getItemFilter(){return D3.getInstancedAttribute(this,"itemFilter")}getItemLast(){return D3.getInterAttribute(this,"itemLast")}getItemFirst(){return D3.getInterAttribute(this,"itemFirst")}applyTransformToBuffers(t){this.getItemFirst().applyMatrix4(t),this.getItemLast().applyMatrix4(t)}updateBounds(){this.boundingBox&&this.computeBoundingBox(),this.boundingSphere&&this.computeBoundingSphere()}}, $ ne=class extends Kl{constructor(t){super(D3.newLodMaterialParams(t)),Ne(this,"isLodMaterial",!0),Ne(thi
` ).map(i=>{let n=i.match(t);if(!n)return null;let s=n[1]||n[2]||"",o=n[3].split("?")[0],r=parseInt(n[4],10),l=parseInt(n[5],10),d=o.split("/").pop();return{fn:s,file:d,line:r,column:l}}).filter(i=>i&&!R8e.some(n=>n.test(i.file)))}var ha=class{constructor(t=null){this.isStackTrace=!0,this.stack=S8e(t||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";let t=this.stack[0],i=t.fn;return ` $ { i ? ` " ${ i } ()" at ` : "" } "${t.file}:${t.line}" ` }getError(t){if(this.stack.length===0)return t;let i=this.stack.map(n=>{let s= ` $ { n . file } : $ { n . line } : $ { n . column } ` ;return n.fn? ` at $ { n . fn } ( $ { s } ) ` : ` at $ { s } ` }).join( `
` );return ` $ { t }
$ { i } ` }};function Sue(e,t=0){let i=3735928559^t,n=1103547991^t;if(Array.isArray(e))for(let s=0,o;s<e.length;s++)o=e[s],i=Math.imul(i^o,2654435761),n=Math.imul(n^o,1597334677);else for(let s=0,o;s<e.length;s++)o=e.charCodeAt(s),i=Math.imul(i^o,2654435761),n=Math.imul(n^o,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&n)+(i>>>0)}var X8=e=>Sue(e),sz=e=>Sue(e),xk=(...e)=>Sue(e),A8e=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),e1e=new WeakMap;function yye(e){return A8e.get(e)}function oZ(e){if(/[iu]?vec \d /.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;if(/mat \d /.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw new Error( ` THREE . NodeUtils : Unsupported type : $ { e } ` )}function Eye(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;yi( ` TSL : Unsupported type : $ { e } ` ,new ha)}function b8e(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;yi( ` TSL : Unsupported type : $ { e } ` ,new ha)}function N8e(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e)||/mat4/.test(e))return 16;yi( ` TSL : Unsupported type : $ { e } ` ,new ha)}function o_(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":e.isVector2===!0?"vec2":e.isVector3===!0?"vec3":e.isVector4===!0?"vec4":e.isMatrix2===!0?"mat2":e.isMatrix3===!0?"mat3":e.isMatrix4===!0?"mat4":e.isColor===!0?"color":e instanceof ArrayBuffer?"ArrayBuffer":null}function Aue(e,...t){let i=e?e.slice(-4):void 0;return t.length===1&&(i==="vec2"?t=[t[0],t[0]]:i==="vec3"?t=[t[0],t[0],t[0]]:i==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),e==="color"?new Oi(...t):i==="vec2"?new hi(...t):i==="vec3"?new ye(...t):i==="vec4"?new xn(...t):i==="mat2"?new NC(...t):i==="mat3"?new Qn(...t):i==="mat4"?new Ai(...t):e==="bool"?t[0]||!1:e==="float"||e==="int"||e==="uint"?t[0]||0:e==="string"?t[0]||"":e==="ArrayBuffer"?D8e(t[0]):null}function Tye(e){let t=e1e.get(e);return t===void 0&&(t={},e1e.set(e,t)),t}function _8e(e){let t="",i=new Uint8Array(e);for(let n=0;n<i.length;n++)t+=String.fromCharCode(i[n]);return btoa(t)}function D8e(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0)).buffer}var Dk={VERTEX:"vertex",FRAGMENT:"fragment"},Zn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},C8e={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},jh={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},gye=["fragment","vertex"],X $ =["setup","analyze","generate"],eZ=[...gye,"compute"],Cx=["x","y","z","w"],x8e={analyze:"setup",generate:"analyze"},O8e=0,Sn=class e extends jc{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=Zn.NONE,this.updateBeforeType=Zn.NONE,this.updateAfterType=Zn.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=O8e++,this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new ha)}set needsUpdate(t){t===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=cr.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(t,i){return this.updateType=i,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,Zn.FRAME)}onRenderUpdate(t){return this.onUpdate(t,Zn.RENDER)}onObjectUpdate(t){return this.onUpdate(t,Zn.OBJECT)}onReference(t){return this.updateReference=t.bind
$ { t . tab } if ( $ { I } ) {
` ).addFlowTab();let y=r.build(t,n);if(y&&(h?y=p+" = "+y+";":(y="return "+y+";",d===null&&(ci("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),y="// "+y))),t.removeFlowTab().addFlowCode(t.tab+" "+y+ `
` +t.tab+"}"),l!==null){t.addFlowCode( ` else {
` ).addFlowTab();let T=l.build(t,n);T&&(h?T=p+" = "+T+";":(T="return "+T+";",d===null&&(ci("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),T="// "+T))),t.removeFlowTab().addFlowCode(t.tab+" "+T+ `
` +t.tab+ ` }
` )}else t.addFlowCode( `
` );return t.format(p,n,i)}},jf=ys(rre).setParameterLength(2,3);Ti("select",jf);var yZ=class extends Sn{static get type(){return"ContextNode"}constructor(t=null,i={}){super(),this.isContextNode=!0,this.node=t,this.value=i}getScope(){return this.node.getScope()}generateNodeType(t){return this.node.getNodeType(t)}getFlowContextData(){let t=[];return this.traverse(i=>{i.isContextNode===!0&&t.push(i.value)}),Object.assign({},...t)}getMemberType(t,i){return this.node.getMemberType(t,i)}analyze(t){let i=t.addContext(this.value);this.node.build(t),t.setContext(i)}setup(t){let i=t.addContext(this.value);this.node.build(t),t.setContext(i)}generate(t,i){let n=t.addContext(this.value),s=this.node.build(t,i);return t.setContext(n),s}},ZS=(e=null,t={})=>{let i=e;return(i===null||i.isNode!==!0)&&(t=i||t,i=null),new yZ(i,t)},_Ee=e=>ZS(e,{uniformFlow:!0}),tce=(e,t)=>ZS(e,{nodeName:t});function DEe(e,t,i=null){return ZS(i,{getShadow:({light:n,shadowColorNode:s})=>t===n?s.mul(e):s})}function CEe(e,t=null){return ZS(t,{getAO:(i,{material:n})=>n.transparent===!0?i:i!==null?i.mul(e):e})}function xEe(e,t){return ci('TSL: "label()" has been deprecated. Use "setName()" instead.'),tce(e,t)}Ti("context",ZS);Ti("label",xEe);Ti("uniformFlow",_Ee);Ti("setName",tce);Ti("builtinShadowContext",(e,t,i)=>DEe(t,i,e));Ti("builtinAOContext",(e,t)=>CEe(t,e));var H8=class extends Sn{static get type(){return"VarNode"}constructor(t,i=null,n=!1){super(),this.node=t,this.name=i,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(t){return this.intent=t,this}isIntent(t){return t.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(t,i){return this.node.getMemberType(t,i)}getElementType(t){return this.node.getElementType(t)}generateNodeType(t){return this.node.getNodeType(t)}getArrayCount(t){return this.node.getArrayCount(t)}isAssign(t){return t.getDataFromNode(this).assign}build(...t){let i=t[0];if(this._hasStack(i)===!1&&i.buildStage==="setup"&&(i.context.nodeLoop||i.context.nodeBlock)){let n=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&i.fnCall&&i.fnCall.shaderNode&&i.getDataFromNode(this.node.shaderNode).hasLoop){let r=i.getDataFromNode(this);r.forceDeclaration=!0,n=!0}let s=i.getBaseStack();n?s.addToStackBefore(this):s.addToStack(this)}return this.isIntent(i)&&this.isAssign(i)!==!0?this.node.build(...t):super.build(...t)}generate(t){let{node:i,name:n,readOnly:s}=this,{renderer:o}=t,r=o.backend.isWebGPUBackend===!0,l=!1,d=!1;s&&(l=t.isDeterministic(i),d=r?s:l);let h=this.getNodeType(t);if(h=="void")return this.isIntent(t)!==!0&&yi('TSL: ".toVar()" can not be used with void type.',this.stackTrace),i.build(t);let p=t.getVectorType(h),I=i.build(t,p),m=t.getVarFromNode(this,n,p,void 0,d),y=t.getPropertyName(m),T=y;if(d)if(r)T=l? ` const $ { y } ` : ` let $ { y } ` ;else{let R=i.getArrayCount(t);T= ` const $ { t . getVar ( m . type , y , R ) } ` }return t.addLineFlowCode( ` $ { T } = $ { I } ` ,this),y}_hasStack(t){return t.getDataFromNode(this).stack!==void 0}},ice=ys(H8),OEe=(e,t=null)=>ice(e,t).toStack(),LEe=(e,t=null)=>ice(e,t,!0).toStack(),PEe=e=>ice(e).setIntent(!0).toStack();Ti("toVar",OEe);Ti("toConst",LEe);Ti("toVarIntent",PEe);var lre=class extends Sn{static get type(){return"SubBuild"}constructor(t,i,n=null){super(n),this.node=t,this.name=i,this.isSubBuildNode=!0}generateNodeType(t){if(this.nodeType!==null)return this.nodeType;t.addSubBuild(this.name);let i=this.node.getNodeType(t);return t.removeSubBuild(),i}build(t,...i){t.addSubBuild(this.name);let n=this.node.build(t,...i);return t.removeSubBuild(),n}},Sx=(e,t,i=null)=>new lre(gn(e),t,i),are=class extends Sn{static get type(){return"VaryingNode"}constructor(t,i=null){super(),this.node=Sx(t,"VERTEX"),this.name=i,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(t,i=null){return this.interpolationType=t,this.interpolationSampling=i,this}getHash(t){return this.name||super.getHash(t)}generateNodeType(t){return this.node.getNodeType(t)}setupVarying(t){let i=t.
$ { t . flow . code } ` }}else{let o=t.getNodeProperties(this).outputComputeNode;if(o)return o.build(t,i)}}},oce=(e,t=[64])=>{(t.length===0||t.length>3)&&yi("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new ha);for(let i=0;i<t.length;i++){let n=t[i];(typeof n!="number"||n<=0||!Number.isInteger(n))&&yi( ` TSL : compute ( ) workgroupSize element at index [ $ { i } ] must be a positive integer ` ,new ha)}for(;t.length<3;)t.push(1);return new hre(gn(e),t)},WEe=(e,t,i)=>{let n=oce(e,i);return typeof t=="number"?n.count=t:n.dispatchSize=t,n};Ti("compute",WEe);Ti("computeKernel",oce);var fre=class extends Sn{static get type(){return"IsolateNode"}constructor(t,i=!0){super(),this.node=t,this.parent=i,this.isIsolateNode=!0}generateNodeType(t){let i=t.getCache(),n=t.getCacheFromNode(this,this.parent);t.setCache(n);let s=this.node.getNodeType(t);return t.setCache(i),s}build(t,...i){let n=t.getCache(),s=t.getCacheFromNode(this,this.parent);t.setCache(s);let o=this.node.build(t,...i);return t.setCache(n),o}setParent(t){return this.parent=t,this}getParent(){return this.parent}},G8=e=>new fre(gn(e));function YEe(e,t=!0){return ci('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),G8(e).setParent(t)}Ti("cache",YEe);Ti("isolate",G8);var pre=class extends Sn{static get type(){return"BypassNode"}constructor(t,i){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=i}generateNodeType(t){return this.outputNode.getNodeType(t)}generate(t){let i=this.callNode.build(t,"void");return i!==""&&t.addLineFlowCode(i,this),this.outputNode.build(t)}},jEe=ys(pre).setParameterLength(2);Ti("bypass",jEe);var rce=Wt(([e,t,i,n=Et(0),s=Et(1),o=M1(!1)])=>{let r=e.sub(t).div(i.sub(t));return z8(o)&&(r=r.clamp()),r.mul(s.sub(n)).add(n)});function qEe(e,t,i,n=Et(0),s=Et(1)){return rce(e,t,i,n,s,!0)}Ti("remap",rce);Ti("remapClamp",qEe);var V8=class extends Sn{static get type(){return"ExpressionNode"}constructor(t="",i="void"){super(i),this.snippet=t}generate(t,i){let n=this.getNodeType(t),s=this.snippet;if(n==="void")t.addLineFlowCode(s,this);else return t.format(s,n,i)}},P1=ys(V8).setParameterLength(1,2), $ Ee=e=>(e?jf(e,P1("discard")):P1("discard")).toStack(),fMe=()=>P1("return").toStack();Ti("discard", $ Ee);var Ire=class extends Fl{static get type(){return"RenderOutputNode"}constructor(t,i,n){super("vec4"),this.colorNode=t,this._toneMapping=i,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(t){return this._toneMapping=t,this}getToneMapping(){return this._toneMapping}setup({context:t}){let i=this.colorNode||t.color,n=(this._toneMapping!==null?this._toneMapping:t.toneMapping)||_c,s=(this.outputColorSpace!==null?this.outputColorSpace:t.outputColorSpace)||Eh;return n!==_c&&(i=i.toneMapping(n)),s!==Eh&&s!==Hn.workingColorSpace&&(i=i.workingToColorSpace(s)),i}},lce=(e,t=null,i=null)=>new Ire(gn(e),t,i);Ti("renderOutput",lce);var mre=class extends Fl{static get type(){return"DebugNode"}constructor(t,i=null){super(),this.node=t,this.callback=i}generateNodeType(t){return this.node.getNodeType(t)}setup(t){return this.node.build(t)}analyze(t){return this.node.build(t)}generate(t){let i=this.callback,n=this.node.build(t);if(i!==null)i(t,n);else{let s="--- TSL debug - "+t.shaderStage+" shader ---",o="-".repeat(s.length),r="";r+="// #"+s+ ` #
` ,r+=t.flow.code.replace(/^ \t /mg,"")+ `
` ,r+="/* ... */ "+n+ ` /* ... */
` ,r+="// #"+o+ ` #
` ,Cb(r)}return n}},ZEe=(e,t=null)=>new mre(gn(e),t).toStack();Ti("debug",ZEe);var gZ=class extends jc{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(t){return this._renderer=t,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},yre=class extends Sn{static get type(){return"InspectorNode"}constructor(t,i="",n=null){super(),this.node=t,this.name=i,this.callback=n,this.updateType=Zn.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(t){t.renderer.inspector.inspect(this)}generateNodeType(t){return this.node.getNodeType(t)}setup(t){let i=this.node;return t.context.inspector===!0&&this.callback!==null&&(i=this.callback(i)),t.renderer.backend.isWebGPUBackend!==!0&&t.renderer.inspector.constructor!==gZ&&Oo('TSL: ".toInspector()" is only available with WebGPU.'),i}};function KEe(e,t="",i=null){return e=gn(e),e.before(new yre(e,t,i))}Ti("toInspector",KEe);function pMe(e){ci("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)}var wZ=class extends Sn{static get type(){return"AttributeNode"}constructor(t,i=null){super(i),this.global=!0,this._attributeName=t}getHash(t){return this.getAttributeName(t)}generateNodeType(t){let i=this.nodeType;if(i===null){let n=this.getAttributeName(t);if(t.hasGeometryAttribute(n)){let s=t.geometry.getAttribute(n);i=t.getTypeFromAttribute(s)}else i="float"}return i}setAttributeName(t){return this._attributeName=t,this}getAttributeName(){return this._attributeName}generate(t){let i=this.getAttributeName(t),n=this.getNodeType(t);if(t.hasGeometryAttribute(i)===!0){let o=t.geometry.getAttribute(i),r=t.getTypeFromAttribute(o),l=t.getAttribute(i,r);return t.shaderStage==="vertex"?t.format(l.name,r,n):f_(this).build(t,n)}else return ci( ` AttributeNode : Vertex attribute "${i}" not found on geometry . ` ),t.generateConst(n)}serialize(t){super.serialize(t),t.global=this.global,t._attributeName=this._attributeName}deserialize(t){super.deserialize(t),this.global=t.global,this._attributeName=t._attributeName}},qS=(e,t=null)=>new wZ(e,t),er=(e=0)=>qS("uv"+(e>0?e:""),"vec2"),Ere=class extends Sn{static get type(){return"TextureSizeNode"}constructor(t,i=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=t,this.levelNode=i}generate(t,i){let n=this.textureNode.build(t,"property"),s=this.levelNode===null?"0":this.levelNode.build(t,"int");return t.format( ` $ { t . getMethod ( "textureDimensions" ) } ( $ { n } , $ { s } ) ` ,this.getNodeType(t),i)}},a_=ys(Ere).setParameterLength(1,2),Tre=class extends Ax{static get type(){return"MaxMipLevelNode"}constructor(t){super(0),this._textureNode=t,this.updateType=Zn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let t=this.texture,i=t.images,n=i&&i.length>0?i[0]&&i[0].image||i[0]:t.image;if(n&&n.width!==void 0){let{width:s,height:o}=n;this.value=Math.log2(Math.max(s,o))}}},ace=ys(Tre).setParameterLength(1),vZ=class extends Error{constructor(t,i=null){super(t),this.name="NodeError",this.stackTrace=i}},uce=new wr,wE=class extends Ax{static get type(){return"TextureNode"}constructor(t=uce,i=null,n=null,s=null){super(t),this.isTextureNode=!0,this.uvNode=i,this.levelNode=n,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Zn.NONE,this.referenceNode=null,this._value=t,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(i===null)}set value(t){this.referenceNode?this.referenceNode.value=t:this._value=t}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===co?"uvec4":this.value.type===Ya?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return er(this.value.channel)}updateReference
` :"")+t.tab+b+ ` {
` ).addFlowTab()}let o=s.build(t,"void");i.returnsNode.build(t,"void"),t.removeFlowTab().addFlowCode( `
` +t.tab+o);for(let r=0,l=this.params.length-1;r<l;r++)t.addFlowCode((r===0?"":t.tab)+ ` }
` ).removeFlowTab();t.addFlowTab()}},zo=(...e)=>new Vre(vx(e,"int")).toStack(),iBe=()=>P1("continue").toStack(),l3e=()=>P1("break").toStack(),Eoe=new WeakMap,x1=new xn,d1e=Wt(({bufferMap:e,influence:t,stride:i,width:n,depth:s,offset:o})=>{let r=Ot(kEe).mul(i).add(o),l=r.div(n),d=r.sub(l.mul(n));return Oa(e,Mc(d,l)).depth(s).xyz.mul(t)});function nBe(e){let t=e.morphAttributes.position!==void 0,i=e.morphAttributes.normal!==void 0,n=e.morphAttributes.color!==void 0,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,o=s!==void 0?s.length:0,r=Eoe.get(e);if(r===void 0||r.count!==o){let A=function(){R.dispose(),Eoe.delete(e),e.removeEventListener("dispose",A)};r!==void 0&&r.texture.dispose();let l=e.morphAttributes.position||[],d=e.morphAttributes.normal||[],h=e.morphAttributes.color||[],p=0;t===!0&&(p=1),i===!0&&(p=2),n===!0&&(p=3);let I=e.attributes.position.count*p,m=1,y=4096;I>y&&(m=Math.ceil(I/y),I=y);let T=new Float32Array(I*m*4*o),R=new Yv(T,I,m,o);R.type=Ro,R.needsUpdate=!0;let b=p*4;for(let O=0;O<o;O++){let P=l[O],U=d[O],Z=h[O],ne=I*m*4*O;for(let K=0;K<P.count;K++){let oe=K*b;t===!0&&(x1.fromBufferAttribute(P,K),T[ne+oe+0]=x1.x,T[ne+oe+1]=x1.y,T[ne+oe+2]=x1.z,T[ne+oe+3]=0),i===!0&&(x1.fromBufferAttribute(U,K),T[ne+oe+4]=x1.x,T[ne+oe+5]=x1.y,T[ne+oe+6]=x1.z,T[ne+oe+7]=0),n===!0&&(x1.fromBufferAttribute(Z,K),T[ne+oe+8]=x1.x,T[ne+oe+9]=x1.y,T[ne+oe+10]=x1.z,T[ne+oe+11]=Z.itemSize===4?x1.w:1)}}r={count:o,texture:R,stride:p,size:new hi(I,m)},Eoe.set(e,r),e.addEventListener("dispose",A)}return r}var kre=class extends Sn{static get type(){return"MorphNode"}constructor(t){super("void"),this.mesh=t,this.morphBaseInfluence=Nn(1),this.updateType=Zn.OBJECT}setup(t){let{geometry:i}=t,n=i.morphAttributes.position!==void 0,s=i.hasAttribute("normal")&&i.morphAttributes.normal!==void 0,o=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,r=o!==void 0?o.length:0,{texture:l,stride:d,size:h}=nBe(i);n===!0&&Ml.mulAssign(this.morphBaseInfluence),s===!0&&om.mulAssign(this.morphBaseInfluence);let p=Ot(h.width);zo(r,({i:I})=>{let m=Et(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?m.assign(Oa(this.mesh.morphTexture,Mc(Ot(I).add(1),Ot(B3))).r):m.assign(Ar("morphTargetInfluences","float").element(I).toVar()),Fn(m.notEqual(0),()=>{n===!0&&Ml.addAssign(d1e({bufferMap:l,influence:m,stride:d,width:p,depth:I,offset:Ot(0)})),s===!0&&om.addAssign(d1e({bufferMap:l,influence:m,stride:d,width:p,depth:I,offset:Ot(1)}))})})}update(){let t=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?t.value=1:t.value=1-this.mesh.morphTargetInfluences.reduce((i,n)=>i+n,0)}},a3e=ys(kre).setParameterLength(1),h_=class extends Sn{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}},zre=class extends h_{static get type(){return"AONode"}constructor(t=null){super(),this.aoNode=t}setup(t){t.context.ambientOcclusion.mulAssign(this.aoNode)}},Wre=class extends yZ{static get type(){return"LightingContextNode"}constructor(t,i=null,n=null,s=null){super(t),this.lightingModel=i,this.backdropNode=n,this.backdropAlphaNode=s,this._value=null}getContext(){let{backdropNode:t,backdropAlphaNode:i}=this,n=Gt().toVar("directDiffuse"),s=Gt().toVar("directSpecular"),o=Gt().toVar("indirectDiffuse"),r=Gt().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:s,indirectDiffuse:o,indirectSpecular:r};return{radiance:Gt().toVar("radiance"),irradiance:Gt().toVar("irradiance"),iblIrradiance:Gt().toVar("iblIrradiance"),ambientOcclusion:Et(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:t,backdropAlpha:i}}setup(t){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||t.context.lightingModel,super.setup(t)}},u3e=ys(Wre),Yre=class extends h_{static get type(){return"IrradianceNode"}constructor(t){super(),this.node=t}setup(t){t.context.irradiance.addAssign(this.node)}},cx=new hi,Z8=class extends wE{static get type(){return"ViewportTextureNode"}constructor(t=G2,i=null,n=null){let s=null;n=
` ,i==="property"?l:t.format( ` $ { l } ( ) ` ,o,i)}}, $ 3e=(e,t=[],i="")=>{for(let o=0;o<t.length;o++){let r=t[o];typeof r=="function"&&(t[o]=r.functionNode)}let n=new GZ(e,t,i),s=(...o)=>n.call(...o);return s.functionNode=n,s},nUe=(e,t)=> $ 3e(e,t,"glsl"),sUe=(e,t)=> $ 3e(e,t,"wgsl");function Pce(e){let t,i=e.context.getViewZ;return i!==void 0&&(t=i(this)),(t||Tu.z).negate()}var Z3e=Wt(([e,t],i)=>{let n=Pce(i);return H3(e,t,n)}),K3e=Wt(([e],t)=>{let i=Pce(t);return e.mul(e,i,i).negate().exp().oneMinus()}),oUe=Wt(([e,t],i)=>{let n=Pce(i),o=t.sub(V2.y).max(0).toConst().mul(n).toConst();return e.mul(e,o,o).negate().exp().oneMinus()}),Xle=Wt(([e,t])=>On(t.toFloat().mix(U8.rgb,e.toVec3()),U8.a)),hx=null,fx=null,eae=class extends Sn{static get type(){return"RangeNode"}constructor(t=Et(),i=Et()){super(),this.minNode=t,this.maxNode=i}getVectorLength(t){let i=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),s=t.getTypeLength(o_(i.value)),o=t.getTypeLength(o_(n.value));return s>o?s:o}generateNodeType(t){return t.object.count>1?t.getTypeFromLength(this.getVectorLength(t)):"float"}getConstNode(t){let i=null;if(t.traverse(n=>{n.isConstNode===!0&&(i=n)}),i===null)throw new vZ('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return i}setup(t){let i=t.object,n=null;if(i.count>1){let s=this.getConstNode(this.minNode),o=this.getConstNode(this.maxNode),r=s.value,l=o.value,d=t.getTypeLength(o_(r)),h=t.getTypeLength(o_(l));hx=hx||new xn,fx=fx||new xn,hx.setScalar(0),fx.setScalar(0),d===1?hx.setScalar(r):r.isColor?hx.set(r.r,r.g,r.b,1):hx.set(r.x,r.y,r.z||0,r.w||0),h===1?fx.setScalar(l):l.isColor?fx.set(l.r,l.g,l.b,1):fx.set(l.x,l.y,l.z||0,l.w||0);let p=4,I=p*i.count,m=new Float32Array(I);for(let R=0;R<I;R++){let b=R%p,A=hx.getComponent(b),O=fx.getComponent(b);m[R]=cr.lerp(A,O,Math.random())}let y=this.getNodeType(t);if(i.count*4*4<=t.getUniformBufferLimit())n=rz(m,"vec4",i.count).element(B3).convert(y);else{let R=new B0(m,4);t.geometry.setAttribute("__range"+this.id,R),n=TZ(R).convert(y)}}else n=Et(0);return n}},rUe=ys(eae).setParameterLength(2),tae=class extends Sn{static get type(){return"ComputeBuiltinNode"}constructor(t,i){super(i),this._builtinName=t}getHash(t){return this.getBuiltinName(t)}generateNodeType(){return this.nodeType}setBuiltinName(t){return this._builtinName=t,this}getBuiltinName(){return this._builtinName}hasBuiltin(t){return t.hasBuiltin(this._builtinName)}generate(t,i){let n=this.getBuiltinName(t),s=this.getNodeType(t);return t.shaderStage==="compute"?t.format(n,s,i):(ci( ` ComputeBuiltinNode : Compute built - in value $ { n } can not be accessed in the $ { t . shaderStage } stage ` ),t.generateConst(s))}serialize(t){super.serialize(t),t.global=this.global,t._builtinName=this._builtinName}deserialize(t){super.deserialize(t),this.global=t.global,this._builtinName=t._builtinName}},uz=(e,t)=>new tae(e,t),lUe=uz("numWorkgroups","uvec3"),aUe=uz("workgroupId","uvec3"),uUe=uz("globalId","uvec3"),cUe=uz("localId","uvec3"),dUe=uz("subgroupSize","uint"),iae=class extends Sn{constructor(t){super(),this.scope=t,this.isBarrierNode=!0}setup(t){t.allowEarlyReturns=!1,t.allowGlobalVariables=!1}generate(t){let{scope:i}=this,{renderer:n}=t;n.backend.isWebGLBackend===!0?t.addFlowCode( ` // ${i}Barrier
` ):t.addLineFlowCode( ` $ { i } Barrier ( ) ` ,this)}},Mce=ys(iae),hUe=()=>Mce("workgroup").toStack(),fUe=()=>Mce("storage").toStack(),pUe=()=>Mce("texture").toStack(),nae=class extends YS{constructor(t,i){super(t,i),this.isWorkgroupInfoElementNode=!0}generate(t,i){let n,s=t.context.assign;if(n=super.generate(t),s!==!0){let o=this.getNodeType(t);n=t.format(n,o,i)}return n}},sae=class extends Sn{constructor(t,i,n=0){super(i),this.bufferType=i,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=i,this.scope=t,this.name=""}setName(t){return this.name=t,this}label(t){return ci('TSL: "label()" has been deprecated. Use "setName()" instead.',new ha),this.setName(t)}setScope(t){return this.scope=t,this}getElementType(){return this.elementType}getInputType(){return ` $ { this . scope } Array ` }element(t){return new nae(this,t)}generate(t){let i=this.name!==""?this.name: ` $ { this . scope } Array _$ { this . id } ` ;return t.getScopedArray(i,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},IUe=(e,t)=>new sae("Workgroup",e,t),Tc=class extends Sn{static get type(){return"AtomicFunctionNode"}constructor(t,i,n){super("uint"),this.method=t,this.pointerNode=i,this.valueNode=n,this.parents=!0}getInputType(t){return this.pointerNode.getNodeType(t)}generateNodeType(t){return this.getInputType(t)}generate(t){let i=t.getNodeProperties(this),n=i.parents,s=this.method,o=this.getNodeType(t),r=this.getInputType(t),l=this.pointerNode,d=this.valueNode,h=[];h.push( ` & $ { l . build ( t , r ) } ` ),d!==null&&h.push(d.build(t,r));let p= ` $ { t . getMethod ( s , o ) } ( $ { h . join ( ", " ) } ) ` ;if(n?n.length===1&&n[0].isStackNode===!0:!1)t.addLineFlowCode(p,this);else return i.constNode===void 0&&(i.constNode=P1(p,o).toConst()),i.constNode.build(t)}};Tc.ATOMIC_LOAD="atomicLoad";Tc.ATOMIC_STORE="atomicStore";Tc.ATOMIC_ADD="atomicAdd";Tc.ATOMIC_SUB="atomicSub";Tc.ATOMIC_MAX="atomicMax";Tc.ATOMIC_MIN="atomicMin";Tc.ATOMIC_AND="atomicAnd";Tc.ATOMIC_OR="atomicOr";Tc.ATOMIC_XOR="atomicXor";var mUe=ys(Tc), $ 2=(e,t,i)=>mUe(e,t,i).toStack(),yUe=e=> $ 2(Tc.ATOMIC_LOAD,e,null),EUe=(e,t)=> $ 2(Tc.ATOMIC_STORE,e,t),TUe=(e,t)=> $ 2(Tc.ATOMIC_ADD,e,t),gUe=(e,t)=> $ 2(Tc.ATOMIC_SUB,e,t),wUe=(e,t)=> $ 2(Tc.ATOMIC_MAX,e,t),vUe=(e,t)=> $ 2(Tc.ATOMIC_MIN,e,t),RUe=(e,t)=> $ 2(Tc.ATOMIC_AND,e,t),SUe=(e,t)=> $ 2(Tc.ATOMIC_OR,e,t),AUe=(e,t)=> $ 2(Tc.ATOMIC_XOR,e,t),mn=class e extends Fl{static get type(){return"SubgroupFunctionNode"}constructor(t,i=null,n=null){super(),this.method=t,this.aNode=i,this.bNode=n}getInputType(t){let i=this.aNode?this.aNode.getNodeType(t):null,n=this.bNode?this.bNode.getNodeType(t):null,s=t.isMatrix(i)?0:t.getTypeLength(i),o=t.isMatrix(n)?0:t.getTypeLength(n);return s>o?i:n}generateNodeType(t){let i=this.method;return i===e.SUBGROUP_ELECT?"bool":i===e.SUBGROUP_BALLOT?"uvec4":this.getInputType(t)}generate(t,i){let n=this.method,s=this.getNodeType(t),o=this.getInputType(t),r=this.aNode,l=this.bNode,d=[];if(n===e.SUBGROUP_BROADCAST||n===e.SUBGROUP_SHUFFLE||n===e.QUAD_BROADCAST){let p=l.getNodeType(t);d.push(r.build(t,s),l.build(t,p==="float"?"int":s))}else n===e.SUBGROUP_SHUFFLE_XOR||n===e.SUBGROUP_SHUFFLE_DOWN||n===e.SUBGROUP_SHUFFLE_UP?d.push(r.build(t,s),l.build(t,"uint")):(r!==null&&d.push(r.build(t,o)),l!==null&&d.push(l.build(t,o)));let h=d.length===0?"()": ` ( $ { d . join ( ", " ) } ) ` ;return t.format( ` $ { t . getMethod ( n , s ) } $ { h } ` ,s,i)}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};mn.SUBGROUP_ELECT="subgroupElect";mn.SUBGROUP_BALLOT="subgroupBallot";mn.SUBGROUP_ADD="subgroupAdd";mn.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";mn.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";mn.SUBGROUP_MUL="subgroupMul";mn.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";mn.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";mn.SUBGROUP_AND="subgroupAnd";mn.SUBGROUP_OR="subgroupOr";mn.SUBGROUP_XOR="subgroupXor";mn.SUBGROUP_MIN="subgroupMin";mn.SUBGROUP_MAX="subgroupMax";mn.SUBGROUP_ALL="subgroupAll";mn.SUBGROUP_ANY="subgroupAny";mn.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";mn.QUAD_SWAP_X="quadSwapX";mn.QUAD_SWAP_Y="quadSwapY";mn.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";
` ),this.flow.code+=t,this)}addFlowCode(t){return this.flow.code+=t,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(t){return this.flowsData.get(t)}flowNode(t){let i=t.getNodeType(this),n=this.flowChildNode(t,i);return this.flowsData.set(t,n),n}addInclude(t){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t)}buildFunctionNode(t){let i=new GZ,n=this.currentFunctionNode;return this.currentFunctionNode=i,i.code=this.buildFunctionCode(t),this.currentFunctionNode=n,i}flowShaderNode(t){let i=t.layout,n={[Symbol.iterator](){let r=0,l=Object.values(this);return{next:()=>({value:l[r],done:r++>=l.length})}}};for(let r of i.inputs)n[r.name]=new PZ(r.type,r.name);t.layout=null;let s=t.call(n),o=this.flowStagesNode(s,i.type);return t.layout=i,o}flowBuildStage(t,i,n=null){let s=this.getBuildStage();this.setBuildStage(i);let o=t.build(this,n);return this.setBuildStage(s),o}flowStagesNode(t,i=null){let n=this.flow,s=this.vars,o=this.declarations,r=this.cache,l=this.buildStage,d=this.stack,h={code:""};this.flow=h,this.vars={},this.declarations={},this.cache=new Hk,this.stack=sZ();for(let p of X $ )this.setBuildStage(p),h.result=t.build(this,i);return h.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=s,this.declarations=o,this.cache=r,this.stack=d,this.setBuildStage(l),h}getFunctionOperator(){return null}buildFunctionCode(){ci("Abstract function.")}flowChildNode(t,i=null){let n=this.flow,s={code:""};return this.flow=s,s.result=t.build(this,i),this.flow=n,s}flowNodeFromShaderStage(t,i,n=null,s=null){let o=this.tab,r=this.cache,l=this.shaderStage,d=this.context;this.setShaderStage(t);let h={...this.context};delete h.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=h;let p=null;if(this.buildStage==="generate"){let I=this.flowChildNode(i,n);s!==null&&(I.code+= ` $ { this . tab + s } = $ { I . result } ;
` ),this.flowCode[t]=this.flowCode[t]+I.code,p=I}else p=i.build(this);return this.setShaderStage(l),this.cache=r,this.tab=o,this.context=d,p}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){ci("Abstract function.")}getVaryings(){ci("Abstract function.")}getVar(t,i,n=null){return ` $ { n !== null ? this . generateArrayDeclaration ( t , n ) : this . getType ( t ) } $ { i } ` }getVars(t,i=!1){let n=[],s=this.vars[t];if(s!==void 0)for(let o of s)n.push( ` $ { this . getVar ( o . type , o . name , o . count ) } ; ` );return n.join(i? `
` : `
` )}getUniforms(){ci("Abstract function.")}getCodes(t){let i=this.codes[t],n="";if(i!==void 0)for(let s of i)n+=s.code+ `
` ;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(t){this.shaderStage=t}getShaderStage(){return this.shaderStage}setBuildStage(t){this.buildStage=t}getBuildStage(){return this.buildStage}buildCode(){ci("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(t){this.subBuildLayers.push(t)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(t){let i;if(t&&t.isNode?t.isShaderCallNodeInternal?i=t.shaderNode.subBuilds:t.isStackNode?i=[t.subBuild]:i=this.getDataFromNode(t,"any").subBuilds:t instanceof Set?i=[...t]:i=t,!i)return null;let n=this.subBuildLayers;for(let s=i.length-1;s>=0;s--){let o=i[s];if(n.includes(o))return o}return null}getSubBuildOutput(t){return this.getSubBuildProperty("outputNode",t)}getSubBuildProperty(t="",i=null){let n;i!==null?n=this.getClosestSubBuild(i):n=this.subBuildFn;let s;return n?s=t?n+"_"+t:n:s=t,s}prebuild(){let{object:t,renderer:i,material:n}=this;if(i.contextNode.isContextNode===!0?this.context={...this.context,...i.contextNode.getFlowContextData()}:yi('NodeBuilder: "renderer.contextNode" must be an instance of ` context ( ) ` .'),n&&n.contextNode&&(n.contextNode.isContextNode===!0?this.context={...this.context,...n.contextNode.getFlowContextData()}:yi('NodeBuilder: "material.contextNode" must be an instance of ` context ( ) ` .')),n!==null){let s=i.library.fromMaterial(n);s===null&&(yi( ` NodeBuilder : Material "${n.type}" is not compatible . ` ),s=new Ul),s.build(this)}else this.addFlow("compute",t)}build(){this.prebuild();for(let t of X $ ){this.setBuildStage(t),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(let i of eZ){this.setShaderStage(i);let n=this.flowNodes[i];for(let s of n)t==="generate"?this.flowNode(s):s.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(let t of X $ ){this.setBuildStage(t),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(let i of eZ){this.setShaderStage(i);let n=this.flowNodes[i];for(let s of n)t==="generate"?this.flowNode(s):s.build(this);await Nte()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(t){let i=nVe.get(t);return i===void 0&&(i={}),i}getNodeUniform(t,i){let n=this.getSharedDataFromNode(t),s=n.cache;if(s===void 0){if(i==="float"||i==="int"||i==="uint")s=new vae(t);else if(i==="vec2"||i==="ivec2"||i==="uvec2")s=new Rae(t);else if(i==="vec3"||i==="ivec3"||i==="uvec3")s=new Sae(t);else if(i==="vec4"||i==="ivec4"||i==="uvec4")s=new Aae(t);else if(i==="color")s=new bae(t);else if(i==="mat2")s=new Nae(t);else if(i==="mat3")s=new _ae(t);else if(i==="mat4")s=new Dae(t);else throw new Error( ` Uniform "${i}" not implemented . ` );n.cache=s}return s}format(t,i,n){if(i=this.getVectorType(i),n=this.getVectorType(n),i===n||n===null||this.isReference(n))return t;let s=this.getTypeLength(i),o=this.getTypeLength(n);return s===16&&o===9? ` $ { this . getType ( n ) } ( $ { t } [ 0 ] . xyz , $ { t } [ 1 ] . xyz , $ { t } [ 2 ] . xyz ) ` :s===9&&o===4? ` $ { this . getType ( n ) } ( $ { t } [ 0 ] . xy , $ { t } [ 1 ] . xy ) ` :s>4||o>4||o===0?t:s===o? ` $ { this . getType ( n ) } ( $ { t } ) ` :s>o?(t=n==="bool"? ` all ( $ { t } ) ` : ` $ { t } . $ { "xyz" . slice ( 0 , o ) } ` ,this.format(t,this.getTypeFromLength(o,this.getComponentType(i)),n)):o===4&&s>1? ` $ { this . getType ( n ) } ( $ { this . format ( t , i , "vec3" ) } , 1.0 ) ` :s===2? ` $ { this . getType ( n ) } ( $ { this . format ( t , i , "vec2" ) } , 0.0 ) ` :(s===1&&o>1&&i!==this.getComponentType(n)&&(t= ` $ { this . getType ( this . getComponentType ( n ) ) } ( $ { t } ) ` ), ` $ { this . getType ( n ) } ( $ { t } ) ` )}getSignature(){return ` // Three.js r${"184"} - Node System
` }needsPreviousData(){let t=this.renderer.getMRT();return t&&t.has("velocity")||Tye(this.object).useVelocity===!0}}, $ Z=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(t,i){let n=t.get(i);return n===void 0&&(n={renderId:0,frameId:0},t.set(i,n)),n}updateBeforeNode(t){let i=t.getUpdateBeforeType(),n=t.updateReference(this);if(i===Zn.FRAME){let s=this._getMaps(this.updateBeforeMap,n);if(s.frameId!==this.frameId){let o=s.frameId;s.frameId=this.frameId,t.updateBefore(this)===!1&&(s.frameId=o)}}else if(i===Zn.RENDER){let s=this._getMaps(this.updateBeforeMap,n);if(s.renderId!==this.renderId){let o=s.renderId;s.renderId=this.renderId,t.updateBefore(this)===!1&&(s.renderId=o)}}else i===Zn.OBJECT&&t.updateBefore(this)}updateAfterNode(t){let i=t.getUpdateAfterType(),n=t.updateReference(this);if(i===Zn.FRAME){let s=this._getMaps(this.updateAfterMap,n);s.frameId!==this.frameId&&t.updateAfter(this)!==!1&&(s.frameId=this.frameId)}else if(i===Zn.RENDER){let s=this._getMaps(this.updateAfterMap,n);s.renderId!==this.renderId&&t.updateAfter(this)!==!1&&(s.renderId=this.renderId)}else i===Zn.OBJECT&&t.updateAfter(this)}updateNode(t){let i=t.getUpdateType(),n=t.updateReference(this);if(i===Zn.FRAME){let s=this._getMaps(this.updateMap,n);s.frameId!==this.frameId&&t.update(this)!==!1&&(s.frameId=this.frameId)}else if(i===Zn.RENDER){let s=this._getMaps(this.updateMap,n);s.renderId!==this.renderId&&t.update(this)!==!1&&(s.renderId=this.renderId)}else i===Zn.OBJECT&&t.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},ez=class{constructor(t,i,n=null,s="",o=!1){this.type=t,this.name=i,this.count=n,this.qualifier=s,this.isConst=o}};ez.isNodeFunctionInput=!0;var Cae=class extends $ S{static get type(){return"AmbientLightNode"}constructor(t=null){super(t)}setup({context:t}){t.irradiance.addAssign(this.colorNode)}},xae=class extends $ S{static get type(){return"DirectionalLightNode"}constructor(t=null){super(t)}setupDirect(){let t=this.colorNode;return{lightDirection:Uce(this.light),lightColor:t}}},Oae=class extends $ S{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=Bce(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Nn(new Oi).setGroup(Mn)}update(t){let{light:i}=this;super.update(t),this.lightPositionNode.object3d=i,this.groundColorNode.value.copy(i.groundColor).multiplyScalar(i.intensity)}setup(t){let{colorNode:i,groundColorNode:n,lightDirectionNode:s}=this,r=m_.dot(s).mul(.5).add(.5),l=zs(n,i,r);t.context.irradiance.addAssign(l)}},tz=class extends $ S{static get type(){return"SpotLightNode"}constructor(t=null){super(t),this.coneCosNode=Nn(0).setGroup(Mn),this.penumbraCosNode=Nn(0).setGroup(Mn),this.cutoffDistanceNode=Nn(0).setGroup(Mn),this.decayExponentNode=Nn(0).setGroup(Mn),this.colorNode=Nn(this.color).setGroup(Mn)}update(t){super.update(t);let{light:i}=this;this.coneCosNode.value=Math.cos(i.angle),this.penumbraCosNode.value=Math.cos(i.angle*(1-i.penumbra)),this.cutoffDistanceNode.value=i.distance,this.decayExponentNode.value=i.decay}getSpotAttenuation(t,i){let{coneCosNode:n,penumbraCosNode:s}=this;return H3(n,s,i)}getLightCoord(t){let i=t.getNodeProperties(this),n=i.projectionUV;return n===void 0&&(n=Q3e(this.light,t.context.positionWorld),i.projectionUV=n),n}setupDirect(t){let{colorNode:i,cutoffDistanceNode:n,decayExponentNode:s,light:o}=this,r=this.getLightVector(t),l=r.normalize(),d=l.dot(Uce(o)),h=this.getSpotAttenuation(t,d),p=r.length(),I=Gce({lightDistance:p,cutoffDistance:n,decayExponent:s}),m=i.mul(h).mul(I),y,T;return o.colorNode?(T=this.getLightCoord(t),y=o.colorNode(T)):o.map&&(T=this.getLightCoord(t),y=lo(o.map,T.xy).onRenderUpdate(()=>o.map)),y&&(m=T.mul(2).sub(1).abs().lessThan(
Message : $ { t . message } ` ;t.reason&&(i+= `
Reason : $ { t . reason } ` ),yi(i),this._isDeviceLost=!0}_renderBundle(t,i,n){let{bundleGroup:s,camera:o,renderList:r}=t,l=this._currentRenderContext,d=this._bundles.get(s,o,l),h=this.backend.get(d),p=s.version!==h.version;if(p||h.bundleGPU===void 0){this.backend.beginBundle(l),(h.renderObjects===void 0||p)&&(h.renderObjects=[]),this._currentRenderBundle=d;let{transparentDoublePass:m,transparent:y,opaque:T}=r;this.opaque===!0&&T.length>0&&this._renderObjects(T,o,i,n),this.transparent===!0&&y.length>0&&this._renderTransparents(y,m,o,i,n),this._currentRenderBundle=null,this.backend.finishBundle(l,d),h.version=s.version}else{let{renderObjects:m}=h;for(let y=0,T=m.length;y<T;y++){let R=m[y];this._nodes.needsRefresh(R)&&(this._nodes.updateBefore(R),this._nodes.updateForRender(R),this._bindings.updateForRender(R),this._nodes.updateAfter(R))}}this.backend.addBundle(l,d)}render(t,i){if(this._initialized===!1)throw new Error('Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(t,i)}get initialized(){return this._initialized}_getFrameBufferTarget(){let{currentToneMapping:t,currentColorSpace:i}=this,n=t!==_c,s=i!==Hn.workingColorSpace;if(n===!1&&s===!1)return null;let{width:o,height:r}=this.getDrawingBufferSize(O8),{depth:l,stencil:d}=this,h=this._outputRenderTarget||this._canvasTarget,p=this._frameBufferTargets.get(h);if(p===void 0){p=new yf(o,r,{depthBuffer:l,stencilBuffer:d,type:this._outputBufferType,format:Ko,colorSpace:Hn.workingColorSpace,generateMipmaps:!1,minFilter:Us,magFilter:Us,samples:this.samples}),p.isPostProcessingRenderTarget=!0;let b=()=>{h.removeEventListener("dispose",b),p.dispose(),this._frameBufferTargets.delete(h)};h.addEventListener("dispose",b),this._frameBufferTargets.set(h,p)}let I=this.getOutputRenderTarget();p.depthBuffer=l,p.stencilBuffer=d,I!==null?p.setSize(I.width,I.height,I.depth):p.setSize(o,r,1);let m=this._outputRenderTarget?this._outputRenderTarget.viewport:h._viewport,y=this._outputRenderTarget?this._outputRenderTarget.scissor:h._scissor,T=this._outputRenderTarget?1:h._pixelRatio,R=this._outputRenderTarget?this._outputRenderTarget.scissorTest:h._scissorTest;return p.viewport.copy(m),p.scissor.copy(y),p.viewport.multiplyScalar(T),p.scissor.multiplyScalar(T),p.scissorTest=R,p.multiview=I!==null?I.multiview:!1,p.resolveDepthBuffer=I!==null?I.resolveDepthBuffer:!0,p._autoAllocateDepthBuffer=I!==null?I._autoAllocateDepthBuffer:!1,p}_renderScene(t,i,n=!0){if(this._isDeviceLost===!0)return;let s=n?this._getFrameBufferTarget():null,o=this._nodes.nodeFrame,r=o.renderId,l=this._currentRenderContext,d=this._currentRenderObjectFunction,h=this._handleObjectFunction;this._callDepth++;let p=t.isScene===!0?t:Q1e,I=this._renderTarget||this._outputRenderTarget,m=this._activeCubeFace,y=this._activeMipmapLevel,T;if(s!==null?(T=s,this.setRenderTarget(T)):T=I,T!==null&&T.depthBuffer===!0){let Ee=this._textures.get(T);Ee.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),Ee.depthInitialized=!0)}let R=this._renderContexts.get(T,this._mrt,this._callDepth);this._currentRenderContext=R,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,o.renderId=this.info.calls,this.backend.updateTimeStampUID(R),this.inspector.beginRender(this.backend.getTimestampUID(R),t,i,T);let b=this.xr;if(b.isPresenting===!1){let Ee=!1;if(this.reversedDepthBuffer===!0&&i.reversedDepth!==!0){if(i._reversedDepth=!0,i.isArrayCamera)for(let Qe of i.cameras)Qe._reversedDepth=!0;Ee=!0}let Ce=this.coordinateSystem;if(i.coordinateSystem!==Ce){if(i.coordinateSystem=Ce,i.isArrayCamera)for(let Qe of i.cameras)Qe.coordinateSystem=Ce;Ee=!0}if(Ee===!0&&(i.updateProjectionMatrix(),i.isArrayCamera))for(let Qe of i.cameras)Qe.updateProjectionMatrix()}t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),i.parent===null&&i.matrixWorldAutoUpdate===!0&&i.updateMatrixWorld(),b.enabled===!0
precision highp float ;
precision highp int ;
precision highp sampler2D ;
precision highp sampler3D ;
precision highp samplerCube ;
precision highp sampler2DArray ;
precision highp usampler2D ;
precision highp usampler3D ;
precision highp usamplerCube ;
precision highp usampler2DArray ;
precision highp isampler2D ;
precision highp isampler3D ;
precision highp isamplerCube ;
precision highp isampler2DArray ;
precision highp sampler2DShadow ;
precision highp sampler2DArrayShadow ;
precision highp samplerCubeShadow ;
` , $ ae=class extends qZ{constructor(t,i){super(t,i,new Uae),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(t){return t.isVideoTexture===!0&&t.colorSpace!==Eh}_include(t){let i=J1e[t];return i.build(this),this.addInclude(i),i}getMethod(t){return J1e[t]!==void 0&&this._include(t),SVe[t]||t}getBitcastMethod(t,i){return this.getMethod( ` bitcast _$ { i } _$ { t } ` )}getFloatPackingMethod(t){return this.getMethod( ` floatpack _$ { t } _2x16 ` )}getFloatUnpackingMethod(t){return this.getMethod( ` floatunpack _$ { t } _2x16 ` )}getTernary(t,i,n){return ` $ { t } ? $ { i } : $ { n } ` }getOutputStructName(){return""}buildFunctionCode(t){let i=t.layout,n=this.flowShaderNode(t),s=[];for(let r of i.inputs)s.push(this.getType(r.type)+" "+r.name);return ` $ { this . getType ( i . type ) } $ { i . name } ( $ { s . join ( ", " ) } ) {
$ { n . vars }
$ { n . code }
return $ { n . result } ;
} ` }setupPBO(t){let i=t.value;if(i.pbo===void 0){let n=i.array,s=i.count*i.itemSize,{itemSize:o}=i,r=i.array.constructor.name.toLowerCase().includes("int"),l=r?HT:uw;o===2?l=r?cw:Dc:o===3?l=r?oG:tR:o===4&&(l=r?iR:Ko);let d={Float32Array:Ro,Uint8Array:Lo,Uint16Array:mh,Uint32Array:co,Int8Array:FT,Int16Array:UT,Int32Array:Ya,Uint8ClampedArray:Lo},h=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(s/o)))),p=Math.ceil(s/o/h);h*p*o<s&&p++;let I=h*p*o,m=new n.constructor(I);m.set(n,0),i.array=m;let y=new Ih(i.array,h,p,l,d[i.array.constructor.name]||Ro);y.needsUpdate=!0,y.isPBOTexture=!0;let T=new wE(y,null,null);T.setPrecision("high"),i.pboNode=T,i.pbo=T.value,this.getUniformFromNode(i.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(t,i=this.shaderStage){return t.isNodeUniform&&t.node.isTextureNode!==!0&&t.node.isBufferNode!==!0?t.name:super.getPropertyName(t,i)}generatePBO(t){let{node:i,indexNode:n}=t,s=i.value;if(this.renderer.backend.has(s)){let p=this.renderer.backend.get(s);p.pbo=s.pbo}let o=this.getUniformFromNode(s.pboNode,"texture",this.shaderStage,this.context.nodeName),r=this.getPropertyName(o);this.increaseUsage(n);let l=n.build(this,"uint"),d=this.getDataFromNode(t),h=d.propertyName;if(h===void 0){let p=this.getVarFromNode(t);h=this.getPropertyName(p);let I=this.getDataFromNode(i),m=I.propertySizeName;m===void 0&&(m=h+"Size",this.getVarFromNode(i,m,"uint"),this.addLineFlowCode( ` $ { m } = uint ( textureSize ( $ { r } , 0 ) . x ) ` ,t),I.propertySizeName=m);let{itemSize:y}=s,T="."+Cx.join("").slice(0,y),R= ` ivec2 ( $ { l } % $ { m } , $ { l } / $ { m } ) ` ,b=this.generateTextureLoad(null,r,R,"0",null,null),A="vec4";s.pbo.type===co?A="uvec4":s.pbo.type===Ya&&(A="ivec4"),this.addLineFlowCode( ` $ { h } = $ { A } ( $ { b } ) $ { T } ` ,t),d.propertyName=h}return h}generateTextureLoad(t,i,n,s,o,r){s===null&&(s="0");let l;return o?r?l= ` texelFetchOffset ( $ { i } , ivec3 ( $ { n } , $ { o } ) , int ( $ { s } ) , $ { r } ) ` :l= ` texelFetch ( $ { i } , ivec3 ( $ { n } , $ { o } ) , int ( $ { s } ) ) ` :r?l= ` texelFetchOffset ( $ { i } , $ { n } , int ( $ { s } ) , $ { r } ) ` :l= ` texelFetch ( $ { i } , $ { n } , int ( $ { s } ) ) ` ,t!==null&&t.isDepthTexture&&(l+=".x"),l}generateTexture(t,i,n,s,o){return s&&(n= ` vec3 ( $ { n } , $ { s } ) ` ),t.isDepthTexture?o? ` textureOffset ( $ { i } , $ { n } , $ { o } ) . x ` : ` texture ( $ { i } , $ { n } ) . x ` :o? ` textureOffset ( $ { i } , $ { n } , $ { o } ) ` : ` texture ( $ { i } , $ { n } ) ` }generateTextureLevel(t,i,n,s,o,r){return o&&(n= ` vec3 ( $ { n } , $ { o } ) ` ),r? ` textureLodOffset ( $ { i } , $ { n } , $ { s } , $ { r } ) ` : ` textureLod ( $ { i } , $ { n } , $ { s } ) ` }generateTextureBias(t,i,n,s,o,r){return o&&(n= ` vec3 ( $ { n } , $ { o } ) ` ),r? ` textureOffset ( $ { i } , $ { n } , $ { r } , $ { s } ) ` : ` texture ( $ { i } , $ { n } , $ { s } ) ` }generateTextureGrad(t,i,n,s,o,r){return o&&(n= ` vec3 ( $ { n } , $ { o } ) ` ),r? ` textureGradOffset ( $ { i } , $ { n } , $ { s [ 0 ] } , $ { s [ 1 ] } , $ { r } ) ` : ` textureGrad ( $ { i } , $ { n } , $ { s [ 0 ] } , $ { s [ 1 ] } ) ` }generateTextureCompare(t,i,n,s,o,r,l=this.shaderStage){if(l==="fragment")return t.isCubeTexture? ` texture ( $ { i } , vec4 ( $ { n } , $ { s } ) ) ` :o?r? ` textureOffset ( $ { i } , vec4 ( $ { n } , $ { o } , $ { s } ) , $ { r } ) ` : ` texture ( $ { i } , vec4 ( $ { n } , $ { o } , $ { s } ) ) ` :r? ` textureOffset ( $ { i } , vec3 ( $ { n } , $ { s } ) , $ { r } ) ` : ` texture ( $ { i } , vec3 ( $ { n } , $ { s } ) ) ` ;yi( ` WebGPURenderer : THREE . DepthTexture . compareFunction ( ) does not support $ { l } shader . ` )}getUniforms(t){let i=this.uniforms[t],n=[],s={};for(let r of i){let l=null,d=!1;if(r.type==="texture"||r.type==="texture3D"){let h=r.node.value,p="";(h.isDataTexture===!0||h.isData3DTexture===!0)&&(h.type===co?p="u":h.type===Ya&&(p="i")),r.type==="texture3D"&&h.isArrayTexture===!1?l= ` $ { p } sampler3D $ { r . name } ; ` :h.compareFunction?h.isArrayTexture===!0?l= ` sampler2DArrayShadow $ { r . name } ; ` :l= ` sampler2DShadow $ { r . name } ; ` :h.isArrayTexture===!0||h.isDataArrayTexture===!0||h.isCompressedArrayTexture===!0?l= ` $ { p } sampler2DArray $ { r . name } ; ` :l= ` $ { p } sampler2D $ { r . name } ; ` }else if(r.type==="cubeTexture")l= ` samplerCube $ { r . name } ; ` ;else if(r.type==="cubeDepthTexture")r.node.value.compareFunction?l= ` samplerCubeShadow $ { r . name } ; ` :l= ` samplerCube $ { r . name } ; ` ;else if(r.type==="buffer"){let h=r.node,p=this.getType(h.bufferType),I=h.bufferCount,m=I>0?I:"";l= ` $ { h . name } {
$ { p } $ { r . name } [ $ { m } ] ;
} ;
` }else{let h=r.groupNode.name;if(s[h]===void 0){let p=this.uniformGroups[h];if(p!==void 0){let I=[];for(let m of p.uniforms){let y=m.getType(),T=this.getVectorType(y),R=m.nodeUniform.node.precision,b= ` $ { T } $ { m . name } ; ` ;R!==null&&(b=X1e[R]+" "+b),I.push(" "+b)}s[h]=I}}d=!0}if(!d){let h=r.node.precision;h!==null&&(l=X1e[h]+" "+l),l="uniform "+l,n.push(l)}}let o="";for(let r in s){let l=s[r];o+=this._getGLSLUniformStruct(r,l.join( `
` ))+ `
` }return o+=n.join( `
` ),o}getTypeFromAttribute(t){let i=super.getTypeFromAttribute(t);if(/^[iu]/.test(i)&&t.gpuType!==Ya){let n=t;t.isInterleavedBufferAttribute&&(n=t.data);let s=n.array;s instanceof Uint32Array||s instanceof Int32Array||(i=i.slice(1))}return i}getAttributes(t){let i="";if(t==="vertex"||t==="compute"){let n=this.getAttributesArray(),s=0;for(let o of n)i+= ` layout ( location = $ { s ++ } ) in $ { o . type } $ { o . name } ;
` }return i}getStructMembers(t){let i=[];for(let n of t.members)i.push( ` $ { n . type } $ { n . name } ; ` );return i.join( `
` )}getStructs(t){let i=[],n=this.structs[t],s=[];for(let o of n)if(o.output)for(let r of o.members)s.push( ` layout ( location = $ { r . index } ) out $ { r . type } $ { r . name } ; ` );else{let r="struct "+o.name+ ` {
` ;r+=this.getStructMembers(o),r+= `
} ;
` ,i.push(r)}return s.length===0&&s.push("layout( location = 0 ) out vec4 fragColor;"), `
` +s.join( `
` )+ `
` +i.join( `
` )}getVaryings(t){let i="",n=this.varyings;if(t==="vertex"||t==="compute")for(let s of n){t==="compute"&&(s.needsInterpolation=!0);let o=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){let r=tye[s.interpolationType]||s.interpolationType,l=iye[s.interpolationSampling]||"";i+= ` $ { r } $ { l } out $ { o } $ { s . name } ;
` }else{let r=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";i+= ` $ { r } out $ { o } $ { s . name } ;
` }else i+= ` $ { o } $ { s . name } ;
` }else if(t==="fragment"){for(let s of n)if(s.needsInterpolation){let o=this.getType(s.type);if(s.interpolationType){let r=tye[s.interpolationType]||s.interpolationType,l=iye[s.interpolationSampling]||"";i+= ` $ { r } $ { l } in $ { o } $ { s . name } ;
` }else{let r=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";i+= ` $ { r } in $ { o } $ { s . name } ;
` }}}for(let s of this.builtins[t])i+= ` $ { s } ;
` ;return i}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return ` uint ( gl _InstanceID ) % $ { this . object . workgroupSize . reduce ( ( n , s ) => n * s , 1 ) } u ` }getSubgroupSize(){yi("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){yi("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){yi("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(t,i,n=this.shaderStage){let s=this.extensions[n]||(this.extensions[n]=new Map);s.has(t)===!1&&s.set(t,{name:t,behavior:i})}getExtensions(t){let i=[];if(t==="vertex"){let s=this.renderer.backend.extensions;this.object.isBatchedMesh&&s.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",t)}let n=this.extensions[t];if(n!==void 0)for(let{name:s,behavior:o}of n.values())i.push( ` # extension $ { s } : $ { o } ` );return i.join( `
` )}getClipDistance(){return"gl_ClipDistance"}isAvailable(t){let i=eye[t];if(i===void 0){let n;switch(i=!1,t){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){let s=this.renderer.backend.extensions;s.has(n)&&(s.get(n),i=!0)}eye[t]=i}return i}isFlipY(){return!0}enableHardwareClipping(t){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push( ` out float gl _ClipDistance [ $ { t } ] ` )}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(t,i){this.transforms.push({varyingName:t,attributeNode:i})}getTransforms(){let t=this.transforms,i="";for(let n=0;n<t.length;n++){let s=t[n],o=this.getPropertyName(s.attributeNode);o&&(i+= ` $ { s . varyingName } = $ { o } ;
` )}return i}_getGLSLUniformStruct(t,i){return `
layout ( std140 ) uniform $ { t } {
$ { i }
} ; ` }_getGLSLVertexCode(t){return ` # version 300 es
$ { this . getSignature ( ) }
// extensions
$ { t . extensions }
// precision
$ { nye }
// uniforms
$ { t . uniforms }
// varyings
$ { t . varyings }
// attributes
$ { t . attributes }
// vars
$ { t . vars }
// codes
$ { t . codes }
void main ( ) {
// transforms
$ { t . transforms }
// flow
$ { t . flow }
gl _PointSize = 1.0 ;
}
` }_getGLSLFragmentCode(t){return ` # version 300 es
$ { this . getSignature ( ) }
// extensions
$ { t . extensions }
// precision
$ { nye }
// structs
$ { t . structs }
// uniforms
$ { t . uniforms }
// varyings
$ { t . varyings }
// vars
$ { t . vars }
// codes
$ { t . codes }
void main ( ) {
// flow
$ { t . flow }
}
` }buildCode(){let t=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(let i in t){let n= ` // code
` ;n+=this.flowCode[i];let s=this.flowNodes[i],o=s[s.length-1];for(let l of s){let d=this.getFlowData(l),h=l.name;h&&(n.length>0&&(n+= `
` ),n+= ` // flow -> ${h}
` ),n+= ` $ { d . code }
` ,l===o&&i!=="compute"&&(n+= ` // result
` ,i==="vertex"?(n+="gl_Position = ",n+= ` $ { d . result } ; ` ):i==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+= ` $ { d . result } ; ` )))}let r=t[i];if(r.extensions=this.getExtensions(i),r.uniforms=this.getUniforms(i),r.attributes=this.getAttributes(i),r.varyings=this.getVaryings(i),r.vars=this.getVars(i,!0),r.structs=this.getStructs(i),r.codes=this.getCodes(i),r.transforms=this.getTransforms(i),r.flow=n,i==="vertex"){let l=this.renderer.backend.extensions;this.object.isBatchedMesh&&l.has("WEBGL_multi_draw")===!1&&(r.uniforms+= `
uniform uint nodeUniformDrawId ;
` )}}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(t.vertex),this.fragmentShader=this._getGLSLFragmentCode(t.fragment)):this.computeShader=this._getGLSLVertexCode(t.compute)}getUniformFromNode(t,i,n,s=null){let o=super.getUniformFromNode(t,i,n,s),r=this.getDataFromNode(t,n,this.globalCache),l=r.uniformGPU;if(l===void 0){let d=t.groupNode,h=d.name,p=this.getBindGroupArray(h,n);if(i==="texture")l=new J8(o.name,o.node,d),p.push(l);else if(i==="cubeTexture"||i==="cubeDepthTexture")l=new sK(o.name,o.node,d),p.push(l);else if(i==="texture3D")l=new nz(o.name,o.node,d),p.push(l);else if(i==="buffer"){o.name= ` buffer$ { t . id } ` ;let I=this.getSharedDataFromNode(t),m=I.buffer;m===void 0&&(t.name= ` NodeBuffer _$ { t . id } ` ,m=new tK(t,d),m.name=t.name,I.buffer=m),p.push(m),l=m}else{let I=this.uniformGroups[h];I===void 0?(I=new iK(h,d),this.uniformGroups[h]=I,p.push(I)):p.indexOf(I)===-1&&p.push(I),l=this.getNodeUniform(o,i);let m=l.name;I.uniforms.some(T=>T.name===m)||I.addUniform(l)}r.uniformGPU=l}return o}},Goe=null,L8=null,oK=class{constructor(t={}){this.parameters=Object.assign({},t),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Lm.RENDER]:null,[Lm.COMPUTE]:null},this.trackTimestamp=t.trackTimestamp===!0}async init(t){this.renderer=t}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(t){let i=this.get(t),n=this.renderer.info.frame,s;t.isComputeNode===!0?s="c:"+this.renderer.info.compute.frameCalls:s="r:"+this.renderer.info.render.frameCalls,i.timestampUID=s+":"+t.id+":f"+n}getTimestampUID(t){return this.get(t).timestampUID}getTimestampFrames(t){let i=this.timestampQueryPool[t];return i?i.getTimestampFrames():[]}_getQueryPool(t){let i=t.startsWith("c:")?Lm.COMPUTE:Lm.RENDER;return this.timestampQueryPool[i]}getTimestamp(t){return this._getQueryPool(t).getTimestamp(t)}hasTimestamp(t){return this._getQueryPool(t).hasTimestamp(t)}isOccluded(){}async resolveTimestampsAsync(t="render"){if(!this.trackTimestamp){Oo("WebGPURenderer: Timestamp tracking is disabled.");return}let i=this.timestampQueryPool[t];if(!i)return;let n=await i.resolveQueriesAsync();return this.renderer.info[t].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return Goe=Goe||new hi,this.renderer.getDrawingBufferSize(Goe)}setScissorTest(){}getClearColor(){let t=this.renderer;return L8=L8||new $ k,t.getClearColor(L8),L8.getRGB(L8),L8}getDomElement(){let t=this.domElement;return t===null&&(t=this.parameters.canvas!==void 0?this.parameters.canvas:dG(),"setAttribute"in t&&t.setAttribute("data-engine", ` three . js r$ { "184" } webgpu ` ),this.domElement=t),t}hasCompatibility(){return!1}initRenderTarget(){}set(t,i){this.data.set(t,i)}get(t){let i=this.data.get(t);return i===void 0&&(i={},this.data.set(t,i)),i}has(t){return this.data.has(t)}delete(t){this.data.delete(t)}deleteBindGroupData(){}dispose(){}},AVe=0,Zae=class{constructor(t,i){this.buffers=[t.bufferGPU,i],this.type=t.type,this.bufferType=t.bufferType,this.pbo=t.pbo,this.byteLength=t.byteLength,this.bytesPerElement=t.BYTES_PER_ELEMENT,this.version=t.version,this.isInteger=t.isInteger,this.activeBufferIndex=0,this.baseId=t.id}get id(){return ` $ { this . baseId } | $ { this . activeBufferIndex } ` }get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},Kae=class{constructor(t){this.backend=t}createAttribute(t,i){
` ),s=[],o=Math.max(i-6,0),r=Math.min(i+6,n.length);for(let l=o;l<r;l++){let d=l+1;s.push( ` $ { d === i ? ">" : " " } $ { d } : $ { n [ l ] } ` )}return s.join( `
` )}_getShaderErrors(t,i,n){let s=t.getShaderParameter(i,t.COMPILE_STATUS),r=(t.getShaderInfoLog(i)||"").trim();if(s&&r==="")return"";let l=/ERROR: 0:( \d +)/.exec(r);if(l){let d=parseInt(l[1]);return n.toUpperCase()+ `
` +r+ `
` +this._handleSource(t.getShaderSource(i),d)}else return r}_logProgramError(t,i,n){if(this.renderer.debug.checkShaderErrors){let s=this.gl,r=(s.getProgramInfoLog(t)||"").trim();if(s.getProgramParameter(t,s.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(s,t,n,i);else{let l=this._getShaderErrors(s,n,"vertex"),d=this._getShaderErrors(s,i,"fragment");yi("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(t,s.VALIDATE_STATUS)+ `
Program Info Log : ` +r+ `
` +l+ `
` +d)}else r!==""&&ci("WebGLProgram: Program Info Log:",r)}}_completeCompile(t,i){let{state:n,gl:s}=this,o=this.get(i),{programGPU:r,fragmentShader:l,vertexShader:d}=o;s.getProgramParameter(r,s.LINK_STATUS)===!1&&this._logProgramError(r,l,d),n.useProgram(r);let h=t.getBindings();this._setupBindings(h,r),this.set(i,{programGPU:r,pipeline:r})}createComputePipeline(t,i){let{state:n,gl:s}=this,o={stage:"fragment",code: ` # version 300 es
precision highp float ;
void main ( ) { } ` };this.createProgram(o);let{computeProgram:r}=t,l=s.createProgram(),d=this.get(o).shaderGPU,h=this.get(r).shaderGPU,p=r.transforms,I=[],m=[];for(let b=0;b<p.length;b++){let A=p[b];I.push(A.varyingName),m.push(A.attributeNode)}s.attachShader(l,d),s.attachShader(l,h),s.transformFeedbackVaryings(l,I,s.SEPARATE_ATTRIBS),s.linkProgram(l),s.getProgramParameter(l,s.LINK_STATUS)===!1&&this._logProgramError(l,d,h),n.useProgram(l),this._setupBindings(i,l);let y=r.attributes,T=[],R=[];for(let b=0;b<y.length;b++){let A=y[b].node.attribute;T.push(A),this.has(A)||this.attributeUtils.createAttribute(A,s.ARRAY_BUFFER)}for(let b=0;b<m.length;b++){let A=m[b].attribute;this.has(A)||this.attributeUtils.createAttribute(A,s.ARRAY_BUFFER);let O=this.get(A);R.push(O)}this.set(t,{programGPU:l,transformBuffers:R,attributes:T})}createBindings(t,i){if(this._knownBindings.has(i)===!1){this._knownBindings.add(i);let n=0,s=0;for(let o of i){this.set(o,{textures:s,uniformBuffers:n});for(let r of o.bindings)r.isUniformBuffer&&n++,r.isSampledTexture&&s++}}this.updateBindings(t,i)}updateBindings(t){let{gl:i}=this;for(let n of t.bindings){let s=this.get(n);if(n.isUniformsGroup||n.isUniformBuffer){let o=n.buffer,{bufferGPU:r}=this.get(o);r===void 0?(r=i.createBuffer(),i.bindBuffer(i.UNIFORM_BUFFER,r),i.bufferData(i.UNIFORM_BUFFER,o.byteLength,i.DYNAMIC_DRAW),this.set(o,{bufferGPU:r})):i.bindBuffer(i.UNIFORM_BUFFER,r);let l=n.updateRanges;if(i.bindBuffer(i.UNIFORM_BUFFER,r),l.length===0)i.bufferData(i.UNIFORM_BUFFER,o,i.DYNAMIC_DRAW);else{let d=LC(o),h=d?1:o.BYTES_PER_ELEMENT;for(let p=0,I=l.length;p<I;p++){let m=l[p],y=m.start*h,T=m.count*h,R=y*(d?o.BYTES_PER_ELEMENT:1);i.bufferSubData(i.UNIFORM_BUFFER,R,o,y,T)}}s.bufferGPU=r,this.set(n,s)}else if(n.isSampledTexture){let{textureGPU:o,glTextureType:r}=this.get(n.texture);s.textureGPU=o,s.glTextureType=r,this.set(n,s)}}}updateBinding(t){let i=this.gl;if(t.isUniformsGroup||t.isUniformBuffer){let s=this.get(t).bufferGPU,o=t.buffer,r=t.updateRanges;if(i.bindBuffer(i.UNIFORM_BUFFER,s),r.length===0)i.bufferData(i.UNIFORM_BUFFER,o,i.DYNAMIC_DRAW);else{let l=LC(o),d=l?1:o.BYTES_PER_ELEMENT;for(let h=0,p=r.length;h<p;h++){let I=r[h],m=I.start*d,y=I.count*d,T=m*(l?o.BYTES_PER_ELEMENT:1);i.bufferSubData(i.UNIFORM_BUFFER,T,o,m,y)}}}}createIndexAttribute(t){let i=this.gl;this.attributeUtils.createAttribute(t,i.ELEMENT_ARRAY_BUFFER)}createAttribute(t){if(this.has(t))return;let i=this.gl;this.attributeUtils.createAttribute(t,i.ARRAY_BUFFER)}createStorageAttribute(t){if(this.has(t))return;let i=this.gl;this.attributeUtils.createAttribute(t,i.ARRAY_BUFFER)}updateAttribute(t){this.attributeUtils.updateAttribute(t)}destroyAttribute(t){this.attributeUtils.destroyAttribute(t)}hasFeature(t){let i=Object.keys(rye).filter(s=>rye[s]===t),n=this.extensions;for(let s=0;s<i.length;s++)if(n.has(i[s]))return!0;return!1}copyTextureToTexture(t,i,n=null,s=null,o=0,r=0){this.textureUtils.copyTextureToTexture(t,i,n,s,o,r)}copyFramebufferToTexture(t,i,n){this.textureUtils.copyFramebufferToTexture(t,i,n)}hasCompatibility(t){return t===dw.TEXTURE_COMPARE?!0:super.hasCompatibility(t)}initRenderTarget(t){let{gl:i,state:n}=this;this._setFramebuffer(t),n.bindFramebuffer(i.FRAMEBUFFER,null)}_setFramebuffer(t){let{gl:i,state:n}=this,s=null;if(t.textures!==null){let o=t.renderTarget,r=this.get(o),{samples:l,depthBuffer:d,stencilBuffer:h}=o,p=o.isCubeRenderTarget===!0,I=o.isRenderTarget3D===!0,m=o.depth>1,y=o.isXRRenderTarget===!0,T=y===!0&&o._hasExternalTextures===!0,R=r.msaaFrameBuffer,b=r.depthRenderbuffer,A=this.extensions.get("WEBGL_multisampled_render_to_texture"),O=this.extensions.get("OVR_multiview2"),P=this._useMultisampledExtension(o),U=C3e(t),Z;if(p?(r.cubeFramebuffers||(r.cubeFramebuffers={}),Z=r.cubeFramebuffers[U]):y&&T===!1?Z=this._xrFramebuffer:(r.framebuffers||(r.framebuffers={}),Z=r.framebuffers[U]),Z===void 0){Z=i.createFramebuffer(),n.bindFramebuffer(i.FRAMEBUFFER,Z);let ne=t.textures,K=[];if(p){r.cubeFramebuffers[U]=Z;let{textureGPU:se}=this.get(ne[0]),he=this.renderer._activeCubeFace,Re=this.renderer._activeMipmapLe
struct VarysStruct {
@ builtin ( position ) Position : vec4f ,
@ location ( 0 ) vTex : vec2f ,
@ location ( 1 ) @ interpolate ( flat , either ) vBaseArrayLayer : u32 ,
} ;
@ group ( 0 ) @ binding ( 2 )
var < uniform > flipY : u32 ;
@ vertex
fn mainVS (
@ builtin ( vertex _index ) vertexIndex : u32 ,
@ builtin ( instance _index ) instanceIndex : u32 ) - > VarysStruct {
var Varys : VarysStruct ;
var pos = array (
vec2f ( - 1 , - 1 ) ,
vec2f ( - 1 , 3 ) ,
vec2f ( 3 , - 1 ) ,
) ;
let p = pos [ vertexIndex ] ;
let mult = select ( vec2f ( 0.5 , - 0.5 ) , vec2f ( 0.5 , 0.5 ) , flipY != 0 ) ;
Varys . vTex = p * mult + vec2f ( 0.5 ) ;
Varys . Position = vec4f ( p , 0 , 1 ) ;
Varys . vBaseArrayLayer = instanceIndex ;
return Varys ;
}
@ group ( 0 ) @ binding ( 0 )
var imgSampler : sampler ;
@ group ( 0 ) @ binding ( 1 )
var img2d : texture _2d < f32 > ;
@ fragment
fn main _2d ( Varys : VarysStruct ) - > @ location ( 0 ) vec4 < f32 > {
return textureSample ( img2d , imgSampler , Varys . vTex ) ;
}
@ group ( 0 ) @ binding ( 1 )
var img2dArray : texture _2d _array < f32 > ;
@ fragment
fn main _2d _array ( Varys : VarysStruct ) - > @ location ( 0 ) vec4 < f32 > {
return textureSample ( img2dArray , imgSampler , Varys . vTex , Varys . vBaseArrayLayer ) ;
}
const faceMat = array (
mat3x3f ( 0 , 0 , - 2 , 0 , - 2 , 0 , 1 , 1 , 1 ) , // pos-x
mat3x3f ( 0 , 0 , 2 , 0 , - 2 , 0 , - 1 , 1 , - 1 ) , // neg-x
mat3x3f ( 2 , 0 , 0 , 0 , 0 , 2 , - 1 , 1 , - 1 ) , // pos-y
mat3x3f ( 2 , 0 , 0 , 0 , 0 , - 2 , - 1 , - 1 , 1 ) , // neg-y
mat3x3f ( 2 , 0 , 0 , 0 , - 2 , 0 , - 1 , 1 , 1 ) , // pos-z
mat3x3f ( - 2 , 0 , 0 , 0 , - 2 , 0 , 1 , 1 , - 1 ) , // neg-z
) ;
@ group ( 0 ) @ binding ( 1 )
var imgCube : texture _cube < f32 > ;
@ fragment
fn main _cube ( Varys : VarysStruct ) - > @ location ( 0 ) vec4 < f32 > {
return textureSample ( imgCube , imgSampler , faceMat [ Varys . vBaseArrayLayer ] * vec3f ( fract ( Varys . vTex ) , 1 ) ) ;
}
` ;this.mipmapSampler=t.createSampler({minFilter:P2.Linear}),this.flipYSampler=t.createSampler({minFilter:P2.Nearest}),this.flipUniformBuffer=t.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),this.noFlipUniformBuffer=t.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM}),this.transferPipelines={},this.mipmapShaderModule=t.createShaderModule({label:"mipmap",code:i})}getTransferPipeline(t,i){i=i||"2d-array";let n= ` $ { t } - $ { i } ` ,s=this.transferPipelines[n];return s===void 0&&(s=this.device.createRenderPipeline({label: ` mipmap - $ { t } - $ { i } ` ,vertex:{module:this.mipmapShaderModule},fragment:{module:this.mipmapShaderModule,entryPoint: ` main _$ { i . replace ( "-" , "_" ) } ` ,targets:[{format:t}]},layout:"auto"}),this.transferPipelines[n]=s),s}flipY(t,i,n=0){let s=i.format,{width:o,height:r}=i.size,l=this.device.createTexture({size:{width:o,height:r},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),d=this.getTransferPipeline(s,t.textureBindingViewDimension),h=this.getTransferPipeline(s,l.textureBindingViewDimension),p=this.device.createCommandEncoder({}),I=(m,y,T,R,b,A)=>{let O=m.getBindGroupLayout(0),P=this.device.createBindGroup({layout:O,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:y.createView({dimension:y.textureBindingViewDimension||"2d-array",baseMipLevel:0,mipLevelCount:1})},{binding:2,resource:{buffer:A?this.flipUniformBuffer:this.noFlipUniformBuffer}}]}),U=p.beginRenderPass({colorAttachments:[{view:R.createView({dimension:"2d",baseMipLevel:0,mipLevelCount:1,baseArrayLayer:b,arrayLayerCount:1}),loadOp:Vo.Clear,storeOp:oI.Store}]});U.setPipeline(m),U.setBindGroup(0,P),U.draw(3,1,0,T),U.end()};I(d,t,n,l,0,!1),I(h,l,0,t,n,!0),this.device.queue.submit([p.finish()]),l.destroy()}generateMipmaps(t,i=null){let n=this.get(t),s=n.layers||this._mipmapCreateBundles(t),o=i||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(o,s),i===null&&this.device.queue.submit([o.finish()]),n.layers=s}_mipmapCreateBundles(t){let i=t.textureBindingViewDimension||"2d-array",n=this.getTransferPipeline(t.format,i),s=n.getBindGroupLayout(0),o=[];for(let r=1;r<t.mipLevelCount;r++)for(let l=0;l<t.depthOrArrayLayers;l++){let d=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:t.createView({dimension:i,baseMipLevel:r-1,mipLevelCount:1})},{binding:2,resource:{buffer:this.noFlipUniformBuffer}}]}),h={colorAttachments:[{view:t.createView({dimension:"2d",baseMipLevel:r,mipLevelCount:1,baseArrayLayer:l,arrayLayerCount:1}),loadOp:Vo.Clear,storeOp:oI.Store}]},p=this.device.createRenderBundleEncoder({colorFormats:[t.format]});p.setPipeline(n),p.setBindGroup(0,d),p.draw(3,1,0,l),o.push({renderBundles:[p.finish()],passDescriptor:h})}return o}_mipmapRunBundles(t,i){let n=i.length;for(let s=0;s<n;s++){let o=i[s],r=t.beginRenderPass(o.passDescriptor);r.executeBundles(o.renderBundles),r.end()}}},_Ve={[KP]:"never",[OC]:"less",[QP]:"equal",[jT]:"less-equal",[Jb]:"greater",[Ty]:"greater-equal",[XP]:"always",[JP]:"not-equal"},DVe=[0,1,3,2,4,5],aue=class{constructor(t){this.backend=t,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(t){let i=this.backend,n=t.minFilter+"-"+t.magFilter+"-"+t.wrapS+"-"+t.wrapT+"-"+(t.wrapR||"0")+"-"+t.anisotropy+"-"+(t.compareFunction||0),s=this._samplerCache.get(n);if(s===void 0){let r={addressModeU:this._convertAddressMode(t.wrapS),addressModeV:this._convertAddressMode(t.wrapT),addressModeW:this._convertAddressMode(t.wrapR),magFilter:this._convertFilterMode(t.magFilter),minFilter:this._convertFilterMode(t.minFilter),mipmapFilter:this._convertFilterMode(t.minFilter),maxAnisotropy:1};t.isDepthTexture&&t.compareFunction===null&&(r.magFilter=P2.Nearest,r.minFilter=P2.Nearest,r.mipmapFilter=P2.Nearest),r.magFilter===P2.Linear&&r.minFilter===P2.Linear&&r.mipmapFilter===P2.Linear&&(r.maxAnisotropy=t.anisotropy),t.isDepthTexture&&t.compareFunction!
fn tsl _biquadraticTexture ( map : texture _2d < f32 > , coord : vec2f , iRes : vec2u , level : u32 ) - > vec4f {
let res = vec2f ( iRes ) ;
let uvScaled = coord * res ;
let uvWrapping = ( ( uvScaled % res ) + res ) % res ;
// https://www.shadertoy.com/view/WtyXRy
let uv = uvWrapping - 0.5 ;
let iuv = floor ( uv ) ;
let f = fract ( uv ) ;
let rg1 = textureLoad ( map , vec2u ( iuv + vec2 ( 0.5 , 0.5 ) ) % iRes , level ) ;
let rg2 = textureLoad ( map , vec2u ( iuv + vec2 ( 1.5 , 0.5 ) ) % iRes , level ) ;
let rg3 = textureLoad ( map , vec2u ( iuv + vec2 ( 0.5 , 1.5 ) ) % iRes , level ) ;
let rg4 = textureLoad ( map , vec2u ( iuv + vec2 ( 1.5 , 1.5 ) ) % iRes , level ) ;
return mix ( mix ( rg1 , rg2 , f . x ) , mix ( rg3 , rg4 , f . x ) , f . y ) ;
}
` ),biquadraticTextureArray:new Ic( `
fn tsl _biquadraticTexture _array ( map : texture _2d _array < f32 > , coord : vec2f , iRes : vec2u , layer : u32 , level : u32 ) - > vec4f {
let res = vec2f ( iRes ) ;
let uvScaled = coord * res ;
let uvWrapping = ( ( uvScaled % res ) + res ) % res ;
// https://www.shadertoy.com/view/WtyXRy
let uv = uvWrapping - 0.5 ;
let iuv = floor ( uv ) ;
let f = fract ( uv ) ;
let rg1 = textureLoad ( map , vec2u ( iuv + vec2 ( 0.5 , 0.5 ) ) % iRes , layer , level ) ;
let rg2 = textureLoad ( map , vec2u ( iuv + vec2 ( 1.5 , 0.5 ) ) % iRes , layer , level ) ;
let rg3 = textureLoad ( map , vec2u ( iuv + vec2 ( 0.5 , 1.5 ) ) % iRes , layer , level ) ;
let rg4 = textureLoad ( map , vec2u ( iuv + vec2 ( 1.5 , 1.5 ) ) % iRes , layer , level ) ;
return mix ( mix ( rg1 , rg2 , f . x ) , mix ( rg3 , rg4 , f . x ) , f . y ) ;
}
` )},BVe={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"},gge="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(gge+= ` diagnostic ( off , derivative _uniformity ) ;
` );var hue=class extends qZ{constructor(t,i){super(t,i,new due),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(t,i,n,s,o,r=this.shaderStage){return r==="fragment"?s?o? ` textureSample ( $ { i } , $ { i } _sampler , $ { n } , $ { s } , $ { o } ) ` : ` textureSample ( $ { i } , $ { i } _sampler , $ { n } , $ { s } ) ` :o? ` textureSample ( $ { i } , $ { i } _sampler , $ { n } , $ { o } ) ` : ` textureSample ( $ { i } , $ { i } _sampler , $ { n } ) ` :this.generateTextureSampleLevel(t,i,n,"0",s)}generateTextureSampleLevel(t,i,n,s,o,r){return this.isUnfilterable(t)===!1?o?r? ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s } , $ { r } ) ` : ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s } ) ` :r? ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } , $ { s } , $ { r } ) ` : ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } , $ { s } ) ` :this.isFilteredTexture(t)?this.generateFilteredTexture(t,i,n,r,s,o):this.generateTextureLod(t,i,n,o,r,s)}generateWrapFunction(t){let i= ` tsl _coord _$ { pye [ t . wrapS ] } S _$ { pye [ t . wrapT ] } _$ { t . is3DTexture || t . isData3DTexture ? "3d" : "2d" } T ` ,n=mye[i];if(n===void 0){let s=[],o=t.is3DTexture||t.isData3DTexture?"vec3f":"vec2f",r= ` fn $ { i } ( coord : $ { o } ) - > $ { o } {
return $ { o } (
` ,l=(d,h)=>{d===bT?(s.push(_k.repeatWrapping_float),r+= ` tsl _repeatWrapping _float ( coord . $ { h } ) ` ):d===_u?(s.push(_k.clampWrapping_float),r+= ` tsl _clampWrapping _float ( coord . $ { h } ) ` ):d===NT?(s.push(_k.mirrorWrapping_float),r+= ` tsl _mirrorWrapping _float ( coord . $ { h } ) ` ):(r+= ` coord . $ { h } ` ,ci( ` WebGPURenderer : Unsupported texture wrap type "${d}" for vertex shader . ` ))};l(t.wrapS,"x"),r+= ` ,
` ,l(t.wrapT,"y"),(t.is3DTexture||t.isData3DTexture)&&(r+= ` ,
` ,l(t.wrapR,"z")),r+= `
) ;
}
` ,mye[i]=n=new Ic(r,s)}return n.build(this),i}generateArrayDeclaration(t,i){return ` array < $ { this . getType ( t ) } , $ { i } > ` }generateTextureDimension(t,i,n){let s=this.getDataFromNode(t,this.shaderStage,this.cache);s.dimensionsSnippet===void 0&&(s.dimensionsSnippet={});let o=s.dimensionsSnippet[n];if(s.dimensionsSnippet[n]===void 0){let r,l,{primarySamples:d}=this.renderer.backend.utils.getTextureSampleData(t),h=d>1;t.is3DTexture||t.isData3DTexture?l="vec3<u32>":l="vec2<u32>",h||t.isStorageTexture?r=i:r= ` $ { i } $ { n ? ` , u32( ${ n } ) ` : "" } ` ,o=new H8(new V8( ` textureDimensions ( $ { r } ) ` ,l)),s.dimensionsSnippet[n]=o,(t.isArrayTexture||t.isDataArrayTexture||t.is3DTexture||t.isData3DTexture)&&(s.arrayLayerCount=new H8(new V8( ` textureNumLayers ( $ { i } ) ` ,"u32"))),t.isTextureCube&&(s.cubeFaceCount=new H8(new V8("6u","u32")))}return o.build(this)}generateFilteredTexture(t,i,n,s,o="0u",r){let l=this.generateWrapFunction(t),d=this.generateTextureDimension(t,i,o);return s&&(n= ` $ { n } + vec2 < f32 > ( $ { s } ) / $ { d } ` ),r?(this._include("biquadraticTextureArray"), ` tsl _biquadraticTexture _array ( $ { i } , $ { l } ( $ { n } ) , $ { d } , u32 ( $ { r } ) , u32 ( $ { o } ) ) ` ):(this._include("biquadraticTexture"), ` tsl _biquadraticTexture ( $ { i } , $ { l } ( $ { n } ) , $ { d } , u32 ( $ { o } ) ) ` )}generateTextureLod(t,i,n,s,o,r="0u"){if(t.isCubeTexture===!0){o&&(n= ` $ { n } + vec3 < f32 > ( $ { o } ) ` );let y=t.isDepthTexture?"u32":"f32";return ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } , $ { y } ( $ { r } ) ) ` }let l=this.generateWrapFunction(t),d=this.generateTextureDimension(t,i,r),h=t.is3DTexture||t.isData3DTexture?"vec3":"vec2",p=h==="vec3"?"vec3<u32>( 1, 1, 1 )":"vec2<u32>( 1, 1 )";o&&(n= ` $ { n } + $ { h } < f32 > ( $ { o } ) / $ { h } < f32 > ( $ { d } ) ` );let I= ` $ { h } < f32 > ( 0 ) ` ,m= ` $ { h } < f32 > ( $ { d } - $ { p } ) ` ;return n= ` $ { h } < u32 > ( clamp ( floor ( $ { l } ( $ { n } ) * $ { h } < f32 > ( $ { d } ) ) , $ { I } , $ { m } ) ) ` ,this.generateTextureLoad(t,i,n,r,s,null)}generateStorageTextureLoad(t,i,n,s,o,r){r&&(n= ` $ { n } + $ { r } ` );let l;return o?l= ` textureLoad ( $ { i } , $ { n } , $ { o } ) ` :l= ` textureLoad ( $ { i } , $ { n } ) ` ,l}generateTextureLoad(t,i,n,s,o,r){s===null&&(s="0u"),r&&(n= ` $ { n } + $ { r } ` );let l;return o?l= ` textureLoad ( $ { i } , $ { n } , $ { o } , u32 ( $ { s } ) ) ` :(l= ` textureLoad ( $ { i } , $ { n } , u32 ( $ { s } ) ) ` ,this.renderer.backend.compatibilityMode&&t.isDepthTexture&&(l+=".x")),l}generateTextureStore(t,i,n,s,o){let r;return s?r= ` textureStore ( $ { i } , $ { n } , $ { s } , $ { o } ) ` :r= ` textureStore ( $ { i } , $ { n } , $ { o } ) ` ,r}isSampleCompare(t){return t.isDepthTexture===!0&&t.compareFunction!==null&&this.renderer.hasCompatibility(dw.TEXTURE_COMPARE)}isUnfilterable(t){return this.getComponentTypeFromTexture(t)!=="float"||!this.isAvailable("float32Filterable")&&t.type===Ro||this.isSampleCompare(t)===!1&&t.minFilter===Vs&&t.magFilter===Vs||this.renderer.backend.utils.getTextureSampleData(t).primarySamples>1}generateTexture(t,i,n,s,o,r=this.shaderStage){let l=null;return this.isUnfilterable(t)?l=this.generateTextureLod(t,i,n,s,o,"0",r):l=this._generateTextureSample(t,i,n,s,o,r),l}generateTextureGrad(t,i,n,s,o,r,l=this.shaderStage){if(l==="fragment")return o?r? ` textureSampleGrad ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s [ 0 ] } , $ { s [ 1 ] } , $ { r } ) ` : ` textureSampleGrad ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s [ 0 ] } , $ { s [ 1 ] } ) ` :r? ` textureSampleGrad ( $ { i } , $ { i } _sampler , $ { n } , $ { s [ 0 ] } , $ { s [ 1 ] } , $ { r } ) ` : ` textureSampleGrad ( $ { i } , $ { i } _sampler , $ { n } , $ { s [ 0 ] } , $ { s [ 1 ] } ) ` ;yi( ` WebGPURenderer : THREE . TextureNode . gradient ( ) does not support $ { l } shader . ` )}generateTextureCompare(t,i,n,s,o,r,l=this.shaderStage){if(l==="fragment")return t.isDepthTexture===!0&&t.isArrayTexture===!0?r? ` textureSampleCompare ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s } , $ { r } ) ` : ` textureSampleCompare ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s } ) ` :r? ` textureSampleCompare ( $ { i } , $ { i } _sampler , $ { n } , $ { s } , $ { r } ) ` : ` textureSampleCompare ( $ { i } , $ { i } _sampler , $ { n } , $ { s } ) ` ;yi( ` WebGPURenderer : THREE . DepthTexture . compareFunction ( ) does not support $ { l } shader . ` )}generateTextureLevel(t,i,n,s,o,r){return this.isUnfilterable(t)===!1?o?r? ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s } , $ { r } ) ` : ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } , $ { o } , $ { s } ) ` :r? ` textureSampleLevel ( $ { i } , $ { i } _sampler , $ { n } ,
$ { n . vars }
$ { n . code }
` ;return n.result&&(o+= ` return $ { n . result } ;
` ),o+= `
}
` ,o}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(t,i=this.shaderStage){(this.directives[i]||(this.directives[i]=new Set)).add(t)}getDirectives(t){let i=[],n=this.directives[t];if(n!==void 0)for(let s of n)i.push( ` enable $ { s } ; ` );return i.join( `
` )}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(t){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances", ` array < f32 , $ { t } > ` ,"vertex")}getBuiltins(t){let i=[],n=this.builtins[t];if(n!==void 0)for(let{name:s,property:o,type:r}of n.values())i.push( ` @ builtin ( $ { s } ) $ { o } : $ { r } ` );return i.join( ` ,
` )}getScopedArray(t,i,n,s){return this.scopedArrays.has(t)===!1&&this.scopedArrays.set(t,{name:t,scope:i,bufferType:n,bufferCount:s}),t}getScopedArrays(t){if(t!=="compute")return;let i=[];for(let{name:n,scope:s,bufferType:o,bufferCount:r}of this.scopedArrays.values()){let l=this.getType(o);i.push( ` var < $ { s } > $ { n } : array < $ { l } , $ { r } > ; ` )}return i.join( `
` )}getAttributes(t){let i=[];if(t==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",t),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),t==="vertex"||t==="compute"){let n=this.getBuiltins("attribute");n&&i.push(n);let s=this.getAttributesArray();for(let o=0,r=s.length;o<r;o++){let l=s[o],d=l.name,h=this.getType(l.type);i.push( ` @ location ( $ { o } ) $ { d } : $ { h } ` )}}return i.join( ` ,
` )}getStructMembers(t){let i=[];for(let n of t.members){let s=t.output?"@location( "+n.index+" ) ":"",o=this.getType(n.type);n.atomic&&(o="atomic< "+o+" >"),i.push( ` $ { s + n . name } : $ { o } ` )}return t.output&&i.push( ` $ { this . getBuiltins ( "output" ) } ` ),i.join( ` ,
` )}getStructs(t){let i="",n=this.structs[t];if(n.length>0){let s=[];for(let o of n){let r= ` struct $ { o . name } {
` ;r+=this.getStructMembers(o),r+= `
} ; ` ,s.push(r)}i= `
` +s.join( `
` )+ `
` }return i}getVar(t,i,n=null,s=""){let o= ` var $ { s } $ { i } : ` ;return n!==null?o+=this.generateArrayDeclaration(t,n):o+=this.getType(t),o}getVars(t,i=!1){let n="";i&&(n="<private>");let s=[],o=this.vars[t];if(o!==void 0)for(let r of o)s.push( ` $ { this . getVar ( r . type , r . name , r . count , n ) } ; ` );return i?s.join( `
` ): `
$ { s . join ( `
` )}
` }getVaryings(t){let i=[];if(t==="vertex"&&this.getBuiltin("position","builtinClipSpace","vec4<f32>","vertex"),t==="vertex"||t==="fragment"){let o=this.varyings,r=this.vars[t],l=0;for(let d=0;d<o.length;d++){let h=o[d];if(h.needsInterpolation){let p= ` @ location ( $ { l ++ } ) ` ;if(h.interpolationType){let I=h.interpolationSampling!==null? ` , $ { h . interpolationSampling } ) ` :" )";p+= ` @ interpolate ( $ { h . interpolationType } $ { I } ` }else/^(int|uint|ivec|uvec)/.test(h.type)&&(p+=" @interpolate(flat, either)");i.push( ` $ { p } $ { h . name } : $ { this . getType ( h . type ) } ` )}else t==="vertex"&&r.includes(h)===!1&&r.push(h)}}let n=this.getBuiltins(t);n&&i.push(n);let s=i.join( ` ,
` );return t==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+s):s}isCustomStruct(t){let i=t.value,n=t.node,s=(i.isBufferAttribute||i.isInstancedBufferAttribute)&&n.structTypeNode!==null,o=n.value&&n.value.array&&typeof n.value.itemSize=="number"&&n.value.array.length>n.value.itemSize;return s&&!o}getUniforms(t){let i=this.renderer.backend,n=this.uniforms[t],s=[],o=[],r=[],l={};for(let h of n){let p=h.groupNode.name,I=this.bindingsIndexes[p];if(h.type==="texture"||h.type==="cubeTexture"||h.type==="cubeDepthTexture"||h.type==="storageTexture"||h.type==="texture3D"){let m=h.node.value;(m.isCubeTexture===!0||this.isUnfilterable(m)===!1&&h.node.isStorageTextureNode!==!0)&&(this.isSampleCompare(m)?s.push( ` @ binding ( $ { I . binding ++ } ) @ group ( $ { I . group } ) var $ { h . name } _sampler : sampler _comparison ; ` ):s.push( ` @ binding ( $ { I . binding ++ } ) @ group ( $ { I . group } ) var $ { h . name } _sampler : sampler ; ` ));let T,R="",{primarySamples:b}=i.utils.getTextureSampleData(m);if(b>1&&(R="_multisampled"),m.isCubeTexture===!0&&m.isDepthTexture===!0)T="texture_depth_cube";else if(m.isCubeTexture===!0)T="texture_cube<f32>";else if(m.isDepthTexture===!0)i.compatibilityMode&&m.compareFunction===null?T= ` texture$ { R } _2d < f32 > ` :T= ` texture _depth$ { R } _2d$ { m . isArrayTexture === ! 0 ? "_array" : "" } ` ;else if(h.node.isStorageTextureNode===!0){let A=uue(m,i.device),O=this.getStorageAccess(h.node,t),P=h.node.value.is3DTexture,U=h.node.value.isArrayTexture;T= ` texture _storage _$ { P ? "3d" : ` 2d ${ U ? "_array" : "" } ` } < $ { A } , $ { O } > ` }else if(m.isArrayTexture===!0||m.isDataArrayTexture===!0||m.isCompressedArrayTexture===!0)T="texture_2d_array<f32>";else if(m.is3DTexture===!0||m.isData3DTexture===!0)T="texture_3d<f32>";else{let A=this.getComponentTypeFromTexture(m).charAt(0);T= ` texture$ { R } _2d < $ { A } 32 > ` }s.push( ` @ binding ( $ { I . binding ++ } ) @ group ( $ { I . group } ) var $ { h . name } : $ { T } ; ` )}else if(h.type==="buffer"||h.type==="storageBuffer"||h.type==="indirectStorageBuffer"){let m=h.node,y=this.getType(m.getNodeType(this)),T=m.bufferCount,R=T>0&&h.type==="buffer"?", "+T:"",b=m.isStorageBufferNode? ` storage , $ { this . getStorageAccess ( m , t ) } ` :"uniform";if(this.isCustomStruct(h))o.push( ` @ binding ( $ { I . binding ++ } ) @ group ( $ { I . group } ) var < $ { b } > $ { h . name } : $ { y } ; ` );else{let O= ` value : array < $ { m . isAtomic ? ` atomic< ${ y } > ` : ` ${ y } ` } $ { R } > ` ;o.push(this._getWGSLStructBinding(h.name,O,b,I.binding++,I.group))}}else{let m=h.groupNode.name;if(l[m]===void 0){let y=this.uniformGroups[m];if(y!==void 0){let T=[];for(let b of y.uniforms){let A=b.getType(),O=this.getType(this.getVectorType(A));T.push( ` $ { b . name } : $ { O } ` )}let R=this.uniformGroupsBindings[m];R===void 0&&(R={index:I.binding++,id:I.group},this.uniformGroupsBindings[m]=R),l[m]={index:R.index,id:R.id,snippets:T}}}}}for(let h in l){let p=l[h];r.push(this._getWGSLStructBinding(h,p.snippets.join( ` ,
` ),"uniform",p.index,p.id))}return[...s,...o,...r].join( `
` )}buildCode(){let t=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(let i in t){this.shaderStage=i;let n=this.allowGlobalVariables,s=t[i];s.uniforms=this.getUniforms(i),s.attributes=this.getAttributes(i),s.varyings=this.getVaryings(i),s.structs=this.getStructs(i),s.vars=this.getVars(i,n),s.codes=this.getCodes(i),s.directives=this.getDirectives(i),s.scopedArrays=this.getScopedArrays(i);let o= ` // code
` ;o+=this.flowCode[i];let r=this.flowNodes[i],l=r[r.length-1],d=l.outputNode,h=d!==void 0&&d.isOutputStructNode===!0;for(let p of r){let I=this.getFlowData(p),m=p.name;if(m&&(o.length>0&&(o+= `
` ),o+= ` // flow -> ${m}
` ),o+= ` $ { I . code }
` ,p===l&&i!=="compute"){if(o+= ` // result
` ,i==="vertex")o+= ` varyings . builtinClipSpace = $ { I . result } ; ` ;else if(i==="fragment")if(h)s.returnType=d.getNodeType(this),s.structs+="var<private> output : "+s.returnType+";",o+= ` return $ { I . result } ; ` ;else{let y=" @location( 0 ) color: vec4<f32>",T=this.getBuiltins("output");T&&(y+= ` ,
` +T),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",y),s.structs+= `
var < private > output : OutputStruct ; ` ,o+= ` output . color = $ { I . result } ;
return output ; ` }}}s.flow=o}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(t.vertex),this.fragmentShader=this._getWGSLFragmentCode(t.fragment);else{let i=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(t.compute,i)}}getMethod(t,i=null){let n;return i!==null&&(n=this._getWGSLMethod(t+"_"+i)),n===void 0&&(n=this._getWGSLMethod(t)),n||t}getBitcastMethod(t){return ` bitcast < $ { this . getType ( t ) } > ` }getFloatPackingMethod(t){return this.getMethod( ` floatpack _$ { t } _2x16 ` )}getFloatUnpackingMethod(t){return this.getMethod( ` floatunpack _$ { t } _2x16 ` )}getTernary(t,i,n){return ` select ( $ { n } , $ { i } , $ { t } ) ` }getType(t){return MVe[t]||t}isAvailable(t){let i=Iye[t];return i===void 0&&(t==="float32Filterable"?i=this.renderer.hasFeature("float32-filterable"):t==="clipDistance"&&(i=this.renderer.hasFeature("clip-distances")),Iye[t]=i),i}_getWGSLMethod(t){return _k[t]!==void 0&&this._include(t),BVe[t]}_include(t){let i=_k[t];return i.build(this),this.addInclude(i),i}_getWGSLVertexCode(t){return ` $ { this . getSignature ( ) }
// directives
$ { t . directives }
// structs
$ { t . structs }
// uniforms
$ { t . uniforms }
// varyings
$ { t . varyings }
var < private > varyings : VaryingsStruct ;
// vars
$ { t . vars }
// codes
$ { t . codes }
@ vertex
fn main ( $ { t . attributes } ) - > VaryingsStruct {
// flow
$ { t . flow }
return varyings ;
}
` }_getWGSLFragmentCode(t){return ` $ { this . getSignature ( ) }
// global
$ { gge }
// structs
$ { t . structs }
// uniforms
$ { t . uniforms }
// vars
$ { t . vars }
// codes
$ { t . codes }
@ fragment
fn main ( $ { t . varyings } ) - > $ { t . returnType } {
// flow
$ { t . flow }
}
` }_getWGSLComputeCode(t,i){let[n,s,o]=i;return ` $ { this . getSignature ( ) }
// directives
$ { t . directives }
// system
var < private > instanceIndex : u32 ;
// locals
$ { t . scopedArrays }
// structs
$ { t . structs }
// uniforms
$ { t . uniforms }
// vars
$ { this . allowGlobalVariables ? t . vars : "" }
// codes
$ { t . codes }
@ compute @ workgroup _size ( $ { n } , $ { s } , $ { o } )
fn main ( $ { t . attributes } ) {
// local vars
$ { this . allowGlobalVariables ? "" : t . vars }
// system
instanceIndex = globalId . x
+ globalId . y * ( $ { n } * numWorkgroups . x )
+ globalId . z * ( $ { n } * numWorkgroups . x ) * ( $ { s } * numWorkgroups . y ) ;
// flow
$ { t . flow }
}
` }_getWGSLStruct(t,i){return `
struct $ { t } {
$ { i }
} ; ` }_getWGSLStructBinding(t,i,n,s=0,o=0){let r=t+"Struct";return ` $ { this . _getWGSLStruct ( r , i ) }
@ binding ( $ { s } ) @ group ( $ { o } )
var < $ { n } > $ { t } : $ { r } ; ` }},fue=class{constructor(t){this.backend=t}getCurrentDepthStencilFormat(t){let i;return t.depth&&(t.depthTexture!==null?i=this.getTextureFormatGPU(t.depthTexture):t.stencil?this.backend.renderer.reversedDepthBuffer===!0?i=Pt.Depth32FloatStencil8:i=Pt.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?i=Pt.Depth32Float:i=Pt.Depth24Plus),i}getTextureFormatGPU(t){return this.backend.get(t).format}getTextureSampleData(t){let i;if(t.isFramebufferTexture)i=1;else if(t.isDepthTexture&&!t.renderTarget){let o=this.backend.renderer,r=o.getRenderTarget();i=r?r.samples:o.currentSamples}else t.renderTarget&&(i=t.renderTarget.samples);i=i||1;let n=i>1&&t.renderTarget!==null&&t.isDepthTexture!==!0&&t.isFramebufferTexture!==!0;return{samples:i,primarySamples:n?1:i,isMSAA:n}}getCurrentColorFormat(t){let i;return t.textures!==null?i=this.getTextureFormatGPU(t.textures[0]):i=this.getPreferredCanvasFormat(),i}getCurrentColorFormats(t){return t.textures!==null?t.textures.map(i=>this.getTextureFormatGPU(i)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(t){return t.textures!==null?t.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(t,i){if(t.isPoints)return Q $ .PointList;if(t.isLineSegments||t.isMesh&&i.wireframe===!0)return Q $ .LineList;if(t.isLine)return Q $ .LineStrip;if(t.isMesh)return Q $ .TriangleList}getSampleCount(t){return t>=4?4:1}getSampleCountRenderContext(t){return t.textures!==null?this.getSampleCount(t.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){let i=this.backend.parameters.outputType;if(i===void 0)return navigator.gpu.getPreferredCanvasFormat();if(i===Lo)return Pt.BGRA8Unorm;if(i===sr)return Pt.RGBA16Float;throw new Error("Unsupported output buffer type.")}},wge=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&wge.set(Float16Array,["float16"]);var FVe=new Map([[rC,["float16"]]]),UVe=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]),pue=class{constructor(t){this.backend=t}createAttribute(t,i){let n=this._getBufferAttribute(t),s=this.backend,o=s.get(n),r=o.buffer;if(r===void 0){let l=s.device,d=n.array;if(t.normalized===!1){if(d.constructor===Int16Array||d.constructor===Int8Array)d=new Int32Array(d);else if((d.constructor===Uint16Array||d.constructor===Uint8Array)&&(d=new Uint32Array(d),i&GPUBufferUsage.INDEX))for(let I=0;I<d.length;I++)d[I]===65535&&(d[I]=4294967295)}if(n.array=d,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){d=new d.constructor(n.count*4);for(let I=0;I<n.count;I++)d.set(n.array.subarray(I*3,I*3+3),I*4);n.itemSize=4,n.array=d,o._force3to4BytesAlignment=!0}let h=d.byteLength,p=h+(4-h%4)%4;r=l.createBuffer({label:n.name,size:p,usage:i,mappedAtCreation:!0}),new d.constructor(r.getMappedRange()).set(d),r.unmap(),o.buffer=r}}updateAttribute(t){let i=this._getBufferAttribute(t),n=this.backend,s=n.device,o=n.get(i),r=n.get(i).buffer,l=i.array;if(o._force3to4BytesAlignment===!0){l=new l.constructor(i.count*4);for(let h=0;h<i.count;h++)l.set(i.array.subarray(h*3,h*3+3),h*4);i.array=l}let d=i.updateRanges;if(d.length===0)s.queue.writeBuffer(r,0,l,0);else{let h=LC(l),p=h?1:l.BYTES_PER_ELEMENT;for(let I=0,m=d.length;I<m;I++){let y=d[I],T,R;if(o._force3to4BytesAlignment===!0){let A=Math.floor(y.start/3),O=Math.ceil(y.count/3);T=A*4*p,R=O*4*p}else T=y.start*p,R=y.count*p;let b=T*(h?l.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(r,b,l,T,R)}i.clearUpdateRanges()}}createShaderVertexBuffers(t){let i=t.getAttributes(),n=new Map;for(let s=0;s<i.length;s++){let o=i[s],r=o.array.BYTES_PER_ELEMENT,l=this._getBufferAttribute(o),d=n.get(l);if(d===void 0){let I,m;o.isInterleavedBufferAttribute===!0?(I=o.data.stride*r,m=o.data.isInstancedInterleavedBuffer?J $ .Instance:J $ .Vertex):(I=o.itemSize*r
2026-04-25 18:24:50 +01:00
- If you ' re the tool creator , you can take one from https : //www.uuidgenerator.net/.
2026-04-25 18:59:02 +01:00
- If you 're using a platform tool, verify the uuid isn' t misspelled or contact the tool creator . ` )}};Le(E0e,"_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} $ /);Le(E0e,"_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 dI=E0e,Qwe=":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",ZVe=Qwe+" \\ -. \\ d \\ u00B7 \\ u0300- \\ u036F \\ u203F- \\ u2040",KVe="["+Qwe+"]["+ZVe+"]*",QVe=new RegExp("^"+KVe+" $ ");function Jwe(e,t){let i=[],n=t.exec(e);for(;n;){let s=[];s.startIndex=t.lastIndex-n[0].length;let o=n.length;for(let r=0;r<o;r++)s.push(n[r]);i.push(s),n=t.exec(e)}return i}var dJ=function(e){let t=QVe.exec(e);return!(t===null||typeof t>"u")};function JVe(e){return typeof e<"u"}var XVe={allowBooleanAttributes:!1,unpairedTags:[]};function eke(e,t){t=Object.assign({},XVe,t);let i=[],n=!1,s=!1;e[0]===" \u FEFF"&&(e=e.substr(1));for(let o=0;o<e.length;o++)if(e[o]==="<"&&e[o+1]==="?"){if(o+=2,o=zge(e,o),o.err)return o}else if(e[o]==="<"){let r=o;if(o++,e[o]==="!"){o=Wge(e,o);continue}else{let l=!1;e[o]==="/"&&(l=!0,o++);let d="";for(;o<e.length&&e[o]!==">"&&e[o]!==" "&&e[o]!==" "&&e[o]!== `
` &&e[o]!==" \r ";o++)d+=e[o];if(d=d.trim(),d[d.length-1]==="/"&&(d=d.substring(0,d.length-1),o--),!ake(d)){let I;return d.trim().length===0?I="Invalid space after '<'.":I="Tag '"+d+"' is an invalid name.",gc("InvalidTag",I,cI(e,o))}let h=nke(e,o);if(h===!1)return gc("InvalidAttr","Attributes for '"+d+"' have open quote.",cI(e,o));let p=h.value;if(o=h.index,p[p.length-1]==="/"){let I=o-p.length;p=p.substring(0,p.length-1);let m=Yge(p,t);if(m===!0)n=!0;else return gc(m.err.code,m.err.msg,cI(e,I+m.err.line))}else if(l)if(h.tagClosed){if(p.trim().length>0)return gc("InvalidTag","Closing tag '"+d+"' can't have attributes or invalid starting.",cI(e,r));if(i.length===0)return gc("InvalidTag","Closing tag '"+d+"' has not been opened.",cI(e,r));{let I=i.pop();if(d!==I.tagName){let m=cI(e,I.tagStartPos);return gc("InvalidTag","Expected closing tag '"+I.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+d+"'.",cI(e,r))}i.length==0&&(s=!0)}}else return gc("InvalidTag","Closing tag '"+d+"' doesn't have proper closing.",cI(e,o));else{let I=Yge(p,t);if(I!==!0)return gc(I.err.code,I.err.msg,cI(e,o-p.length+I.err.line));if(s===!0)return gc("InvalidXml","Multiple possible root nodes found.",cI(e,o));t.unpairedTags.indexOf(d)!==-1||i.push({tagName:d,tagStartPos:r}),n=!0}for(o++;o<e.length;o++)if(e[o]==="<")if(e[o+1]==="!"){o++,o=Wge(e,o);continue}else if(e[o+1]==="?"){if(o=zge(e,++o),o.err)return o}else break;else if(e[o]==="&"){let I=rke(e,o);if(I==-1)return gc("InvalidChar","char '&' is not expected.",cI(e,o));o=I}else if(s===!0&&!kge(e[o]))return gc("InvalidXml","Extra text at the end",cI(e,o));e[o]==="<"&&o--}}else{if(kge(e[o]))continue;return gc("InvalidChar","char '"+e[o]+"' is not expected.",cI(e,o))}if(n){if(i.length==1)return gc("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",cI(e,i[0].tagStartPos));if(i.length>0)return gc("InvalidXml","Invalid '"+JSON.stringify(i.map(o=>o.tagName),null,4).replace(/ \r ? \n /g,"")+"' found.",{line:1,col:1})}else return gc("InvalidXml","Start tag expected.",1);return!0}function kge(e){return e===" "||e===" "||e=== `
` ||e===" \r "}function zge(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 gc("InvalidXml","XML declaration allowed only at the start of the document.",cI(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function Wge(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 tke='"',ike="'";function nke(e,t){let i="",n="",s=!1;for(;t<e.length;t++){if(e[t]===tke||e[t]===ike)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 ske=new RegExp( ` ( \ \ s * ) ( [ ^ \ \ s = ] + ) ( \ \ s *= ) ? ( \ \ s * ( [ '"])(([\\s\\S])*?)\\5)?`,"g");function Yge(e,t){let i=Jwe(e,ske),n={};for(let s=0;s<i.length;s++){if(i[s][1].length===0)return gc("InvalidAttr","Attribute ' "+i[s][2]+" ' has no space in starting.",wz(i[s]));if(i[s][3]!==void 0&&i[s][4]===void 0)return gc("InvalidAttr","Attribute ' "+i[s][2]+" ' is without value.",wz(i[s]));if(i[s][3]===void 0&&!t.allowBooleanAttributes)return gc("InvalidAttr","boolean attribute ' "+i[s][2]+" ' is not allowed.",wz(i[s]));let o=i[s][2];if(!lke(o))return gc("InvalidAttr","Attribute ' "+o+" ' is an invalid name.",wz(i[s]));if(!n.hasOwnProperty(o))n[o]=1;else return gc("InvalidAttr","Attribute ' "+o+" ' is repeated . ",wz(i[s]))}return!0}function oke(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 rke(e,t){if(t++,e[t]===" ; ")return-1;if(e[t]===" # ")return t++,oke(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 gc(e,t,i){return{err:{code:e,msg:t,line:i.line||i,col:i.col}}}function lke(e){return dJ(e)}function ake(e){return dJ(e)}function cI(e,t){let i=e.substring(0,t).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function wz(e){return e.startIndex+e[1].length}var uke={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},captureMetaData:!1};function Xwe(e){return typeof e==" boolean "?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof e==" object "&&e!==null?{enabled:e.enabled!==!1,maxEntitySize:e.maxEntitySize??1e4,maxExpansionDepth:e.maxExpansionDepth??10,maxTotalExpansions:e.maxTotalExpansions??1e3,maxExpandedLength:e.maxExpandedLength??1e5,allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null}:Xwe(!0)}var cke=function(e){let t=Object.assign({},uke,e);return t.processEntities=Xwe(t.processEntities),t},DQ;typeof Symbol!=" function "?DQ=" @ @ xmlMetadata ":DQ=Symbol(" XML Node Metadata ");var nA=class{constructor(t){this.tagname=t,this.child=[],this[" : @ "]={}}add(t,i){t===" _ _proto _ _ "&&(t=" # _ _proto _ _ "),this.child.push({[t]:i})}addChild(t,i){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 } ) , i !== void 0 && ( this . child [ this . child . length - 1 ] [ DQ ] = { startIndex : i } ) } static getMetaDataSymbol ( ) { return DQ } } , bde = cla
` );let t=new nA("!xml"),i=t,n="",s="";this.entityExpansionCount=0,this.currentExpandedLength=0;let o=new bde(this.options.processEntities);for(let r=0;r<e.length;r++)if(e[r]==="<")if(e[r+1]==="/"){let d=Yx(e,">",r,"Closing Tag is not closed."),h=e.substring(r+2,d).trim();if(this.options.removeNSPrefix){let m=h.indexOf(":");m!==-1&&(h=h.substr(m+1))}this.options.transformTagName&&(h=this.options.transformTagName(h)),i&&(n=this.saveTextToParentTag(n,i,s));let p=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;p&&this.options.unpairedTags.indexOf(p)!==-1?(I=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):I=s.lastIndexOf("."),s=s.substring(0,I),i=this.tagsNodeStack.pop(),n="",r=d}else if(e[r+1]==="?"){let d=_de(e,r,!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 nA(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,r)}r=d.closeIndex+1}else if(e.substr(r+1,3)==="!--"){let d=Yx(e,"-->",r+4,"Comment is not closed.");if(this.options.commentPropName){let h=e.substring(r+4,d-2);n=this.saveTextToParentTag(n,i,s),i.add(this.options.commentPropName,[{[this.options.textNodeName]:h}])}r=d}else if(e.substr(r+1,2)==="!D"){let d=o.readDocType(e,r);this.docTypeEntities=d.entities,r=d.i}else if(e.substr(r+1,2)==="!["){let d=Yx(e,"]]>",r,"CDATA is not closed.")-2,h=e.substring(r+9,d);n=this.saveTextToParentTag(n,i,s);let p=this.parseTextData(h,i.tagname,s,!0,!1,!0,!0);p==null&&(p=""),this.options.cdataPropName?i.add(this.options.cdataPropName,[{[this.options.textNodeName]:h}]):i.add(this.options.textNodeName,p),r=d+2}else{let d=_de(e,r,this.options.removeNSPrefix),h=d.tagName,p=d.rawTagName,I=d.tagExp,m=d.attrExpPresent,y=d.closeIndex;if(this.options.transformTagName){let b=this.options.transformTagName(h);I===h&&(I=b),h=b}i&&n&&i.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,i,s,!1));let T=i;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);let R=r;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,s,h)){let b="";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),r=d.closeIndex;else if(this.options.unpairedTags.indexOf(h)!==-1)r=d.closeIndex;else{let O=this.readStopNodeData(e,p,y+1);if(!O)throw new Error(`Unexpected end of ${p}`);r=O.i,b=O.tagContent}let A=new nA(h);h!==I&&m&&(A[" : @ "]=this.buildAttributesMap(I,s,h)),b&&(b=this.parseTextData(b,h,s,!0,m,!0,!0)),s=s.substr(0,s.lastIndexOf(" . ")),A.add(this.options.textNodeName,b),this.addChild(i,A,s,R)}else{if(I.length>0&&I.lastIndexOf(" / ")===I.length-1){if(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){let A=this.options.transformTagName(h);I===h&&(I=A),h=A}let b=new nA(h);h!==I&&m&&(b[" : @ "]=this.buildAttributesMap(I,s,h)),this.addChild(i,b,s,R),s=s.substr(0,s.lastIndexOf(" . "))}else{let b=new nA(h);this.tagsNodeStack.push(i),h!==I&&m&&(b[" : @ "]=this.buildAttributesMap(I,s,h)),this.addChild(i,b,s,R),i=b}n=" ",r=y}}else n+=e[r];return t.child};function Ake(e,t,i,n){this.options.captureMetaData||(n=void 0);let s=this.options.updateTag(t.tagname,i,t[" : @ "]);s===!1||(typeof s==" string "&&(t.tagname=s),e.addChild(t,n))}var bke=function(e,t,i){if(e.indexOf(" & " ) === - 1 ) return e ; let n = this . options . processEntities ; if ( ! n . enabled || n . allowedTags && ! n . allowedTags . includes ( t ) || n . tagFilter && ! n . tagFilter ( t , i ) ) return e ; for ( let s in this . docTypeEntities ) { let o = this . docTypeEntities [ s ] , r = e . match ( o . regx ) ; if ( r ) { if ( this . entityExpansionCount += r . length , n . maxTotalExpansions && this . entityExpansionCount > n . maxTotalExpansions ) throw new Error ( ` Entity expansion limit ex
` ;function Bke(e,t){let i="";return t.format&&t.indentBy.length>0&&(i=Mke),i2e(e,t,"",i)}function i2e(e,t,i,n){let s="",o=!1;for(let r=0;r<e.length;r++){let l=e[r],d=Fke(l);if(d===void 0)continue;let h="";if(i.length===0?h=d:h= ` $ { i } . $ { d } ` ,d===t.textNodeName){let T=l[d];Uke(h,t)||(T=t.tagValueProcessor(d,T),T=n2e(T,t)),o&&(s+=n),s+=T,o=!1;continue}else if(d===t.cdataPropName){o&&(s+=n),s+= ` < ! [ CDATA [ $ { l [ d ] [ 0 ] [ t . textNodeName ] } ] ] > ` ,o=!1;continue}else if(d===t.commentPropName){s+=n+ ` <!-- $ { l [ d ] [ 0 ] [ t . textNodeName ] } -- > ` ,o=!0;continue}else if(d[0]==="?"){let T=qge(l[":@"],t),R=d==="?xml"?"":n,b=l[d][0][t.textNodeName];b=b.length!==0?" "+b:"",s+=R+ ` < $ { d } $ { b } $ { T } ? > ` ,o=!0;continue}let p=n;p!==""&&(p+=t.indentBy);let I=qge(l[":@"],t),m=n+ ` < $ { d } $ { I } ` ,y=i2e(l[d],t,h,p);t.unpairedTags.indexOf(d)!==-1?t.suppressUnpairedNode?s+=m+">":s+=m+"/>":(!y||y.length===0)&&t.suppressEmptyNode?s+=m+"/>":y&&y.endsWith(">")?s+=m+ ` > $ { y } $ { n } < /${d}>`:(s+=m+">",y&&n!==""&&(y.includes("/ > ")||y.includes(" < /"))?s+=n+t.indentBy+y+n:s+=y,s+=`</ $ { d } > ` ),o=!0}return s}function Fke(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 qge(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=n2e(s,t),s===!0&&t.suppressBooleanAttributes?i+= ` $ { n . substr ( t . attributeNamePrefix . length ) } ` :i+= ` $ { n . substr ( t . attributeNamePrefix . length ) } = "${s}" ` }return i}function Uke(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 n2e(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 Hke={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 C_(e){this.options=Object.assign({},Hke,e),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=e2e(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=kke),this.processTextOrObjNode=Gke,this.options.format?(this.indentate=Vke,this.tagEndChar= ` >
2026-04-25 18:24:50 +01:00
` ,this.newLine= `
2026-04-25 18:59:02 +01:00
` ):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}C_.prototype.build=function(e){return this.options.preserveOrder?Bke(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)};C_.prototype.j2x=function(e,t,i){let n="",s="",o=i.join(".");for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r))if(typeof e[r]>"u")this.isAttribute(r)&&(s+="");else if(e[r]===null)this.isAttribute(r)||r===this.options.cdataPropName?s+="":r[0]==="?"?s+=this.indentate(t)+"<"+r+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+r+"/"+this.tagEndChar;else if(e[r]instanceof Date)s+=this.buildTextValNode(e[r],r,"",t);else if(typeof e[r]!="object"){let l=this.isAttribute(r);if(l&&!this.ignoreAttributesFn(l,o))n+=this.buildAttrPairStr(l,""+e[r]);else if(!l)if(r===this.options.textNodeName){let d=this.options.tagValueProcessor(r,""+e[r]);s+=this.replaceEntitiesValue(d)}else s+=this.buildTextValNode(e[r],r,"",t)}else if(Array.isArray(e[r])){let l=e[r].length,d="",h="";for(let p=0;p<l;p++){let I=e[r][p];if(!(typeof I>"u"))if(I===null)r[0]==="?"?s+=this.indentate(t)+"<"+r+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+r+"/"+this.tagEndChar;else if(typeof I=="object")if(this.options.oneListGroup){let m=this.j2x(I,t+1,i.concat(r));d+=m.val,this.options.attributesGroupName&&I.hasOwnProperty(this.options.attributesGroupName)&&(h+=m.attrStr)}else d+=this.processTextOrObjNode(I,r,t,i);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(r,I);m=this.replaceEntitiesValue(m),d+=m}else d+=this.buildTextValNode(I,r,"",t)}this.options.oneListGroup&&(d=this.buildObjectNode(d,r,h,t)),s+=d}else if(this.options.attributesGroupName&&r===this.options.attributesGroupName){let l=Object.keys(e[r]),d=l.length;for(let h=0;h<d;h++)n+=this.buildAttrPairStr(l[h],""+e[r][l[h]])}else s+=this.processTextOrObjNode(e[r],r,t,i);return{attrStr:n,val:s}};C_.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 Gke(e,t,i,n){let s=this.j2x(e,i+1,n.concat(t));return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,s.attrStr,i):this.buildObjectNode(s.val,t,s.attrStr,i)}C_.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,o="";return t[0]==="?"&&(o="?",s=""),(i||i==="")&&e.indexOf("<")===-1?this.indentate(n)+"<"+t+i+o+">"+e+s:this.options.commentPropName!==!1&&t===this.options.commentPropName&&o.length===0?this.indentate(n)+ ` <!-- $ { e } -- > ` +this.newLine:this.indentate(n)+"<"+t+i+o+this.tagEndChar+e+this.indentate(n)+s}};C_.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t= ` > < /${e}`,t};C_.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}};C_.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 Vke(e){return this.options.indentBy.repeat(e)}function kke(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}var jx=class{};Le(jx," parser " , n
void main ( ) {
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
}
` ,fragmentShader: `
layout ( location = 0 ) out vec4 out _id ;
uniform vec4 objectId ;
void main ( ) {
out _id = objectId ;
}
` }),this._objectId=0,this.setValues(t)}}, $ de=1e-16,qze=new ye(0,1,0),Twe=new ye;function gwe(e){return e.delta(Twe).normalize(),Math.abs(Twe.dot(qze))>=1- $ de}function Zde(e,t){let{start:i,end:n}=t,s=e.points,o=!1,r=!1;for(let l=0;l<3;l++){let d=s[l];if(!o&&i.distanceToSquared(d)<= $ de&&(o=!0),!r&&n.distanceToSquared(d)<= $ de&&(r=!0),o&&r)return!0}return o&&r}var R_=new ds;function wwe(e,t,i=!1,n=[]){let s=[[0,1]];for(let o=0,r=t.length;o<r;o++){let l=s[o],d=t[o];l[1]=d[0],s.push([d[1],1])}i&&([t,s]=[s,t]);for(let o=0,r=s.length;o<r;o++){let{start:l,end:d}=e;R_.start.lerpVectors(l,d,s[o][0]),R_.end.lerpVectors(l,d,s[o][1]),n.push(new Float32Array([R_.start.x,R_.start.y,R_.start.z,R_.end.x,R_.end.y,R_.end.z]))}return n}var vwe=1e-10, $ ze=new ye(0,1,0),Rwe=new ye,Swe=new ye,cQ=new ye,dQ=new fr;function*Awe(e,t=[],i={}){let{projectionDirection:n= $ ze,thresholdAngle:s=1,iterationTime:o=30}=i,l=Math.pow(10,4),d=Math.cos(cr.DEG2RAD*s),h=e.getIndex(),p=e.getAttribute("position"),I=h?h.count:p.count,m=[0,0,0],y=["a","b","c"],T=new Array(3),R={},b=performance.now();for(let A=0;A<I;A+=3){performance.now()-b>o&&(yield,b=performance.now()),h?(m[0]=h.getX(A),m[1]=h.getX(A+1),m[2]=h.getX(A+2)):(m[0]=A,m[1]=A+1,m[2]=A+2);let{a:O,b:P,c:U}=dQ;if(O.fromBufferAttribute(p,m[0]),P.fromBufferAttribute(p,m[1]),U.fromBufferAttribute(p,m[2]),dQ.getNormal(cQ),T[0]= ` $ { Math . round ( O . x * l ) } , $ { Math . round ( O . y * l ) } , $ { Math . round ( O . z * l ) } ` ,T[1]= ` $ { Math . round ( P . x * l ) } , $ { Math . round ( P . y * l ) } , $ { Math . round ( P . z * l ) } ` ,T[2]= ` $ { Math . round ( U . x * l ) } , $ { Math . round ( U . y * l ) } , $ { Math . round ( U . z * l ) } ` ,!(T[0]===T[1]||T[1]===T[2]||T[2]===T[0]))for(let Z=0;Z<3;Z++){let ne=(Z+1)%3,K=T[Z],oe=T[ne],se=dQ[y[Z]],he=dQ[y[ne]],Re= ` $ { K } _$ { oe } ` ,ee= ` $ { oe } _$ { K } ` ;if(ee in R&&R[ee]){let Ae=R[ee].normal,Ee=cQ.dot(Ae)<=d,Ce=!1;if(n!==null){let Qe=n.dot(cQ);Qe=Math.abs(Qe)<vwe?0:Qe;let qe=n.dot(Ae);qe=Math.abs(qe)<vwe?0:qe,Ce=Math.sign(Qe)!==Math.sign(qe)}if(Ee||Ce){let Qe=new ds;Qe.start.copy(se),Qe.end.copy(he),t.push(Qe)}R[ee]=null}else Re in R||(R[Re]={index0:m[Z],index1:m[ne],normal:cQ.clone()})}}for(let A in R)if(R[A]){let{index0:O,index1:P}=R[A];Rwe.fromBufferAttribute(p,O),Swe.fromBufferAttribute(p,P);let U=new ds;U.start.copy(Rwe),U.end.copy(Swe),t.push(U)}return t}var hQ=new ds;function bwe(e,t,i,n=[]){return e.bvhcast(t,i,{intersectsTriangles:(s,o)=>{if(Kze(s,o)||(s.needsUpdate&&s.update(),o.needsUpdate&&o.update(),Math.abs(s.plane.normal.dot(o.plane.normal))>1-1e-6))return!1;s.intersectsTriangle(o,hQ,!0)&&!Zde(s,hQ)&&!Zde(o,hQ)&&n.push(hQ.clone())}}),n}function Zze(e,t){return e.distanceTo(t)<1e-10}function Kze(e,t){let i=["a","b","c"],n=0;for(let s=0;s<3;s++)for(let o=0;o<3;o++){let r=e[i[s]],l=t[i[o]];Zze(r,l)&&n++}return n>=2}function Kde(e){f2e(e);let t=[];return e.traverse(i=>{i.geometry&&i.visible&&t.push(i)}),t}var f2e=e=>{if(e===void 0)return;let t=[...e.children];for(let i of t)i===void 0?e.children.splice(e.children.indexOf(i),1):f2e(i)},fQ=new Ai,Nwe=new Ai,Qde=class{constructor(){this.projectionDirection=new ye(0,1,0),this.thresholdAngle=50,this.iterationTime=30}getEdges(...t){let i=this.iterationTime;this.iterationTime=1/0;let n=this.getEdgesGenerator(...t).next().value;return this.iterationTime=i,n}*getEdgesGenerator(t,i=[],n=null){let{projectionDirection:s,thresholdAngle:o,iterationTime:r}=this;if(t.isObject3D){let l=Kde(t),d=null;s&&(d=new ye);let h=performance.now();for(let p=0;p<l.length;p++){h-performance.now()>r&&(yield);let I=l[p];d&&(Nwe.copy(I.matrixWorld).invert(),d.copy(s).transformDirection(Nwe).normalize());let m=yield*Awe(I.geometry,[],{projectionDirection:d,thresholdAngle:o,iterationTime:r});_we(m,I.matrixWorld);for(let y=0;y<m.length;y++)i.push(m[y]);if(n!==null)for(let y=0;y<m.length;y++)n.push(I)}return i}else return yield*Awe(t,i,{projectionDirection:s,thresholdAngle:o,iterationTime:r})}getIntersectionEdges(...t){let i=this.iterationTime;this.iterationTime=1/0;let n=this.getIntersectionEdgesGenerator(...t).next().value;return this.iterationTime=i,n}*getIntersectionEdgesGenerator(t,i=[],n=null){let{iterationTime:s}=this;if(t.isObject3D){let o=Kde(t),r=new Map
=== Projection Summary === ` ),console.log( ` Total time : $ { e . toFixed ( 1 ) } ms
` );for(let[t,i]of Object.entries(mQ)){let n=(i/e*100).toFixed(1);console.log( ` $ { t } : $ { i . toFixed ( 1 ) } ms ( $ { n } % ) ` )}if(Object.keys(Cz).length>0){console.log( `
-- - Stats -- - ` );for(let[t,i]of Object.entries(Cz))console.log( ` $ { t } : $ { i } ` )}console.log("")}},z3=1e-5,yQ=1e-16,EQ=1e-16;function lWe(e){let t=new Float32Array(e.length*6);for(let i=0;i<e.length;i++){let n=e[i];t[i*6+0]=n.start.x,t[i*6+1]=n.start.y,t[i*6+2]=n.start.z,t[i*6+3]=n.end.x,t[i*6+4]=n.end.y,t[i*6+5]=n.end.z}return t}function aWe(e,t,i,n,s){e.bvhcast(t,i.matrixWorld,{intersectsRanges:(o,r,l,d)=>{n._edgeOffsets.push(o),n._edgeCounts.push(r),n._meshOffsets.push(l),n._meshCounts.push(d),n._meshIndex.push(s),n.groupCount++}})}var uWe=1e3,cWe=1e5,wde=5,vde=3,dWe=2e6,xz=null;async function hWe(){return xz===null&&(xz=new cK,await xz.init()),xz}async function fWe(e,t,i,n,s=null){let o=await hWe();e._edgeOffsets&&(e.edgeOffsets=new Uint32Array(e._edgeOffsets),e.edgeCounts=new Uint32Array(e._edgeCounts),e.meshOffsets=new Uint32Array(e._meshOffsets),e.meshCounts=new Uint32Array(e._meshCounts),e.meshIndex=new Uint32Array(e._meshIndex),e._edgeOffsets=null,e._edgeCounts=null,e._meshOffsets=null,e._meshCounts=null,e._meshIndex=null);let r=y_(lWe(i.lines),"float");wo.enabled&&console.log("Number of meshes:",t.length),wo.enabled&&console.log("Group count:",e.groupCount);let l=[];{let T=0;for(;T<t.length;){let R=T,b=0;for(;R<t.length;){let A=t[R].geometry,O=A.index?A.index.count/3:A.attributes.position.count/3;if(R>T&&(R-T>=uWe||b+O>cWe))break;b+=O,R++}l.push({start:T,end:R}),T=R}}wo.enabled&&console.log( ` Split $ { t . length } meshes into $ { l . length } batches ` );let d=0,h=0,p=0,I=0,m=0;for(let T=0;T<l.length;T++){let{start:R,end:b}=l[T],A=b-R;wo.enabled&&console.log( ` Processing batch $ { T + 1 } / $ { l . length } ( meshes $ { R } - $ { b - 1 } ) ` );let O=0,P=0,U=[];for(let Kt=R;Kt<b;Kt++){let ui=t[Kt].geometry;U.push(P/3),O+=ui.attributes.position.array.length,P+=ui.index.array.length}let Z=new Float32Array(O),ne=new Uint32Array(P),K=0,oe=0,se=0;for(let Kt=R;Kt<b;Kt++){let ui=t[Kt].geometry,jt=ui.attributes.position.array,Oe=ui.index.array;Z.set(jt,K),K+=jt.length;for(let Ft=0;Ft<Oe.length;Ft++)ne[oe+Ft]=Oe[Ft]+se;oe+=Oe.length,se+=ui.attributes.position.count}let he=new Float32Array(A*16);for(let Kt=R;Kt<b;Kt++){let ui=Kt-R;he.set(t[Kt].matrixWorld.elements,ui*16)}let Re=[];for(let Kt=0;Kt<e.groupCount;Kt++){let ui=e.meshIndex[Kt];if(ui>=R&&ui<b){let jt=ui-R,Oe=U[jt]+e.meshOffsets[Kt];Re.push({edgeOffset:e.edgeOffsets[Kt],edgeCount:e.edgeCounts[Kt],triOffset:Oe,triCount:e.meshCounts[Kt],meshIdx:jt})}}if(Re.length===0){wo.enabled&&console.log( ` Batch $ { T + 1 } : no groups , skipping ` );continue}let ee=new Uint32Array(Re.length*wde);for(let Kt=0;Kt<Re.length;Kt++){let ui=Re[Kt],jt=Kt*wde;ee[jt+0]=ui.edgeOffset,ee[jt+1]=ui.edgeCount,ee[jt+2]=ui.triOffset,ee[jt+3]=ui.triCount,ee[jt+4]=ui.meshIdx}let Ae=0;for(let Kt=0;Kt<Re.length;Kt++)Ae+=Re[Kt].edgeCount*Re[Kt].triCount;s&&(s.candidates+=Ae);let Ee=Math.min(Math.ceil(Ae*.1),dWe),Ce=Math.max(Ee,1e4);wo.enabled&&console.log( ` Batch $ { T + 1 } : $ { Re . length } groups , $ { O / 3 } vertices , $ { P / 3 } triangles , $ { Ae } pairs , buffer for $ { Ce } overlaps ` );let Qe=performance.now(),qe=y_(Z,"float"),St=y_(ne,"uint"), $ e=y_(he,"float"),ke=y_(ee,"uint"),It=y_(new Uint32Array([0]),"uint").toAtomic(),ft=y_(new Float32Array(Ce*vde),"float");I+=performance.now()-Qe;let Dt=performance.now(),Zt=vge(()=>{let ui=Sge.mul(wde),jt=ke.element(ui),Oe=ke.element(ui.add(1)),Ft=ke.element(ui.add(2)),ge=ke.element(ui.add(3)),Pe=ke.element(ui.add(4)).mul(16),Me=Age( $ e.element(Pe), $ e.element(Pe.add(1)), $ e.element(Pe.add(2)), $ e.element(Pe.add(3)), $ e.element(Pe.add(4)), $ e.element(Pe.add(5)), $ e.element(Pe.add(6)), $ e.element(Pe.add(7)), $ e.element(Pe.add(8)), $ e.element(Pe.add(9)), $ e.element(Pe.add(10)), $ e.element(Pe.add(11)), $ e.element(Pe.add(12)), $ e.element(Pe.add(13)), $ e.element(Pe.add(14)), $ e.element(Pe.add(15)));zce({start:Wce(0),end:ge.toInt(),type:"int",condition:"<",name:"triIdx"},({triIdx:ze})=>{let He=Ft.add(ze.toUint()).mul(3),At=St.element(He),Tt=St.element(He.add(1)),Lt=St.element(He.add(2)),Ht=w0(qe.element(At.mul(3)),qe.element(At.mul(3).add(1)),qe.element(At.mul(3).add(2))),ri=w0(qe.element(Tt.mul(3)),qe.element(Tt.mul(3).add(1)),qe.element(Tt.mul(3
2026-04-25 18:24:50 +01:00
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 ;
}
2026-04-25 18:59:02 +01:00
` ,extensions:{derivatives:!0}});this.three=new _i(l,d),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(Vz).list.delete(this.config.uuid),this.components.get(CM).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 bM))return;let i=this.world.camera.controls;t?i.addEventListener("update",this.updateZoom):i.removeEventListener("update",this.updateZoom)}},P2e=class M2e extends Gl{constructor(t){super(t),Le(this,"list",new Map),Le(this,"onDisposed",new $ i),Le(this,"enabled",!0),t.add(M2e.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");let i=new VQ(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()}};Le(P2e,"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");var yWe=P2e,B2e=class F2e{constructor(){Le(this,"onDisposed",new $ i),Le(this,"list",new fo),Le(this,"enabled",!1),Le(this,"_clock"),Le(this,"onInit",new $ i),Le(this,"update",()=>{if(!this.enabled)return;let t=this._clock.getDelta();for(let[i,n]of this.list)n.enabled&&n.isUpdateable()&&n.update(t);requestAnimationFrame(this.update)}),this._clock=new NP,F2e.setupBVH()}add(t,i){if(this.list.has(t))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");dI.validate(t),this.list.set(t,i)}get(t){var i;let n=t.uuid;if(!this.list.has(n)){let s=new t(this);return(i=s.isDisposeable)!=null&&i.call(s)&&s.onDisposed.add(()=>this.list.delete(n)),this.list.has(n)||this.add(n,s),s}return this.list.get(n)}init(){this.enabled=!0;for(let[t,i]of this.list.entries())i.enabled=!0;this._clock.start(),this.update(),this.onInit.trigger()}dispose(){this.enabled=!1;let t;for(let[i,n]of this.list){if(n.enabled=!1,i===_s.uuid){t=n;continue}n.isDisposeable()&&n.dispose()}t?.dispose(),this._clock.stop(),this.onDisposed.trigger()}static setupBVH(){nn.prototype.computeBoundsTree=kze,nn.prototype.disposeBoundsTree=zze,_i.prototype.raycast=Ewe,xs.prototype.raycast=Ewe}};Le(B2e,"release","2.4.3");var b0e=B2e,kQ=class{constructor(t){Le(this,"enabled",!1),Le(this,"id","FirstPerson"),this.camera=t}set(t){if(this.enabled=t,t){if(this.camera.projection.current!=="Perspective"){this.camera.set("Orbit");return}this.setupFirstPersonCamera()}}setupFirstPersonCamera(){let t=this.camera.controls,i=new ye;t.distance--,t.getPosition(i),t.minDistance=1,t.maxDistance=1,t.distance=1,t.moveTo(i.x,i.y,i.z),t.truckSpeed=50,t.mouseButtons.wheel= $ f.ACTION.DOLLY,t.touches.two= $ f.ACTION.TOUCH_ZOOM_TRUCK}},zQ=class{constructor(t){Le(this,"enabled",!0),Le(this,"id","Orbit"),this.camera=t,this.activateOrbitControls()}set(t){this.enabled=t,t&&this.activateOrbitControls()}activateOrbitControls(){let t=this.camera.controls;t.minDistance=1,t.maxDistance=300;let i=new ye;t.getPosition(i);let n=i.length();t.distance=n,t.truckSpeed=2;let{rotation:s}=this.camera.three,o=new ye(0,0,-1).applyEuler(s),r=i.addScaledVector(o,n);t.moveTo(r.x,r.y,r.z)}},WQ=class{constructor(t){Le(this,"enabled",!1),Le(this,"id","Plan"),Le(this,"mouseAction1"),Le(this,"mouseAction2"),Le(this,"mouseInitialized",!1),Le(this,"defaultAzimuthSpeed"),Le(this,"defaultPolarSpeed")
\ 0 ` ,Zt+=o(It,2),Zt+=ne.magic,Zt+=o(P,2),Zt+=o(U,2),Zt+=o(ke.crc32,4),Zt+=o(ke.compressedSize,4),Zt+=o(ke.uncompressedSize,4),Zt+=o(oe.length,2),Zt+=o(Ce.length,2),{fileRecord:I.LOCAL_FILE_HEADER+Zt+oe+Ce,dirRecord:I.CENTRAL_FILE_HEADER+o(Dt,2)+Zt+o(Re.length,2)+" \0 \0 \0 \0 "+o(ft,4)+o(b,4)+oe+Ce+Re}}var l=i("../utils"),d=i("../stream/GenericWorker"),h=i("../utf8"),p=i("../crc32"),I=i("../signature");function m(y,T,R,b){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=T,this.zipPlatform=R,this.encodeFileName=b,this.streamFiles=y,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,d),m.prototype.push=function(y){var T=y.meta.percent||0,R=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(y):(this.bytesWritten+=y.data.length,d.prototype.push.call(this,{data:y.data,meta:{currentFile:this.currentFile,percent:R?(T+100*(R-b-1))/R:100}}))},m.prototype.openedSource=function(y){this.currentSourceOffset=this.bytesWritten,this.currentFile=y.file.name;var T=this.streamFiles&&!y.file.dir;if(T){var R=r(y,T,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:R.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(y){this.accumulate=!1;var T=this.streamFiles&&!y.file.dir,R=r(y,T,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(R.dirRecord),T)this.push({data:(function(b){return I.DATA_DESCRIPTOR+o(b.crc32,4)+o(b.compressedSize,4)+o(b.uncompressedSize,4)})(y),meta:{percent:100}});else for(this.push({data:R.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var y=this.bytesWritten,T=0;T<this.dirRecords.length;T++)this.push({data:this.dirRecords[T],meta:{percent:100}});var R=this.bytesWritten-y,b=(function(A,O,P,U,Z){var ne=l.transformTo("string",Z(U));return I.CENTRAL_DIRECTORY_END+" \0 \0 \0 \0 "+o(A,2)+o(A,2)+o(O,4)+o(P,4)+o(ne.length,2)+ne})(this.dirRecords.length,R,y,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(y){this._sources.push(y);var T=this;return y.on("data",function(R){T.processChunk(R)}),y.on("end",function(){T.closedSource(T.previous.streamInfo),T._sources.length?T.prepareNextSource():T.end()}),y.on("error",function(R){T.error(R)}),this},m.prototype.resume=function(){return!!d.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(y){var T=this._sources;if(!d.prototype.error.call(this,y))return!1;for(var R=0;R<T.length;R++)try{T[R].error(y)}catch{}return!0},m.prototype.lock=function(){d.prototype.lock.call(this);for(var y=this._sources,T=0;T<y.length;T++)y[T].lock()},n.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(i,n,s){var o=i("../compressions"),r=i("./ZipFileWorker");s.generateWorker=function(l,d,h){var p=new r(d.streamFiles,h,d.platform,d.encodeFileName),I=0;try{l.forEach(function(m,y){I++;var T=(function(O,P){var U=O||P,Z=o[U];if(!Z)throw new Error(U+" is not a valid compression method !");return Z})(y.options.compression,d.compression),R=y.options.compressionOptions||d.compressionOptions||{},b=y.dir,A=y.date;y._compressWorker(T,R).withStreamInfo("file",{name:m,dir:b,date:A,comment:y.comment||"",unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions}).pipe(p)}),p.entriesCount=I}catch(m){p.error(m)}return p}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(i,n,s){function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in
$ { jx . builder . build ( o ) } ` }};Le(H2e,"default",{title:"BCF Topic",type:"Issue",status:"Active"});var l0e=H2e,G2e=(e,t)=>{if(t.trim()==="")return;let i=v0.xmlParser.parse(t).Extensions;if(!i)return;let{Priorities:n,TopicStatuses:s,TopicTypes:o,Users:r}=i;if(n&&n.Priority){let l=Array.isArray(n.Priority)?n.Priority:[n.Priority];for(let d of l)e.config.priorities.add(d)}if(s&&s.TopicStatus){let l=Array.isArray(s.TopicStatus)?s.TopicStatus:[s.TopicStatus];for(let d of l)e.config.statuses.add(d)}if(o&&o.TopicType){let l=Array.isArray(o.TopicType)?o.TopicType:[o.TopicType];for(let d of l)e.config.types.add(d)}if(r&&r.User){let l=Array.isArray(r.User)?r.User:[r.User];for(let d of l)e.config.users.add(d)}},jQ=class extends __{constructor(){super(...arguments),Le(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}},N0e=class Oz extends Gl{constructor(){super(...arguments),Le(this,"enabled",!1),Le(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}),Le(this,"config",new jQ(this,this.components,"BCF Topics",Oz.uuid)),Le(this,"list",new fo),Le(this,"documents",new fo),Le(this,"onSetup",new $ i),Le(this,"isSetup",!1),Le(this,"onBCFImported",new $ i),Le(t
2026-04-25 18:24:50 +01:00
< 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" >
2026-04-25 18:59:02 +01:00
< /Version>`);for(let[o,r]of this.documents.entries())r.type!=="external"&&i.file(this.config.version==="2.1"?r.fileName:`documents/ $ { o } ` ,r.data);if(this.config.version==="3"){let o=[];for(let[r,l]of this.documents.entries()){let{type:d,description:h}=l;d!=="external"&&o.push( ` < Document Guid = "${r}" >
< Filename > $ { l . fileName } < / F i l e n a m e >
$ { h ? ` <Description> ${ h } </Description> ` : "" }
< / D o c u m e n t > ` ) } o . l e n g t h > 0 & & i . f i l e ( " d o c u m e n t s . x m l " , ` < ? x m l v e r s i o n = " 1 . 0 " e n c o d i n g = " U T F - 8 " s t a n d a l o n e = " y e s " ? >
2026-04-25 18:24:50 +01:00
< DocumentInfo xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation = "documents.xsd" >
< Documents >
2026-04-25 18:59:02 +01:00
$ { o . join ( `
2026-04-25 18:24:50 +01:00
` )}
< / D o c u m e n t s >
2026-04-25 18:59:02 +01:00
< / D o c u m e n t I n f o > ` ) } i . f i l e ( " b c f . e x t e n s i o n s " , t h i s . s e r i a l i z e E x t e n s i o n s ( ) ) ; l e t n = t h i s . c o m p o n e n t s . g e t ( e 4 ) ; f o r ( l e t o o f t ) { l e t r = i . f o l d e r ( o . g u i d ) ; r . f i l e ( " m a r k u p . b c f " , o . s e r i a l i z e ( ) ) ; f o r ( l e t l o f o . v i e w p o i n t s ) { l e t d = n . l i s t . g e t ( l ) ; i f ( ! d ) c o n t i n u e ; l e t h = d . t i t l e ? ? d . g u i d ; r . f i l e ( ` $ { h } . b c f v ` , a w a i t d . s e r i a l i z e ( ) ) ; l e t p = n . s n a p s h o t s . g e t ( d . s n a p s h o t ) ; i f ( ! p ) c o n t i n u e ; l e t I = p ? d . s n a p s h o t : d . g u i d , m = n . g e t S n a p s h o t E x t e n s i o n ( d . s n a p s h o t ) ; r . f i l e ( ` $ { I } . $ { m } ` , p , { b i n a r y : ! 0 } ) } } r e t u r n a w a i t i . g e n e r a t e A s y n c ( { t y p e : " b l o b " } ) } s e r i a l i z e E x t e n s i o n s ( ) { l e t t = [ . . . t h i s . c o n f i g . t y p e s ] . m a p ( l = > ` < T o p i c T y p e > $ { l } < / T o p i c T y p e > ` ) . j o i n ( `
` ),i=[...this.config.statuses].map(l=> ` < TopicStatus > $ { l } < / T o p i c S t a t u s > ` ) . j o i n ( `
` ),n=[...this.config.priorities].map(l=> ` < Priority > $ { l } < / P r i o r i t y > ` ) . j o i n ( `
` ),s=[...this.config.labels].map(l=> ` < TopicLabel > $ { l } < / T o p i c L a b e l > ` ) . j o i n ( `
` ),o=[...this.config.stages].map(l=> ` < Stage > $ { l } < / S t a g e > ` ) . j o i n ( `
` ),r=[...this.config.users].map(l=> ` < User > $ { l } < / U s e r > ` ) . j o i n ( `
2026-04-25 18:24:50 +01:00
` );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 }
< / T o p i c T y p e s > ` : " " }
$ { i . length !== 0 ? ` <TopicStatuses>
$ { i }
< / T o p i c S t a t u s e s > ` : " " }
$ { n . length !== 0 ? ` <Priorities>
$ { n }
< / P r i o r i t i e s > ` : " " }
$ { s . length !== 0 ? ` <TopicLabels>
$ { s }
< / T o p i c L a b e l s > ` : " " }
2026-04-25 18:59:02 +01:00
$ { o . length !== 0 ? ` <Stages>
$ { o }
2026-04-25 18:24:50 +01:00
< / S t a g e s > ` : " " }
2026-04-25 18:59:02 +01:00
$ { r . length !== 0 ? ` <Users>
$ { r }
2026-04-25 18:24:50 +01:00
< / U s e r s > ` : " " }
< / E x t e n s i o n s >
2026-04-25 18:59:02 +01:00
` }processMarkupComment(t){let{Guid:i,Date:n,Author:s,Comment:o,Viewpoint:r}=t;if(!(i&&n&&s&&(_M||r)))return null;let l=new _M(this.components,o??"");return l.guid=i,l.date=new Date(n),l.author=s,l.viewpoint=r?.Guid,l.modifiedAuthor=t.ModifiedAuthor,l.modifiedDate=t.ModifiedDate?new Date(t.ModifiedDate):void 0,l}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 o=s.map(l=>this.processMarkupComment(l)).filter(l=>l);return Array.isArray(o)?o:[o]}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(r=>r.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:o,ignoreIncompleteTopicsOnImport:r,updateExtensionsOnImport:l}=this.config,d=new Hwe;await d.loadAsync(t);let h=Object.values(d.files),p=o,I=h.find(P=>P.name.endsWith(".version"));if(I){let P=await I.async("string"),U=Oz.xmlParser.parse(P).Version.VersionId;p=String(U)}if(!(p&&(p==="2.1"||p==="3")))throw new Error( ` BCFTopics : $ { p } is not supported . ` );let m=h.find(P=>P.name.endsWith(".extensions"));if(l&&m){let P=await m.async("string");G2e(this,P)}let y=[],T=this.components.get(e4),R=h.filter(P=>P.name.endsWith(".bcfv"));for(let P of R){let U=await P.async("string"),Z=Oz.xmlParser.parse(U).VisualizationInfo;if(!Z){console.warn("Missing VisualizationInfo in Viewpoint");continue}let ne={},{Guid:K,ClippingPlanes:oe,Components:se,OrthogonalCamera:he,PerspectiveCamera:Re}=Z;if(K&&(ne.guid=K),se){let Ae={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};ne.components=Ae;let{Selection:Ee,Visibility:Ce}=se;if(Ee&&Ee.Component){let St=Array.isArray(Ee.Component)?Ee.Component:[Ee.Component];Ae.selection=St.map( $ e=> $ e.IfcGuid?{ifc_guid: $ e.IfcGuid}:null).filter( $ e=> $ e!==null)}if(Ce&&"DefaultVisibility"in Ce&&(Ae.visibility.default_visibility=Ce.DefaultVisibility),Ce&&Ce.Exceptions&&"Component"in Ce.Exceptions){let{Component:St}=Ce.Exceptions, $ e=Array.isArray(St)?St:[St];Ae.visibility.exceptions= $ e.map(ke=>ke.IfcGuid?{ifc_guid:ke.IfcGuid}:null).filter(ke=>ke!==null)}let Qe;p==="2.1"&&(Qe=se.ViewSetupHints),p==="3"&&(Qe=(i=se.Visibility)==null?void 0:i.ViewSetupHints),Qe&&("OpeningsVisible"in Qe&&(Ae.visibility.view_setup_hints.openings_visible=Qe.OpeningsVisible),"SpacesVisible"in Qe&&(Ae.visibility.view_setup_hints.spaces_visible=Qe.SpacesVisible),"SpaceBoundariesVisible"in Qe&&(Ae.visibility.view_setup_hints.space_boundaries_visible=Qe.SpaceBoundariesVisible));let{Coloring:qe}=se;if(qe&&qe.Color){let St=Array.isArray(qe.Color)?qe.Color:[qe.Color];for(let $ e of St){let{Color:ke,Component:It}= $ e;if(!(ke.length===6||ke.length===8))continue;let ft=ke.length===6?ke:ke.slice(2),Zt=(Array.isArray(It)?It:[It]).map(Ct=>Ct.IfcGuid?{ifc_guid:Ct.IfcGuid}:null).filter(Ct=>Ct!==null);Ae.coloring.push({color:ft,components:Zt})}}}if(he||Re){let Ae=Z.PerspectiveCamera??Z.OrthogonalCamera,{CameraViewPoint:Ee,CameraDirection:Ce}=Ae,Qe=new ye(Number(Ee.X),Number(Ee.Z),Number(-Ee.Y)),qe=new ye(Number(Ce.X),Number(Ce.Z),Number(-Ce.Y)),St={camera_view_point:{x:Qe.x,y:Qe.y,z:Qe.z},camera_direction:{x:qe.x,y:qe.y,z:qe.z},aspect_ratio:"AspectRatio"in Ae?Ae.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in Ae&&(ne.orthogonal_camera={...St,view_to_world_scale:Ae.ViewToWorldScale}),"FieldOfView"in Ae&&(ne.perspective_camera={...St,fiel
< Component IfcGuid = "${m}" $ { T ? ? "" } / > ` }}}else o=[...this.selectionComponents].map(r=> ` < Component IfcGuid = "${r}" / > ` ).join( `
` );return o}createColorTags(){let t="";for(let[i,n]of this.componentColors.entries()){let s=n.map(o=> `
< Component IfcGuid = "${o}" / > ` ).join( `
2026-04-25 18:24:50 +01:00
` );t+= ` < Color Color = "${i}" >
$ { s }
< / C o l o r > ` } r e t u r n t . l e n g t h ! = = 0 ? ` < C o l o r i n g >
$ { t }
2026-04-25 18:59:02 +01:00
< /Coloring>`:"<Coloring / > "}toJSON(){let t=this._components.get(Wx),i={guid:this.guid,components:{selection:[...this.selectionComponents].map(o=>({ifc_guid:o,authoring_tool_id:null})),coloring:[...this.componentColors].map(([o,r])=>({color:o,components:r.map(l=>({ifc_guid:l,authoring_tool_id:null}))})),visibility:{default_visibility:this.defaultVisibility,exceptions:[...this.exceptionComponents].map(o=>({ifc_guid:o,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(o=>{let r=t.list.get(o);if(!r)return null;let l=r._controls.worldPosition??r.origin,{normal:d}=r;return{location:{x:l.x,y:-l.z,z:l.y},direction:{x:d.x,y:-d.z,z:d.y}}}).filter(o=>o!==null)};" field _of _view " in this . camera ? i . perspective _camera = this . camera : i . orthogonal _camera = this . camera ; let n = this . _components . get ( e4 ) , s = n . snapshots . get ( this . snapshot ) ; if ( s ) { let o = s . toString ( ) , r = btoa ( o ) , l = n . getSnapshotExtension ( this . snapshot ) ; i . snapshot = { snapshot _type : l , snapshot _data : r } } return i } async serialize ( t = this . _managerVersion ) { let i = this . _components . get ( _s ) , n = this . position ; n . applyMatrix4 ( i . baseCoordinationMatrix . clone ( ) . invert ( ) ) ; let s = this . direction ; s . normalize ( ) ; let o = new Ai ( ) . makeRotationX ( Math . PI / 2 ) , r = s . clone ( ) . applyMatrix4 ( o ) ; r . normalize ( ) ; let l = ` <CameraViewPoint>
2026-04-25 18:24:50 +01:00
< X > $ { n . x } < / X >
< Y > $ { - n . z } < / Y >
< Z > $ { n . y } < / Z >
2026-04-25 18:59:02 +01:00
< / C a m e r a V i e w P o i n t > ` , d = ` < C a m e r a D i r e c t i o n >
2026-04-25 18:24:50 +01:00
< X > $ { s . x } < / X >
< Y > $ { - s . z } < / Y >
< Z > $ { s . y } < / Z >
2026-04-25 18:59:02 +01:00
< / C a m e r a D i r e c t i o n > ` , h = ` < C a m e r a U p V e c t o r >
< X > $ { r . x } < / X >
< Y > $ { - r . z } < / Y >
< Z > $ { r . y } < / Z >
< / C a m e r a U p V e c t o r > ` , p = ` < A s p e c t R a t i o > $ { t h i s . c a m e r a . a s p e c t _ r a t i o } < / A s p e c t R a t i o > ` , I = " " ; " v i e w _ t o _ w o r l d _ s c a l e " i n t h i s . c a m e r a ? I = ` < O r t h o g o n a l C a m e r a >
$ { l }
2026-04-25 18:24:50 +01:00
$ { d }
$ { h }
2026-04-25 18:59:02 +01:00
$ { p }
2026-04-25 18:24:50 +01:00
< ViewToWorldScale > $ { this . camera . view _to _world _scale } < / V i e w T o W o r l d S c a l e >
2026-04-25 18:59:02 +01:00
< / O r t h o g o n a l C a m e r a > ` : " f i e l d _ o f _ v i e w " i n t h i s . c a m e r a & & ( I = ` < P e r s p e c t i v e C a m e r a >
$ { l }
2026-04-25 18:24:50 +01:00
$ { d }
$ { h }
2026-04-25 18:59:02 +01:00
$ { p }
2026-04-25 18:24:50 +01:00
< FieldOfView > $ { this . camera . field _of _view } < / F i e l d O f V i e w >
2026-04-25 18:59:02 +01:00
< /PerspectiveCamera>`);let m=`<ViewSetupHints SpacesVisible="${this.spacesVisible??!1}" SpaceBoundariesVisible="${this.spaceBoundariesVisible??!1}" OpeningsVisible="${this.openingsVisible??!1}" / > ` ,y=(await this.createComponentTags("selection")).trim(),T=(await this.createComponentTags("exception")).trim(),R=this.createColorTags();return ` < ? xml version = "1.0" encoding = "UTF-8" ? >
2026-04-25 18:24:50 +01:00
< VisualizationInfo Guid = "${this.guid}" >
< Components >
2026-04-25 18:59:02 +01:00
$ { t === "2.1" ? m : "" }
$ { y . length !== 0 ? ` <Selection> ${ y } </Selection> ` : "" }
2026-04-25 18:24:50 +01:00
< Visibility DefaultVisibility = "${this.defaultVisibility}" >
2026-04-25 18:59:02 +01:00
$ { t === "3" ? m : "" }
$ { T . length !== 0 ? ` <Exceptions> ${ T } </Exceptions> ` : "" }
2026-04-25 18:24:50 +01:00
< / V i s i b i l i t y >
2026-04-25 18:59:02 +01:00
$ { R }
2026-04-25 18:24:50 +01:00
< / C o m p o n e n t s >
2026-04-25 18:59:02 +01:00
$ { I }
< / V i s u a l i z a t i o n I n f o > ` } } , u 0 e = c l a s s e x t e n d s _ _ { c o n s t r u c t o r ( ) { s u p e r ( . . . a r g u m e n t s ) , L e ( t h i s , " _ c o n f i g " , { o v e r w r i t e C o l o r s : { v a l u e : ! 1 , t y p e : " B o o l e a n " } } ) } g e t o v e r w r i t e C o l o r s ( ) { r e t u r n t h i s . _ c o n f i g . o v e r w r i t e C o l o r s . v a l u e } s e t o v e r w r i t e C o l o r s ( t ) { t h i s . _ c o n f i g . o v e r w r i t e C o l o r s . v a l u e = t } } , k 2 e = c l a s s c 0 e e x t e n d s G l { c o n s t r u c t o r ( t ) { s u p e r ( t ) , L e ( t h i s , " e n a b l e d " , ! 0 ) , L e ( t h i s , " w o r l d " , n u l l ) , L e ( t h i s , " l i s t " , n e w f o ) , L e ( t h i s , " s n a p s h o t s " , n e w f o ) , L e ( t h i s , " i s S e t u p " , ! 1 ) , L e ( t h i s , " o n S e t u p " , n e w $ i ) , L e ( t h i s , " c o n f i g " , n e w u 0 e ( t h i s , t h i s . c o m p o n e n t s , " V i e w p o i n t s " , c 0 e . u u i d ) ) , L e ( t h i s , " o n D i s p o s e d " , n e w $ i ) , t . a d d ( c 0 e . u u i d , t h i s ) } c r e a t e ( t ) { l e t i = n e w U z ( t h i s . c o m p o n e n t s , t ) ; r e t u r n i . w o r l d = t h i s . w o r l d , t | | t h i s . l i s t . s e t ( i . g u i d , i ) , i } g e t S n a p s h o t E x t e n s i o n ( t ) { l e t i = " j p e g " , n = t h i s . s n a p s h o t s . g e t ( t ) ; i f ( ! n ) r e t u r n i ; l e t s = n . s u b a r r a y ( 0 , 4 ) , o = " " ; f o r ( l e t r = 0 ; r < s . l e n g t h ; r + + ) o + = s [ r ] . t o S t r i n g ( 1 6 ) ; r e t u r n o . s t a r t s W i t h ( " 8 9 5 0 4 e 4 7 " ) & & ( i = " p n g " ) , o . s t a r t s W i t h ( " f f d 8 f f e " ) & & ( i = " j p e g " ) , i } s e t u p ( ) { } d i s p o s e ( ) { t h i s . l i s t . d i s p o s e ( ) , t h i s . o n D i s p o s e d . t r i g g e r ( ) , t h i s . o n D i s p o s e d . r e s e t ( ) } } ; L e ( k 2 e , " u u i d " , " e e 8 6 7 8 2 4 - a 7 9 6 - 4 0 8 d - 8 a a 0 - 4 e 5 9 6 2 a 8 3 c 6 6 " ) ; v a r e 4 = k 2 e , H z = c l a s s { c o n s t r u c t o r ( t , i ) { L e ( t h i s , " _ c o m p o n e n t s " ) , L e ( t h i s , " _ c a m e r a O f f s e t " , 1 0 ) , L e ( t h i s , " _ p l a n e H e l p e r " ) , L e ( t h i s , " _ f a r P l a n e H e l p e r " ) , L e ( t h i s , " _ c a m e r a H e l p e r " ) , L e ( t h i s , " o n S t a t e C h a n g e d " , n e w $ i ) , L e ( t h i s , " o n U p d a t e d " , n e w $ i ) , L e ( t h i s , " o n D i s p o s e d " , n e w $ i ) , L e ( t h i s , " c a m e r a " ) , L e ( t h i s , " p l a n e " , n e w e s ) , L e ( t h i s , " f a r P l a n e " , n e w e s ) , L e ( t h i s , " i d " , d I . c r e a t e ( ) ) , L e ( t h i s , " _ o p e n " , ! 1 ) , L e ( t h i s , " _ r a n g e " , W 2 e . d e f a u l t R a n g e ) , L e ( t h i s , " _ w o r l d " , n u l l ) , L e ( t h i s , " _ h e l p e r s V i s i b l e " , ! 1 ) , L e ( t h i s , " _ p l a n e s E n a b l e d " , ! 1 ) , t h i s . _ c o m p o n e n t s = t , t h i s . c a m e r a = n e w N M ( t h i s . _ c o m p o n e n t s ) ; l e t { t h r e e O r t h o : n } = t h i s . c a m e r a ; i f ( i ? . i d & & ( t h i s . i d = i . i d ) , i ? . n o r m a l & & i ? . p o i n t ) { l e t { n o r m a l : s , p o i n t : o } = i ; t h i s . p l a n e . s e t F r o m N o r m a l A n d C o p l a n a r P o i n t ( s , o ) } t h i s . _ c a m e r a H e l p e r = n e w D P ( n ) , t h i s . _ p l a n e H e l p e r = n e w _ C ( t h i s . p l a n e , 5 0 ) , t h i s . _ f a r P l a n e H e l p e r = n e w _ C ( t h i s . f a r P l a n e , 5 0 ) , t h i s . f a r P l a n e H e l p e r C o l o r = n e w O i ( " b l u e " ) , t h i s . u p d a t e ( ) } g e t _ p l a n e N o r m a l O p p o s i t e ( ) { r e t u r n t h i s . p l a n e . n o r m a l . c l o n e ( ) . n e g a t e ( ) } g e t _ p l a n e P o s i t i o n ( ) { r e t u r n t h i s . p l a n e . n o r m a l . c l o n e ( ) . m u l t i p l y S c a l a r ( - t h i s . p l a n e . c o n s t a n t ) } g e t _ c a m e r a P o s i t i o n ( ) { r e t u r n t h i s . _ p l a n e P o s i t i o n . a d d S c a l e d V e c t o r ( t h i s . _ p l a n e N o r m a l O p p o s i t e , t h i s . _ c a m e r a O f f s e t ) } s e t o p e n ( t ) { t h i s . _ o p e n = t , t h i s . o n S t a t e C h a n g e d . t r i g g e r ( [ " o p e n " ] ) } g e t o p e n ( ) { r e t u r n t h i s . _ o p e n } s e t p l a n e H e l p e r C o l o r ( t ) { ! A r r a y . i s A r r a y ( t h i s . _ p l a n e H e l p e r . m a t e r i a l ) & & " c o l o r " i n t h i s . _ p l a n e H e l p e r . m a t e r i a l & & t h i s . _ p l a n e H e l p e r . m a t e r i a l . c o l o r i n s t a n c e o f O i & & ( t h i s . _ p l a n e H e l p e r . m a t e r i a l . c o l o r = t ) } s e t f a r P l a n e H e l p e r C o l o r ( t ) { ! A r r a y . i s A r r a y ( t h i s . _ f a r P l a n e H e l p e r . m a t e r i a l ) & & " c o l o r " i n t h i s . _ f a r P l a n e H e l p e r . m a t e r i a l & & t h i s . _ f a r P l a n e H e l p e r . m a t e r i a l . c o l o r i n s t a n c e o f O i & & ( t h i s . _ f a r P l a n e H e l p e r . m a t e r i a l . c o l o r = t ) } s e t r a n g e ( t ) { t h i s . _ r a n g e = t , t h i s . u p d a t e ( ) } g e t r a n g e ( ) { r e t u r n t h i s . _ r a n g e } s e t d i s t a n c e ( t ) { t h i s . p l a n e . c o n s t a n t = t , t h i s . u p d a t e ( ) } g e t d i s t a n c e ( ) { r e t u r n t h i s . p l a n e . c o n s t a n t } s e t w o r l d ( t ) { t h i s . _ w o r l d = t , t h i s . c a m e r a . c u r r e n t W o r l d = t , t & & ( t h i s . c a m e r a . p r o j e c t i o n . s e t ( " O r t h o g r a p h i c " ) , t h i s . c a m e r a . s e t ( " P l a n " ) , t h i s . c a m e r a . c o n t r o l s . d o l l y S p e e d = 6 , t h i s . c a m e r a . c o n t r o l s . r e s t T h r e s h o l d = . 0 0 5 , t h i s . u p d a t e ( ) ) } g e t w o r l d ( ) { r e t u r n t h i s . _ w o r l d } s e t h e l p e r s V i s i b l e ( t ) { i f ( ! t ) { t h i s . _ h e l p e r s V i s i b l e = t , t h i s . _ p l a n e H e l p e r . r e m o v e F r o m P a r e n t ( ) , t h i s . _ f a r P l a n e H e l p e r . r e m o v e F r o m P a r e n t ( ) , t h i s . _ c a m e r a H e l p e r . r e m o v e F r o m P a r e n t ( ) ; r e t u r n } t h i s . w o r l d & & ( t h i s . _ h e l p e r s V i s i b l e = t , t h i s . w o r l d . s c e n e . t h r e e . a d d ( t h i s . _ p l a n e H e l p e r , t h i s . _ f a r P l a n e H e l p e r ) ) } g e t h e l p e r s V i s i b l e ( ) { r e t u r n t h i s . _ h e l p e r s V i s i b l e } s e t p l a n e s E n a b l e d ( t ) { l e t { w o r l d : i } = t h i s ; i f ( ! i ) r e t u r n ; l e t { r e n d e r e r : n } = i ; n & & ( n . s e t P l a n e ( t , t h i s . p l a n e ) , n . s e t P l a n e ( t , t h i s . f a r P l a n e ) , t h i s . _ p l a n e s E n a b l e d = t ) } g e t p l a n e s E n a b l e d ( ) { r e t u r n t h i s . _ p l a n e s E n a b l e d } d i s p o s e ( ) { t h i s . h e l p e r s V i s i b l e = ! 1 ; l e t t = t h i s . _ c o m p o n e n t s . g e t ( C M ) ; t . d e s t r o y ( t h i s . _ p l a n e H e l p e r ) , t . d e s t r o y ( t h i s . _ f a r P l a n e H e l p e r ) , t . d e s t r o y ( t h i s . _ c a m e r a H e l p e r ) , t h i s . c a m e r a . d i s p o s e ( ) , t h i s . o n D i s p o s e d . t r i g g e r ( ) } u p d a t e ( ) { i f ( t h i s . w o r l d ) { l e t t = t h i s . _ c a m e r a P o s i t i o n , i = t h i s . _ p l a n e P o s i t i o n ; t h i s . c a m e r a . c o n t r o l s . s e t L o o k A t ( t . x , t . y , t . z , i . x , i . y , i . z , ! 1 ) } t h i s . f a r P l a n e . n o r m a l . c o p y ( t h i s . _ p l a n e N o r m a l O p p o s i t e ) , t h i s . f a r P l a n e . c o n s t a n t = t h i s . r a n g e - t h i s . p l a n e . c o n s t a n t , t h i s . o n U p d a t e d . t r i g g e r ( ) } f l i p ( ) { t h i s . p l a n e .
2026-04-25 18:24:50 +01:00
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 ;
}
2026-04-25 18:59:02 +01:00
` ,uniforms:{cameraNear:{value:n.near},cameraFar:{value:n.far},tDiffuse:{value:null},tDepth:{value:null}}});let s=new dp(2,2);this._postQuad=new _i(s,this.depthMaterial),this.scene.add(this._postQuad);let o= `
2026-04-25 18:24:50 +01:00
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 } ) ;
} ) ;
2026-04-25 18:59:02 +01:00
` ,r=new Blob([o],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(r)),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()}},h0e=class extends HQ{constructor(){super(...arguments),Le(this,"_distanceRenderer"),Le(this,"autoBias",!0),Le(this,"_defaultShadowConfig",{cascade:1,resolution:512}),Le(this,"_lightsWithShadow",new Map),Le(this,"_isComputingShadows",!1),Le(this,"_shadowsEnabled",!0),Le(this,"_bias",0),Le(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 xo)&&!(n instanceof ba))throw new Error("Invalid camera type!");let s=new ye;n.getWorldDirection(s);let o=t,r=new ye;r.copy(this.config.directionalLight.position),r.normalize();for(let[l,d]of this._lightsWithShadow){let h=this.directionalLights.get(d);if(!h)throw new Error("Light not found.");let p=new ye;p.copy(s);let I=l===this._lightsWithShadow.size-1,m=I?o/2:o*2/3;p.multiplyScalar(m),p.add(n.position);let y=o-m,T=new ye;T.copy(r),T.multiplyScalar(y),h.target.position.copy(p),h.position.copy(p),h.position.add(T),h.shadow.camera.right=y,h.shadow.camera.left=-y,h.shadow.camera.top=y,h.shadow.camera.bottom=-y,h.shadow.camera.far=y*2,h.shadow.camera.updateProjectionMatrix(),h.shadow.camera.updateMatrix(),I||(o/=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 d0e(this.components,this.currentWorld),this._distanceRenderer.onDistanceComputed.add(this.recomputeShadows)),this._lightsWithShadow.clear();for(let n=0;n<i.cascade;n++){let s=new sw;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())}},sA=class{constructor(t){Le(this,"cardinality","required"),Le(this,"instructions"),Le(this,"evalRequirement",(i,n,s,o)=>{let r={parameter:s,currentValue:i,requiredValue:n,pass:!1};o&&this.addCheckResult(r,o);let l=!1;if(n.type==="simple"&&(l=i===n.parameter),n.type==="enumeration"&&(l=n.parameter.includes(i)),n.type==="pattern"&&(l=new RegExp(n.parameter).test(String(i))),n.type==="length"){let{min:d,len
$ { t . parameter . map ( o => ` <xs:enumeration value=" ${ o } " /> ` ) . join ( `
2026-04-25 18:24:50 +01:00
` )}
< / x s : r e s t r i c t i o n > ` ) , t . t y p e = = = " p a t t e r n " & & ( i = ` < x s : r e s t r i c t i o n b a s e = " x s : s t r i n g " >
< xs : pattern value = "${t.parameter}" / >
2026-04-25 18:59:02 +01:00
< / x s : r e s t r i c t i o n > ` ) , t . t y p e = = = " b o u n d s " ) { l e t { m i n : s , m i n I n c l u s i v e : o , m a x : r , m a x I n c l u s i v e : l } = t . p a r a m e t e r , d = " " ; s ! = = v o i d 0 & & ( d = ` < x s : m i n $ { o ? " I n c l u s i v e " : " E x c l u s i v e " } v a l u e = " $ { s } " > ` ) ; l e t h = " " ; r ! = = v o i d 0 & & ( h = ` < x s : m a x $ { l ? " I n c l u s i v e " : " E x c l u s i v e " } v a l u e = " $ { r } " > ` ) , i = ` < x s : r e s t r i c t i o n b a s e = " x s : d o u b l e " >
$ { d }
2026-04-25 18:24:50 +01:00
$ { h }
2026-04-25 18:59:02 +01:00
< /xs:restriction>`}if(t.type==="length"){let{length:s,min:o,max:r}=t.parameter,l="";s!==void 0&&o===void 0&&r===void 0&&(l=`<xs:length value="${s}" / > ` );let d="";o!==void 0&&s===void 0&&(d= ` < xs : minLength value = "${o}" / > ` );let h="";r!==void 0&&s===void 0&&(h= ` < xs : maxLength value = "${r}" / > ` ),i= ` < xs : restriction base = "xs:string" >
$ { l }
2026-04-25 18:24:50 +01:00
$ { d }
$ { h }
< / x s : r e s t r i c t i o n > ` } r e t u r n ` < $ { e [ 0 ] . t o L o w e r C a s e ( ) + e . s l i c e ( 1 ) } >
$ { i }
2026-04-25 18:59:02 +01:00
< / $ { e [ 0 ] . t o L o w e r C a s e ( ) + e . s l i c e ( 1 ) } > ` } , $ Q = c l a s s e x t e n d s s A { c o n s t r u c t o r ( t , i ) { s u p e r ( t ) , L e ( t h i s , " f a c e t T y p e " , " A t t r i b u t e " ) , L e ( t h i s , " n a m e " ) , L e ( t h i s , " v a l u e " ) , t h i s . n a m e = i } s e r i a l i z e ( t ) { l e t i = t 4 ( " N a m e " , t h i s . n a m e ) , n = t 4 ( " V a l u e " , t h i s . v a l u e ) , s = " " ; r e t u r n t = = = " r e q u i r e m e n t " & & ( s + = ` c a r d i n a l i t y = " $ { t h i s . c a r d i n a l i t y } " ` , s + = t h i s . i n s t r u c t i o n s ? ` i n s t r u c t i o n s = " $ { t h i s . i n s t r u c t i o n s } " ` : " " ) , ` < a t t r i b u t e $ { s } >
2026-04-25 18:24:50 +01:00
$ { i }
$ { n }
2026-04-25 18:59:02 +01:00
< / a t t r i b u t e > ` } a s y n c g e t E n t i t i e s ( ) { } a s y n c t e s t ( t , i , n = { s k i p I f F a i l s : ! 0 } ) { l e t s = t h i s . _ c o m p o n e n t s . g e t ( _ s ) ; f o r ( l e t [ o , r ] o f O b j e c t . e n t r i e s ( t ) ) { l e t l = s . l i s t . g e t ( o ) ; i f ( ! l ) c o n t i n u e ; l e t d = a w a i t l . g e t I t e m s D a t a ( [ . . . r ] ) ; f o r ( l e t h o f d ) { l e t p = t h i s . g e t I t e m C h e c k s ( i , o , h , n . s k i p I f F a i l s ) ; i f ( ! p ) c o n t i n u e ; l e t m = O b j e c t . k e y s ( h ) . f i l t e r ( T = > { l e t R = t h i s . e v a l R e q u i r e m e n t ( T , t h i s . n a m e , " N a m e " ) ; i f ( ! R ) r e t u r n ! 1 ; l e t b = h [ T ] ; r e t u r n A r r a y . i s A r r a y ( b ) ? ! 0 : b = = = n u l l | | b . v a l u e = = = n u l l ? t h i s . c a r d i n a l i t y = = = " o p t i o n a l " | | t h i s . c a r d i n a l i t y = = = " p r o h i b i t e d " : A r r a y . i s A r r a y ( b . v a l u e ) & & b . v a l u e . l e n g t h = = = 0 | | t y p e o f b . v a l u e = = " s t r i n g " & & b . v a l u e . t r i m ( ) = = = " " ? ! 1 : R } ) , y = m . l e n g t h > 0 ; i f ( p . p u s h ( { p a r a m e t e r : " N a m e " , c u r r e n t V a l u e : y ? m [ 0 ] : n u l l , r e q u i r e d V a l u e : t h i s . n a m e , p a s s : t h i s . c a r d i n a l i t y = = = " p r o h i b i t e d " ? ! y : y } ) , t h i s . v a l u e ) i f ( m [ 0 ] ) { l e t T = h [ m [ 0 ] ] ; A r r a y . i s A r r a y ( T ) ? p . p u s h ( { p a r a m e t e r : " V a l u e " , c u r r e n t V a l u e : n u l l , r e q u i r e d V a l u e : t h i s . v a l u e , p a s s : t h i s . c a r d i n a l i t y = = = " p r o h i b i t e d " } ) : A r r a y . i s A r r a y ( T . v a l u e ) ? p . p u s h ( { p a r a m e t e r : " V a l u e " , c u r r e n t V a l u e : n u l l , r e q u i r e d V a l u e : t h i s . v a l u e , p a s s : t h i s . c a r d i n a l i t y = = = " p r o h i b i t e d " } ) : t h i s . e v a l R e q u i r e m e n t ( T . v a l u e , t h i s . v a l u e , " V a l u e " , p ) } e l s e p . p u s h ( { p a r a m e t e r : " V a l u e " , c u r r e n t V a l u e : n u l l , r e q u i r e d V a l u e : t h i s . v a l u e , p a s s : t h i s . c a r d i n a l i t y = = = " p r o h i b i t e d " } ) } } } } , Z Q = c l a s s e x t e n d s s A { c o n s t r u c t o r ( t , i ) { s u p e r ( t ) , L e ( t h i s , " f a c e t T y p e " , " C l a s s i f i c a t i o n " ) , L e ( t h i s , " s y s t e m " ) , L e ( t h i s , " v a l u e " ) , L e ( t h i s , " u r i " ) , t h i s . s y s t e m = i } s e r i a l i z e ( t ) { l e t i = t 4 ( " S y s t e m " , t h i s . s y s t e m ) , n = t 4 ( " V a l u e " , t h i s . v a l u e ) , s = " " ; r e t u r n t = = = " r e q u i r e m e n t " & & ( s + = ` c a r d i n a l i t y = " $ { t h i s . c a r d i n a l i t y } " ` , s + = t h i s . u r i ? ` u r i = $ { t h i s . u r i } ` : " " , s + = t h i s . i n s t r u c t i o n s ? ` i n s t r u c t i o n s = " $ { t h i s . i n s t r u c t i o n s } " ` : " " ) , ` < c l a s s i f i c a t i o n $ { s } >
2026-04-25 18:24:50 +01:00
$ { i }
$ { n }
2026-04-25 18:59:02 +01:00
< / c l a s s i f i c a t i o n > ` } a s y n c g e t E n t i t i e s ( t , i ) { } a s y n c t e s t ( t , i ) { } } , D M = c l a s s e x t e n d s s A { c o n s t r u c t o r ( t , i ) { s u p e r ( t ) , L e ( t h i s , " f a c e t T y p e " , " E n t i t y " ) , L e ( t h i s , " n a m e " ) , L e ( t h i s , " p r e d e f i n e d T y p e " ) , t h i s . n a m e = i } s e r i a l i z e ( t ) { l e t i = t 4 ( " N a m e " , t h i s . n a m e ) , n = t 4 ( " N a m e " , t h i s . p r e d e f i n e d T y p e ) , s = " " ; r e t u r n t = = = " r e q u i r e m e n t " & & ( s + = ` c a r d i n a l i t y = " $ { t h i s . c a r d i n a l i t y } " ` , s + = t h i s . i n s t r u c t i o n s ? ` i n s t r u c t i o n s = " $ { t h i s . i n s t r u c t i o n s } " ` : " " ) , ` < e n t i t y $ { s } >
2026-04-25 18:24:50 +01:00
$ { i }
$ { n }
2026-04-25 18:59:02 +01:00
< /entity>`}async getEntities(t,i){let n=this._components.get(_s),s=new Map;for(let[r,l]of n.list){if(!t.find(p=>p.test(r)))continue;let h=await l.getCategories();for(let p of h){if(!await this.evalName(p))continue;let m=s.get(r);m||(m=[],s.set(r,m)),m.push(p)}}let o={};if(await Promise.all(Array.from(s.entries()).map(async([r,l])=>{let d=n.list.get(r);if(!d)return;let h=l.map(m=>new RegExp(`^${m}$`)),p=await d.getItemsOfCategories(h),I=Object.values(p).flat();o[r]=new Set(I)})),!this.predefinedType){Kh.add(i,o);return}for(let[r,l]of Object.entries(o)){let d=n.list.get(r);if(!d)continue;let h=await d.getItemsData([...l]);for(let p of h){if(!("value"in p._localId))continue;await this.evalPredefinedType(r,p)&&Kh.append(i,r,p._localId.value)}}}async test(t,i,n){let s=this._components.get(_s);for(let[o,r]of Object.entries(t)){let l=s.list.get(o);if(!l)continue;let d=await l.getItemsData([...r]);for(let h of d){if(!("value"in h._category))continue;let p=this.getItemChecks(i,o,h,n.skipIfFails);p&&(await this.evalName(h._category.value,p),await this.evalPredefinedType(o,h,p))}}}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",o=i.PredefinedType.value;if(o==="USERDEFINED"&&!s){let d=Object.keys(i).find(h=>/ ^ ( ( ? ! Predefined ) . ) * Type$ / . test ( h ) ) ; if ( d ) { let h = i [ d ] ; "value" in h && ( o = h . value ) } else o = "USERDEFINED" } if ( ! o ) { let d = this . _components . get ( _s ) . list . get ( t ) ; if ( d && "value" in i . _localId ) { let [ h ] = await d . getItemsData ( [ i . _localId . value ] , { relations : { IsTypedBy : { attributes : ! 0 , relations : ! 1 } } } ) ; if ( Array . isArray ( h . IsTypedBy ) ) { let p = h . IsTypedBy [ 0 ] ; if ( p && "value" in p . PredefinedType && ( o = p . PredefinedType . value , o === "USERDEFINED" && ! s ) ) { let m = Object . keys ( p ) . find ( y => / ^ ( ( ? ! Predefined ) . ) * Type$ / . test ( y ) ) ; if ( m ) { let y = p [ m ] ; "value" in y && ( o = y . value ) } else o = "USERDEFINED" } } } } return this . evalRequirement ( o , this . predefinedType , "PredefinedType" , n ) } } , KQ = class extends sA { constructor ( t , i , n ) { super ( t ) , Le ( this , "facetType" , "Property" ) , Le ( this , "propertySet" ) , Le ( this , "baseName" ) , Le ( this , "value" ) , Le ( this , "dataType" ) , Le ( this , "uri" ) , Le ( this , "_unsupportedTypes" , [ "IFCCOMPLEXPROPERTY" , "IFCPHYSICALCOMPLEXQUANTITY" ] ) , this . propertySet = i , this . baseName = n } serialize ( t ) { let i = t4 ( "PropertySet" , this . propertySet ) , n = t4 ( "BaseName" , this . baseName ) , s = t4 ( "Value" , this . value ) , o = this . dataType ? ` dataType= ${ this . dataType } ` : "" , r = "" ; return t === "requirement" && ( r += ` cardinality=" ${ this . cardinality } " ` , r += this . uri ? ` uri= ${ this . uri } ` : "" , r += this . instructions ? ` instructions=" ${ this . instructions } " ` : "" ) , ` <property ${ o } ${ r } >
2026-04-25 18:24:50 +01:00
$ { i }
$ { n }
$ { s }
2026-04-25 18:59:02 +01:00
< / p r o p e r t y > ` } a s y n c g e t E n t i t i e s ( t , i ) { l e t n = t h i s . _ c o m p o n e n t s . g e t ( _ s ) ; f o r ( l e t [ s , o ] o f n . l i s t ) { i f ( ! t . f i n d ( p = > p . t e s t ( s ) ) ) c o n t i n u e ; l e t l = a w a i t o . g e t I t e m s O f C a t e g o r i e s ( [ / P R O P E R T Y S E T / , / E L E M E N T Q U A N T I T Y / ] ) , d = O b j e c t . v a l u e s ( l ) . f l a t ( ) ; i f ( d . l e n g t h = = = 0 ) c o n t i n u e ; l e t h = a w a i t o . g e t I t e m s D a t a ( d , { r e l a t i o n s : { H a s P r o p e r t i e s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 1 } , D e f i n e s O c u r r e n c e : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 1 } } } ) ; f o r ( l e t p o f h ) { i f ( ! ( " v a l u e " i n p . _ l o c a l I d & & " v a l u e " i n p . _ c a t e g o r y & & " v a l u e " i n p . N a m e & & A r r a y . i s A r r a y ( p . D e f i n e s O c u r r e n c e ) ) | | ! t h i s . e v a l R e q u i r e m e n t ( p . N a m e . v a l u e , t h i s . p r o p e r t y S e t , " P r o p e r t y S e t " ) ) c o n t i n u e ; l e t m ; i f ( p . _ c a t e g o r y . v a l u e = = = " I F C P R O P E R T Y S E T " & & ( m = " H a s P r o p e r t i e s " ) , p . _ c a t e g o r y . v a l u e = = = " I F C E L E M E N T Q U A N T I T Y " & & ( m = " Q u a n t i t i e s " ) , ! m ) c o n t i n u e ; l e t y = p [ m ] ; i f ( A r r a y . i s A r r a y ( y ) ) f o r ( l e t T o f y ) { l e t R = O b j e c t . k e y s ( T ) , b = R . f i n d ( U = > / N a m e / . t e s t ( U ) ) ; i f ( ! ( b & & " v a l u e " i n T [ b ] ) ) c o n t i n u e ; l e t A = T [ b ] ; i f ( ! ( " v a l u e " i n A ) | | ! t h i s . e v a l R e q u i r e m e n t ( A . v a l u e , t h i s . b a s e N a m e , " B a s e N a m e " ) ) c o n t i n u e ; i f ( t h i s . v a l u e ) { l e t U = R . f i n d ( K = > / V a l u e / . t e s t ( K ) ) ; i f ( ! U ) c o n t i n u e ; l e t Z = T [ U ] ; i f ( ! ( " v a l u e " i n Z ) | | ! t h i s . e v a l R e q u i r e m e n t ( Z . v a l u e , t h i s . v a l u e , " V a l u e " ) ) c o n t i n u e } l e t P = p . D e f i n e s O c u r r e n c e . m a p ( U = > " v a l u e " i n U . _ l o c a l I d & & t y p e o f U . _ l o c a l I d . v a l u e = = " n u m b e r " ? U . _ l o c a l I d . v a l u e : n u l l ) . f i l t e r ( U = > U ! = = n u l l ) ; K h . a p p e n d ( i , s , . . . P ) } } } } a s y n c t e s t ( t , i , n = { s k i p I f F a i l s : ! 0 } ) { l e t s = t h i s . _ c o m p o n e n t s . g e t ( _ s ) ; f o r ( l e t [ o , r ] o f O b j e c t . e n t r i e s ( t ) ) { l e t l = s . l i s t . g e t ( o ) ; i f ( ! l ) c o n t i n u e ; l e t d = a w a i t l . g e t I t e m s D a t a ( [ . . . r ] , { r e l a t i o n s : { I s D e f i n e d B y : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , I s T y p e d B y : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 1 } , H a s P r o p e r t y S e t s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , D e f i n e s O c u r r e n c e : { a t t r i b u t e s : ! 1 , r e l a t i o n s : ! 1 } } } ) ; f o r ( l e t h o f d ) { l e t p = t h i s . g e t I t e m C h e c k s ( i , o , h , n . s k i p I f F a i l s ) ; i f ( ! p ) c o n t i n u e ; l e t m = ( a w a i t t h i s . g e t P s e t s ( h ) ) . f i l t e r ( y = > ! ( " v a l u e " i n y . N a m e ) | | ! t h i s . e v a l R e q u i r e m e n t ( y . N a m e . v a l u e , t h i s . p r o p e r t y S e t , " P r o p e r t y S e t " ) ? ! 1 : ( p . p u s h ( { c u r r e n t V a l u e : y . N a m e . v a l u e , p a r a m e t e r : " P r o p e r t y S e t " , p a s s : ! 0 , r e q u i r e d V a l u e : t h i s . p r o p e r t y S e t } ) , ! 0 ) ) ; i f ( m . l e n g t h = = = 0 ) { p . p u s h ( { c u r r e n t V a l u e : n u l l , p a r a m e t e r : " P r o p e r t y S e t " , p a s s : ! 1 , r e q u i r e d V a l u e : t h i s . p r o p e r t y S e t } ) ; c o n t i n u e } f o r ( l e t y o f m ) { l e t T = t h i s . g e t P r o p e r t y L i s t N a m e ( y ) ; i f ( ! T ) c o n t i n u e ; l e t R = y [ T ] ; i f ( ! A r r a y . i s A r r a y ( R ) ) { p . p u s h ( { c u r r e n t V a l u e : n u l l , p a r a m e t e r : " B a s e N a m e " , p a s s : ! 1 , r e q u i r e d V a l u e : t h i s . b a s e N a m e } ) ; c o n t i n u e } l e t b = R . f i l t e r ( A = > ! ( " v a l u e " i n A . _ c a t e g o r y & & " v a l u e " i n A . N a m e ) | | t h i s . _ u n s u p p o r t e d T y p e s . i n c l u d e s ( A . _ c a t e g o r y . v a l u e ) | | ! t h i s . e v a l R e q u i r e m e n t ( A . N a m e . v a l u e , t h i s . b a s e N a m e , " B a s e N a m e " ) ? ! 1 : ( p . p u s h ( { c u r r e n t V a l u e : A . N a m e . v a l u e , p a r a m e t e r : " B a s e N a m e " , p a s s : ! 0 , r e q u i r e d V a l u e : t h i s . b a s e N a m e } ) , ! 0 ) ) ; i f ( b . l e n g t h = = = 0 ) { p . p u s h ( { c u r r e n t V a l u e : n u l l , p a r a m e t e r : " B a s e N a m e " , p a s s : ! 1 , r e q u i r e d V a l u e : t h i s . b a s e N a m e } ) ; c o n t i n u e } f o r ( l e t A o f b ) t h i s . e v a l V a l u e ( A , p ) , t h i s . e v a l D a t a T y p e ( A , p ) , t h i s . e v a l U R I ( ) } } } } g e t P r o p e r t y L i s t N a m e ( t ) { l e t i ; r e t u r n " v a l u e " i n t . _ c a t e g o r y & & ( t . _ c a t e g o r y . v a l u e = = = " I F C P R O P E R T Y S E T " & & ( i = " H a s P r o p e r t i e s " ) , t . _ c a t e g o r y . v a l u e = = = " I F C E L E M E N T Q U A N T I T Y " & & ( i = " Q u a n t i t i e s " ) ) , i } g e t V a l u e K e y ( t ) { r e t u r n O b j e c t . k e y s ( t ) . f i n d ( i = > / V a l u e / . t e s t ( i ) | | / V a l u e s / . t e s t ( i ) ) } g e t T y p e P s e t s ( t ) { i f ( ! A r r a y . i s A r r a y ( t . I s T y p e d B y ) ) r e t u r n [ ] ; l e t [ i ] = t . I s T y p e d B y ; r e t u r n i & & A r r a y . i s A r r a y ( i . H a s P r o p e r t y S e t s ) ? i . H a s P r o p e r t y S e t s : [ ] } a s y n c g e t P s e t s ( t ) { l e t i = t h i s . g e t T y p e P s e t s ( t ) ; i f ( ! A r r a y . i s A r r a y ( t . I s D e f i n e d B y ) ) r e t u r n i ; l e t n = [ ] ; f o r ( l e t s o f t . I s D e f i n e d B y ) { i f ( ! ( " v a l u e " i n s . N a m e ) ) c o n t i n u e ; l e t o = s . N a m e . v a l u e , r = t h i s . g e t P r o p e r t y L i s t N a m e ( s ) ; i f ( ! ( o & & r ) ) c o n t i n u e ; l e t l = i . f i n d ( d = > " v a l u e " i n d . N a m e ? d . N a m e . v a l u e = = = o : ! 1 ) ; i f ( l & & A r r a y . i s A r r a y ( l . H a s P r o p e r t i e s ) & & A r r a y . i s A r r a y ( s . H a s P r o p e r t i e s ) ) f o r ( l e t d o f l . H a s P r o p e r t i e s ) { i f ( ! ( " v a l u e " i n d . N a m e ) ) c o n t i n u e ; l e t h = d . N a m e . v a l u e ; s . H a s P r o p e r t i e s . f i n d ( I = > " v a l u e " i n I . N a m e ? I . N a m e . v a l u e = = = h : ! 1 ) | | s . H a s P r o p e r t i e s . p u s h ( d ) } n . p u s h ( s ) } r e t u r n n } e v a l V a l u e ( t , i ) { l e t n = t h i s . g e t V a l u e K e y ( t ) , s = t [ n ] ; i f ( ! ( " v a l u e " i n s ) ) r e t u r n ! 1 ; i f ( t h i s . v a l u e ) { i f ( ! n ) r e t u r n i ? . p u s h ( { p a r a m e t e r : " V a l u e " , c u r r e n t V a l u e : n u l l , p a s s : ! 1 , r e q u i r e d V a l u e : t h i s . v a l u e } ) , ! 1 ; l e t o = s t r u c t u r e d C l o n e ( t h i s . v a l u e ) ; r e t u r n s . t y p e = = = " I F C L A B E L " & & o . t y p e = = = " s i m p l e " & & ( o . p a r a m e t e r = S t r i n g ( o . p a r a m e t e r ) ) , t h i s . e v a l R e q u i r e m e n t ( s . v a l u e , o , " V a l u e " , i ) } r e t u r n n & & t y p e o f s . v a l u e = = " s t r i n g " & & s . v a l u e . t r i m ( ) = = = " " ? ( i ? . p u s h ( { p a r a m e t e r : " V a l u e " , c u r r e n t V a l u e : " " , p a s s : ! 1 , r e q u i r e d V a l u e : t h i s . v a l u e } ) ,
2026-04-25 18:24:50 +01:00
$ { i }
2026-04-25 18:59:02 +01:00
< / m a t e r i a l > ` } a s y n c g e t E n t i t i e s ( t , i ) { l e t n = t h i s . _ c o m p o n e n t s . g e t ( _ s ) ; f o r ( l e t [ s , o ] o f n . l i s t ) { i f ( ! t . f i n d ( p = > p . t e s t ( s ) ) ) c o n t i n u e ; l e t l = a w a i t o . g e t I t e m s O f C a t e g o r i e s ( t h i s . _ i f c M a t e r i a l E n t i t i e s ) , d = O b j e c t . v a l u e s ( l ) . f l a t ( ) ; i f ( d . l e n g t h = = = 0 ) c o n t i n u e ; l e t h = a w a i t o . g e t I t e m s D a t a ( d , { r e l a t i o n s : { A s s o c i a t e d T o : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 1 } , M a t e r i a l C o n s t i t u e n t s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , F o r L a y e r S e t : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , M a t e r i a l L a y e r s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , M a t e r i a l s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 1 } } } ) ; f o r ( l e t p o f h ) { i f ( ! ( " v a l u e " i n p . _ l o c a l I d & & " v a l u e " i n p . _ c a t e g o r y & & A r r a y . i s A r r a y ( p . A s s o c i a t e d T o ) ) | | ! t h i s . h a s V a l i d M a t e r i a l ( p ) ) c o n t i n u e ; l e t m = p . A s s o c i a t e d T o . m a p ( y = > " v a l u e " i n y . _ l o c a l I d & & y . _ l o c a l I d . v a l u e ? y . _ l o c a l I d . v a l u e : n u l l ) . f i l t e r ( y = > y ! = = n u l l ) ; K h . a p p e n d ( i , s , . . . m ) } } } a s y n c t e s t ( t , i , n = { s k i p I f F a i l s : ! 0 } ) { l e t s = t h i s . _ c o m p o n e n t s . g e t ( _ s ) ; f o r ( l e t [ o , r ] o f O b j e c t . e n t r i e s ( t ) ) { l e t l = s . l i s t . g e t ( o ) ; i f ( ! l ) c o n t i n u e ; l e t d = a w a i t l . g e t I t e m s D a t a ( [ [ . . . r ] [ 0 ] ] , { r e l a t i o n s : { A s s o c i a t e d T o : { a t t r i b u t e s : ! 1 , r e l a t i o n s : ! 1 } , H a s A s s o c i a t i o n s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , M a t e r i a l C o n s t i t u e n t s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , F o r L a y e r S e t : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , M a t e r i a l L a y e r s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 0 } , M a t e r i a l s : { a t t r i b u t e s : ! 0 , r e l a t i o n s : ! 1 } } } ) ; f o r ( l e t h o f d ) { l e t p = t h i s . g e t I t e m C h e c k s ( i , o , h , n . s k i p I f F a i l s ) ; i f ( p ) { i f ( ! A r r a y . i s A r r a y ( h . H a s A s s o c i a t i o n s ) ) { p . p u s h ( { p a r a m e t e r : n u l l , c u r r e n t V a l u e : n u l l , r e q u i r e d V a l u e : t h i s . v a l u e , p a s s : ! 1 } ) ; c o n t i n u e } f o r ( l e t I o f h . H a s A s s o c i a t i o n s ) { i f ( ! t h i s . _ i f c M a t e r i a l E n t i t i e s . s o m e ( y = > " v a l u e " i n I . _ c a t e g o r y ? y . t e s t ( I . _ c a t e g o r y . v a l u e ) : ! 1 ) ) c o n t i n u e ; i f ( t h i s . h a s V a l i d M a t e r i a l ( I , p ) ) b r e a k } } } } } h a s V a l i d M a t e r i a l ( t , i ) { l e t n = ! 1 ; i f ( " v a l u e " i n t . _ c a t e g o r y & & t . _ c a t e g o r y . v a l u e = = = " I F C M A T E R I A L " ) t h i s . e v a l V a l u e ( t , i ) & & ( n = ! 0 ) ; e l s e f o r ( l e t [ s , o ] o f O b j e c t . e n t r i e s ( t ) ) i f ( [ " F o r L a y e r S e t " , " M a t e r i a l L a y e r s " , " M a t e r i a l " , " M a t e r i a l C o n s t i t u e n t s " , " M a t e r i a l s " ] . i n c l u d e s ( s ) & & A r r a y . i s A r r a y ( o ) ) { f o r ( l e t r o f o ) i f ( " v a l u e " i n r . _ c a t e g o r y & & r . _ c a t e g o r y . v a l u e = = = " I F C M A T E R I A L " ) { i f ( t h i s . e v a l V a l u e ( r , i ) ) { n = ! 0 ; b r e a k } } e l s e i f ( t h i s . h a s V a l i d M a t e r i a l ( r ) ) { n = ! 0 ; b r e a k } } r e t u r n n } e v a l V a l u e ( t , i ) { i f ( ! t h i s . v a l u e ) r e t u r n i ? . p u s h ( { p a r a m e t e r : n u l l , c u r r e n t V a l u e : t . N a m e & & " v a l u e " i n t . N a m e ? t . N a m e . v a l u e : n u l l , p a s s : ! 0 } ) , ! 0 ; i f ( ! ( " v a l u e " i n t . _ c a t e g o r y & & t . _ c a t e g o r y . v a l u e = = = " I F C M A T E R I A L " ) ) r e t u r n n u l l ; l e t n = ! 1 ; r e t u r n t . N a m e & & " v a l u e " i n t . N a m e & & ( n = t h i s . e v a l R e q u i r e m e n t ( t . N a m e . v a l u e , t h i s . v a l u e , " V a l u e " , i ) ) , n | | ( t . C a t e g o r y & & " v a l u e " i n t . C a t e g o r y & & ( n = t h i s . e v a l R e q u i r e m e n t ( t . C a t e g o r y . v a l u e , t h i s . v a l u e , " V a l u e " , i ) ) , n ) } } , J Q = c l a s s e x t e n d s s A { c o n s t r u c t o r ( t , i ) { s u p e r ( t ) , L e ( t h i s , " f a c e t T y p e " , " P a r t O f " ) , L e ( t h i s , " _ e n t i t y F a c e t " ) , L e ( t h i s , " _ e n t i t y " ) , L e ( t h i s , " r e l a t i o n " ) , L e ( t h i s , " c a r d i n a l i t y " , " r e q u i r e d " ) , t h i s . _ e n t i t y = i , t h i s . _ e n t i t y F a c e t = n e w D M ( t , i . n a m e ) , t h i s . _ e n t i t y F a c e t . p r e d e f i n e d T y p e = i . p r e d e f i n e d T y p e } s e t e n t i t y ( t ) { t h i s . _ e n t i t y = t ; l e t { n a m e : i , p r e d e f i n e d T y p e : n } = t ; t h i s . _ e n t i t y F a c e t = n e w D M ( t h i s . _ c o m p o n e n t s , i ) , t h i s . _ e n t i t y F a c e t . p r e d e f i n e d T y p e = n } g e t e n t i t y ( ) { r e t u r n t h i s . _ e n t i t y } s e r i a l i z e ( ) { r e t u r n " " } a s y n c g e t E n t i t i e s ( t , i ) { } a s y n c t e s t ( t ) { } } , X Q = c l a s s { c o n s t r u c t o r ( t , i , n ) { L e ( t h i s , " n a m e " ) , L e ( t h i s , " i f c V e r s i o n " , n e w S e t ) , L e ( t h i s , " i d e n t i f i e r " , d I . c r e a t e ( ) ) , L e ( t h i s , " d e s c r i p t i o n " ) , L e ( t h i s , " i n s t r u c t i o n s " ) , L e ( t h i s , " r e q u i r e m e n t s D e s c r i p t i o n " ) , L e ( t h i s , " a p p l i c a b i l i t y " , n e w s I ) , L e ( t h i s , " r e q u i r e m e n t s " , n e w s I ) , L e ( t h i s , " c o m p o n e n t s " ) , t h i s . c o m p o n e n t s = t , t h i s . n a m e = i ; f o r ( l e t s o f n ) t h i s . i f c V e r s i o n . a d d ( s ) } s e t ( t ) { l e t i = t , n = t h i s ; f o r ( l e t o i n t ) { i f ( o = = = " i d e n t i f i e r " ) c o n t i n u e ; l e t r = i [ o ] ; o i n t h i s & & ( n [ o ] = r ) } r e t u r n t h i s . c o m p o n e n t s . g e t ( Y 2 e ) . l i s t . s e t ( t h i s . i d e n t i f i e r , t h i s ) , t h i s } a s y n c t e s t ( t , i = { s k i p I f F a i l s : ! 0 } ) { l e t n = n e w f o ; i f ( t h i s . r e q u i r e m e n t s . s i z e = = = 0 ) r e t u r n n ; l e t s = { } , o = [ ] ; f o r ( l e t l o f t h i s . a p p l i c a b i l i t y ) o . p u s h ( l . g e t E n t i t i e s ( t , s ) ) ; a w a i t P r o m i s e . a l l ( o ) ; l e t r = [ ] ; f o r ( l e t l o f t h i s . r e q u i r e m e n t s ) r . p u s h ( l . t e s t ( s , n , i ) ) ; r e t u r n a w a i t P r o m i s e . a l l ( r ) , n } s e r i a l i z e ( ) { l e t t = ` n a m e = " $ { t h i s . n a m e } " ` , i = t h i s . i d e n t i f i e r ? ` i d e n t i f i e r = " $ { t h i s . i d e n t i f i e r } " ` : " " , n = t h i s . d e s c r i p t i o n ? ` d e s c r i p t i o n = " $ { t h i s . d e s c r i p t i o n } " ` : " " , s = t h i s . i n s t r u c t i o n s ? ` i n s t r u c t i o n s = " $ { t h i s . i n s t r u c t i o n s } " ` : " " ; r e t u r n ` < s p e c i f i c a t i o n i f c V e r s i o n = " $ { [ . . . t h i s . i f c V e r s i o n ] . j o i n ( " " ) } " $ { t } $ { i } $ { n } $ { s } >
2026-04-25 18:24:50 +01:00
< applicability minOccurs = "1" maxOccurs = "unbounded" >
2026-04-25 18:59:02 +01:00
$ { [ ... this . applicability ] . map ( r => r . serialize ( "applicability" ) ) . join ( `
2026-04-25 18:24:50 +01:00
` )}
< / a p p l i c a b i l i t y >
< requirements >
2026-04-25 18:59:02 +01:00
$ { [ ... this . requirements ] . map ( r => r . serialize ( "requirement" ) ) . join ( `
2026-04-25 18:24:50 +01:00
` )}
< / r e q u i r e m e n t s >
2026-04-25 18:59:02 +01:00
< / s p e c i f i c a t i o n > ` } } , b E = e = > { i f ( ! e ) r e t u r n ; l e t t = { } ; i f ( " s i m p l e V a l u e " i n e & & ( t . t y p e = " s i m p l e " , t . p a r a m e t e r = e . s i m p l e V a l u e ) , " r e s t r i c t i o n " i n e ) { l e t i = e . r e s t r i c t i o n , n = O b j e c t . k e y s ( i ) ; i f ( " p a t t e r n " i n i & & ( t . t y p e = " p a t t e r n " , t . p a r a m e t e r = i . p a t t e r n . v a l u e ) , " e n u m e r a t i o n " i n i ) { t . t y p e = " e n u m e r a t i o n " ; l e t s = i . e n u m e r a t i o n . m a p ( ( { v a l u e : o } ) = > i . b a s e . i n c l u d e s ( " s t r i n g " ) ? S t r i n g ( o ) : i . b a s e . i n c l u d e s ( " i n t e g e r " ) | | i . b a s e . i n c l u d e s ( " d o u b l e " ) ? N u m b e r ( o ) : o ) ; t . p a r a m e t e r = s } i f ( n . s o m e ( s = > [ " m i n I n c l u s i v e " , " m i n E x c l u s i v e " , " m a x I n c l u s i v e " , " m a x E x c l u s i v e " ] . i n c l u d e s ( s ) ) ) { t . t y p e = " b o u n d s " ; l e t s = { } , o = n . f i n d ( l = > l . i n c l u d e s ( " m i n " ) ) , r = n . f i n d ( l = > l . i n c l u d e s ( " m a x " ) ) ; o & & ( s . m i n I n c l u s i v e = o = = = " m i n I n c l u s i v e " , s . m i n = i [ o ] . v a l u e ) , r & & ( s . m a x I n c l u s i v e = r = = = " m a x I n c l u s i v e " , s . m a x = i [ r ] . v a l u e ) , t . p a r a m e t e r = s } i f ( n . s o m e ( s = > [ " m i n L e n g t h " , " l e n g t h " , " m a x L e n g t h " ] . i n c l u d e s ( s ) ) ) { t . t y p e = " l e n g t h " ; l e t s = { } ; i . l e n g t h ! = = v o i d 0 & & ( s . l e n g t h = i . l e n g t h . v a l u e ) , i . m i n L e n g t h ! = = v o i d 0 & & ( s . m i n = i . m i n L e n g t h . v a l u e ) , i . m a x L e n g t h ! = = v o i d 0 & & ( s . m a x = i . m a x L e n g t h . v a l u e ) , t . p a r a m e t e r = s } } i f ( t . p a r a m e t e r ! = = v o i d 0 ) r e t u r n t } , G w e = ( e , t ) = > { l e t i = [ ] ; f o r ( l e t n o f t ) { l e t s = n . n a m e , o = b E ( s ) ; i f ( ! o ) c o n t i n u e ; l e t r = n e w D M ( e , o ) ; n . c a r d i n a l i t y & & ( r . c a r d i n a l i t y = n . c a r d i n a l i t y ) , r . p r e d e f i n e d T y p e = b E ( n . p r e d e f i n e d T y p e ) , r . i n s t r u c t i o n s = n . i n s t r u c t i o n s , i . p u s h ( r ) } r e t u r n i } , V w e = ( e , t ) = > { l e t i = [ ] ; f o r ( l e t n o f t ) { l e t s = n . n a m e , o = b E ( s ) ; i f ( ! o ) c o n t i n u e ; l e t r = n e w $ Q ( e , o ) ; n . c a r d i n a l i t y & & ( r . c a r d i n a l i t y = n . c a r d i n a l i t y ) , r . v a l u e = b E ( n . v a l u e ) , r . i n s t r u c t i o n s = n . i n s t r u c t i o n s , i . p u s h ( r ) } r e t u r n i } , k w e = ( e , t ) = > { l e t i = [ ] ; f o r ( l e t n o f t ) { l e t s = n e w Q Q ( e ) ; n . c a r d i n a l i t y & & ( s . c a r d i n a l i t y = n . c a r d i n a l i t y ) ; l e t o = b E ( n . v a l u e ) ; o ? . t y p e = = = " e n u m e r a t i o n " & & A r r a y . i s A r r a y ( o . p a r a m e t e r ) & & ( o . p a r a m e t e r = o . p a r a m e t e r . m a p ( S t r i n g ) ) , s . v a l u e = o , s . u r i = n . u r i , s . i n s t r u c t i o n s = n . i n s t r u c t i o n s , i . p u s h ( s ) } r e t u r n i } , z w e = ( e , t ) = > { l e t i = [ ] ; f o r ( l e t n o f t ) { l e t s = n . p r o p e r t y S e t , o = n . b a s e N a m e , r = b E ( s ) , l = b E ( o ) ; i f ( ! ( l & & r ) ) c o n t i n u e ; l e t d = n e w K Q ( e , r , l ) ; n . c a r d i n a l i t y & & ( d . c a r d i n a l i t y = n . c a r d i n a l i t y ) ; l e t h = b E ( n . v a l u e ) ; d . v a l u e = h , d . d a t a T y p e = n . d a t a T y p e , d . u r i = n . u r i , d . i n s t r u c t i o n s = n . i n s t r u c t i o n s , i . p u s h ( d ) } r e t u r n i } , W w e = ( e , t ) = > { l e t i = [ ] ; f o r ( l e t n o f t ) { l e t s = n . s y s t e m , o = b E ( s ) ; i f ( ! o ) c o n t i n u e ; l e t r = n e w Z Q ( e , o ) ; n . c a r d i n a l i t y & & ( r . c a r d i n a l i t y = n . c a r d i n a l i t y ) ; l e t l = b E ( n . v a l u e ) ; l ? . t y p e = = = " s i m p l e " & & ( l . p a r a m e t e r = S t r i n g ( l . p a r a m e t e r ) ) , l ? . t y p e = = = " e n u m e r a t i o n " & & A r r a y . i s A r r a y ( l . p a r a m e t e r ) & & ( l . p a r a m e t e r = l . p a r a m e t e r . m a p ( S t r i n g ) ) , r . v a l u e = l , r . u r i = n . u r i , r . i n s t r u c t i o n s = n . i n s t r u c t i o n s , i . p u s h ( r ) } r e t u r n i } , Y w e = ( e , t ) = > { l e t i = [ ] ; f o r ( l e t n o f t ) { l e t s = b E ( n . e n t i t y . n a m e ) ; i f ( ! s ) c o n t i n u e ; l e t o = b E ( n . e n t i t y . p r e d e f i n e d T y p e ) , r = n e w J Q ( e , { n a m e : s , p r e d e f i n e d T y p e : o } ) ; r . r e l a t i o n = n . r e l a t i o n , n . c a r d i n a l i t y & & ( r . c a r d i n a l i t y = n . c a r d i n a l i t y ) , r . i n s t r u c t i o n s = n . i n s t r u c t i o n s , i . p u s h ( r ) } r e t u r n i } , D 0 e = c l a s s f 0 e e x t e n d s G l { c o n s t r u c t o r ( t ) { s u p e r ( t ) , L e ( t h i s , " e n a b l e d " , ! 0 ) , L e ( t h i s , " I D S I n f o " ) , L e ( t h i s , " l i s t " , n e w f o ) , t . a d d ( f 0 e . u u i d , t h i s ) } g e t M o d e l I d M a p ( t ) { l e t i = { } , n = { } ; f o r ( l e t [ s , o ] o f t ) { l e t l = [ . . . o ] . f i l t e r ( ( [ , p ] ) = > p . p a s s ) . m a p ( ( [ p ] ) = > p ) ; K h . a p p e n d ( i , s , . . . l ) ; l e t h = [ . . . o ] . f i l t e r ( ( [ , p ] ) = > ! p . p a s s ) . m a p ( ( [ p ] ) = > p ) ; K h . a p p e n d ( n , s , . . . h ) } r e t u r n { p a s s : i , f a i l : n } } c r e a t e ( t , i , n ) { l e t s = n e w X Q ( t h i s . c o m p o n e n t s , t , i ) ; r e t u r n n & & ( s . i d e n t i f i e r = n ) , t h i s . l i s t . s e t ( s . i d e n t i f i e r , s ) , s } l o a d ( t ) { l e t i = [ ] , n = f 0 e . x m l P a r s e r . p a r s e ( t ) . i d s , { s p e c i f i c a t i o n s : s , i n f o : o } = n ; i f ( t h i s . I D S I n f o = { . . . o } , s & & s . s p e c i f i c a t i o n ) { l e t r = A r r a y . i s A r r a y ( s . s p e c i f i c a t i o n ) ? s . s p e c i f i c a t i o n : [ s . s p e c i f i c a t i o n ] ; f o r ( l e t l o f r ) { l e t { n a m e : d , i f c V e r s i o n : h , d e s c r i p t i o n : p , i n s t r u c t i o n s : I , i d e n t i f i e r : m } = l ; i f ( ! ( d & & h ) ) c o n t i n u e ; l e t y = [ ] , T = [ ] , { a p p l i c a b i l i t y : R , r e q u i r e m e n t s : b } = l ; i f ( R ) { l e t { m a x O c c u r s : P , . . . U } = R , Z = A r r a y . i s A r r a y ( U ) ? U : [ U ] ; f o r ( l e t n e o f Z ) f o r ( l e t K i n n e ) { l e t o e = A r r a y . i s A r r a y ( n e [ K ] ) ? n e [ K ] : [ n e [ K ] ] ; i f ( K = = = " e n t i t y " ) { l e t s e = G w e ( t h i s . c o m p o n e n t s , o e ) ; y . p u s h ( . . . s e ) } i f ( K = = = " a t t r i b u t e " ) { l e t s e = V w e ( t h i s . c o m p o n e n t s , o e ) ; y . p u s h ( . . . s e ) } i f ( K = = = " m a t e r i a l " ) { l e t s e = k w e ( t h i s . c o m p o n e n t s , o e ) ; y . p u s h ( . . . s e ) } i f ( K = = = " c l a s s i f i c a t i o n " ) { l e t s e = W w e ( t h i s . c o m p o n e n t s , o e ) ; y . p u s h ( . . . s e ) } i f ( K = = = " p r o p e r t y " ) { l e t s e = z w e ( t h i s . c o m p o n e n t s , o e ) ; y . p u s h ( . . . s e ) } i f ( K = = = " p a r t O f " ) { l e t s e = Y w e ( t h i s . c o m p o n e n t s , o e ) ; y . p u s h ( . . . s e ) } } } l e t A ; i f ( b ) { l e t { m a x O c c u r s : P , . . . U } = b ; A = b . d e s c r i p t i o n ; l e t Z = A r r a y . i s A r r a y ( U ) ? U : [ U ] ; f o r ( l e t n e o f Z ) f o r ( l e t K i n n e ) { l e t o e = A r r a y . i s A r r a y ( n e [
<!-- Made with That Open Engine $ { b0e . release } ( https : //github.com/thatopen/engine_components) -->
2026-04-25 18:24:50 +01:00
< info >
< title > $ { t . title } < / t i t l e >
$ { 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> ` : "" }
< / i n f o >
< specifications >
2026-04-25 18:59:02 +01:00
$ { [ ... n ] . map ( o => o . serialize ( ) ) . join ( `
2026-04-25 18:24:50 +01:00
` )}
< / s p e c i f i c a t i o n s >
2026-04-25 18:59:02 +01:00
< / i d s > ` } } ; L e ( D 0 e , " u u i d " , " 9 f 0 b 9 f 7 8 - 9 b 2 e - 4 8 1 a - b 7 6 6 - 2 f b f d 0 1 f 3 4 2 c " ) ; L e ( D 0 e , " x m l P a r s e r " , n e w M z ( { a l l o w B o o l e a n A t t r i b u t e s : ! 0 , a t t r i b u t e N a m e P r e f i x : " " , i g n o r e A t t r i b u t e s : ! 1 , i g n o r e D e c l a r a t i o n : ! 0 , i g n o r e P i T a g s : ! 0 , n u m b e r P a r s e O p t i o n s : { l e a d i n g Z e r o s : ! 0 , h e x : ! 0 } , p a r s e A t t r i b u t e V a l u e : ! 0 , p r e s e r v e O r d e r : ! 1 , p r o c e s s E n t i t i e s : ! 1 , r e m o v e N S P r e f i x : ! 0 , t r i m V a l u e s : ! 0 } ) ) ; v a r Y 2 e = D 0 e , j 2 e = c l a s s q 2 e e x t e n d s G l { c o n s t r u c t o r ( t ) { s u p e r ( t ) , L e ( t h i s , " e n a b l e d " , ! 0 ) , t . a d d ( q 2 e . u u i d , t h i s ) } s t a t i c d i s t a n c e F r o m P o i n t T o L i n e ( t , i , n , s = ! 1 ) { l e t o = n e w d s , r = n e w y e ; r e t u r n o . s e t ( i , n ) , o . c l o s e s t P o i n t T o P o i n t ( t , s , r ) , r . d i s t a n c e T o ( t ) } r o u n d ( t ) { t . x = M a t h . t r u n c ( t . x * 1 e 3 ) / 1 e 3 , t . y = M a t h . t r u n c ( t . y * 1 e 3 ) / 1 e 3 , t . z = M a t h . t r u n c ( t . z * 1 e 3 ) / 1 e 3 } a s y n c g e t V o l u m e F r o m F r a g m e n t s ( t ) { r e t u r n c o n s o l e . w a r n ( " g e t V o l u m e F r o m F r a g m e n t s i s d e p r e c a t e d . U s e g e t I t e m s V o l u m e i n s t e a d . " ) , t h i s . g e t I t e m s V o l u m e ( t ) } a s y n c g e t I t e m s V o l u m e ( t ) { l e t i = 0 , n = t h i s . c o m p o n e n t s . g e t ( _ s ) ; f o r ( l e t [ s , o ] o f O b j e c t . e n t r i e s ( t ) ) { l e t r = n . l i s t . g e t ( s ) ; r & & ( i + = a w a i t r . g e t I t e m s V o l u m e ( [ . . . o ] ) ) } r e t u r n i } s t a t i c c o n v e r t U n i t s ( t , i , n , s = 2 ) { l e t o = { m : 1 , c m : . 0 1 , m m : . 0 0 1 , k m : 1 e 3 , m 2 : 1 , c m 2 : 1 e - 4 , m m 2 : 1 e - 6 , k m 2 : 1 e 6 , m 3 : 1 , c m 3 : 1 e - 6 , m m 3 : 1 e - 9 , k m 3 : 1 e 9 } ; i f ( ! o [ i ] | | ! o [ n ] ) t h r o w n e w E r r o r ( " I n v a l i d u n i t s p r o v i d e d f o r c o n v e r s i o n . " ) ; i f ( ! N u m b e r . i s I n t e g e r ( s ) | | s < 0 | | s > 5 ) t h r o w n e w E r r o r ( " P r e c i s i o n m u s t b e a n i n t e g e r b e t w e e n 0 a n d 5 . " ) ; l e t r = o [ i ] / o [ n ] , l = t * r , d = 1 0 * * s ; r e t u r n M a t h . r o u n d ( l * d ) / d } } ; L e ( j 2 e , " u u i d " , " 2 6 7 c a 0 3 2 - 6 7 2 f - 4 c b 0 - a f a 9 - d 2 4 e 9 0 4 f 3 9 d 6 " ) ; v a r R W e = j 2 e , C 0 e = ( e , t , i ) = > { l e t n = n e w y e ( - t . z , 0 , t . x ) , s = n e w y e ( t . x + n . x , 0 , t . z + n . z ) . n o r m a l i z e ( ) . m u l t i p l y S c a l a r ( i / 2 ) ; r e t u r n [ e . x + s . x , e . y , e . z + s . z , e . x - s . x , e . y , e . z - s . z ] } , S W e = ( e , t , i ) = > { l e t n = n e w y e ( - t . z , 0 , t . x ) , s = e . x - t . x * i + n . x * i * . 4 , o = e . z - t . z * i + n . z * i * . 4 , r = e . x - t . x * i - n . x * i * . 4 , l = e . z - t . z * i - n . z * i * . 4 ; r e t u r n [ e . x , e . y , e . z , s , e . y , o , e . x , e . y , e . z , r , e . y , l , s , e . y , o , r , e . y , l ] } , x 0 e = ( e , t , i ) = > { l e t n = n e w y e ( - t . z , 0 , t . x ) , s = e . x - t . x * i + n . x * i * . 4 , o = e . z - t . z * i + n . z * i * . 4 , r = e . x - t . x * i - n . x * i * . 4 , l = e . z - t . z * i - n . z * i * . 4 ; r e t u r n [ e . x , e . y , e . z , s , e . y , o , e . x , e . y , e . z , r , e . y , l ] } , $ 2 e = ( ) = > [ ] , A W e = ( e , t , i ) = > { l e t n = i * . 4 , s = 1 2 , o = [ ] ; f o r ( l e t r = 0 ; r < s ; r + + ) { l e t l = r / s * M a t h . P I * 2 , d = ( r + 1 ) / s * M a t h . P I * 2 ; o . p u s h ( e . x + M a t h . c o s ( l ) * n , e . y , e . z + M a t h . s i n ( l ) * n , e . x + M a t h . c o s ( d ) * n , e . y , e . z + M a t h . s i n ( d ) * n ) } r e t u r n o } , b W e = ( e , t , i ) = > { l e t n = i * . 4 , s = 1 6 , o = [ ] ; f o r ( l e t r = 0 ; r < s ; r + + ) { l e t l = r / s * M a t h . P I * 2 , d = ( r + 1 ) / s * M a t h . P I * 2 ; o . p u s h ( e . x , e . y , e . z , e . x + M a t h . c o s ( l ) * n , e . y , e . z + M a t h . s i n ( l ) * n , e . x + M a t h . c o s ( d ) * n , e . y , e . z + M a t h . s i n ( d ) * n ) } r e t u r n o } , N W e = ( e , t , i ) = > { l e t n = n e w y e ( - t . z , 0 , t . x ) , s = i * . 4 , o = e . c l o n e ( ) . a d d S c a l e d V e c t o r ( t , s ) . a d d S c a l e d V e c t o r ( n , s ) , r = e . c l o n e ( ) . a d d S c a l e d V e c t o r ( t , s ) . a d d S c a l e d V e c t o r ( n , - s ) , l = e . c l o n e ( ) . a d d S c a l e d V e c t o r ( t , - s ) . a d d S c a l e d V e c t o r ( n , - s ) , d = e . c l o n e ( ) . a d d S c a l e d V e c t o r ( t , - s ) . a d d S c a l e d V e c t o r ( n , s ) ; r e t u r n [ o . x , o . y , o . z , r . x , r . y , r . z , l . x , l . y , l . z , o . x , o . y , o . z , l . x , l . y , l . z , d . x , d . y , d . z ] } , Z 2 e = ( e , t , i ) = > { l e t n = n e w y e ( - t . z , 0 , t . x ) , s = e . c l o n e ( ) . a d d S c a l e d V e c t o r ( t , - i ) , o = s . c l o n e ( ) . a d d S c a l e d V e c t o r ( n , i * . 4 ) , r = s . c l o n e ( ) . a d d S c a l e d V e c t o r ( n , - i * . 4 ) ; r e t u r n [ e . x , e . y , e . z , o . x , o . y , o . z , r . x , r . y , r . z ] } , e J = c l a s s e x t e n d s f o { c o n s t r u c t o r ( ) { s u p e r ( ) } g e t B y S y s t e m ( t ) { l e t i = n e w M a p ; f o r ( l e t [ n , s ] o f t h i s ) s . s y s t e m = = = t & & i . s e t ( n , s . d a t a ) ; r e t u r n i } } , t J = c l a s s e x t e n d s f o { c o n s t r u c t o r ( t ) { s u p e r ( ) , L e ( t h i s , " _ c o n t a i n e r " ) , t h i s . _ c o n t a i n e r = t , t h i s . d e l e t e G u a r d = i = > i ! = = " 0 " , t h i s . s e t ( " 0 " , { n a m e : " 0 " , v i s i b l e : ! 0 , m a t e r i a l : n e w Q o ( { c o l o r : 0 } ) } ) } c r e a t e ( t , i ) { i f ( ! t h i s . h a s ( t ) ) { l e t n = { n a m e : t , v i s i b l e : i ? . v i s i b l e ? ? ! 0 , m a t e r i a l : i ? . m a t e r i a l ? ? n e w Q o ( { c o l o r : 0 } ) } ; t h i s . s e t ( t , n ) } r e t u r n t h i s . g e t ( t ) } s e t C o l o r ( t , i ) { l e t n = t h i s . g e t ( t ) ; n & & ( n . m a t e r i a l . c o l o r . s e t H e x ( i ) , t h i s . s e t ( t , n ) ) } s e t M a t e r i a l ( t , i ) { l e t n = t h i s . g e t ( t ) ; i f ( ! n ) r e t u r n ; l e t s = n . m a t e r i a l ; n . m a t e r i a l = i , t h i s . _ c o n t a i n e r . t r a v e r s e ( o = > { o . u s e r D a t a . l a y e r = = = t & & ( o . u s e r D a t a . i s D i m e n s i o n | | o . i s L i n e S e g m e n t s & & ( o . m a t e r i a l = i ) ) } ) , s . d i s p o s e ( ) , t h i s . s e t ( t , n ) } s e t V i s i b i l i t y ( t , i ) { l e t n = t h i s . g e t ( t ) ; n & & ( n . v i s i b l e = i , t h i s . _ c o n t a i n e r . t r a v e r s e ( s = > { s . u s e r D a t a . l a y e r = = = t & & ( s . v i s i b l e = i ) } ) , t h i s . s e t ( t , n ) ) } a s s i g n ( t , i ) { l e t n = t h i s . g e t ( i ) ; n & & ( t . u s e r D a t a . l a y e r = i , n . v i s i b l e | | ( t . v i s i b l e = ! 1 ) , t . i s L i n e S e g m e n t s & & ( t . m a t e r i a l = n . m a t e r i a l ) ) } r e s o l v e C o l o r ( t ) { l e t i = t h i s . g e t ( t ) ; i f ( i ) r e t u r n i . m a t e r i a l . c o l o r . g e t H e x ( ) } } , k z = c l a s s t A e x t e n d s Z o { c o n s t r u c t o r ( t ) { s u p e r ( ) , L e ( t h i s , " _ v i e w p o r t " ) , L e ( t h i s , " _ b o r d e r " ) , L e ( t h i s , " _ h a n d l e s " , [ ] ) , L e ( t h i s , " _ r a y c a s t e r " , n e w f p ) , L e ( t h i s , " _ r e s i z a b l e " , ! 1 ) , L e ( t h i s , " _ m o v a b l e
` )+ `
` }},cJ=class{constructor(t){Le(this,"precision",2),Le(this,"config",{trueColor:!1}),Le(this,"_viewport",null),Le(this,"_paperSlot",null),Le(this,"_annotationLayers",new Map),Le(this,"_systemExporters",new Map),this._components=t}registerSystemExporter(t,i){this._systemExporters.set(t,i)}export(t,i){let n=!!i,s=new y0e,o=new Map;for(let p of t)for(let I of p.drawing.layers.values())o.has(I.name)||o.set(I.name,I);let r=[...o.values()],d=this._components.get(X2).systems.get(Gz),h=d?[...d.definitions.keys()]:[];this._writeHeader(s,n),this._writeTables(s,r,h),this._writeBlocks(s,d??null),s.p(0,"SECTION").p(2,"ENTITIES"),n&&i&&this._writePaperBorders(s,i);for(let p of t){p.drawing.three.traverse(I=>{I.userData.isDimension&&I.userData.annotationUuid&&this._annotationLayers.set(I.userData.annotationUuid,I.userData.layer??"0")});for(let I of p.viewports){if(this._viewport=I.viewport??null,n&&I.viewport){let m=I.viewport,y=i.heightMm-2*i.margin;this._paperSlot={x:I.x??0,y:y-(I.y??0),mmPerUnit:1e3/m.drawingScale,vpLeft:m.left,vpTop:m.top}}else this._paperSlot=null;this._writeViewportBorder(s),this._writeRawLines(s,p.drawing),this._writeLinearAnnotations(s,p.drawing),this._writeAngleAnnotations(s,p.drawing),this._writeLeaderAnnotations(s,p.drawing),this._writeSlopeAnnotations(s,p.drawing),this._writeCalloutAnnotations(s,p.drawing),this._writeBlockInsertions(s,p.drawing),this._writeCustomSystems(s,p.drawing)}this._annotationLayers.clear()}return s.p(0,"ENDSEC"),this._writeObjects(s),s.p(0,"EOF"),this._viewport=null,this._paperSlot=null,s.build()}_writeHeader(t,i){t.p(0,"SECTION").p(2,"HEADER"),t.p(9," $ ACADVER").p(1,this.config.trueColor?"AC1018":"AC1015"),t.p(9," $ INSUNITS").p(70,i?4:6),t.p(0,"ENDSEC")}_writeTables(t,i,n){t.p(0,"SECTION").p(2,"TABLES"),t.p(0,"TABLE").p(2,"VPORT").p(70,0).p(0,"ENDTAB"),t.p(0,"TABLE").p(2,"LTYPE").p(70,1),t.p(0,"LTYPE").p(2,"CONTINUOUS").p(70,0).p(3,"Solid line").p(72,65).p(73,0).n(40,0),t.p(0,"ENDTAB"),t.p(0,"TABLE").p(2,"LAYER").p(70,i.length);for(let o of i){let r=XS(o.material.color.getHex());t.p(0,"LAYER").p(2,o.name).p(70,0).p(62,r).p(6,"CONTINUOUS")}t.p(0,"ENDTAB"),t.p(0,"TABLE").p(2,"STYLE").p(70,1),t.p(0,"STYLE").p(2,"STANDARD").p(70,0).n(40,0).n(41,1).n(50,0).p(71,0).n(42,.2).p(3,"txt").p(4,""),t.p(0,"ENDTAB"),t.p(0,"TABLE").p(2,"VIEW").p(70,0).p(0,"ENDTAB"),t.p(0,"TABLE").p(2,"UCS").p(70,0).p(0,"ENDTAB"),t.p(0,"TABLE").p(2,"APPID").p(70,1),t.p(0,"APPID").p(2,"ACAD").p(70,0),t.p(0,"ENDTAB"),t.p(0,"TABLE").p(2,"DIMSTYLE").p(70,0).p(0,"ENDTAB");let s=["*Model_Space","*Paper_Space",...n];t.p(0,"TABLE").p(2,"BLOCK_RECORD").p(70,s.length);for(let o of s)t.p(0,"BLOCK_RECORD").p(5,t.handle()).p(2,o);t.p(0,"ENDTAB"),t.p(0,"ENDSEC")}_writeBlocks(t,i){if(t.p(0,"SECTION").p(2,"BLOCKS"),this._writeBlock(t,"*Model_Space",null),this._writeBlock(t,"*Paper_Space",null),i)for(let[n,s]of i.definitions)this._writeBlock(t,n,s.lines??null);t.p(0,"ENDSEC")}_writeBlock(t,i,n){if(t.p(0,"BLOCK").p(5,t.handle()).p(8,"0").p(2,i).p(70,0).n(10,0).n(20,0).n(30,0).p(3,i).p(1,""),n){let s=this._viewport,o=this._paperSlot;this._viewport=null,this._paperSlot=null,this._writeGeoAsLines(t,n,"0"),this._viewport=s,this._paperSlot=o}t.p(0,"ENDBLK").p(5,t.handle()).p(8,"0")}_writeViewportBorder(t){if(!this._viewport)return;let i=this._viewport,n=this._tx(i.left),s=this._tx(i.right),o=this._ty(-i.bottom),r=this._ty(-i.top);this._writeRawLine(t,n,o,s,o,"0",7),this._writeRawLine(t,s,o,s,r,"0",7),this._writeRawLine(t,s,r,n,r,"0",7),this._writeRawLine(t,n,r,n,o,"0",7)}_writePaperBorders(t,i){let{margin:n,widthMm:s,heightMm:o}=i,r=s-2*n,l=o-2*n;this._writeRawLine(t,0,0,r,0,"0",7),this._writeRawLine(t,r,0,r,l,"0",7),this._writeRawLine(t,r,l,0,l,"0",7),this._writeRawLine(t,0,l,0,0,"0",7),this._writeRawLine(t,-n,-n,r+n,-n,"0",7),this._writeRawLine(t,r+n,-n,r+n,l+n,"0",7),this._writeRawLine(t,r+n,l+n,-n,l+n,"0",7),this._writeRawLine(t,-n,l+n,-n,-n,"0",7)}_writeObjects(t){t.p(0,"SECTION").p(2,"OBJECTS"),t.p(0,"DICTIONARY").p(5,t.handle()).p(330,0).p(100,"AcDbRootDictionary"),t.p(0,"ENDSEC")}_writeRawLines(t,i){i.three.traverse(n=>{var s;if(!(
2026-04-25 18:24:50 +01:00
/ * ! B u n d l e d l i c e n s e i n f o r m a t i o n :
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 :
2026-04-25 18:59:02 +01:00
three / build / three . webgpu . js :
three / build / three . tsl . js :
2026-04-25 18:24:50 +01:00
( * *
* @ license
2026-04-25 18:59:02 +01:00
* Copyright 2010 - 2026 Three . js Authors
2026-04-25 18:24:50 +01:00
* SPDX - License - Identifier : MIT
* )
@ thatopen / fragments / dist / index . mjs :
( * ! pako 2.1 . 0 https : //github.com/nodeca/pako @license (MIT AND Zlib) *)
2026-04-25 18:59:02 +01:00
camera - controls / dist / camera - controls . module . js :
2026-04-25 18:24:50 +01:00
( * !
* camera - controls
* https : //github.com/yomotsu/camera-controls
* ( c ) 2017 @ yomotsu
* Released under the MIT License .
* )
* /