diff --git a/README.md b/README.md index a1726b9..86a0e32 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,9 @@ ioviewer project.glb -o viewer.html ``` Open **Element table** in the viewer and choose `elements.csv`. The viewer reads the file locally and links rows to GLB node -`extras.elementId` values. Search by any part of the element ID or name and narrow the rows by category. Selecting a row +`extras.elementId` values. When both files provide a `uniqueId` for that ID, it must match. The viewer warns about +conflicts and excludes those rows from the table, totals and downloads. Older files without `uniqueId` still match by +`elementId`. Search by any part of the element ID or name and narrow the rows by category. Selecting a row highlights all its 3D placements. Picking in 3D opens the row's page and highlights the row. If the row is outside the current results, it appears above them while the search and category stay active. Click a column heading to sort ascending, then click again to sort descending. Element, category, and type IDs and the quantity columns are sorted numerically, diff --git a/src/IOViewer/Exporters/JsonViewerExporter.cs b/src/IOViewer/Exporters/JsonViewerExporter.cs index a32ad4b..da68f2f 100644 --- a/src/IOViewer/Exporters/JsonViewerExporter.cs +++ b/src/IOViewer/Exporters/JsonViewerExporter.cs @@ -65,6 +65,8 @@ internal sealed class ViewerJsonFile public string Kind { get; set; } = FileKind; public int Format { get; set; } = CurrentFormat; public SceneDocument Scene { get; set; } = new(); + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public Dictionary? GlbUniqueIds { get; set; } public List SectionPlanes { get; set; } = []; public ViewerSectionBox? SectionBox { get; set; } public List HiddenModelKeys { get; set; } = []; @@ -88,6 +90,7 @@ internal sealed class ViewerJsonFile public static ViewerJsonFile From(ViewerDocument doc) => new() { Scene = doc.Scene, + GlbUniqueIds = doc.GlbUniqueIds.Count > 0 ? doc.GlbUniqueIds : null, SectionPlanes = doc.SectionPlanes, SectionBox = doc.SectionBox, HiddenModelKeys = doc.HiddenModelKeys, @@ -104,6 +107,7 @@ internal sealed class ViewerJsonFile public ViewerDocument ToDocument() => new(Scene) { + GlbUniqueIds = GlbUniqueIds ?? [], SectionPlanes = SectionPlanes, SectionBox = SectionBox, HiddenModelKeys = HiddenModelKeys, diff --git a/src/IOViewer/Exporters/ViewerPayloadWriter.cs b/src/IOViewer/Exporters/ViewerPayloadWriter.cs index e66b223..8be4d82 100644 --- a/src/IOViewer/Exporters/ViewerPayloadWriter.cs +++ b/src/IOViewer/Exporters/ViewerPayloadWriter.cs @@ -66,6 +66,7 @@ internal sealed class ViewerPayloadWriter private InstanceViews _lineViews; private readonly Dictionary _pointColors; private readonly Dictionary _pointIntensities; + private readonly Dictionary _glbUniqueIds; private readonly List<(int Element, Vector3d Position, double Yaw, BlobView Image, BlobView? Intensity, string? Name)> _panoramas = []; private readonly List _annotations = []; private readonly List _sheets = []; @@ -79,6 +80,7 @@ private ViewerPayloadWriter(ViewerDocument doc, HtmlViewerOptions options) _bcfTopics = doc.BcfTopics; _pointColors = doc.PointColors; _pointIntensities = doc.PointIntensities; + _glbUniqueIds = doc.GlbUniqueIds; _initialSheetKey = doc.InitialSheetKey; _options = options; } @@ -895,7 +897,19 @@ public void WriteMeta(Stream output) w.WriteString("author", host?.Author ?? "IOViewer"); w.WriteString("createdAt", host?.CreatedAt ?? DateTimeOffset.UtcNow.ToString("O", CultureInfo.InvariantCulture)); if (_scene.Models.Count == 1 && host?.SourceFormat == "glb" && _scene.Elements.Any(el => el.SourceId is not null)) + { w.WriteBoolean("elementCsv", true); + if (_glbUniqueIds.Count > 0) + { + w.WriteStartObject("glbUniqueIds"); + foreach (var (elementId, uniqueId) in _glbUniqueIds) + { + w.WriteString(elementId.ToString(CultureInfo.InvariantCulture), uniqueId); + FlushIfLarge(w); + } + w.WriteEndObject(); + } + } WriteVector(w, "rtcOffset", _rtcOffset); WriteBox(w, "bbox", _bounds, _rtcOffset); diff --git a/src/IOViewer/Importers/GlbViewerImporter.cs b/src/IOViewer/Importers/GlbViewerImporter.cs index cec20b8..a0f7b83 100644 --- a/src/IOViewer/Importers/GlbViewerImporter.cs +++ b/src/IOViewer/Importers/GlbViewerImporter.cs @@ -76,6 +76,7 @@ private static ViewerDocument Load(Stream stream, string documentTitle, string m var doc = new SceneDocument { Title = documentTitle }; doc.Models.Add(new SceneModel { Id = 1, Key = modelKey, Name = documentTitle, Path = path, SourceFormat = "glb" }); + var viewer = new ViewerDocument(doc); using var jsonDoc = JsonDocument.Parse(jsonText); var root = jsonDoc.RootElement; @@ -94,7 +95,7 @@ private static ViewerDocument Load(Stream stream, string documentTitle, string m !root.TryGetProperty("bufferViews", out var bufferViewsEl) || binBuffer is null) { - return new ViewerDocument(doc); + return viewer; } var bufferViews = bufferViewsEl.EnumerateArray().ToArray(); @@ -256,10 +257,16 @@ void Instantiate(int meshIndex, Transform3d world, string? nodeName, int? source var node = nodes[nodeIndex]; var world = ReadNodeTransform(node).Then(parentWorld); + var (sourceId, uniqueId) = ReadIdentity(node); + if (sourceId is int id && uniqueId is not null + && !viewer.GlbUniqueIds.TryAdd(id, uniqueId) && viewer.GlbUniqueIds[id] != uniqueId) + { + viewer.GlbUniqueIds[id] = null; + } if (node.TryGetProperty("mesh", out var meshProp)) { Instantiate(meshProp.GetInt32(), world, - node.TryGetProperty("name", out var nodeName) ? nodeName.GetString() : null, ReadElementId(node)); + node.TryGetProperty("name", out var nodeName) ? nodeName.GetString() : null, sourceId); } if (node.TryGetProperty("children", out var children)) @@ -275,13 +282,19 @@ void Instantiate(int meshIndex, Transform3d world, string? nodeName, int? source for (int i = 0; i < meshElements.Length; i++) Instantiate(i, Transform3d.Identity, null, null); } - return new ViewerDocument(doc); + return viewer; } - private static int? ReadElementId(JsonElement node) => - node.TryGetProperty("extras", out var extras) && extras.ValueKind == JsonValueKind.Object - && extras.TryGetProperty("elementId", out var id) && id.ValueKind == JsonValueKind.Number && id.TryGetInt32(out int value) - ? value : null; + private static (int? ElementId, string? UniqueId) ReadIdentity(JsonElement node) + { + if (!node.TryGetProperty("extras", out var extras) || extras.ValueKind != JsonValueKind.Object + || !extras.TryGetProperty("elementId", out var id) || id.ValueKind != JsonValueKind.Number || !id.TryGetInt32(out int value)) + return (null, null); + + string? uniqueId = extras.TryGetProperty("uniqueId", out var unique) && unique.ValueKind == JsonValueKind.String + ? unique.GetString() : null; + return (value, string.IsNullOrWhiteSpace(uniqueId) ? null : uniqueId); + } // The sRGB byte of a linear channel: the standard sRGB transfer function, then the nearest byte. private static byte Srgb(double linear) diff --git a/src/IOViewer/Model/ViewerDocument.cs b/src/IOViewer/Model/ViewerDocument.cs index f0ed8a0..d66fd50 100644 --- a/src/IOViewer/Model/ViewerDocument.cs +++ b/src/IOViewer/Model/ViewerDocument.cs @@ -29,6 +29,9 @@ public ViewerDocument(SceneDocument scene) /// The model data. public SceneDocument Scene { get; set; } = new(); + // Keyed by GLB extras.elementId, including nodes without geometry. Null marks conflicting UniqueIds in the GLB. + internal Dictionary GlbUniqueIds { get; set; } = []; + /// Cutting planes active at start. public List SectionPlanes { get; set; } = []; diff --git a/src/IOViewer/Viewer/dist/viewer.js b/src/IOViewer/Viewer/dist/viewer.js index a234b51..225f4dc 100644 --- a/src/IOViewer/Viewer/dist/viewer.js +++ b/src/IOViewer/Viewer/dist/viewer.js @@ -1,10 +1,10 @@ -(()=>{var pu=i=>{throw TypeError(i)};var Hl=(i,t,e)=>t.has(i)||pu("Cannot "+e);var di=(i,t,e)=>(Hl(i,t,"read from private field"),e?e.call(i):t.get(i)),Vl=(i,t,e)=>t.has(i)?pu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),mu=(i,t,e,n)=>(Hl(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),to=(i,t,e)=>(Hl(i,t,"access private method"),e);var Zu=0,Mc=1,Ku=2;var yr=1,Ju=2,Ps=3,Yn=0,ze=1,ke=2,$n=0,Ls=1,bc=2,Sc=3,wc=4,ju=5;var Gi=100,Qu=101,td=102,ed=103,nd=104,id=200,sd=201,rd=202,od=203,Ec=204,Tc=205,ad=206,ld=207,cd=208,hd=209,ud=210,dd=211,fd=212,pd=213,md=214,Lo=0,Do=1,No=2,_s=3,Uo=4,Fo=5,Bo=6,Oo=7,Mr=0,gd=1,_d=2,En=0,Ac=1,Rc=2,Cc=3,Ic=4,Pc=5,Lc=6,Dc=7;var Nc=300,bi=301,Wi=302,ua=303,da=304,br=306,xs=1e3,Bn=1001,zo=1002,Le=1003,xd=1004;var Sr=1005;var qe=1006,fa=1007;var Si=1008;var rn=1009,Uc=1010,Fc=1011,Ds=1012,pa=1013,Tn=1014,Ye=1015,An=1016,ma=1017,ga=1018,Ns=1020,Bc=35902,Oc=35899,zc=1021,kc=1022,je=1023,On=1026,wi=1027,Us=1028,_a=1029,Ei=1030,xa=1031;var va=1033,wr=33776,Er=33777,Tr=33778,Ar=33779,ya=35840,Ma=35841,ba=35842,Sa=35843,wa=36196,Ea=37492,Ta=37496,Aa=37488,Ra=37489,Rr=37490,Ca=37491,Ia=37808,Pa=37809,La=37810,Da=37811,Na=37812,Ua=37813,Fa=37814,Ba=37815,Oa=37816,za=37817,ka=37818,Ha=37819,Va=37820,Ga=37821,Wa=36492,Xa=36494,qa=36495,Ya=36283,$a=36284,Cr=36285,Za=36286;var nr=2300,ko=2301,Co=2302,dc=2303,fc=2400,pc=2401,mc=2402;var vd=3200;var Ir=0,yd=1,ai="",me="srgb",ir="srgb-linear",sr="linear",fe="srgb";var Io=7680;var Hc=34055,Vc=34056;var Gc=517;var Md=519,bd=512,Sd=513,wd=514,Ka=515,Ed=516,Td=517,Ja=518,Ad=519,Wc=35044,Pr=35048;var Xc="300 es",bn=2e3,vs=2001;function Mm(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function bm(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ys(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Rd(){let i=ys("canvas");return i.style.display="block",i}var gu={},Ms=null;function rr(...i){let t="THREE."+i.shift();Ms?Ms("log",t,...i):console.log(t,...i)}function Cd(i){let t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Gt(...i){i=Cd(i);let t="THREE."+i.shift();if(Ms)Ms("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Yt(...i){i=Cd(i);let t="THREE."+i.shift();if(Ms)Ms("error",t,...i);else{let e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Fi(...i){let t=i.join(" ");t in gu||(gu[t]=!0,Gt(...i))}function Id(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var Pd={[Lo]:Do,[No]:Bo,[Uo]:Oo,[_s]:Fo,[Do]:Lo,[Bo]:No,[Oo]:Uo,[Fo]:_s},zn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,o=s.length;r>8&255]+Ze[i>>16&255]+Ze[i>>24&255]+"-"+Ze[t&255]+Ze[t>>8&255]+"-"+Ze[t>>16&15|64]+Ze[t>>24&255]+"-"+Ze[e&63|128]+Ze[e>>8&255]+"-"+Ze[e>>16&255]+Ze[e>>24&255]+Ze[n&255]+Ze[n>>8&255]+Ze[n>>16&255]+Ze[n>>24&255]).toLowerCase()}function se(i,t,e){return Math.max(t,Math.min(e,i))}function qc(i,t){return(i%t+t)%t}function Sm(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function wm(i,t,e){return i!==t?(e-i)/(t-i):0}function er(i,t,e){return(1-e)*i+e*t}function Em(i,t,e,n){return er(i,t,1-Math.exp(-e*n))}function Tm(i,t=1){return t-Math.abs(qc(i,t*2)-t)}function Am(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Rm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Cm(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Im(i,t){return i+Math.random()*(t-i)}function Pm(i){return i*(.5-Math.random())}function Lm(i){i!==void 0&&(_u=i);let t=_u+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Dm(i){return i*ms}function Nm(i){return i*bs}function Um(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function Fm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Bm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Om(i,t,e,n,s){let r=Math.cos,o=Math.sin,a=r(e/2),l=o(e/2),c=r((t+n)/2),h=o((t+n)/2),d=r((t-n)/2),u=o((t-n)/2),f=r((n-t)/2),m=o((n-t)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*m,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*m,a*c);break;case"ZYZ":i.set(l*m,l*f,a*h,a*c);break;default:Gt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Mn(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function pe(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var ae={DEG2RAD:ms,RAD2DEG:bs,generateUUID:si,clamp:se,euclideanModulo:qc,mapLinear:Sm,inverseLerp:wm,lerp:er,damp:Em,pingpong:Tm,smoothstep:Am,smootherstep:Rm,randInt:Cm,randFloat:Im,randFloatSpread:Pm,seededRandom:Lm,degToRad:Dm,radToDeg:Nm,isPowerOfTwo:Um,ceilPowerOfTwo:Fm,floorPowerOfTwo:Bm,setQuaternionFromProperEuler:Om,normalize:pe,denormalize:Mn},Jc=class Jc{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=se(this.x,t.x,e.x),this.y=se(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=se(this.x,t,e),this.y=se(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(se(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(se(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*s+t.x,this.y=r*s+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Jc.prototype.isVector2=!0;var qt=Jc,Fe=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],m=r[o+2],_=r[o+3];if(d!==_||l!==u||c!==f||h!==m){let g=l*u+c*f+h*m+d*_;g<0&&(u=-u,f=-f,m=-m,_=-_,g=-g);let p=1-a;if(g<.9995){let y=Math.acos(g),E=Math.sin(y);p=Math.sin(p*y)/E,a=Math.sin(a*y)/E,l=l*p+u*a,c=c*p+f*a,h=h*p+m*a,d=d*p+_*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+m*a,d=d*p+_*a;let y=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=y,c*=y,h*=y,d*=y}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],m=r[o+3];return t[e]=a*m+h*d+l*f-c*u,t[e+1]=l*m+h*u+c*d-a*f,t[e+2]=c*m+h*f+a*u-l*d,t[e+3]=h*m-a*d-l*u-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),m=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d-u*f*m;break;case"YXZ":this._x=u*h*d+c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d+u*f*m;break;case"ZXY":this._x=u*h*d-c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d-u*f*m;break;case"ZYX":this._x=u*h*d-c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d+u*f*m;break;case"YZX":this._x=u*h*d+c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d-u*f*m;break;case"XZY":this._x=u*h*d-c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d+u*f*m;break;default:Gt("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],d=e[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(se(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-e;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},jc=class jc{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(xu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(xu.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*s-a*n),h=2*(a*e-r*s),d=2*(r*n-o*e);return this.x=e+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=se(this.x,t.x,e.x),this.y=se(this.y,t.y,e.y),this.z=se(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=se(this.x,t,e),this.y=se(this.y,t,e),this.z=se(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(se(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,o=e.x,a=e.y,l=e.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Gl.copy(this).projectOnVector(t),this.sub(Gl)}reflect(t){return this.sub(Gl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(se(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};jc.prototype.isVector3=!0;var C=jc,Gl=new C,xu=new Fe,Qc=class Qc{constructor(t,e,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,o,a,l,c)}set(t,e,n,s,r,o,a,l,c){let h=this.elements;return h[0]=t,h[1]=s,h[2]=a,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],m=n[8],_=s[0],g=s[3],p=s[6],y=s[1],E=s[4],M=s[7],x=s[2],S=s[5],A=s[8];return r[0]=o*_+a*y+l*x,r[3]=o*g+a*E+l*S,r[6]=o*p+a*M+l*A,r[1]=c*_+h*y+d*x,r[4]=c*g+h*E+d*S,r[7]=c*p+h*M+d*A,r[2]=u*_+f*y+m*x,r[5]=u*g+f*E+m*S,r[8]=u*p+f*M+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,m=e*d+n*u+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/m;return t[0]=d*_,t[1]=(s*c-h*n)*_,t[2]=(a*n-s*o)*_,t[3]=u*_,t[4]=(h*e-s*l)*_,t[5]=(s*r-a*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(o*e-n*r)*_,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-s*c,s*l,-s*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return Fi("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Wl.makeScale(t,e)),this}rotate(t){return Fi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Wl.makeRotation(-t)),this}translate(t,e){return Fi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Wl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};Qc.prototype.isMatrix3=!0;var Kt=Qc,Wl=new Kt,vu=new Kt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),yu=new Kt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zm(){let i={enabled:!0,workingColorSpace:ir,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===fe&&(s.r=ri(s.r),s.g=ri(s.g),s.b=ri(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===fe&&(s.r=gs(s.r),s.g=gs(s.g),s.b=gs(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===ai?sr:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Fi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Fi("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[ir]:{primaries:t,whitePoint:n,transfer:sr,toXYZ:vu,fromXYZ:yu,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:me},outputColorSpaceConfig:{drawingBufferColorSpace:me}},[me]:{primaries:t,whitePoint:n,transfer:fe,toXYZ:vu,fromXYZ:yu,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:me}}}),i}var ie=zm();function ri(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function gs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ts,Ho=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{ts===void 0&&(ts=ys("canvas")),ts.width=t.width,ts.height=t.height;let s=ts.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=ts}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=ys("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let o=0;o1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(ql).x}get height(){return this.source.getSize(ql).y}get depth(){return this.source.getSize(ql).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){Gt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Gt(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Nc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case xs:t.x=t.x-Math.floor(t.x);break;case Bn:t.x=t.x<0?0:1;break;case zo:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case xs:t.y=t.y-Math.floor(t.y);break;case Bn:t.y=t.y<0?0:1;break;case zo:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};We.DEFAULT_IMAGE=null;We.DEFAULT_MAPPING=Nc;We.DEFAULT_ANISOTROPY=1;var th=class th{constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*s+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,l=t.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],m=l[9],_=l[2],g=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let E=(c+1)/2,M=(f+1)/2,x=(p+1)/2,S=(h+u)/4,A=(d+_)/4,v=(m+g)/4;return E>M&&E>x?E<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(E),s=S/n,r=A/n):M>x?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=S/s,r=v/s):x<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(x),n=A/r,s=v/r),this.set(n,s,r,e),this}let y=Math.sqrt((g-m)*(g-m)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(d-_)/y,this.z=(u-h)/y,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=se(this.x,t.x,e.x),this.y=se(this.y,t.y,e.y),this.z=se(this.z,t.z,e.z),this.w=se(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=se(this.x,t,e),this.y=se(this.y,t,e),this.z=se(this.z,t,e),this.w=se(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(se(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};th.prototype.isVector4=!0;var ve=th,Vo=class extends zn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qe,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new ve(0,0,t,e),this.scissorTest=!1,this.viewport=new ve(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new We(s),o=n.count;for(let a=0;a1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;nf+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&u<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:t,target:this})));a!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent($m)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Re;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Ld={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},pi={h:0,s:0,l:0},io={h:0,s:0,l:0};function $l(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var Vt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=me){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,ie.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=ie.workingColorSpace){return this.r=t,this.g=e,this.b=n,ie.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=ie.workingColorSpace){if(t=qc(t,1),e=se(e,0,1),n=se(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=$l(o,r,t+1/3),this.g=$l(o,r,t),this.b=$l(o,r,t-1/3)}return ie.colorSpaceToWorking(this,s),this}setStyle(t,e=me){function n(r){r!==void 0&&parseFloat(r)<1&&Gt("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Gt("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(r,16),e);Gt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=me){let n=Ld[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Gt("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ri(t.r),this.g=ri(t.g),this.b=ri(t.b),this}copyLinearToSRGB(t){return this.r=gs(t.r),this.g=gs(t.g),this.b=gs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=me){return ie.workingToColorSpace(Ke.copy(this),t),Math.round(se(Ke.r*255,0,255))*65536+Math.round(se(Ke.g*255,0,255))*256+Math.round(se(Ke.b*255,0,255))}getHexString(t=me){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ie.workingColorSpace){ie.workingToColorSpace(Ke.copy(this),e);let n=Ke.r,s=Ke.g,r=Ke.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){vn.subVectors(s,e),Qn.subVectors(n,e),Zl.subVectors(t,e);let o=vn.dot(vn),a=vn.dot(Qn),l=vn.dot(Zl),c=Qn.dot(Qn),h=Qn.dot(Zl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,m=(o*h-a*l)*u;return r.set(1-f-m,m,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,ti)===null?!1:ti.x>=0&&ti.y>=0&&ti.x+ti.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,ti)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,ti.x),l.addScaledVector(o,ti.y),l.addScaledVector(a,ti.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return Ql.setScalar(0),tc.setScalar(0),ec.setScalar(0),Ql.fromBufferAttribute(t,e),tc.fromBufferAttribute(t,n),ec.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(Ql,r.x),o.addScaledVector(tc,r.y),o.addScaledVector(ec,r.z),o}static isFrontFacing(t,e,n,s){return vn.subVectors(n,e),Qn.subVectors(t,e),vn.cross(Qn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return vn.subVectors(this.c,this.b),Qn.subVectors(this.a,this.b),vn.cross(Qn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,o,a;ss.subVectors(s,n),rs.subVectors(r,n),Kl.subVectors(t,n);let l=ss.dot(Kl),c=rs.dot(Kl);if(l<=0&&c<=0)return e.copy(n);Jl.subVectors(t,s);let h=ss.dot(Jl),d=rs.dot(Jl);if(h>=0&&d<=h)return e.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(ss,o);jl.subVectors(t,r);let f=ss.dot(jl),m=rs.dot(jl);if(m>=0&&f<=m)return e.copy(r);let _=f*c-l*m;if(_<=0&&c>=0&&m<=0)return a=c/(c-m),e.copy(n).addScaledVector(rs,a);let g=h*m-f*d;if(g<=0&&d-h>=0&&f-m>=0)return Ru.subVectors(r,s),a=(d-h)/(d-h+(f-m)),e.copy(s).addScaledVector(Ru,a);let p=1/(g+_+u);return o=_*p,a=u*p,e.copy(n).addScaledVector(ss,o).addScaledVector(rs,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},oe=class{constructor(t=new C(1/0,1/0,1/0),e=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,yn),yn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Zs),ro.subVectors(this.max,Zs),os.subVectors(t.a,Zs),as.subVectors(t.b,Zs),ls.subVectors(t.c,Zs),mi.subVectors(as,os),gi.subVectors(ls,as),Li.subVectors(os,ls);let e=[0,-mi.z,mi.y,0,-gi.z,gi.y,0,-Li.z,Li.y,mi.z,0,-mi.x,gi.z,0,-gi.x,Li.z,0,-Li.x,-mi.y,mi.x,0,-gi.y,gi.x,0,-Li.y,Li.x,0];return!nc(e,os,as,ls,ro)||(e=[1,0,0,0,1,0,0,0,1],!nc(e,os,as,ls,ro))?!1:(oo.crossVectors(mi,gi),e=[oo.x,oo.y,oo.z],nc(e,os,as,ls,ro))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,yn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(yn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ei[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ei[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ei[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ei[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ei[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ei[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ei[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ei[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ei),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},ei=[new C,new C,new C,new C,new C,new C,new C,new C],yn=new C,so=new oe,os=new C,as=new C,ls=new C,mi=new C,gi=new C,Li=new C,Zs=new C,ro=new C,oo=new C,Di=new C;function nc(i,t,e,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Di.fromArray(i,r);let a=s.x*Math.abs(Di.x)+s.y*Math.abs(Di.y)+s.z*Math.abs(Di.z),l=t.dot(Di),c=e.dot(Di),h=n.dot(Di);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Ne=new C,ao=new qt,Zm=0,xe=class extends zn{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Zm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Wc,this.updateRanges=[],this.gpuType=Ye,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ks.subVectors(t,this.center);let e=Ks.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ks,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ic.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ks.copy(t.center).add(ic)),this.expandByPoint(Ks.copy(t.center).sub(ic))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},Jm=0,fn=new Zt,sc=new Xe,cs=new C,an=new oe,Js=new oe,Ge=new C,he=class i extends zn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Jm++}),this.uuid=si(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Mm(t)?lr:ar)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Kt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return fn.makeRotationFromQuaternion(t),this.applyMatrix4(fn),this}rotateX(t){return fn.makeRotationX(t),this.applyMatrix4(fn),this}rotateY(t){return fn.makeRotationY(t),this.applyMatrix4(fn),this}rotateZ(t){return fn.makeRotationZ(t),this.applyMatrix4(fn),this}translate(t,e,n){return fn.makeTranslation(t,e,n),this.applyMatrix4(fn),this}scale(t,e,n){return fn.makeScale(t,e,n),this.applyMatrix4(fn),this}lookAt(t){return sc.lookAt(t),sc.updateMatrix(),this.applyMatrix4(sc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cs).negate(),this.translate(cs.x,cs.y,cs.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;se.count&&Gt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new oe);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let c=n[l];t.data.attributes[l]=c.toJSON(t.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(e))}let r=t.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u1)?null:e.copy(t.start).addScaledVector(s,o)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||Qm.getNormalMatrix(t),s=this.coplanarPoint(rc).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(t){return this.normal.fromArray(t.normal),this.constant=t.constant,this}},tg=0,Sn=class extends zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:tg++}),this.uuid=si(),this.name="",this.type="Material",this.blending=Ls,this.side=Yn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ec,this.blendDst=Tc,this.blendEquation=Gi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=_s,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Md,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Io,this.stencilZFail=Io,this.stencilZPass=Io,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){Gt(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Gt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(e){let r=s(t.textures),o=s(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new Vt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.retroreflectivity!==void 0&&(this.retroreflectivity=t.retroreflectivity),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.clippingPlanes!==void 0&&(this.clippingPlanes=t.clippingPlanes.map(n=>new Ae().fromJSON(n))),t.clipIntersection!==void 0&&(this.clipIntersection=t.clipIntersection),t.clipShadows!==void 0&&(this.clipShadows=t.clipShadows),t.depthPacking!==void 0&&(this.depthPacking=t.depthPacking),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.linecap!==void 0&&(this.linecap=t.linecap),t.linejoin!==void 0&&(this.linejoin=t.linejoin),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new qt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new qt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};var ni=new C,oc=new C,lo=new C,co=new C,Bi=class{constructor(t=new C,e=new C(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ni)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=ni.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ni.copy(this.origin).addScaledVector(this.direction,e),ni.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){oc.copy(t).add(e).multiplyScalar(.5),lo.copy(e).sub(t).normalize(),co.copy(this.origin).sub(oc);let r=t.distanceTo(e)*.5,o=-this.direction.dot(lo),a=co.dot(this.direction),l=-co.dot(lo),c=co.lengthSq(),h=Math.abs(1-o*o),d,u,f,m;if(h>0)if(d=o*l-a,u=o*a-l,m=r*h,d>=0)if(u>=-m)if(u<=m){let _=1/h;d*=_,u*=_,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-m?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=m?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(oc).addScaledVector(lo,u),f}intersectSphere(t,e){if(t.radius<0)return null;ni.subVectors(t.center,this.origin);let n=ni.dot(this.direction),s=ni.dot(ni)-n*n,r=t.radius*t.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,s=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,s=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,o=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,o=(t.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(t.min.z-u.z)*d,l=(t.max.z-u.z)*d):(a=(t.max.z-u.z)*d,l=(t.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,ni)!==null}intersectTriangle(t,e,n,s,r){let o=this.origin,a=this.direction,l=a.x,c=a.y,h=a.z,d=t.x-o.x,u=t.y-o.y,f=t.z-o.z,m=e.x-o.x,_=e.y-o.y,g=e.z-o.z,p=n.x-o.x,y=n.y-o.y,E=n.z-o.z,M=Math.abs(l),x=Math.abs(c),S=Math.abs(h),A,v,w,R,L,N,B,D,F,H,V,k;if(M>=x&&M>=S?(w=l,N=d,F=m,k=p,l>=0?(A=c,v=h,R=u,L=f,B=_,D=g,H=y,V=E):(A=h,v=c,R=f,L=u,B=g,D=_,H=E,V=y)):x>=S?(w=c,N=u,F=_,k=y,c>=0?(A=h,v=l,R=f,L=d,B=g,D=m,H=E,V=p):(A=l,v=h,R=d,L=f,B=m,D=g,H=p,V=E)):(w=h,N=f,F=g,k=E,h>=0?(A=l,v=c,R=d,L=u,B=m,D=_,H=p,V=y):(A=c,v=l,R=u,L=d,B=_,D=m,H=y,V=p)),w===0)return null;let U=A/w,O=v/w,Y=1/w,G=R-U*N,J=L-O*N,rt=B-U*F,nt=D-O*F,it=H-U*k,z=V-O*k,$=it*nt-z*rt,st=G*z-J*it,gt=rt*J-nt*G;if(s){if($<0||st<0||gt<0)return null}else if(($<0||st<0||gt<0)&&($>0||st>0||gt>0))return null;let ht=$+st+gt;if(ht===0)return null;let _t=Y*($*N+st*F+gt*k);return(ht>0?_t<0:_t>0)?null:this.at(_t/ht,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Je=class extends Sn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.combine=Mr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},Cu=new Zt,Ni=new Bi,ho=new Oe,Iu=new C,uo=new C,fo=new C,po=new C,ac=new C,mo=new C,Pu=new C,go=new C,ge=class extends Xe{constructor(t=new he,e=new Je){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r(t.far-t.near)**2))&&(Cu.copy(r).invert(),Ni.copy(t.ray).applyMatrix4(Cu),!(n.boundingBox!==null&&Ni.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Ni)))}_computeIntersections(t,e,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,_=u.length;m<_;m++){let g=u[m],p=o[g.materialIndex],y=Math.max(g.start,f.start),E=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let M=y,x=E;Me.far?null:{distance:c,point:go.clone(),object:i}}function _o(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,uo),i.getVertexPosition(l,fo),i.getVertexPosition(c,po);let h=eg(i,t,e,n,uo,fo,po,Pu);if(h){let d=new C;ii.getBarycoord(Pu,uo,fo,po,d),s&&(h.uv=ii.getInterpolatedAttribute(s,a,l,c,d,new qt)),r&&(h.uv1=ii.getInterpolatedAttribute(r,a,l,c,d,new qt)),o&&(h.normal=ii.getInterpolatedAttribute(o,a,l,c,d,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new C,materialIndex:0};ii.getNormal(uo,fo,po,u.normal),h.face=u,h.barycoord=d}return h}var mn=class extends We{constructor(t=null,e=1,n=1,s,r,o,a,l,c=Le,h=Le,d,u){super(null,o,a,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var oi=class extends xe{constructor(t,e,n,s=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},hs=new Zt,Lu=new Zt,xo=[],Du=new oe,ng=new Zt,js=new ge,Qs=new Oe,xi=class extends ge{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new oi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s0?t.max.x:t.min.x,vo.y=s.normal.y>0?t.max.y:t.min.y,vo.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(vo)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var sn=class extends Sn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Vt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},Xo=new C,qo=new C,Nu=new Zt,tr=new Bi,yo=new Oe,lc=new C,Uu=new C,Oi=class extends Xe{constructor(t=new he,e=new sn){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rn)return;lc.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(lc);if(!(ct.far))return{distance:c,point:Uu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Fu=new C,Bu=new C,ln=class extends Oi{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rs.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var cr=class extends We{constructor(t=[],e=bi,n,s,r,o,a,l,c,h){super(t,e,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},hr=class extends We{constructor(t,e,n,s,r,o,a,l,c){super(t,e,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var Gn=class extends We{constructor(t,e,n=Tn,s,r,o,a=Le,l=Le,c,h=On,d=1){if(h!==On&&h!==wi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:t,height:e,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ss(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},Yo=class extends Gn{constructor(t,e=Tn,n=bi,s,r,o=Le,a=Le,l,c=On){let h={width:t,height:t,depth:1},d=[h,h,h,h,h,h];super(t,t,e,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}},ur=class extends We{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},gn=class i extends he{constructor(t=1,e=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],d=[],u=0,f=0;m("z","y","x",-1,-1,n,e,t,o,r,0),m("z","y","x",1,-1,n,e,-t,o,r,1),m("x","z","y",1,1,t,n,e,s,o,2),m("x","z","y",1,-1,t,n,-e,s,o,3),m("x","y","z",1,-1,t,e,n,s,r,4),m("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new we(c,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(d,2));function m(_,g,p,y,E,M,x,S,A,v,w){let R=M/A,L=x/v,N=M/2,B=x/2,D=S/2,F=A+1,H=v+1,V=0,k=0,U=new C;for(let O=0;O0?1:-1,h.push(U.x,U.y,U.z),d.push(G/A),d.push(1-O/v),V+=1}}for(let O=0;O0&&E(!0),e>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new we(d,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(f,2));function y(){let M=new C,x=new C,S=0,A=(e-t)/n;for(let v=0;v<=r;v++){let w=[],R=v/r,L=R*(e-t)+t;for(let N=0;N<=s;N++){let B=N/s,D=B*l+a,F=Math.sin(D),H=Math.cos(D);x.x=L*F,x.y=-R*n+g,x.z=L*H,d.push(x.x,x.y,x.z),M.set(F,A,H).normalize(),u.push(M.x,M.y,M.z),f.push(B,1-R),w.push(m++)}_.push(w)}for(let v=0;v0||w!==0)&&(h.push(R,L,B),S+=3),(e>0||w!==r-1)&&(h.push(L,N,B),S+=3)}c.addGroup(p,S,0),p+=S}function E(M){let x=m,S=new qt,A=new C,v=0,w=M===!0?t:e,R=M===!0?1:-1;for(let N=1;N<=s;N++)d.push(0,g*R,0),u.push(0,R,0),f.push(.5,.5),m++;let L=m;for(let N=0;N<=s;N++){let D=N/s*l+a,F=Math.cos(D),H=Math.sin(D);A.x=w*H,A.y=g*R,A.z=w*F,d.push(A.x,A.y,A.z),u.push(0,R,0),S.x=F*.5+.5,S.y=H*.5*R+.5,f.push(S.x,S.y),m++}for(let N=0;N0)&&f.push(E,M,S),(p!==n-1||l{var gu=i=>{throw TypeError(i)};var Hl=(i,t,e)=>t.has(i)||gu("Cannot "+e);var di=(i,t,e)=>(Hl(i,t,"read from private field"),e?e.call(i):t.get(i)),Vl=(i,t,e)=>t.has(i)?gu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),_u=(i,t,e,n)=>(Hl(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),to=(i,t,e)=>(Hl(i,t,"access private method"),e);var Ju=0,Mc=1,ju=2;var yr=1,Qu=2,Ps=3,Yn=0,ze=1,ke=2,$n=0,Ls=1,bc=2,Sc=3,wc=4,td=5;var Wi=100,ed=101,nd=102,id=103,sd=104,rd=200,od=201,ad=202,ld=203,Ec=204,Tc=205,cd=206,hd=207,ud=208,dd=209,fd=210,pd=211,md=212,gd=213,_d=214,Lo=0,Do=1,No=2,_s=3,Uo=4,Fo=5,Bo=6,Oo=7,Mr=0,xd=1,vd=2,En=0,Ac=1,Rc=2,Cc=3,Ic=4,Pc=5,Lc=6,Dc=7;var Nc=300,bi=301,Xi=302,ua=303,da=304,br=306,xs=1e3,Bn=1001,zo=1002,Le=1003,yd=1004;var Sr=1005;var qe=1006,fa=1007;var Si=1008;var rn=1009,Uc=1010,Fc=1011,Ds=1012,pa=1013,Tn=1014,Ye=1015,An=1016,ma=1017,ga=1018,Ns=1020,Bc=35902,Oc=35899,zc=1021,kc=1022,je=1023,On=1026,wi=1027,Us=1028,_a=1029,Ei=1030,xa=1031;var va=1033,wr=33776,Er=33777,Tr=33778,Ar=33779,ya=35840,Ma=35841,ba=35842,Sa=35843,wa=36196,Ea=37492,Ta=37496,Aa=37488,Ra=37489,Rr=37490,Ca=37491,Ia=37808,Pa=37809,La=37810,Da=37811,Na=37812,Ua=37813,Fa=37814,Ba=37815,Oa=37816,za=37817,ka=37818,Ha=37819,Va=37820,Ga=37821,Wa=36492,Xa=36494,qa=36495,Ya=36283,$a=36284,Cr=36285,Za=36286;var nr=2300,ko=2301,Co=2302,dc=2303,fc=2400,pc=2401,mc=2402;var Md=3200;var Ir=0,bd=1,ai="",me="srgb",ir="srgb-linear",sr="linear",fe="srgb";var Io=7680;var Hc=34055,Vc=34056;var Gc=517;var Sd=519,wd=512,Ed=513,Td=514,Ka=515,Ad=516,Rd=517,Ja=518,Cd=519,Wc=35044,Pr=35048;var Xc="300 es",bn=2e3,vs=2001;function bm(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Sm(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ys(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Id(){let i=ys("canvas");return i.style.display="block",i}var xu={},Ms=null;function rr(...i){let t="THREE."+i.shift();Ms?Ms("log",t,...i):console.log(t,...i)}function Pd(i){let t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Wt(...i){i=Pd(i);let t="THREE."+i.shift();if(Ms)Ms("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function $t(...i){i=Pd(i);let t="THREE."+i.shift();if(Ms)Ms("error",t,...i);else{let e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Bi(...i){let t=i.join(" ");t in xu||(xu[t]=!0,Wt(...i))}function Ld(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var Dd={[Lo]:Do,[No]:Bo,[Uo]:Oo,[_s]:Fo,[Do]:Lo,[Bo]:No,[Oo]:Uo,[Fo]:_s},zn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,o=s.length;r>8&255]+Ze[i>>16&255]+Ze[i>>24&255]+"-"+Ze[t&255]+Ze[t>>8&255]+"-"+Ze[t>>16&15|64]+Ze[t>>24&255]+"-"+Ze[e&63|128]+Ze[e>>8&255]+"-"+Ze[e>>16&255]+Ze[e>>24&255]+Ze[n&255]+Ze[n>>8&255]+Ze[n>>16&255]+Ze[n>>24&255]).toLowerCase()}function re(i,t,e){return Math.max(t,Math.min(e,i))}function qc(i,t){return(i%t+t)%t}function wm(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Em(i,t,e){return i!==t?(e-i)/(t-i):0}function er(i,t,e){return(1-e)*i+e*t}function Tm(i,t,e,n){return er(i,t,1-Math.exp(-e*n))}function Am(i,t=1){return t-Math.abs(qc(i,t*2)-t)}function Rm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Cm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Im(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Pm(i,t){return i+Math.random()*(t-i)}function Lm(i){return i*(.5-Math.random())}function Dm(i){i!==void 0&&(vu=i);let t=vu+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Nm(i){return i*ms}function Um(i){return i*bs}function Fm(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function Bm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Om(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function zm(i,t,e,n,s){let r=Math.cos,o=Math.sin,a=r(e/2),l=o(e/2),c=r((t+n)/2),h=o((t+n)/2),d=r((t-n)/2),u=o((t-n)/2),f=r((n-t)/2),m=o((n-t)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*m,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*m,a*c);break;case"ZYZ":i.set(l*m,l*f,a*h,a*c);break;default:Wt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Mn(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function pe(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var le={DEG2RAD:ms,RAD2DEG:bs,generateUUID:si,clamp:re,euclideanModulo:qc,mapLinear:wm,inverseLerp:Em,lerp:er,damp:Tm,pingpong:Am,smoothstep:Rm,smootherstep:Cm,randInt:Im,randFloat:Pm,randFloatSpread:Lm,seededRandom:Dm,degToRad:Nm,radToDeg:Um,isPowerOfTwo:Fm,ceilPowerOfTwo:Bm,floorPowerOfTwo:Om,setQuaternionFromProperEuler:zm,normalize:pe,denormalize:Mn},Jc=class Jc{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=re(this.x,t.x,e.x),this.y=re(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=re(this.x,t,e),this.y=re(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(re(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(re(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*s+t.x,this.y=r*s+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Jc.prototype.isVector2=!0;var qt=Jc,Fe=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],m=r[o+2],_=r[o+3];if(d!==_||l!==u||c!==f||h!==m){let g=l*u+c*f+h*m+d*_;g<0&&(u=-u,f=-f,m=-m,_=-_,g=-g);let p=1-a;if(g<.9995){let y=Math.acos(g),w=Math.sin(y);p=Math.sin(p*y)/w,a=Math.sin(a*y)/w,l=l*p+u*a,c=c*p+f*a,h=h*p+m*a,d=d*p+_*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+m*a,d=d*p+_*a;let y=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=y,c*=y,h*=y,d*=y}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],m=r[o+3];return t[e]=a*m+h*d+l*f-c*u,t[e+1]=l*m+h*u+c*d-a*f,t[e+2]=c*m+h*f+a*u-l*d,t[e+3]=h*m-a*d-l*u-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),m=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d-u*f*m;break;case"YXZ":this._x=u*h*d+c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d+u*f*m;break;case"ZXY":this._x=u*h*d-c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d-u*f*m;break;case"ZYX":this._x=u*h*d-c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d+u*f*m;break;case"YZX":this._x=u*h*d+c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d-u*f*m;break;case"XZY":this._x=u*h*d-c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d+u*f*m;break;default:Wt("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],d=e[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(re(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-e;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},jc=class jc{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(yu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(yu.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*s-a*n),h=2*(a*e-r*s),d=2*(r*n-o*e);return this.x=e+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=re(this.x,t.x,e.x),this.y=re(this.y,t.y,e.y),this.z=re(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=re(this.x,t,e),this.y=re(this.y,t,e),this.z=re(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(re(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,o=e.x,a=e.y,l=e.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Gl.copy(this).projectOnVector(t),this.sub(Gl)}reflect(t){return this.sub(Gl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(re(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};jc.prototype.isVector3=!0;var C=jc,Gl=new C,yu=new Fe,Qc=class Qc{constructor(t,e,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,o,a,l,c)}set(t,e,n,s,r,o,a,l,c){let h=this.elements;return h[0]=t,h[1]=s,h[2]=a,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],m=n[8],_=s[0],g=s[3],p=s[6],y=s[1],w=s[4],M=s[7],x=s[2],S=s[5],A=s[8];return r[0]=o*_+a*y+l*x,r[3]=o*g+a*w+l*S,r[6]=o*p+a*M+l*A,r[1]=c*_+h*y+d*x,r[4]=c*g+h*w+d*S,r[7]=c*p+h*M+d*A,r[2]=u*_+f*y+m*x,r[5]=u*g+f*w+m*S,r[8]=u*p+f*M+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,m=e*d+n*u+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/m;return t[0]=d*_,t[1]=(s*c-h*n)*_,t[2]=(a*n-s*o)*_,t[3]=u*_,t[4]=(h*e-s*l)*_,t[5]=(s*r-a*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(o*e-n*r)*_,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-s*c,s*l,-s*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return Bi("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Wl.makeScale(t,e)),this}rotate(t){return Bi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Wl.makeRotation(-t)),this}translate(t,e){return Bi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Wl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};Qc.prototype.isMatrix3=!0;var Jt=Qc,Wl=new Jt,Mu=new Jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),bu=new Jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function km(){let i={enabled:!0,workingColorSpace:ir,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===fe&&(s.r=ri(s.r),s.g=ri(s.g),s.b=ri(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===fe&&(s.r=gs(s.r),s.g=gs(s.g),s.b=gs(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===ai?sr:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Bi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Bi("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[ir]:{primaries:t,whitePoint:n,transfer:sr,toXYZ:Mu,fromXYZ:bu,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:me},outputColorSpaceConfig:{drawingBufferColorSpace:me}},[me]:{primaries:t,whitePoint:n,transfer:fe,toXYZ:Mu,fromXYZ:bu,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:me}}}),i}var se=km();function ri(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function gs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ts,Ho=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{ts===void 0&&(ts=ys("canvas")),ts.width=t.width,ts.height=t.height;let s=ts.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=ts}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=ys("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let o=0;o1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(ql).x}get height(){return this.source.getSize(ql).y}get depth(){return this.source.getSize(ql).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){Wt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Wt(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Nc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case xs:t.x=t.x-Math.floor(t.x);break;case Bn:t.x=t.x<0?0:1;break;case zo:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case xs:t.y=t.y-Math.floor(t.y);break;case Bn:t.y=t.y<0?0:1;break;case zo:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};We.DEFAULT_IMAGE=null;We.DEFAULT_MAPPING=Nc;We.DEFAULT_ANISOTROPY=1;var th=class th{constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*s+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,l=t.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],m=l[9],_=l[2],g=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let w=(c+1)/2,M=(f+1)/2,x=(p+1)/2,S=(h+u)/4,A=(d+_)/4,v=(m+g)/4;return w>M&&w>x?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=S/n,r=A/n):M>x?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=S/s,r=v/s):x<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(x),n=A/r,s=v/r),this.set(n,s,r,e),this}let y=Math.sqrt((g-m)*(g-m)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(d-_)/y,this.z=(u-h)/y,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=re(this.x,t.x,e.x),this.y=re(this.y,t.y,e.y),this.z=re(this.z,t.z,e.z),this.w=re(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=re(this.x,t,e),this.y=re(this.y,t,e),this.z=re(this.z,t,e),this.w=re(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(re(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};th.prototype.isVector4=!0;var ve=th,Vo=class extends zn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qe,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new ve(0,0,t,e),this.scissorTest=!1,this.viewport=new ve(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new We(s),o=n.count;for(let a=0;a1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;nf+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&u<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:t,target:this})));a!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Zm)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Re;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Nd={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},pi={h:0,s:0,l:0},io={h:0,s:0,l:0};function $l(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var Vt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=me){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,se.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=se.workingColorSpace){return this.r=t,this.g=e,this.b=n,se.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=se.workingColorSpace){if(t=qc(t,1),e=re(e,0,1),n=re(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=$l(o,r,t+1/3),this.g=$l(o,r,t),this.b=$l(o,r,t-1/3)}return se.colorSpaceToWorking(this,s),this}setStyle(t,e=me){function n(r){r!==void 0&&parseFloat(r)<1&&Wt("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Wt("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(r,16),e);Wt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=me){let n=Nd[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Wt("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ri(t.r),this.g=ri(t.g),this.b=ri(t.b),this}copyLinearToSRGB(t){return this.r=gs(t.r),this.g=gs(t.g),this.b=gs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=me){return se.workingToColorSpace(Ke.copy(this),t),Math.round(re(Ke.r*255,0,255))*65536+Math.round(re(Ke.g*255,0,255))*256+Math.round(re(Ke.b*255,0,255))}getHexString(t=me){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=se.workingColorSpace){se.workingToColorSpace(Ke.copy(this),e);let n=Ke.r,s=Ke.g,r=Ke.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){vn.subVectors(s,e),Qn.subVectors(n,e),Zl.subVectors(t,e);let o=vn.dot(vn),a=vn.dot(Qn),l=vn.dot(Zl),c=Qn.dot(Qn),h=Qn.dot(Zl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,m=(o*h-a*l)*u;return r.set(1-f-m,m,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,ti)===null?!1:ti.x>=0&&ti.y>=0&&ti.x+ti.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,ti)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,ti.x),l.addScaledVector(o,ti.y),l.addScaledVector(a,ti.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return Ql.setScalar(0),tc.setScalar(0),ec.setScalar(0),Ql.fromBufferAttribute(t,e),tc.fromBufferAttribute(t,n),ec.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(Ql,r.x),o.addScaledVector(tc,r.y),o.addScaledVector(ec,r.z),o}static isFrontFacing(t,e,n,s){return vn.subVectors(n,e),Qn.subVectors(t,e),vn.cross(Qn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return vn.subVectors(this.c,this.b),Qn.subVectors(this.a,this.b),vn.cross(Qn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,o,a;ss.subVectors(s,n),rs.subVectors(r,n),Kl.subVectors(t,n);let l=ss.dot(Kl),c=rs.dot(Kl);if(l<=0&&c<=0)return e.copy(n);Jl.subVectors(t,s);let h=ss.dot(Jl),d=rs.dot(Jl);if(h>=0&&d<=h)return e.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(n).addScaledVector(ss,o);jl.subVectors(t,r);let f=ss.dot(jl),m=rs.dot(jl);if(m>=0&&f<=m)return e.copy(r);let _=f*c-l*m;if(_<=0&&c>=0&&m<=0)return a=c/(c-m),e.copy(n).addScaledVector(rs,a);let g=h*m-f*d;if(g<=0&&d-h>=0&&f-m>=0)return Iu.subVectors(r,s),a=(d-h)/(d-h+(f-m)),e.copy(s).addScaledVector(Iu,a);let p=1/(g+_+u);return o=_*p,a=u*p,e.copy(n).addScaledVector(ss,o).addScaledVector(rs,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},ae=class{constructor(t=new C(1/0,1/0,1/0),e=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,yn),yn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Zs),ro.subVectors(this.max,Zs),os.subVectors(t.a,Zs),as.subVectors(t.b,Zs),ls.subVectors(t.c,Zs),mi.subVectors(as,os),gi.subVectors(ls,as),Di.subVectors(os,ls);let e=[0,-mi.z,mi.y,0,-gi.z,gi.y,0,-Di.z,Di.y,mi.z,0,-mi.x,gi.z,0,-gi.x,Di.z,0,-Di.x,-mi.y,mi.x,0,-gi.y,gi.x,0,-Di.y,Di.x,0];return!nc(e,os,as,ls,ro)||(e=[1,0,0,0,1,0,0,0,1],!nc(e,os,as,ls,ro))?!1:(oo.crossVectors(mi,gi),e=[oo.x,oo.y,oo.z],nc(e,os,as,ls,ro))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,yn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(yn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ei[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ei[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ei[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ei[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ei[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ei[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ei[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ei[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ei),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},ei=[new C,new C,new C,new C,new C,new C,new C,new C],yn=new C,so=new ae,os=new C,as=new C,ls=new C,mi=new C,gi=new C,Di=new C,Zs=new C,ro=new C,oo=new C,Ni=new C;function nc(i,t,e,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Ni.fromArray(i,r);let a=s.x*Math.abs(Ni.x)+s.y*Math.abs(Ni.y)+s.z*Math.abs(Ni.z),l=t.dot(Ni),c=e.dot(Ni),h=n.dot(Ni);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Ne=new C,ao=new qt,Km=0,xe=class extends zn{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Km++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Wc,this.updateRanges=[],this.gpuType=Ye,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ks.subVectors(t,this.center);let e=Ks.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ks,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ic.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ks.copy(t.center).add(ic)),this.expandByPoint(Ks.copy(t.center).sub(ic))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},jm=0,fn=new Kt,sc=new Xe,cs=new C,an=new ae,Js=new ae,Ge=new C,he=class i extends zn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jm++}),this.uuid=si(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(bm(t)?lr:ar)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Jt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return fn.makeRotationFromQuaternion(t),this.applyMatrix4(fn),this}rotateX(t){return fn.makeRotationX(t),this.applyMatrix4(fn),this}rotateY(t){return fn.makeRotationY(t),this.applyMatrix4(fn),this}rotateZ(t){return fn.makeRotationZ(t),this.applyMatrix4(fn),this}translate(t,e,n){return fn.makeTranslation(t,e,n),this.applyMatrix4(fn),this}scale(t,e,n){return fn.makeScale(t,e,n),this.applyMatrix4(fn),this}lookAt(t){return sc.lookAt(t),sc.updateMatrix(),this.applyMatrix4(sc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cs).negate(),this.translate(cs.x,cs.y,cs.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;se.count&&Wt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ae);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){$t("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let c=n[l];t.data.attributes[l]=c.toJSON(t.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(e))}let r=t.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u1)?null:e.copy(t.start).addScaledVector(s,o)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||tg.getNormalMatrix(t),s=this.coplanarPoint(rc).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(t){return this.normal.fromArray(t.normal),this.constant=t.constant,this}},eg=0,Sn=class extends zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eg++}),this.uuid=si(),this.name="",this.type="Material",this.blending=Ls,this.side=Yn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ec,this.blendDst=Tc,this.blendEquation=Wi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=_s,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Sd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Io,this.stencilZFail=Io,this.stencilZPass=Io,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){Wt(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Wt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(e){let r=s(t.textures),o=s(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new Vt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.retroreflectivity!==void 0&&(this.retroreflectivity=t.retroreflectivity),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.clippingPlanes!==void 0&&(this.clippingPlanes=t.clippingPlanes.map(n=>new Ae().fromJSON(n))),t.clipIntersection!==void 0&&(this.clipIntersection=t.clipIntersection),t.clipShadows!==void 0&&(this.clipShadows=t.clipShadows),t.depthPacking!==void 0&&(this.depthPacking=t.depthPacking),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.linecap!==void 0&&(this.linecap=t.linecap),t.linejoin!==void 0&&(this.linejoin=t.linejoin),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new qt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new qt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};var ni=new C,oc=new C,lo=new C,co=new C,Oi=class{constructor(t=new C,e=new C(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ni)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=ni.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ni.copy(this.origin).addScaledVector(this.direction,e),ni.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){oc.copy(t).add(e).multiplyScalar(.5),lo.copy(e).sub(t).normalize(),co.copy(this.origin).sub(oc);let r=t.distanceTo(e)*.5,o=-this.direction.dot(lo),a=co.dot(this.direction),l=-co.dot(lo),c=co.lengthSq(),h=Math.abs(1-o*o),d,u,f,m;if(h>0)if(d=o*l-a,u=o*a-l,m=r*h,d>=0)if(u>=-m)if(u<=m){let _=1/h;d*=_,u*=_,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-m?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=m?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(oc).addScaledVector(lo,u),f}intersectSphere(t,e){if(t.radius<0)return null;ni.subVectors(t.center,this.origin);let n=ni.dot(this.direction),s=ni.dot(ni)-n*n,r=t.radius*t.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,s=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,s=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,o=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,o=(t.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(t.min.z-u.z)*d,l=(t.max.z-u.z)*d):(a=(t.max.z-u.z)*d,l=(t.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,ni)!==null}intersectTriangle(t,e,n,s,r){let o=this.origin,a=this.direction,l=a.x,c=a.y,h=a.z,d=t.x-o.x,u=t.y-o.y,f=t.z-o.z,m=e.x-o.x,_=e.y-o.y,g=e.z-o.z,p=n.x-o.x,y=n.y-o.y,w=n.z-o.z,M=Math.abs(l),x=Math.abs(c),S=Math.abs(h),A,v,E,R,L,N,B,D,F,H,V,z;if(M>=x&&M>=S?(E=l,N=d,F=m,z=p,l>=0?(A=c,v=h,R=u,L=f,B=_,D=g,H=y,V=w):(A=h,v=c,R=f,L=u,B=g,D=_,H=w,V=y)):x>=S?(E=c,N=u,F=_,z=y,c>=0?(A=h,v=l,R=f,L=d,B=g,D=m,H=w,V=p):(A=l,v=h,R=d,L=f,B=m,D=g,H=p,V=w)):(E=h,N=f,F=g,z=w,h>=0?(A=l,v=c,R=d,L=u,B=m,D=_,H=p,V=y):(A=c,v=l,R=u,L=d,B=_,D=m,H=y,V=p)),E===0)return null;let U=A/E,k=v/E,Y=1/E,G=R-U*N,J=L-k*N,it=B-U*F,nt=D-k*F,at=H-U*z,O=V-k*z,$=at*nt-O*it,rt=G*O-J*at,mt=it*J-nt*G;if(s){if($<0||rt<0||mt<0)return null}else if(($<0||rt<0||mt<0)&&($>0||rt>0||mt>0))return null;let ht=$+rt+mt;if(ht===0)return null;let Et=Y*($*N+rt*F+mt*z);return(ht>0?Et<0:Et>0)?null:this.at(Et/ht,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Je=class extends Sn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.combine=Mr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},Pu=new Kt,Ui=new Oi,ho=new Oe,Lu=new C,uo=new C,fo=new C,po=new C,ac=new C,mo=new C,Du=new C,go=new C,ge=class extends Xe{constructor(t=new he,e=new Je){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r(t.far-t.near)**2))&&(Pu.copy(r).invert(),Ui.copy(t.ray).applyMatrix4(Pu),!(n.boundingBox!==null&&Ui.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Ui)))}_computeIntersections(t,e,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,_=u.length;m<_;m++){let g=u[m],p=o[g.materialIndex],y=Math.max(g.start,f.start),w=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let M=y,x=w;Me.far?null:{distance:c,point:go.clone(),object:i}}function _o(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,uo),i.getVertexPosition(l,fo),i.getVertexPosition(c,po);let h=ng(i,t,e,n,uo,fo,po,Du);if(h){let d=new C;ii.getBarycoord(Du,uo,fo,po,d),s&&(h.uv=ii.getInterpolatedAttribute(s,a,l,c,d,new qt)),r&&(h.uv1=ii.getInterpolatedAttribute(r,a,l,c,d,new qt)),o&&(h.normal=ii.getInterpolatedAttribute(o,a,l,c,d,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new C,materialIndex:0};ii.getNormal(uo,fo,po,u.normal),h.face=u,h.barycoord=d}return h}var mn=class extends We{constructor(t=null,e=1,n=1,s,r,o,a,l,c=Le,h=Le,d,u){super(null,o,a,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var oi=class extends xe{constructor(t,e,n,s=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},hs=new Kt,Nu=new Kt,xo=[],Uu=new ae,ig=new Kt,js=new ge,Qs=new Oe,xi=class extends ge{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new oi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s0?t.max.x:t.min.x,vo.y=s.normal.y>0?t.max.y:t.min.y,vo.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(vo)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var sn=class extends Sn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Vt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},Xo=new C,qo=new C,Fu=new Kt,tr=new Oi,yo=new Oe,lc=new C,Bu=new C,zi=class extends Xe{constructor(t=new he,e=new sn){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rn)return;lc.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(lc);if(!(ct.far))return{distance:c,point:Bu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Ou=new C,zu=new C,ln=class extends zi{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rs.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var cr=class extends We{constructor(t=[],e=bi,n,s,r,o,a,l,c,h){super(t,e,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},hr=class extends We{constructor(t,e,n,s,r,o,a,l,c){super(t,e,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var Gn=class extends We{constructor(t,e,n=Tn,s,r,o,a=Le,l=Le,c,h=On,d=1){if(h!==On&&h!==wi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:t,height:e,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ss(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},Yo=class extends Gn{constructor(t,e=Tn,n=bi,s,r,o=Le,a=Le,l,c=On){let h={width:t,height:t,depth:1},d=[h,h,h,h,h,h];super(t,t,e,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}},ur=class extends We{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},gn=class i extends he{constructor(t=1,e=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],d=[],u=0,f=0;m("z","y","x",-1,-1,n,e,t,o,r,0),m("z","y","x",1,-1,n,e,-t,o,r,1),m("x","z","y",1,1,t,n,e,s,o,2),m("x","z","y",1,-1,t,n,-e,s,o,3),m("x","y","z",1,-1,t,e,n,s,r,4),m("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new we(c,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(d,2));function m(_,g,p,y,w,M,x,S,A,v,E){let R=M/A,L=x/v,N=M/2,B=x/2,D=S/2,F=A+1,H=v+1,V=0,z=0,U=new C;for(let k=0;k0?1:-1,h.push(U.x,U.y,U.z),d.push(G/A),d.push(1-k/v),V+=1}}for(let k=0;k0&&w(!0),e>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new we(d,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(f,2));function y(){let M=new C,x=new C,S=0,A=(e-t)/n;for(let v=0;v<=r;v++){let E=[],R=v/r,L=R*(e-t)+t;for(let N=0;N<=s;N++){let B=N/s,D=B*l+a,F=Math.sin(D),H=Math.cos(D);x.x=L*F,x.y=-R*n+g,x.z=L*H,d.push(x.x,x.y,x.z),M.set(F,A,H).normalize(),u.push(M.x,M.y,M.z),f.push(B,1-R),E.push(m++)}_.push(E)}for(let v=0;v0||E!==0)&&(h.push(R,L,B),S+=3),(e>0||E!==r-1)&&(h.push(L,N,B),S+=3)}c.addGroup(p,S,0),p+=S}function w(M){let x=m,S=new qt,A=new C,v=0,E=M===!0?t:e,R=M===!0?1:-1;for(let N=1;N<=s;N++)d.push(0,g*R,0),u.push(0,R,0),f.push(.5,.5),m++;let L=m;for(let N=0;N<=s;N++){let D=N/s*l+a,F=Math.cos(D),H=Math.sin(D);A.x=E*H,A.y=g*R,A.z=E*F,d.push(A.x,A.y,A.z),u.push(0,R,0),S.x=F*.5+.5,S.y=H*.5*R+.5,f.push(S.x,S.y),m++}for(let N=0;N0)&&f.push(w,M,S),(p!==n-1||l0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Vt().setHex(s.value);break;case"v2":this.uniforms[n].value=new qt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new C().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ve().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Kt().fromArray(s.value);break;case"m4":this.uniforms[n].value=new Zt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(let n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}},$o=class extends Ie{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var fr=class extends Sn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Vt(16777215),this.specular=new Vt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.combine=Mr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,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.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,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}};var Rs=class extends Sn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.combine=Mr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,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.color.copy(t.color),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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,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}},Zo=class extends Sn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=vd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Ko=class extends Sn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};function us(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function hc(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var vi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let o;e:{i:if(!(t=r)){let a=e[1];t=r)break t}o=n,n=0;break e}break n}for(;n>>1;te;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(Yt("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Yt("KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Yt("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Yt("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(s!==void 0&&bm(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Yt("KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Co,r=t.length-1,o=1;for(let a=1;a0){t[o]=t[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,hc(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Hu(i,t){for(let e=0,n=i.length;e!==n;e+=2)i[e]*=t}hn.prototype.ValueTypeName="";hn.prototype.TimeBufferType=Float32Array;hn.prototype.ValueBufferType=Float32Array;hn.prototype.DefaultInterpolation=ko;var yi=class extends hn{constructor(t,e,n){super(t,e,n)}};yi.prototype.ValueTypeName="bool";yi.prototype.ValueBufferType=Array;yi.prototype.DefaultInterpolation=nr;yi.prototype.InterpolantFactoryMethodLinear=void 0;yi.prototype.InterpolantFactoryMethodSmooth=void 0;var ea=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};ea.prototype.ValueTypeName="color";var na=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};na.prototype.ValueTypeName="number";var ia=class extends vi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(s-e),c=t*a;for(let h=c+a;c!==h;c+=4)Fe.slerpFlat(r,0,o,c-a,o,c,l);return r}},pr=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new ia(this.times,this.values,this.getValueSize(),t)}};pr.prototype.ValueTypeName="quaternion";pr.prototype.InterpolantFactoryMethodSmooth=void 0;var Mi=class extends hn{constructor(t,e,n){super(t,e,n)}};Mi.prototype.ValueTypeName="string";Mi.prototype.ValueBufferType=Array;Mi.prototype.DefaultInterpolation=nr;Mi.prototype.InterpolantFactoryMethodLinear=void 0;Mi.prototype.InterpolantFactoryMethodSmooth=void 0;var sa=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};sa.prototype.ValueTypeName="vector";var Po={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(Vu(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Vu(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Vu(i){try{let t=i.slice(i.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}var ra=class{constructor(t,e,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;df.start-m.start);let u=0;for(let f=1;f0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Vt().setHex(s.value);break;case"v2":this.uniforms[n].value=new qt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new C().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ve().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Jt().fromArray(s.value);break;case"m4":this.uniforms[n].value=new Kt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(let n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}},$o=class extends Ie{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var fr=class extends Sn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Vt(16777215),this.specular=new Vt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.combine=Mr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,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.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,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}};var Rs=class extends Sn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ir,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new kn,this.combine=Mr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,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.color.copy(t.color),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.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,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}},Zo=class extends Sn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Md,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Ko=class extends Sn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};function us(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function hc(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var vi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let o;e:{i:if(!(t=r)){let a=e[1];t=r)break t}o=n,n=0;break e}break n}for(;n>>1;te;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&($t("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&($t("KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){$t("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){$t("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(s!==void 0&&Sm(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){$t("KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Co,r=t.length-1,o=1;for(let a=1;a0){t[o]=t[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,hc(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Gu(i,t){for(let e=0,n=i.length;e!==n;e+=2)i[e]*=t}hn.prototype.ValueTypeName="";hn.prototype.TimeBufferType=Float32Array;hn.prototype.ValueBufferType=Float32Array;hn.prototype.DefaultInterpolation=ko;var yi=class extends hn{constructor(t,e,n){super(t,e,n)}};yi.prototype.ValueTypeName="bool";yi.prototype.ValueBufferType=Array;yi.prototype.DefaultInterpolation=nr;yi.prototype.InterpolantFactoryMethodLinear=void 0;yi.prototype.InterpolantFactoryMethodSmooth=void 0;var ea=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};ea.prototype.ValueTypeName="color";var na=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};na.prototype.ValueTypeName="number";var ia=class extends vi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(s-e),c=t*a;for(let h=c+a;c!==h;c+=4)Fe.slerpFlat(r,0,o,c-a,o,c,l);return r}},pr=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new ia(this.times,this.values,this.getValueSize(),t)}};pr.prototype.ValueTypeName="quaternion";pr.prototype.InterpolantFactoryMethodSmooth=void 0;var Mi=class extends hn{constructor(t,e,n){super(t,e,n)}};Mi.prototype.ValueTypeName="string";Mi.prototype.ValueBufferType=Array;Mi.prototype.DefaultInterpolation=nr;Mi.prototype.InterpolantFactoryMethodLinear=void 0;Mi.prototype.InterpolantFactoryMethodSmooth=void 0;var sa=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};sa.prototype.ValueTypeName="vector";var Po={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(Wu(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Wu(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Wu(i){try{let t=i.slice(i.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}var ra=class{constructor(t,e,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;df.start-m.start);let u=0;for(let f=1;f 0 +#endif`,Fg=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; @@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve if ( clipped ) discard; #endif #endif -#endif`,Fg=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; - uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,Bg=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,Og=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,zg=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,zg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) - diffuseColor *= vColor; #endif`,kg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#endif`,Hg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + diffuseColor *= vColor; +#endif`,Hg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; #endif`,Vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Gg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec4( 1.0 ); #endif #ifdef USE_COLOR_ALPHA @@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #endif #ifdef USE_BATCHING_COLOR vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); -#endif`,Gg=`#define PI 3.141592653589793 +#endif`,Wg=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -351,7 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,Wg=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,Xg=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { @@ -444,7 +444,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { return vec4( mix( color0, color1, mipF ), 1.0 ); } } -#endif`,Xg=`vec3 transformedNormal = objectNormal; +#endif`,qg=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif @@ -470,21 +470,21 @@ transformedNormal = normalMatrix * transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; -#endif`,qg=`#ifdef USE_DISPLACEMENTMAP +#endif`,Yg=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,Yg=`#ifdef USE_DISPLACEMENTMAP +#endif`,$g=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,$g=`#ifdef USE_EMISSIVEMAP +#endif`,Zg=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,Zg=`#ifdef USE_EMISSIVEMAP +#endif`,Kg=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,Kg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Jg=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,Jg="gl_FragColor = linearToOutputTexel( gl_FragColor );",jg=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { @@ -492,7 +492,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) { } 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 ); -}`,jg=`#ifdef USE_ENVMAP +}`,Qg=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -519,7 +519,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif -#endif`,Qg=`#ifdef USE_ENVMAP +#endif`,t0=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE @@ -527,7 +527,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { #else uniform sampler2D envMap; #endif -#endif`,t0=`#ifdef USE_ENVMAP +#endif`,e0=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS @@ -538,7 +538,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { #else varying vec3 vReflect; #endif -#endif`,e0=`#ifdef USE_ENVMAP +#endif`,n0=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif @@ -549,7 +549,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`,n0=`#ifdef USE_ENVMAP +#endif`,i0=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -566,18 +566,18 @@ vec4 sRGBTransferOETF( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`,i0=`#ifdef USE_FOG - vFogDepth = - mvPosition.z; #endif`,s0=`#ifdef USE_FOG - varying float vFogDepth; + vFogDepth = - mvPosition.z; #endif`,r0=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,o0=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,o0=`#ifdef USE_FOG +#endif`,a0=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -586,7 +586,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`,a0=`#ifdef USE_GRADIENTMAP +#endif`,l0=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -598,12 +598,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { 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 -}`,l0=`#ifdef USE_LIGHTMAP +}`,c0=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,c0=`LambertMaterial material; +#endif`,h0=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,h0=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,u0=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; @@ -617,7 +617,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,u0=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,d0=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; @@ -746,7 +746,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi return irradiance; } #endif -#include `,d0=`#ifdef USE_ENVMAP +#include `,f0=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); @@ -803,8 +803,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi } #endif #endif -#endif`,f0=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,p0=`varying vec3 vViewPosition; +#endif`,p0=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,m0=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -816,11 +816,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,m0=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,g0=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,g0=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,_0=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -837,7 +837,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,_0=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,x0=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; @@ -930,7 +930,7 @@ material.roughness = min( material.roughness, 1.0 ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,x0=`uniform sampler2D dfgLUT; +#endif`,v0=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; @@ -1297,7 +1297,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia #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 ); -}`,v0=` +}`,y0=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); @@ -1445,7 +1445,7 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,y0=`#if defined( RE_IndirectDiffuse ) +#endif`,M0=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; @@ -1475,7 +1475,7 @@ IncidentLight directLight; #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif -#endif`,M0=`#if defined( RE_IndirectDiffuse ) +#endif`,b0=`#if defined( RE_IndirectDiffuse ) #if defined( LAMBERT ) || defined( PHONG ) irradiance += iblIrradiance; #endif @@ -1483,7 +1483,7 @@ IncidentLight directLight; #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,b0=`#ifdef USE_LIGHT_PROBES_GRID +#endif`,S0=`#ifdef USE_LIGHT_PROBES_GRID uniform highp sampler3D probesSH; uniform vec3 probesMin; uniform vec3 probesMax; @@ -1528,27 +1528,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { result += c8 * 0.429043 * ( x * x - y * y ); return max( result, vec3( 0.0 ) ); } -#endif`,S0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) - gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,w0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,E0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,E0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,T0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,T0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,A0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,A0=`#ifdef USE_MAP +#endif`,R0=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,R0=`#ifdef USE_MAP +#endif`,C0=`#ifdef USE_MAP uniform sampler2D map; -#endif`,C0=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,I0=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else @@ -1560,7 +1560,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,I0=`#if defined( USE_POINTS_UV ) +#endif`,P0=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) @@ -1572,19 +1572,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,P0=`float metalnessFactor = metalness; +#endif`,L0=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,L0=`#ifdef USE_METALNESSMAP +#endif`,D0=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,D0=`#ifdef USE_INSTANCING_MORPH +#endif`,N0=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } -#endif`,N0=`#if defined( USE_MORPHCOLORS ) +#endif`,U0=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) @@ -1593,12 +1593,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,U0=`#ifdef USE_MORPHNORMALS +#endif`,F0=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } -#endif`,F0=`#ifdef USE_MORPHTARGETS +#endif`,B0=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; @@ -1612,12 +1612,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } -#endif`,B0=`#ifdef USE_MORPHTARGETS +#endif`,O0=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } -#endif`,O0=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,z0=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); @@ -1658,7 +1658,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { tbn2[1] *= faceDirection; #endif #endif -vec3 nonPerturbedNormal = normal;`,z0=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,k0=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; @@ -1676,19 +1676,19 @@ vec3 nonPerturbedNormal = normal;`,z0=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,k0=`#ifndef FLAT_SHADED +#endif`,H0=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,H0=`#ifndef FLAT_SHADED +#endif`,V0=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,V0=`#ifndef FLAT_SHADED +#endif`,G0=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,z0=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,G0=`#ifdef USE_NORMALMAP +#endif`,W0=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,z0=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,W0=`#ifdef USE_CLEARCOAT +#endif`,X0=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,X0=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,q0=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,q0=`#ifdef USE_CLEARCOATMAP +#endif`,Y0=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,z0=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,Y0=`#ifdef USE_IRIDESCENCEMAP +#endif`,$0=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,$0=`#ifdef OPAQUE +#endif`,Z0=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Z0=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,K0=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -1824,9 +1824,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const #else return ( near * far ) / ( ( far - near ) * depth - far ); #endif -}`,K0=`#ifdef PREMULTIPLIED_ALPHA +}`,J0=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,J0=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,j0=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif @@ -1834,22 +1834,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,Q0=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,Q0=`#ifdef DITHERING +#endif`,t_=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } -#endif`,t_=`float roughnessFactor = roughness; +#endif`,e_=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,e_=`#ifdef USE_ROUGHNESSMAP +#endif`,n_=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,n_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,i_=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 @@ -2100,7 +2100,7 @@ gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING } #endif #endif -#endif`,i_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,s_=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif @@ -2145,7 +2145,7 @@ gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,s_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) +#endif`,r_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else @@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,r_=`float getShadowMask() { +#endif`,o_=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING #endif #endif return shadow; -}`,o_=`#ifdef USE_SKINNING +}`,a_=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,a_=`#ifdef USE_SKINNING +#endif`,l_=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,l_=`#ifdef USE_SKINNING +#endif`,c_=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -2254,7 +2254,7 @@ gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,c_=`#ifdef USE_SKINNING +#endif`,h_=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,h_=`float specularStrength; +#endif`,u_=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,u_=`#ifdef USE_SPECULARMAP +#endif`,d_=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,d_=`#if defined( TONE_MAPPING ) +#endif`,f_=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,f_=`#ifndef saturate +#endif`,p_=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; @@ -2372,7 +2372,7 @@ vec3 NeutralToneMapping( vec3 color ) { float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } -vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,m_=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,m_=`#ifdef USE_TRANSMISSION +#endif`,g_=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISS float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`,g_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,__=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,__=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,x_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,x_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,v_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP @@ -2754,7 +2754,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,v_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,y_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; @@ -2763,12 +2763,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,y_=`varying vec2 vUv; +#endif`,M_=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,M_=`uniform sampler2D t2D; +}`,b_=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2780,14 +2780,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,b_=`varying vec3 vWorldDirection; +}`,S_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,S_=`#ifdef ENVMAP_TYPE_CUBE +}`,w_=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; @@ -2809,14 +2809,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,w_=`varying vec3 vWorldDirection; +}`,E_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,E_=`uniform samplerCube tCube; +}`,T_=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2826,7 +2826,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,T_=`#include +}`,A_=`#include #include #include #include @@ -2853,7 +2853,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,A_=`#if DEPTH_PACKING == 3200 +}`,R_=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -2891,7 +2891,7 @@ void main() { #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif -}`,R_=`#define DISTANCE +}`,C_=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2918,7 +2918,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,C_=`#define DISTANCE +}`,I_=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -2941,13 +2941,13 @@ void main() { dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); -}`,I_=`varying vec3 vWorldDirection; +}`,P_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,P_=`uniform sampler2D tEquirect; +}`,L_=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2956,7 +2956,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,L_=`uniform float scale; +}`,D_=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2978,7 +2978,7 @@ void main() { #include #include #include -}`,D_=`uniform vec3 diffuse; +}`,N_=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3006,7 +3006,7 @@ void main() { #include #include #include -}`,N_=`#include +}`,U_=`#include #include #include #include @@ -3038,7 +3038,7 @@ void main() { #include #include #include -}`,U_=`uniform vec3 diffuse; +}`,F_=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -3086,7 +3086,7 @@ void main() { #include #include #include -}`,F_=`#define LAMBERT +}`,B_=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3125,7 +3125,7 @@ void main() { #include #include #include -}`,B_=`#define LAMBERT +}`,O_=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3183,7 +3183,7 @@ void main() { #include #include #include -}`,O_=`#define MATCAP +}`,z_=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3217,7 +3217,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,z_=`#define MATCAP +}`,k_=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3263,7 +3263,7 @@ void main() { #include #include #include -}`,k_=`#define NORMAL +}`,H_=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif @@ -3296,7 +3296,7 @@ void main() { #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`,H_=`#define NORMAL +}`,V_=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; @@ -3317,7 +3317,7 @@ void main() { #ifdef OPAQUE gl_FragColor.a = 1.0; #endif -}`,V_=`#define PHONG +}`,G_=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3356,7 +3356,7 @@ void main() { #include #include #include -}`,G_=`#define PHONG +}`,W_=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3416,7 +3416,7 @@ void main() { #include #include #include -}`,W_=`#define STANDARD +}`,X_=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3459,7 +3459,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,X_=`#define STANDARD +}`,q_=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3587,7 +3587,7 @@ void main() { #include #include #include -}`,q_=`#define TOON +}`,Y_=`#define TOON varying vec3 vViewPosition; #include #include @@ -3624,7 +3624,7 @@ void main() { #include #include #include -}`,Y_=`#define TOON +}`,$_=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3676,7 +3676,7 @@ void main() { #include #include #include -}`,$_=`uniform float size; +}`,Z_=`uniform float size; uniform float scale; #include #include @@ -3707,7 +3707,7 @@ void main() { #include #include #include -}`,Z_=`uniform vec3 diffuse; +}`,K_=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3732,7 +3732,7 @@ void main() { #include #include #include -}`,K_=`#include +}`,J_=`#include #include #include #include @@ -3755,7 +3755,7 @@ void main() { #include #include #include -}`,J_=`uniform vec3 color; +}`,j_=`uniform vec3 color; uniform float opacity; #include #include @@ -3771,7 +3771,7 @@ void main() { #include #include #include -}`,j_=`uniform float rotation; +}`,Q_=`uniform float rotation; uniform vec2 center; #include #include @@ -3795,7 +3795,7 @@ void main() { #include #include #include -}`,Q_=`uniform vec3 diffuse; +}`,tx=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3820,7 +3820,7 @@ void main() { #include #include #include -}`,Qt={alphahash_fragment:yg,alphahash_pars_fragment:Mg,alphamap_fragment:bg,alphamap_pars_fragment:Sg,alphatest_fragment:wg,alphatest_pars_fragment:Eg,aomap_fragment:Tg,aomap_pars_fragment:Ag,batching_pars_vertex:Rg,batching_vertex:Cg,begin_vertex:Ig,beginnormal_vertex:Pg,bsdfs:Lg,iridescence_fragment:Dg,bumpmap_pars_fragment:Ng,clipping_planes_fragment:Ug,clipping_planes_pars_fragment:Fg,clipping_planes_pars_vertex:Bg,clipping_planes_vertex:Og,color_fragment:zg,color_pars_fragment:kg,color_pars_vertex:Hg,color_vertex:Vg,common:Gg,cube_uv_reflection_fragment:Wg,defaultnormal_vertex:Xg,displacementmap_pars_vertex:qg,displacementmap_vertex:Yg,emissivemap_fragment:$g,emissivemap_pars_fragment:Zg,colorspace_fragment:Kg,colorspace_pars_fragment:Jg,envmap_fragment:jg,envmap_common_pars_fragment:Qg,envmap_pars_fragment:t0,envmap_pars_vertex:e0,envmap_physical_pars_fragment:d0,envmap_vertex:n0,fog_vertex:i0,fog_pars_vertex:s0,fog_fragment:r0,fog_pars_fragment:o0,gradientmap_pars_fragment:a0,lightmap_pars_fragment:l0,lights_lambert_fragment:c0,lights_lambert_pars_fragment:h0,lights_pars_begin:u0,lights_toon_fragment:f0,lights_toon_pars_fragment:p0,lights_phong_fragment:m0,lights_phong_pars_fragment:g0,lights_physical_fragment:_0,lights_physical_pars_fragment:x0,lights_fragment_begin:v0,lights_fragment_maps:y0,lights_fragment_end:M0,lightprobes_pars_fragment:b0,logdepthbuf_fragment:S0,logdepthbuf_pars_fragment:w0,logdepthbuf_pars_vertex:E0,logdepthbuf_vertex:T0,map_fragment:A0,map_pars_fragment:R0,map_particle_fragment:C0,map_particle_pars_fragment:I0,metalnessmap_fragment:P0,metalnessmap_pars_fragment:L0,morphinstance_vertex:D0,morphcolor_vertex:N0,morphnormal_vertex:U0,morphtarget_pars_vertex:F0,morphtarget_vertex:B0,normal_fragment_begin:O0,normal_fragment_maps:z0,normal_pars_fragment:k0,normal_pars_vertex:H0,normal_vertex:V0,normalmap_pars_fragment:G0,clearcoat_normal_fragment_begin:W0,clearcoat_normal_fragment_maps:X0,clearcoat_pars_fragment:q0,iridescence_pars_fragment:Y0,opaque_fragment:$0,packing:Z0,premultiplied_alpha_fragment:K0,project_vertex:J0,dithering_fragment:j0,dithering_pars_fragment:Q0,roughnessmap_fragment:t_,roughnessmap_pars_fragment:e_,shadowmap_pars_fragment:n_,shadowmap_pars_vertex:i_,shadowmap_vertex:s_,shadowmask_pars_fragment:r_,skinbase_vertex:o_,skinning_pars_vertex:a_,skinning_vertex:l_,skinnormal_vertex:c_,specularmap_fragment:h_,specularmap_pars_fragment:u_,tonemapping_fragment:d_,tonemapping_pars_fragment:f_,transmission_fragment:p_,transmission_pars_fragment:m_,uv_pars_fragment:g_,uv_pars_vertex:__,uv_vertex:x_,worldpos_vertex:v_,background_vert:y_,background_frag:M_,backgroundCube_vert:b_,backgroundCube_frag:S_,cube_vert:w_,cube_frag:E_,depth_vert:T_,depth_frag:A_,distance_vert:R_,distance_frag:C_,equirect_vert:I_,equirect_frag:P_,linedashed_vert:L_,linedashed_frag:D_,meshbasic_vert:N_,meshbasic_frag:U_,meshlambert_vert:F_,meshlambert_frag:B_,meshmatcap_vert:O_,meshmatcap_frag:z_,meshnormal_vert:k_,meshnormal_frag:H_,meshphong_vert:V_,meshphong_frag:G_,meshphysical_vert:W_,meshphysical_frag:X_,meshtoon_vert:q_,meshtoon_frag:Y_,points_vert:$_,points_frag:Z_,shadow_vert:K_,shadow_frag:J_,sprite_vert:j_,sprite_frag:Q_},wt={common:{diffuse:{value:new Vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Kt},alphaMap:{value:null},alphaMapTransform:{value:new Kt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Kt}},envmap:{envMap:{value:null},envMapRotation:{value:new Kt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Kt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Kt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Kt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Kt},normalScale:{value:new qt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Kt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Kt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Kt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Kt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new Vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Kt},alphaTest:{value:0},uvTransform:{value:new Kt}},sprite:{diffuse:{value:new Vt(16777215)},opacity:{value:1},center:{value:new qt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Kt},alphaMap:{value:null},alphaMapTransform:{value:new Kt},alphaTest:{value:0}}},Kn={basic:{uniforms:Qe([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.fog]),vertexShader:Qt.meshbasic_vert,fragmentShader:Qt.meshbasic_frag},lambert:{uniforms:Qe([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,wt.lights,{emissive:{value:new Vt(0)},envMapIntensity:{value:1}}]),vertexShader:Qt.meshlambert_vert,fragmentShader:Qt.meshlambert_frag},phong:{uniforms:Qe([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,wt.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Qt.meshphong_vert,fragmentShader:Qt.meshphong_frag},standard:{uniforms:Qe([wt.common,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.roughnessmap,wt.metalnessmap,wt.fog,wt.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag},toon:{uniforms:Qe([wt.common,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.gradientmap,wt.fog,wt.lights,{emissive:{value:new Vt(0)}}]),vertexShader:Qt.meshtoon_vert,fragmentShader:Qt.meshtoon_frag},matcap:{uniforms:Qe([wt.common,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,{matcap:{value:null}}]),vertexShader:Qt.meshmatcap_vert,fragmentShader:Qt.meshmatcap_frag},points:{uniforms:Qe([wt.points,wt.fog]),vertexShader:Qt.points_vert,fragmentShader:Qt.points_frag},dashed:{uniforms:Qe([wt.common,wt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qt.linedashed_vert,fragmentShader:Qt.linedashed_frag},depth:{uniforms:Qe([wt.common,wt.displacementmap]),vertexShader:Qt.depth_vert,fragmentShader:Qt.depth_frag},normal:{uniforms:Qe([wt.common,wt.bumpmap,wt.normalmap,wt.displacementmap,{opacity:{value:1}}]),vertexShader:Qt.meshnormal_vert,fragmentShader:Qt.meshnormal_frag},sprite:{uniforms:Qe([wt.sprite,wt.fog]),vertexShader:Qt.sprite_vert,fragmentShader:Qt.sprite_frag},background:{uniforms:{uvTransform:{value:new Kt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qt.background_vert,fragmentShader:Qt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Kt}},vertexShader:Qt.backgroundCube_vert,fragmentShader:Qt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qt.cube_vert,fragmentShader:Qt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qt.equirect_vert,fragmentShader:Qt.equirect_frag},distance:{uniforms:Qe([wt.common,wt.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qt.distance_vert,fragmentShader:Qt.distance_frag},shadow:{uniforms:Qe([wt.lights,wt.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:Qt.shadow_vert,fragmentShader:Qt.shadow_frag}};Kn.physical={uniforms:Qe([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Kt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Kt},clearcoatNormalScale:{value:new qt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Kt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Kt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Kt},sheen:{value:0},sheenColor:{value:new Vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Kt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Kt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Kt},transmissionSamplerSize:{value:new qt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Kt},attenuationDistance:{value:0},attenuationColor:{value:new Vt(0)},specularColor:{value:new Vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Kt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Kt},anisotropyVector:{value:new qt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Kt}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag};var ja={r:0,b:0,g:0},tx=new Zt,rf=new Kt;rf.set(-1,0,0,0,1,0,0,0,1);function ex(i,t,e,n,s,r){let o=new Vt(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(y){let E=y.isScene===!0?y.background:null;if(E&&E.isTexture){let M=y.backgroundBlurriness>0;E=t.get(E,M)}return E}function m(y){let E=!1,M=f(y);M===null?g(o,a):M&&M.isColor&&(g(M,1),E=!0);let x=i.xr.getEnvironmentBlendMode();x==="additive"?e.buffers.color.setClear(0,0,0,1,r):x==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||E)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(y,E){let M=f(E);M&&(M.isCubeTexture||M.mapping===br)?(c===void 0&&(c=new ge(new gn(1,1,1),new Ie({name:"BackgroundCubeMaterial",uniforms:Xi(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:ze,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(x,S,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(tx.makeRotationFromEuler(E.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(rf),c.material.toneMapped=ie.getTransfer(M.colorSpace)!==fe,(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new ge(new cn(2,2),new Ie({name:"BackgroundMaterial",uniforms:Xi(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Yn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=ie.getTransfer(M.colorSpace)!==fe,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function g(y,E){y.getRGB(ja,Yc(i)),e.buffers.color.setClear(ja.r,ja.g,ja.b,E,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,E=1){o.set(y),a=E,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,g(o,a)},render:m,addToRenderList:_,dispose:p}}function nx(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(L,N,B,D,F){let H=!1,V=d(L,D,B,N);r!==V&&(r=V,c(r.object)),H=f(L,D,B,F),H&&m(L,D,B,F),F!==null&&t.update(F,i.ELEMENT_ARRAY_BUFFER),(H||o)&&(o=!1,M(L,N,B,D),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(F).buffer))}function l(){return i.createVertexArray()}function c(L){return i.bindVertexArray(L)}function h(L){return i.deleteVertexArray(L)}function d(L,N,B,D){let F=D.wireframe===!0,H=n[N.id];H===void 0&&(H={},n[N.id]=H);let V=L.isInstancedMesh===!0?L.id:0,k=H[V];k===void 0&&(k={},H[V]=k);let U=k[B.id];U===void 0&&(U={},k[B.id]=U);let O=U[F];return O===void 0&&(O=u(l()),U[F]=O),O}function u(L){let N=[],B=[],D=[];for(let F=0;F=0){let Y=F[U],G=H[U];if(G===void 0&&(U==="instanceMatrix"&&L.instanceMatrix&&(G=L.instanceMatrix),U==="instanceColor"&&L.instanceColor&&(G=L.instanceColor)),Y===void 0||Y.attribute!==G||G&&Y.data!==G.data)return!0;V++}return r.attributesNum!==V||r.index!==D}function m(L,N,B,D){let F={},H=N.attributes,V=0,k=B.getAttributes();for(let U in k)if(k[U].location>=0){let Y=H[U];Y===void 0&&(U==="instanceMatrix"&&L.instanceMatrix&&(Y=L.instanceMatrix),U==="instanceColor"&&L.instanceColor&&(Y=L.instanceColor));let G={};G.attribute=Y,Y&&Y.data&&(G.data=Y.data),F[U]=G,V++}r.attributes=F,r.attributesNum=V,r.index=D}function _(){let L=r.newAttributes;for(let N=0,B=L.length;N=0){let O=F[k];if(O===void 0&&(k==="instanceMatrix"&&L.instanceMatrix&&(O=L.instanceMatrix),k==="instanceColor"&&L.instanceColor&&(O=L.instanceColor)),O!==void 0){let Y=O.normalized,G=O.itemSize,J=t.get(O);if(J===void 0)continue;let rt=J.buffer,nt=J.type,it=J.bytesPerElement,z=nt===i.INT||nt===i.UNSIGNED_INT||O.gpuType===pa;if(O.isInterleavedBufferAttribute){let $=O.data,st=$.stride,gt=O.offset;if($.isInstancedInterleavedBuffer){for(let ht=0;ht0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp",h=l(c);h!==c&&(Gt("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&u===!1&&Gt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),x=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:y,maxVaryings:E,maxFragmentUniforms:M,maxSamples:x,samples:S}}function rx(i){let t=this,e=null,n=0,s=!1,r=!1,o=new Ae,a=new Kt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,f){let m=d.clippingPlanes,_=d.clipIntersection,g=d.clipShadows,p=i.get(d);if(!s||m===null||m.length===0||r&&!g)r?h(null):c();else{let y=r?0:n,E=y*4,M=p.clippingState||null;l.value=M,M=h(m,u,E,f);for(let x=0;x!==E;++x)M[x]=e[x];p.clippingState=M,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,f,m){let _=d!==null?d.length:0,g=null;if(_!==0){if(g=l.value,m!==!0||g===null){let p=f+_*4,y=u.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Od(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?x:0,x,x),d.setRenderTarget(s),p&&d.render(_,l),d.render(t,l)}d.toneMapping=f,d.autoClear=u,t.background=y}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===bi||t.mapping===Wi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=zd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Od());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=t;let l=this._cubeSize;Fs(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Lr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rm-Bs?n-m+Bs:0),p=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=m-e,Fs(r,g,p,3*_,2*_),s.setRenderTarget(r),s.render(a,Lr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-n,Fs(t,g,p,3*_,2*_),s.setRenderTarget(t),s.render(a,Lr)}_blur(t,e,n,s){let r=this._pingPongRenderTarget,o=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(t,r,e,n,o),this._blurPass(r,t,n,n,o)}_blurPass(t,e,n,s,r){let o=this._renderer,a=this._blurMaterial,l=this._lodMeshes[s];l.material=a;let c=a.uniforms;c.envMap.value=t.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],d=3*h*(s>this._lodMax-Bs?s-this._lodMax+Bs:0),u=4*(this._cubeSize-h);Fs(e,d,u,3*h,2*h),o.setRenderTarget(e),o.render(l,Lr)}};function hx(i){let t=[],e=[],n=i,s=i-Bs+1+ox;for(let r=0;r2?0:-1,M=[y,E,0,y+2/3,E,0,y+2/3,E+1,0,y,E,0,y+2/3,E+1,0,y,E+1,0];m.set(M,f*u*p);for(let x=0;xBs&&n--}return{lodMeshes:e,sizeLods:t}}function Bd(i,t,e){let n=new Be(i,t,e);return n.texture.mapping=br,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Fs(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function ux(i,t,e){return new Ie({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:lx,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:nl(),fragmentShader:` +}`,te={alphahash_fragment:Mg,alphahash_pars_fragment:bg,alphamap_fragment:Sg,alphamap_pars_fragment:wg,alphatest_fragment:Eg,alphatest_pars_fragment:Tg,aomap_fragment:Ag,aomap_pars_fragment:Rg,batching_pars_vertex:Cg,batching_vertex:Ig,begin_vertex:Pg,beginnormal_vertex:Lg,bsdfs:Dg,iridescence_fragment:Ng,bumpmap_pars_fragment:Ug,clipping_planes_fragment:Fg,clipping_planes_pars_fragment:Bg,clipping_planes_pars_vertex:Og,clipping_planes_vertex:zg,color_fragment:kg,color_pars_fragment:Hg,color_pars_vertex:Vg,color_vertex:Gg,common:Wg,cube_uv_reflection_fragment:Xg,defaultnormal_vertex:qg,displacementmap_pars_vertex:Yg,displacementmap_vertex:$g,emissivemap_fragment:Zg,emissivemap_pars_fragment:Kg,colorspace_fragment:Jg,colorspace_pars_fragment:jg,envmap_fragment:Qg,envmap_common_pars_fragment:t0,envmap_pars_fragment:e0,envmap_pars_vertex:n0,envmap_physical_pars_fragment:f0,envmap_vertex:i0,fog_vertex:s0,fog_pars_vertex:r0,fog_fragment:o0,fog_pars_fragment:a0,gradientmap_pars_fragment:l0,lightmap_pars_fragment:c0,lights_lambert_fragment:h0,lights_lambert_pars_fragment:u0,lights_pars_begin:d0,lights_toon_fragment:p0,lights_toon_pars_fragment:m0,lights_phong_fragment:g0,lights_phong_pars_fragment:_0,lights_physical_fragment:x0,lights_physical_pars_fragment:v0,lights_fragment_begin:y0,lights_fragment_maps:M0,lights_fragment_end:b0,lightprobes_pars_fragment:S0,logdepthbuf_fragment:w0,logdepthbuf_pars_fragment:E0,logdepthbuf_pars_vertex:T0,logdepthbuf_vertex:A0,map_fragment:R0,map_pars_fragment:C0,map_particle_fragment:I0,map_particle_pars_fragment:P0,metalnessmap_fragment:L0,metalnessmap_pars_fragment:D0,morphinstance_vertex:N0,morphcolor_vertex:U0,morphnormal_vertex:F0,morphtarget_pars_vertex:B0,morphtarget_vertex:O0,normal_fragment_begin:z0,normal_fragment_maps:k0,normal_pars_fragment:H0,normal_pars_vertex:V0,normal_vertex:G0,normalmap_pars_fragment:W0,clearcoat_normal_fragment_begin:X0,clearcoat_normal_fragment_maps:q0,clearcoat_pars_fragment:Y0,iridescence_pars_fragment:$0,opaque_fragment:Z0,packing:K0,premultiplied_alpha_fragment:J0,project_vertex:j0,dithering_fragment:Q0,dithering_pars_fragment:t_,roughnessmap_fragment:e_,roughnessmap_pars_fragment:n_,shadowmap_pars_fragment:i_,shadowmap_pars_vertex:s_,shadowmap_vertex:r_,shadowmask_pars_fragment:o_,skinbase_vertex:a_,skinning_pars_vertex:l_,skinning_vertex:c_,skinnormal_vertex:h_,specularmap_fragment:u_,specularmap_pars_fragment:d_,tonemapping_fragment:f_,tonemapping_pars_fragment:p_,transmission_fragment:m_,transmission_pars_fragment:g_,uv_pars_fragment:__,uv_pars_vertex:x_,uv_vertex:v_,worldpos_vertex:y_,background_vert:M_,background_frag:b_,backgroundCube_vert:S_,backgroundCube_frag:w_,cube_vert:E_,cube_frag:T_,depth_vert:A_,depth_frag:R_,distance_vert:C_,distance_frag:I_,equirect_vert:P_,equirect_frag:L_,linedashed_vert:D_,linedashed_frag:N_,meshbasic_vert:U_,meshbasic_frag:F_,meshlambert_vert:B_,meshlambert_frag:O_,meshmatcap_vert:z_,meshmatcap_frag:k_,meshnormal_vert:H_,meshnormal_frag:V_,meshphong_vert:G_,meshphong_frag:W_,meshphysical_vert:X_,meshphysical_frag:q_,meshtoon_vert:Y_,meshtoon_frag:$_,points_vert:Z_,points_frag:K_,shadow_vert:J_,shadow_frag:j_,sprite_vert:Q_,sprite_frag:tx},St={common:{diffuse:{value:new Vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Jt}},envmap:{envMap:{value:null},envMapRotation:{value:new Jt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Jt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Jt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Jt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Jt},normalScale:{value:new qt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Jt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Jt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Jt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Jt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new Vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0},uvTransform:{value:new Jt}},sprite:{diffuse:{value:new Vt(16777215)},opacity:{value:1},center:{value:new qt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}}},Kn={basic:{uniforms:Qe([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:te.meshbasic_vert,fragmentShader:te.meshbasic_frag},lambert:{uniforms:Qe([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new Vt(0)},envMapIntensity:{value:1}}]),vertexShader:te.meshlambert_vert,fragmentShader:te.meshlambert_frag},phong:{uniforms:Qe([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:te.meshphong_vert,fragmentShader:te.meshphong_frag},standard:{uniforms:Qe([St.common,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.roughnessmap,St.metalnessmap,St.fog,St.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:te.meshphysical_vert,fragmentShader:te.meshphysical_frag},toon:{uniforms:Qe([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new Vt(0)}}]),vertexShader:te.meshtoon_vert,fragmentShader:te.meshtoon_frag},matcap:{uniforms:Qe([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:te.meshmatcap_vert,fragmentShader:te.meshmatcap_frag},points:{uniforms:Qe([St.points,St.fog]),vertexShader:te.points_vert,fragmentShader:te.points_frag},dashed:{uniforms:Qe([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:te.linedashed_vert,fragmentShader:te.linedashed_frag},depth:{uniforms:Qe([St.common,St.displacementmap]),vertexShader:te.depth_vert,fragmentShader:te.depth_frag},normal:{uniforms:Qe([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:te.meshnormal_vert,fragmentShader:te.meshnormal_frag},sprite:{uniforms:Qe([St.sprite,St.fog]),vertexShader:te.sprite_vert,fragmentShader:te.sprite_frag},background:{uniforms:{uvTransform:{value:new Jt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:te.background_vert,fragmentShader:te.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Jt}},vertexShader:te.backgroundCube_vert,fragmentShader:te.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:te.cube_vert,fragmentShader:te.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:te.equirect_vert,fragmentShader:te.equirect_frag},distance:{uniforms:Qe([St.common,St.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:te.distance_vert,fragmentShader:te.distance_frag},shadow:{uniforms:Qe([St.lights,St.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:te.shadow_vert,fragmentShader:te.shadow_frag}};Kn.physical={uniforms:Qe([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Jt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Jt},clearcoatNormalScale:{value:new qt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Jt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Jt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Jt},sheen:{value:0},sheenColor:{value:new Vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Jt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Jt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Jt},transmissionSamplerSize:{value:new qt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Jt},attenuationDistance:{value:0},attenuationColor:{value:new Vt(0)},specularColor:{value:new Vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Jt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Jt},anisotropyVector:{value:new qt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Jt}}]),vertexShader:te.meshphysical_vert,fragmentShader:te.meshphysical_frag};var ja={r:0,b:0,g:0},ex=new Kt,af=new Jt;af.set(-1,0,0,0,1,0,0,0,1);function nx(i,t,e,n,s,r){let o=new Vt(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(y){let w=y.isScene===!0?y.background:null;if(w&&w.isTexture){let M=y.backgroundBlurriness>0;w=t.get(w,M)}return w}function m(y){let w=!1,M=f(y);M===null?g(o,a):M&&M.isColor&&(g(M,1),w=!0);let x=i.xr.getEnvironmentBlendMode();x==="additive"?e.buffers.color.setClear(0,0,0,1,r):x==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||w)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(y,w){let M=f(w);M&&(M.isCubeTexture||M.mapping===br)?(c===void 0&&(c=new ge(new gn(1,1,1),new Ie({name:"BackgroundCubeMaterial",uniforms:qi(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:ze,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(x,S,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(ex.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(af),c.material.toneMapped=se.getTransfer(M.colorSpace)!==fe,(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new ge(new cn(2,2),new Ie({name:"BackgroundMaterial",uniforms:qi(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Yn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=se.getTransfer(M.colorSpace)!==fe,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function g(y,w){y.getRGB(ja,Yc(i)),e.buffers.color.setClear(ja.r,ja.g,ja.b,w,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,w=1){o.set(y),a=w,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,g(o,a)},render:m,addToRenderList:_,dispose:p}}function ix(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(L,N,B,D,F){let H=!1,V=d(L,D,B,N);r!==V&&(r=V,c(r.object)),H=f(L,D,B,F),H&&m(L,D,B,F),F!==null&&t.update(F,i.ELEMENT_ARRAY_BUFFER),(H||o)&&(o=!1,M(L,N,B,D),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(F).buffer))}function l(){return i.createVertexArray()}function c(L){return i.bindVertexArray(L)}function h(L){return i.deleteVertexArray(L)}function d(L,N,B,D){let F=D.wireframe===!0,H=n[N.id];H===void 0&&(H={},n[N.id]=H);let V=L.isInstancedMesh===!0?L.id:0,z=H[V];z===void 0&&(z={},H[V]=z);let U=z[B.id];U===void 0&&(U={},z[B.id]=U);let k=U[F];return k===void 0&&(k=u(l()),U[F]=k),k}function u(L){let N=[],B=[],D=[];for(let F=0;F=0){let Y=F[U],G=H[U];if(G===void 0&&(U==="instanceMatrix"&&L.instanceMatrix&&(G=L.instanceMatrix),U==="instanceColor"&&L.instanceColor&&(G=L.instanceColor)),Y===void 0||Y.attribute!==G||G&&Y.data!==G.data)return!0;V++}return r.attributesNum!==V||r.index!==D}function m(L,N,B,D){let F={},H=N.attributes,V=0,z=B.getAttributes();for(let U in z)if(z[U].location>=0){let Y=H[U];Y===void 0&&(U==="instanceMatrix"&&L.instanceMatrix&&(Y=L.instanceMatrix),U==="instanceColor"&&L.instanceColor&&(Y=L.instanceColor));let G={};G.attribute=Y,Y&&Y.data&&(G.data=Y.data),F[U]=G,V++}r.attributes=F,r.attributesNum=V,r.index=D}function _(){let L=r.newAttributes;for(let N=0,B=L.length;N=0){let k=F[z];if(k===void 0&&(z==="instanceMatrix"&&L.instanceMatrix&&(k=L.instanceMatrix),z==="instanceColor"&&L.instanceColor&&(k=L.instanceColor)),k!==void 0){let Y=k.normalized,G=k.itemSize,J=t.get(k);if(J===void 0)continue;let it=J.buffer,nt=J.type,at=J.bytesPerElement,O=nt===i.INT||nt===i.UNSIGNED_INT||k.gpuType===pa;if(k.isInterleavedBufferAttribute){let $=k.data,rt=$.stride,mt=k.offset;if($.isInstancedInterleavedBuffer){for(let ht=0;ht0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp",h=l(c);h!==c&&(Wt("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&u===!1&&Wt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),x=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:y,maxVaryings:w,maxFragmentUniforms:M,maxSamples:x,samples:S}}function ox(i){let t=this,e=null,n=0,s=!1,r=!1,o=new Ae,a=new Jt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,f){let m=d.clippingPlanes,_=d.clipIntersection,g=d.clipShadows,p=i.get(d);if(!s||m===null||m.length===0||r&&!g)r?h(null):c();else{let y=r?0:n,w=y*4,M=p.clippingState||null;l.value=M,M=h(m,u,w,f);for(let x=0;x!==w;++x)M[x]=e[x];p.clippingState=M,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,f,m){let _=d!==null?d.length:0,g=null;if(_!==0){if(g=l.value,m!==!0||g===null){let p=f+_*4,y=u.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Hd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=kd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?x:0,x,x),d.setRenderTarget(s),p&&d.render(_,l),d.render(t,l)}d.toneMapping=f,d.autoClear=u,t.background=y}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===bi||t.mapping===Xi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Hd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=kd());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=t;let l=this._cubeSize;Fs(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Lr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rm-Bs?n-m+Bs:0),p=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=m-e,Fs(r,g,p,3*_,2*_),s.setRenderTarget(r),s.render(a,Lr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-n,Fs(t,g,p,3*_,2*_),s.setRenderTarget(t),s.render(a,Lr)}_blur(t,e,n,s){let r=this._pingPongRenderTarget,o=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(t,r,e,n,o),this._blurPass(r,t,n,n,o)}_blurPass(t,e,n,s,r){let o=this._renderer,a=this._blurMaterial,l=this._lodMeshes[s];l.material=a;let c=a.uniforms;c.envMap.value=t.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],d=3*h*(s>this._lodMax-Bs?s-this._lodMax+Bs:0),u=4*(this._cubeSize-h);Fs(e,d,u,3*h,2*h),o.setRenderTarget(e),o.render(l,Lr)}};function ux(i){let t=[],e=[],n=i,s=i-Bs+1+ax;for(let r=0;r2?0:-1,M=[y,w,0,y+2/3,w,0,y+2/3,w+1,0,y,w,0,y+2/3,w+1,0,y,w+1,0];m.set(M,f*u*p);for(let x=0;xBs&&n--}return{lodMeshes:e,sizeLods:t}}function zd(i,t,e){let n=new Be(i,t,e);return n.texture.mapping=br,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Fs(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function dx(i,t,e){return new Ie({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:cx,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:nl(),fragmentShader:` precision highp float; precision highp int; @@ -3924,7 +3924,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:$n,depthTest:!1,depthWrite:!1})}function dx(i,t,e){return new Ie({name:"SphericalGaussianBlur",defines:{SAMPLES:ax,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:nl(),fragmentShader:` + `,blending:$n,depthTest:!1,depthWrite:!1})}function fx(i,t,e){return new Ie({name:"SphericalGaussianBlur",defines:{SAMPLES:lx,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:nl(),fragmentShader:` precision highp float; precision highp int; @@ -3984,7 +3984,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `,blending:$n,depthTest:!1,depthWrite:!1})}function Od(){return new Ie({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:nl(),fragmentShader:` + `,blending:$n,depthTest:!1,depthWrite:!1})}function kd(){return new Ie({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:nl(),fragmentShader:` precision mediump float; precision mediump int; @@ -4003,7 +4003,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:$n,depthTest:!1,depthWrite:!1})}function zd(){return new Ie({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:nl(),fragmentShader:` + `,blending:$n,depthTest:!1,depthWrite:!1})}function Hd(){return new Ie({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:nl(),fragmentShader:` precision mediump float; precision mediump int; @@ -4069,7 +4069,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},s=new gn(5,5,5),r=new Ie({name:"CubemapFromEquirect",uniforms:Xi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ze,blending:$n});r.uniforms.tEquirect.value=e;let o=new ge(s,r),a=e.minFilter;return e.minFilter===Si&&(e.minFilter=qe),new la(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){let r=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,s);t.setRenderTarget(r)}};function fx(i){let t=new WeakMap,e=new WeakMap,n=null;function s(u,f=!1){return u==null?null:f?o(u):r(u)}function r(u){if(u&&u.isTexture){let f=u.mapping;if(f===ua||f===da)if(t.has(u)){let m=t.get(u).texture;return a(m,u.mapping)}else{let m=u.image;if(m&&m.height>0){let _=new el(m.height);return _.fromEquirectangularTexture(i,u),t.set(u,_),u.addEventListener("dispose",c),a(_.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,m=f===ua||f===da,_=f===bi||f===Wi;if(m||_){let g=e.get(u),p=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new tl(i)),g=m?n.fromEquirectangular(u,g):n.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,e.set(u,g),g.texture;if(g!==void 0)return g.texture;{let y=u.image;return m&&y&&y.height>0||_&&y&&l(y)?(n===null&&(n=new tl(i)),g=m?n.fromEquirectangular(u):n.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,e.set(u,g),u.addEventListener("dispose",h),g.texture):null}}}return u}function a(u,f){return f===ua?u.mapping=bi:f===da&&(u.mapping=Wi),u}function l(u){let f=0,m=6;for(let _=0;_=65535?lr:ar)(u,1);g.version=_;let p=r.get(d);p&&t.remove(p),r.set(d,g)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.versiont.maxTextureSize&&(x=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);let S=new Float32Array(M*x*4*d),A=new or(S,M,x,d);A.type=Ye,A.needsUpdate=!0;let v=E*4;for(let R=0;R0){let _=new el(m.height);return _.fromEquirectangularTexture(i,u),t.set(u,_),u.addEventListener("dispose",c),a(_.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,m=f===ua||f===da,_=f===bi||f===Xi;if(m||_){let g=e.get(u),p=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new tl(i)),g=m?n.fromEquirectangular(u,g):n.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,e.set(u,g),g.texture;if(g!==void 0)return g.texture;{let y=u.image;return m&&y&&y.height>0||_&&y&&l(y)?(n===null&&(n=new tl(i)),g=m?n.fromEquirectangular(u):n.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,e.set(u,g),u.addEventListener("dispose",h),g.texture):null}}}return u}function a(u,f){return f===ua?u.mapping=bi:f===da&&(u.mapping=Xi),u}function l(u){let f=0,m=6;for(let _=0;_=65535?lr:ar)(u,1);g.version=_;let p=r.get(d);p&&t.remove(p),r.set(d,g)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.versiont.maxTextureSize&&(x=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);let S=new Float32Array(M*x*4*d),A=new or(S,M,x,d);A.type=Ye,A.needsUpdate=!0;let v=w*4;for(let R=0;R0&&y[0].isRenderPass===!0;let x=o.width,S=o.height;y.length>0&&a===null&&(a=new Be(x,S,{type:An,depthBuffer:!1,stencilBuffer:!1}),l=new Be(x,S,{type:An,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=kd[s];if(r===void 0&&(r=new Float32Array(s),kd[s]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(r,a)}return r}function He(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e0&&(this.seq=s.concat(r))}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,o=e.length;r!==o;++r){let a=e[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let o=t[s];o.id in e&&n.push(o)}return n}};function qd(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var cv=37297,hv=0;function uv(i,t){let e=i.split(` + }`,depthTest:!1,depthWrite:!1}),d=new ge(c,h),u=new Xn(-1,1,1,-1,0,1),f=null,m=null,_=!1,g,p=null,y=[],w=!1;this.setSize=function(M,x){o.setSize(M,x),a!==null&&a.setSize(M,x),l!==null&&l.setSize(M,x);for(let S=0;S0&&y[0].isRenderPass===!0;let x=o.width,S=o.height;y.length>0&&a===null&&(a=new Be(x,S,{type:An,depthBuffer:!1,stencilBuffer:!1}),l=new Be(x,S,{type:An,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=Vd[s];if(r===void 0&&(r=new Float32Array(s),Vd[s]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(r,a)}return r}function He(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e0&&(this.seq=s.concat(r))}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,o=e.length;r!==o;++r){let a=e[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let o=t[s];o.id in e&&n.push(o)}return n}};function $d(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var hv=37297,uv=0;function dv(i,t){let e=i.split(` `),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let o=s;o":" "} ${a}: ${e[o]}`)}return n.join(` -`)}var Yd=new Kt;function dv(i){ie._getMatrix(Yd,ie.workingColorSpace,i);let t=`mat3( ${Yd.elements.map(e=>e.toFixed(4))} )`;switch(ie.getTransfer(i)){case sr:return[t,"LinearTransferOETF"];case fe:return[t,"sRGBTransferOETF"];default:return Gt("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function $d(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return e.toUpperCase()+` +`)}var Zd=new Jt;function fv(i){se._getMatrix(Zd,se.workingColorSpace,i);let t=`mat3( ${Zd.elements.map(e=>e.toFixed(4))} )`;switch(se.getTransfer(i)){case sr:return[t,"LinearTransferOETF"];case fe:return[t,"sRGBTransferOETF"];default:return Wt("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Kd(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return e.toUpperCase()+` `+r+` -`+uv(i.getShaderSource(t),a)}else return r}function fv(i,t){let e=dv(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` -`)}var pv={[Ac]:"Linear",[Rc]:"Reinhard",[Cc]:"Cineon",[Ic]:"ACESFilmic",[Lc]:"AgX",[Dc]:"Neutral",[Pc]:"Custom"};function mv(i,t){let e=pv[t];return e===void 0?(Gt("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var Qa=new C;function gv(){ie.getLuminanceCoefficients(Qa);let i=Qa.x.toFixed(4),t=Qa.y.toFixed(4),e=Qa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(` -`)}function _v(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Nr).join(` -`)}function xv(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` -`)}function vv(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function dh(i){return i.replace(yv,bv)}var Mv=new Map;function bv(i,t){let e=Qt[t];if(e===void 0){let n=Mv.get(t);if(n!==void 0)e=Qt[n],Gt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return dh(e)}var Sv=/#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 Jd(i){return i.replace(Sv,wv)}function wv(i,t,e,n){let s="";for(let r=parseInt(t);r/gm;function dh(i){return i.replace(Mv,Sv)}var bv=new Map;function Sv(i,t){let e=te[t];if(e===void 0){let n=bv.get(t);if(n!==void 0)e=te[n],Wt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return dh(e)}var wv=/#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 Qd(i){return i.replace(wv,Ev)}function Ev(i,t,e,n){let s="";for(let r=parseInt(t);r0&&(g+=` `),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Nr).join(` `),p.length>0&&(p+=` -`)):(g=[jd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`)):(g=[tf(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Nr).join(` -`),p=[jd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.retroreflection?"#define USE_RETROREFLECTION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==En?"#define TONE_MAPPING":"",e.toneMapping!==En?Qt.tonemapping_pars_fragment:"",e.toneMapping!==En?mv("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Qt.colorspace_pars_fragment,fv("linearToOutputTexel",e.outputColorSpace),gv(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`),p=[tf(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.retroreflection?"#define USE_RETROREFLECTION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==En?"#define TONE_MAPPING":"",e.toneMapping!==En?te.tonemapping_pars_fragment:"",e.toneMapping!==En?gv("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",te.colorspace_pars_fragment,pv("linearToOutputTexel",e.outputColorSpace),_v(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` `].filter(Nr).join(` -`)),o=dh(o),o=Zd(o,e),o=Kd(o,e),a=dh(a),a=Zd(a,e),a=Kd(a,e),o=Jd(o),a=Jd(a),e.isRawShaderMaterial!==!0&&(y=`#version 300 es +`)),o=dh(o),o=Jd(o,e),o=jd(o,e),a=dh(a),a=Jd(a,e),a=jd(a,e),o=Qd(o),a=Qd(a),e.isRawShaderMaterial!==!0&&(y=`#version 300 es `,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+g,p=["#define varying in",e.glslVersion===Xc?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Xc?"":"#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(` `)+` -`+p);let E=y+g+o,M=y+p+a,x=qd(s,s.VERTEX_SHADER,E),S=qd(s,s.FRAGMENT_SHADER,M);s.attachShader(_,x),s.attachShader(_,S),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(L){if(i.debug.checkShaderErrors){let N=s.getProgramInfoLog(_)||"",B=s.getShaderInfoLog(x)||"",D=s.getShaderInfoLog(S)||"",F=N.trim(),H=B.trim(),V=D.trim(),k=!0,U=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(k=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,x,S);else{let O=$d(s,x,"vertex"),Y=$d(s,S,"fragment");Yt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` +`+p);let w=y+g+o,M=y+p+a,x=$d(s,s.VERTEX_SHADER,w),S=$d(s,s.FRAGMENT_SHADER,M);s.attachShader(_,x),s.attachShader(_,S),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(L){if(i.debug.checkShaderErrors){let N=s.getProgramInfoLog(_)||"",B=s.getShaderInfoLog(x)||"",D=s.getShaderInfoLog(S)||"",F=N.trim(),H=B.trim(),V=D.trim(),z=!0,U=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,x,S);else{let k=Kd(s,x,"vertex"),Y=Kd(s,S,"fragment");$t("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` Material Name: `+L.name+` Material Type: `+L.type+` Program Info Log: `+F+` -`+O+` -`+Y)}else F!==""?Gt("WebGLProgram: Program Info Log:",F):(H===""||V==="")&&(U=!1);U&&(L.diagnostics={runnable:k,programLog:F,vertexShader:{log:H,prefix:g},fragmentShader:{log:V,prefix:p}})}s.deleteShader(x),s.deleteShader(S),v=new Os(s,_),w=vv(s,_)}let v;this.getUniforms=function(){return v===void 0&&A(this),v};let w;this.getAttributes=function(){return w===void 0&&A(this),w};let R=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=s.getProgramParameter(_,cv)),R},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=hv++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=x,this.fragmentShader=S,this}var Uv=0,fh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){let s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new ph(t),e.set(t,n)),n}},ph=class{constructor(t){this.id=Uv++,this.code=t,this.usedTimes=0}};function Fv(i){return i===Ei||i===Rr||i===Cr}function Bv(i,t,e,n,s,r){let o=new ws,a=new fh,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={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 m(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,w,R,L,N,B){let D=L.fog,F=N.geometry,H=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,V=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,k=t.get(v.envMap||H,V),U=k&&k.mapping===br?k.image.height:null,O=f[v.type];v.precision!==null&&(u=n.getMaxPrecision(v.precision),u!==v.precision&&Gt("WebGLProgram.getParameters:",v.precision,"not supported, using",u,"instead."));let Y=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,G=Y!==void 0?Y.length:0,J=0;F.morphAttributes.position!==void 0&&(J=1),F.morphAttributes.normal!==void 0&&(J=2),F.morphAttributes.color!==void 0&&(J=3);let rt,nt,it,z;if(O){let be=Kn[O];rt=be.vertexShader,nt=be.fragmentShader}else{rt=v.vertexShader,nt=v.fragmentShader;let be=a.getVertexShaderStage(v),ue=a.getFragmentShaderStage(v);a.update(v,be,ue),it=be.id,z=ue.id}let $=i.getRenderTarget(),st=i.state.buffers.depth.getReversed(),gt=N.isInstancedMesh===!0,ht=N.isBatchedMesh===!0,_t=!!v.map,Bt=!!v.matcap,Ft=!!k,Wt=!!v.aoMap,te=!!v.lightMap,pt=!!v.bumpMap&&v.wireframe===!1,kt=!!v.normalMap,$t=!!v.displacementMap,le=!!v.emissiveMap,ft=!!v.metalnessMap,Dt=!!v.roughnessMap,P=v.anisotropy>0,dt=v.clearcoat>0,Tt=v.dispersion>0,I=v.retroreflectivity>0,b=v.iridescence>0,Z=v.sheen>0,tt=v.transmission>0,ot=P&&!!v.anisotropyMap,mt=dt&&!!v.clearcoatMap,xt=dt&&!!v.clearcoatNormalMap,at=dt&&!!v.clearcoatRoughnessMap,ct=b&&!!v.iridescenceMap,vt=b&&!!v.iridescenceThicknessMap,Ot=Z&&!!v.sheenColorMap,St=Z&&!!v.sheenRoughnessMap,yt=!!v.specularMap,zt=!!v.specularColorMap,Xt=!!v.specularIntensityMap,Jt=tt&&!!v.transmissionMap,X=tt&&!!v.thicknessMap,Mt=!!v.gradientMap,lt=!!v.alphaMap,bt=v.alphaTest>0,Rt=!!v.alphaHash,ut=!!v.extensions,Ht=En;v.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(Ht=i.toneMapping);let Nt={shaderID:O,shaderType:v.type,shaderName:v.name,vertexShader:rt,fragmentShader:nt,defines:v.defines,customVertexShaderID:it,customFragmentShaderID:z,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:ht,batchingColor:ht&&N._colorsTexture!==null,instancing:gt,instancingColor:gt&&N.instanceColor!==null,instancingMorph:gt&&N.morphTexture!==null,outputColorSpace:$===null?i.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:ie.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:_t,matcap:Bt,envMap:Ft,envMapMode:Ft&&k.mapping,envMapCubeUVHeight:U,aoMap:Wt,lightMap:te,bumpMap:pt,normalMap:kt,displacementMap:$t,emissiveMap:le,normalMapObjectSpace:kt&&v.normalMapType===yd,normalMapTangentSpace:kt&&v.normalMapType===Ir,packedNormalMap:kt&&v.normalMapType===Ir&&Fv(v.normalMap.format),metalnessMap:ft,roughnessMap:Dt,anisotropy:P,anisotropyMap:ot,clearcoat:dt,clearcoatMap:mt,clearcoatNormalMap:xt,clearcoatRoughnessMap:at,dispersion:Tt,retroreflection:I,iridescence:b,iridescenceMap:ct,iridescenceThicknessMap:vt,sheen:Z,sheenColorMap:Ot,sheenRoughnessMap:St,specularMap:yt,specularColorMap:zt,specularIntensityMap:Xt,transmission:tt,transmissionMap:Jt,thicknessMap:X,gradientMap:Mt,opaque:v.transparent===!1&&v.blending===Ls&&v.alphaToCoverage===!1,alphaMap:lt,alphaTest:bt,alphaHash:Rt,combine:v.combine,mapUv:_t&&m(v.map.channel),aoMapUv:Wt&&m(v.aoMap.channel),lightMapUv:te&&m(v.lightMap.channel),bumpMapUv:pt&&m(v.bumpMap.channel),normalMapUv:kt&&m(v.normalMap.channel),displacementMapUv:$t&&m(v.displacementMap.channel),emissiveMapUv:le&&m(v.emissiveMap.channel),metalnessMapUv:ft&&m(v.metalnessMap.channel),roughnessMapUv:Dt&&m(v.roughnessMap.channel),anisotropyMapUv:ot&&m(v.anisotropyMap.channel),clearcoatMapUv:mt&&m(v.clearcoatMap.channel),clearcoatNormalMapUv:xt&&m(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:at&&m(v.clearcoatRoughnessMap.channel),iridescenceMapUv:ct&&m(v.iridescenceMap.channel),iridescenceThicknessMapUv:vt&&m(v.iridescenceThicknessMap.channel),sheenColorMapUv:Ot&&m(v.sheenColorMap.channel),sheenRoughnessMapUv:St&&m(v.sheenRoughnessMap.channel),specularMapUv:yt&&m(v.specularMap.channel),specularColorMapUv:zt&&m(v.specularColorMap.channel),specularIntensityMapUv:Xt&&m(v.specularIntensityMap.channel),transmissionMapUv:Jt&&m(v.transmissionMap.channel),thicknessMapUv:X&&m(v.thicknessMap.channel),alphaMapUv:lt&&m(v.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(kt||P),vertexNormals:!!F.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!F.attributes.uv&&(_t||lt),fog:!!D,useFog:v.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||F.attributes.normal===void 0&&kt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:st,skinning:N.isSkinnedMesh===!0,hasPositionAttribute:F.attributes.position!==void 0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:G,morphTextureStride:J,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:B.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&R.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ht,decodeVideoTexture:_t&&v.map.isVideoTexture===!0&&ie.getTransfer(v.map.colorSpace)===fe,decodeVideoTextureEmissive:le&&v.emissiveMap.isVideoTexture===!0&&ie.getTransfer(v.emissiveMap.colorSpace)===fe,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ke,flipSided:v.side===ze,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:ut&&v.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ut&&v.extensions.multiDraw===!0||ht)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Nt.vertexUv1s=l.has(1),Nt.vertexUv2s=l.has(2),Nt.vertexUv3s=l.has(3),l.clear(),Nt}function g(v){let w=[];if(v.shaderID?w.push(v.shaderID):(w.push(v.customVertexShaderID),w.push(v.customFragmentShaderID)),v.defines!==void 0)for(let R in v.defines)w.push(R),w.push(v.defines[R]);return v.isRawShaderMaterial===!1&&(p(w,v),y(w,v),w.push(i.outputColorSpace)),w.push(v.customProgramCacheKey),w.join()}function p(v,w){v.push(w.precision),v.push(w.outputColorSpace),v.push(w.envMapMode),v.push(w.envMapCubeUVHeight),v.push(w.mapUv),v.push(w.alphaMapUv),v.push(w.lightMapUv),v.push(w.aoMapUv),v.push(w.bumpMapUv),v.push(w.normalMapUv),v.push(w.displacementMapUv),v.push(w.emissiveMapUv),v.push(w.metalnessMapUv),v.push(w.roughnessMapUv),v.push(w.anisotropyMapUv),v.push(w.clearcoatMapUv),v.push(w.clearcoatNormalMapUv),v.push(w.clearcoatRoughnessMapUv),v.push(w.iridescenceMapUv),v.push(w.iridescenceThicknessMapUv),v.push(w.sheenColorMapUv),v.push(w.sheenRoughnessMapUv),v.push(w.specularMapUv),v.push(w.specularColorMapUv),v.push(w.specularIntensityMapUv),v.push(w.transmissionMapUv),v.push(w.thicknessMapUv),v.push(w.combine),v.push(w.fogExp2),v.push(w.sizeAttenuation),v.push(w.morphTargetsCount),v.push(w.morphAttributeCount),v.push(w.numSunLights),v.push(w.numDirLights),v.push(w.numPointLights),v.push(w.numSpotLights),v.push(w.numSpotLightMaps),v.push(w.numHemiLights),v.push(w.numRectAreaLights),v.push(w.numSunLightShadows),v.push(w.numDirLightShadows),v.push(w.numPointLightShadows),v.push(w.numSpotLightShadows),v.push(w.numSpotLightShadowsWithMaps),v.push(w.numLightProbes),v.push(w.shadowMapType),v.push(w.toneMapping),v.push(w.numClippingPlanes),v.push(w.numClipIntersection),v.push(w.depthPacking)}function y(v,w){o.disableAll(),w.instancing&&o.enable(0),w.instancingColor&&o.enable(1),w.instancingMorph&&o.enable(2),w.matcap&&o.enable(3),w.envMap&&o.enable(4),w.normalMapObjectSpace&&o.enable(5),w.normalMapTangentSpace&&o.enable(6),w.clearcoat&&o.enable(7),w.iridescence&&o.enable(8),w.alphaTest&&o.enable(9),w.vertexColors&&o.enable(10),w.vertexAlphas&&o.enable(11),w.vertexUv1s&&o.enable(12),w.vertexUv2s&&o.enable(13),w.vertexUv3s&&o.enable(14),w.vertexTangents&&o.enable(15),w.anisotropy&&o.enable(16),w.alphaHash&&o.enable(17),w.batching&&o.enable(18),w.dispersion&&o.enable(19),w.retroreflection&&o.enable(24),w.batchingColor&&o.enable(20),w.gradientMap&&o.enable(21),w.packedNormalMap&&o.enable(22),w.vertexNormals&&o.enable(23),v.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.reversedDepthBuffer&&o.enable(4),w.skinning&&o.enable(5),w.morphTargets&&o.enable(6),w.morphNormals&&o.enable(7),w.morphColors&&o.enable(8),w.premultipliedAlpha&&o.enable(9),w.shadowMapEnabled&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),w.decodeVideoTexture&&o.enable(19),w.decodeVideoTextureEmissive&&o.enable(20),w.alphaToCoverage&&o.enable(21),w.numLightProbeGrids>0&&o.enable(22),w.hasPositionAttribute&&o.enable(23),v.push(o.mask)}function E(v){let w=f[v.type],R;if(w){let L=Kn[w];R=Dd.clone(L.uniforms)}else R=v.uniforms;return R}function M(v,w){let R=h.get(w);return R!==void 0?++R.usedTimes:(R=new Nv(i,w,v,s),c.push(R),h.set(w,R)),R}function x(v){if(--v.usedTimes===0){let w=c.indexOf(v);c[w]=c[c.length-1],c.pop(),h.delete(v.cacheKey),v.destroy()}}function S(v){a.remove(v)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:g,getUniforms:E,acquireProgram:M,releaseProgram:x,releaseShaderCache:S,programs:c,dispose:A}}function Ov(){let i=new WeakMap;function t(o){return i.has(o)}function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function zv(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Qd(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function tf(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,m,_,g,p){let y=i[t];return y===void 0?(y={id:u.id,object:u,geometry:f,material:m,materialVariant:o(u),groupOrder:_,renderOrder:u.renderOrder,z:g,group:p},i[t]=y):(y.id=u.id,y.object=u,y.geometry=f,y.material=m,y.materialVariant=o(u),y.groupOrder=_,y.renderOrder=u.renderOrder,y.z=g,y.group=p),t++,y}function l(u,f,m,_,g,p,y){y.reversedDepth===!0&&(g=-g);let E=a(u,f,m,_,g,p);m.transmission>0?n.push(E):m.transparent===!0?s.push(E):e.push(E)}function c(u,f,m,_,g,p){let y=a(u,f,m,_,g,p);m.transmission>0?n.unshift(y):m.transparent===!0?s.unshift(y):e.unshift(y)}function h(u,f){e.length>1&&e.sort(u||zv),n.length>1&&n.sort(f||Qd),s.length>1&&s.sort(f||Qd)}function d(){for(let u=t,f=i.length;u=r.length?(o=new tf,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function Hv(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={direction:new C,color:new Vt};break;case"SpotLight":e={position:new C,direction:new C,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":e={color:new Vt,position:new C,halfWidth:new C,halfHeight:new C};break}return i[t.id]=e,e}}}function Vv(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Gv=0;function Wv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Xv(i){let t=new Hv,e=Vv(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);let s=new C,r=new Zt,o=new Zt;function a(c){let h=0,d=0,u=0;for(let N=0;N<9;N++)n.probe[N].set(0,0,0);let f=0,m=0,_=0,g=0,p=0,y=0,E=0,M=0,x=0,S=0,A=0,v=0,w=0,R=0;c.sort(Wv);for(let N=0,B=c.length;N0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=wt.LTC_FLOAT_1,n.rectAreaLTC2=wt.LTC_FLOAT_2):(n.rectAreaLTC1=wt.LTC_HALF_1,n.rectAreaLTC2=wt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let L=n.hash;(L.sunLength!==f||L.directionalLength!==g||L.pointLength!==p||L.spotLength!==y||L.rectAreaLength!==E||L.hemiLength!==M||L.numSunShadows!==m||L.numDirectionalShadows!==x||L.numPointShadows!==S||L.numSpotShadows!==A||L.numSpotMaps!==v||L.numLightProbes!==R)&&(n.sun.length=f,n.directional.length=g,n.spot.length=y,n.rectArea.length=E,n.point.length=p,n.hemi.length=M,n.sunShadow.length=m,n.sunShadowMap.length=m,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=x,n.directionalShadowMap.length=x,n.directionalShadowMatrix.length=x,n.pointShadow.length=S,n.pointShadowMap.length=S,n.pointShadowMatrix.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+v-w,n.spotLightMap.length=v,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,L.sunLength=f,L.directionalLength=g,L.pointLength=p,L.spotLength=y,L.rectAreaLength=E,L.hemiLength=M,L.numSunShadows=m,L.numDirectionalShadows=x,L.numPointShadows=S,L.numSpotShadows=A,L.numSpotMaps=v,L.numLightProbes=R,n.version=Gv++)}function l(c,h){let d=0,u=0,f=0,m=0,_=0,g=0,p=h.matrixWorldInverse;for(let y=0,E=c.length;y=o.length?(a=new ef(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var Yv=`void main() { +`+k+` +`+Y)}else F!==""?Wt("WebGLProgram: Program Info Log:",F):(H===""||V==="")&&(U=!1);U&&(L.diagnostics={runnable:z,programLog:F,vertexShader:{log:H,prefix:g},fragmentShader:{log:V,prefix:p}})}s.deleteShader(x),s.deleteShader(S),v=new Os(s,_),E=yv(s,_)}let v;this.getUniforms=function(){return v===void 0&&A(this),v};let E;this.getAttributes=function(){return E===void 0&&A(this),E};let R=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=s.getProgramParameter(_,hv)),R},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=uv++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=x,this.fragmentShader=S,this}var Fv=0,fh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){let s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new ph(t),e.set(t,n)),n}},ph=class{constructor(t){this.id=Fv++,this.code=t,this.usedTimes=0}};function Bv(i){return i===Ei||i===Rr||i===Cr}function Ov(i,t,e,n,s,r){let o=new ws,a=new fh,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={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 m(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,E,R,L,N,B){let D=L.fog,F=N.geometry,H=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,V=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,z=t.get(v.envMap||H,V),U=z&&z.mapping===br?z.image.height:null,k=f[v.type];v.precision!==null&&(u=n.getMaxPrecision(v.precision),u!==v.precision&&Wt("WebGLProgram.getParameters:",v.precision,"not supported, using",u,"instead."));let Y=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,G=Y!==void 0?Y.length:0,J=0;F.morphAttributes.position!==void 0&&(J=1),F.morphAttributes.normal!==void 0&&(J=2),F.morphAttributes.color!==void 0&&(J=3);let it,nt,at,O;if(k){let be=Kn[k];it=be.vertexShader,nt=be.fragmentShader}else{it=v.vertexShader,nt=v.fragmentShader;let be=a.getVertexShaderStage(v),ue=a.getFragmentShaderStage(v);a.update(v,be,ue),at=be.id,O=ue.id}let $=i.getRenderTarget(),rt=i.state.buffers.depth.getReversed(),mt=N.isInstancedMesh===!0,ht=N.isBatchedMesh===!0,Et=!!v.map,Zt=!!v.matcap,Ct=!!z,Yt=!!v.aoMap,Ht=!!v.lightMap,dt=!!v.bumpMap&&v.wireframe===!1,Nt=!!v.normalMap,Gt=!!v.displacementMap,ne=!!v.emissiveMap,pt=!!v.metalnessMap,Ut=!!v.roughnessMap,P=v.anisotropy>0,ft=v.clearcoat>0,Tt=v.dispersion>0,I=v.retroreflectivity>0,b=v.iridescence>0,Z=v.sheen>0,tt=v.transmission>0,st=P&&!!v.anisotropyMap,gt=ft&&!!v.clearcoatMap,_t=ft&&!!v.clearcoatNormalMap,ot=ft&&!!v.clearcoatRoughnessMap,ct=b&&!!v.iridescenceMap,xt=b&&!!v.iridescenceThicknessMap,Ot=Z&&!!v.sheenColorMap,bt=Z&&!!v.sheenRoughnessMap,vt=!!v.specularMap,zt=!!v.specularColorMap,Xt=!!v.specularIntensityMap,jt=tt&&!!v.transmissionMap,X=tt&&!!v.thicknessMap,yt=!!v.gradientMap,lt=!!v.alphaMap,Mt=v.alphaTest>0,Rt=!!v.alphaHash,ut=!!v.extensions,kt=En;v.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(kt=i.toneMapping);let Ft={shaderID:k,shaderType:v.type,shaderName:v.name,vertexShader:it,fragmentShader:nt,defines:v.defines,customVertexShaderID:at,customFragmentShaderID:O,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:ht,batchingColor:ht&&N._colorsTexture!==null,instancing:mt,instancingColor:mt&&N.instanceColor!==null,instancingMorph:mt&&N.morphTexture!==null,outputColorSpace:$===null?i.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:se.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Et,matcap:Zt,envMap:Ct,envMapMode:Ct&&z.mapping,envMapCubeUVHeight:U,aoMap:Yt,lightMap:Ht,bumpMap:dt,normalMap:Nt,displacementMap:Gt,emissiveMap:ne,normalMapObjectSpace:Nt&&v.normalMapType===bd,normalMapTangentSpace:Nt&&v.normalMapType===Ir,packedNormalMap:Nt&&v.normalMapType===Ir&&Bv(v.normalMap.format),metalnessMap:pt,roughnessMap:Ut,anisotropy:P,anisotropyMap:st,clearcoat:ft,clearcoatMap:gt,clearcoatNormalMap:_t,clearcoatRoughnessMap:ot,dispersion:Tt,retroreflection:I,iridescence:b,iridescenceMap:ct,iridescenceThicknessMap:xt,sheen:Z,sheenColorMap:Ot,sheenRoughnessMap:bt,specularMap:vt,specularColorMap:zt,specularIntensityMap:Xt,transmission:tt,transmissionMap:jt,thicknessMap:X,gradientMap:yt,opaque:v.transparent===!1&&v.blending===Ls&&v.alphaToCoverage===!1,alphaMap:lt,alphaTest:Mt,alphaHash:Rt,combine:v.combine,mapUv:Et&&m(v.map.channel),aoMapUv:Yt&&m(v.aoMap.channel),lightMapUv:Ht&&m(v.lightMap.channel),bumpMapUv:dt&&m(v.bumpMap.channel),normalMapUv:Nt&&m(v.normalMap.channel),displacementMapUv:Gt&&m(v.displacementMap.channel),emissiveMapUv:ne&&m(v.emissiveMap.channel),metalnessMapUv:pt&&m(v.metalnessMap.channel),roughnessMapUv:Ut&&m(v.roughnessMap.channel),anisotropyMapUv:st&&m(v.anisotropyMap.channel),clearcoatMapUv:gt&&m(v.clearcoatMap.channel),clearcoatNormalMapUv:_t&&m(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&m(v.clearcoatRoughnessMap.channel),iridescenceMapUv:ct&&m(v.iridescenceMap.channel),iridescenceThicknessMapUv:xt&&m(v.iridescenceThicknessMap.channel),sheenColorMapUv:Ot&&m(v.sheenColorMap.channel),sheenRoughnessMapUv:bt&&m(v.sheenRoughnessMap.channel),specularMapUv:vt&&m(v.specularMap.channel),specularColorMapUv:zt&&m(v.specularColorMap.channel),specularIntensityMapUv:Xt&&m(v.specularIntensityMap.channel),transmissionMapUv:jt&&m(v.transmissionMap.channel),thicknessMapUv:X&&m(v.thicknessMap.channel),alphaMapUv:lt&&m(v.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(Nt||P),vertexNormals:!!F.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!F.attributes.uv&&(Et||lt),fog:!!D,useFog:v.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||F.attributes.normal===void 0&&Nt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:rt,skinning:N.isSkinnedMesh===!0,hasPositionAttribute:F.attributes.position!==void 0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:G,morphTextureStride:J,numSunLights:E.sun.length,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numSunLightShadows:E.sunShadowMap.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:B.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&R.length>0,shadowMapType:i.shadowMap.type,toneMapping:kt,decodeVideoTexture:Et&&v.map.isVideoTexture===!0&&se.getTransfer(v.map.colorSpace)===fe,decodeVideoTextureEmissive:ne&&v.emissiveMap.isVideoTexture===!0&&se.getTransfer(v.emissiveMap.colorSpace)===fe,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ke,flipSided:v.side===ze,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:ut&&v.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ut&&v.extensions.multiDraw===!0||ht)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Ft.vertexUv1s=l.has(1),Ft.vertexUv2s=l.has(2),Ft.vertexUv3s=l.has(3),l.clear(),Ft}function g(v){let E=[];if(v.shaderID?E.push(v.shaderID):(E.push(v.customVertexShaderID),E.push(v.customFragmentShaderID)),v.defines!==void 0)for(let R in v.defines)E.push(R),E.push(v.defines[R]);return v.isRawShaderMaterial===!1&&(p(E,v),y(E,v),E.push(i.outputColorSpace)),E.push(v.customProgramCacheKey),E.join()}function p(v,E){v.push(E.precision),v.push(E.outputColorSpace),v.push(E.envMapMode),v.push(E.envMapCubeUVHeight),v.push(E.mapUv),v.push(E.alphaMapUv),v.push(E.lightMapUv),v.push(E.aoMapUv),v.push(E.bumpMapUv),v.push(E.normalMapUv),v.push(E.displacementMapUv),v.push(E.emissiveMapUv),v.push(E.metalnessMapUv),v.push(E.roughnessMapUv),v.push(E.anisotropyMapUv),v.push(E.clearcoatMapUv),v.push(E.clearcoatNormalMapUv),v.push(E.clearcoatRoughnessMapUv),v.push(E.iridescenceMapUv),v.push(E.iridescenceThicknessMapUv),v.push(E.sheenColorMapUv),v.push(E.sheenRoughnessMapUv),v.push(E.specularMapUv),v.push(E.specularColorMapUv),v.push(E.specularIntensityMapUv),v.push(E.transmissionMapUv),v.push(E.thicknessMapUv),v.push(E.combine),v.push(E.fogExp2),v.push(E.sizeAttenuation),v.push(E.morphTargetsCount),v.push(E.morphAttributeCount),v.push(E.numSunLights),v.push(E.numDirLights),v.push(E.numPointLights),v.push(E.numSpotLights),v.push(E.numSpotLightMaps),v.push(E.numHemiLights),v.push(E.numRectAreaLights),v.push(E.numSunLightShadows),v.push(E.numDirLightShadows),v.push(E.numPointLightShadows),v.push(E.numSpotLightShadows),v.push(E.numSpotLightShadowsWithMaps),v.push(E.numLightProbes),v.push(E.shadowMapType),v.push(E.toneMapping),v.push(E.numClippingPlanes),v.push(E.numClipIntersection),v.push(E.depthPacking)}function y(v,E){o.disableAll(),E.instancing&&o.enable(0),E.instancingColor&&o.enable(1),E.instancingMorph&&o.enable(2),E.matcap&&o.enable(3),E.envMap&&o.enable(4),E.normalMapObjectSpace&&o.enable(5),E.normalMapTangentSpace&&o.enable(6),E.clearcoat&&o.enable(7),E.iridescence&&o.enable(8),E.alphaTest&&o.enable(9),E.vertexColors&&o.enable(10),E.vertexAlphas&&o.enable(11),E.vertexUv1s&&o.enable(12),E.vertexUv2s&&o.enable(13),E.vertexUv3s&&o.enable(14),E.vertexTangents&&o.enable(15),E.anisotropy&&o.enable(16),E.alphaHash&&o.enable(17),E.batching&&o.enable(18),E.dispersion&&o.enable(19),E.retroreflection&&o.enable(24),E.batchingColor&&o.enable(20),E.gradientMap&&o.enable(21),E.packedNormalMap&&o.enable(22),E.vertexNormals&&o.enable(23),v.push(o.mask),o.disableAll(),E.fog&&o.enable(0),E.useFog&&o.enable(1),E.flatShading&&o.enable(2),E.logarithmicDepthBuffer&&o.enable(3),E.reversedDepthBuffer&&o.enable(4),E.skinning&&o.enable(5),E.morphTargets&&o.enable(6),E.morphNormals&&o.enable(7),E.morphColors&&o.enable(8),E.premultipliedAlpha&&o.enable(9),E.shadowMapEnabled&&o.enable(10),E.doubleSided&&o.enable(11),E.flipSided&&o.enable(12),E.useDepthPacking&&o.enable(13),E.dithering&&o.enable(14),E.transmission&&o.enable(15),E.sheen&&o.enable(16),E.opaque&&o.enable(17),E.pointsUvs&&o.enable(18),E.decodeVideoTexture&&o.enable(19),E.decodeVideoTextureEmissive&&o.enable(20),E.alphaToCoverage&&o.enable(21),E.numLightProbeGrids>0&&o.enable(22),E.hasPositionAttribute&&o.enable(23),v.push(o.mask)}function w(v){let E=f[v.type],R;if(E){let L=Kn[E];R=Ud.clone(L.uniforms)}else R=v.uniforms;return R}function M(v,E){let R=h.get(E);return R!==void 0?++R.usedTimes:(R=new Uv(i,E,v,s),c.push(R),h.set(E,R)),R}function x(v){if(--v.usedTimes===0){let E=c.indexOf(v);c[E]=c[c.length-1],c.pop(),h.delete(v.cacheKey),v.destroy()}}function S(v){a.remove(v)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:g,getUniforms:w,acquireProgram:M,releaseProgram:x,releaseShaderCache:S,programs:c,dispose:A}}function zv(){let i=new WeakMap;function t(o){return i.has(o)}function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function kv(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function ef(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function nf(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,m,_,g,p){let y=i[t];return y===void 0?(y={id:u.id,object:u,geometry:f,material:m,materialVariant:o(u),groupOrder:_,renderOrder:u.renderOrder,z:g,group:p},i[t]=y):(y.id=u.id,y.object=u,y.geometry=f,y.material=m,y.materialVariant=o(u),y.groupOrder=_,y.renderOrder=u.renderOrder,y.z=g,y.group=p),t++,y}function l(u,f,m,_,g,p,y){y.reversedDepth===!0&&(g=-g);let w=a(u,f,m,_,g,p);m.transmission>0?n.push(w):m.transparent===!0?s.push(w):e.push(w)}function c(u,f,m,_,g,p){let y=a(u,f,m,_,g,p);m.transmission>0?n.unshift(y):m.transparent===!0?s.unshift(y):e.unshift(y)}function h(u,f){e.length>1&&e.sort(u||kv),n.length>1&&n.sort(f||ef),s.length>1&&s.sort(f||ef)}function d(){for(let u=t,f=i.length;u=r.length?(o=new nf,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function Vv(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={direction:new C,color:new Vt};break;case"SpotLight":e={position:new C,direction:new C,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":e={color:new Vt,position:new C,halfWidth:new C,halfHeight:new C};break}return i[t.id]=e,e}}}function Gv(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"SunLight":case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Wv=0;function Xv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function qv(i){let t=new Vv,e=Gv(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);let s=new C,r=new Kt,o=new Kt;function a(c){let h=0,d=0,u=0;for(let N=0;N<9;N++)n.probe[N].set(0,0,0);let f=0,m=0,_=0,g=0,p=0,y=0,w=0,M=0,x=0,S=0,A=0,v=0,E=0,R=0;c.sort(Xv);for(let N=0,B=c.length;N0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=St.LTC_FLOAT_1,n.rectAreaLTC2=St.LTC_FLOAT_2):(n.rectAreaLTC1=St.LTC_HALF_1,n.rectAreaLTC2=St.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let L=n.hash;(L.sunLength!==f||L.directionalLength!==g||L.pointLength!==p||L.spotLength!==y||L.rectAreaLength!==w||L.hemiLength!==M||L.numSunShadows!==m||L.numDirectionalShadows!==x||L.numPointShadows!==S||L.numSpotShadows!==A||L.numSpotMaps!==v||L.numLightProbes!==R)&&(n.sun.length=f,n.directional.length=g,n.spot.length=y,n.rectArea.length=w,n.point.length=p,n.hemi.length=M,n.sunShadow.length=m,n.sunShadowMap.length=m,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=x,n.directionalShadowMap.length=x,n.directionalShadowMatrix.length=x,n.pointShadow.length=S,n.pointShadowMap.length=S,n.pointShadowMatrix.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+v-E,n.spotLightMap.length=v,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=R,L.sunLength=f,L.directionalLength=g,L.pointLength=p,L.spotLength=y,L.rectAreaLength=w,L.hemiLength=M,L.numSunShadows=m,L.numDirectionalShadows=x,L.numPointShadows=S,L.numSpotShadows=A,L.numSpotMaps=v,L.numLightProbes=R,n.version=Wv++)}function l(c,h){let d=0,u=0,f=0,m=0,_=0,g=0,p=h.matrixWorldInverse;for(let y=0,w=c.length;y=o.length?(a=new sf(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var $v=`void main() { gl_Position = vec4( position, 1.0 ); -}`,$v=`uniform sampler2D shadow_pass; +}`,Zv=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { @@ -4193,12 +4193,12 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); -}`,Zv=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],Kv=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],nf=new Zt,Dr=new C,ah=new C;function Jv(i,t,e){let n=new Hn,s=new qt,r=new qt,o=new ve,a=new Zo,l=new Ko,c={},h=e.maxTextureSize,d={[Yn]:ze,[ze]:Yn,[ke]:ke},u=new Ie({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qt},radius:{value:4}},vertexShader:Yv,fragmentShader:$v}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let m=new he;m.setAttribute("position",new xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new ge(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yr;let p=this.type;this.render=function(S,A,v){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;this.type===Ju&&(Gt("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=yr);let w=i.getRenderTarget(),R=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),N=i.state;N.setBlending($n),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let B=p!==this.type;B&&A.traverse(function(D){D.material&&(Array.isArray(D.material)?D.material.forEach(F=>F.needsUpdate=!0):D.material.needsUpdate=!0)});for(let D=0,F=S.length;Dh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/k.x),s.x=r.x*k.x,V.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/k.y),s.y=r.y*k.y,V.mapSize.y=r.y));let U=i.state.buffers.depth.getReversed();if(V.camera._reversedDepth=U,V.map===null||B===!0){if(V.map!==null&&(V.map.depthTexture!==null&&(V.map.depthTexture.dispose(),V.map.depthTexture=null),V.map.dispose()),this.type===Ps){if(H.isPointLight){Gt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new Be(s.x,s.y,{format:Ei,type:An,minFilter:qe,magFilter:qe,generateMipmaps:!1}),V.map.texture.name=H.name+".shadowMap",V.map.depthTexture=new Gn(s.x,s.y,Ye),V.map.depthTexture.name=H.name+".shadowMapDepth",V.map.depthTexture.format=On,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Le,V.map.depthTexture.magFilter=Le}else H.isPointLight?(V.map=new el(s.x),V.map.depthTexture=new Yo(s.x,Tn)):(V.map=new Be(s.x,s.y),V.map.depthTexture=new Gn(s.x,s.y,Tn)),V.map.depthTexture.name=H.name+".shadowMap",V.map.depthTexture.format=On,this.type===yr?(V.map.depthTexture.compareFunction=U?Ja:Ka,V.map.depthTexture.minFilter=qe,V.map.depthTexture.magFilter=qe):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Le,V.map.depthTexture.magFilter=Le);V.camera.updateProjectionMatrix()}V.map.isWebGLCubeRenderTarget!==!0&&(V.map.width!==s.x||V.map.height!==s.y)&&V.map.setSize(s.x,s.y);let O=V.map.isWebGLCubeRenderTarget?6:V.getViewportCount();H.isPointLight!==!0&&V.updateMatrices(H,v);for(let Y=0;Y0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let N=R.uuid,B=A.uuid,D=c[N];D===void 0&&(D={},c[N]=D);let F=D[B];F===void 0&&(F=R.clone(),D[B]=F,A.addEventListener("dispose",x)),R=F}if(R.visible=A.visible,R.wireframe=A.wireframe,w===Ps?R.side=A.shadowSide!==null?A.shadowSide:A.side:R.side=A.shadowSide!==null?A.shadowSide:d[A.side],R.alphaMap=A.alphaMap,R.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,R.map=A.map,R.clipShadows=A.clipShadows,R.clippingPlanes=A.clippingPlanes,R.clipIntersection=A.clipIntersection,R.displacementMap=A.displacementMap,R.displacementScale=A.displacementScale,R.displacementBias=A.displacementBias,R.wireframeLinewidth=A.wireframeLinewidth,R.linewidth=A.linewidth,v.isPointLight===!0&&R.isMeshDistanceMaterial===!0){let N=i.properties.get(R);N.light=v}return R}function M(S,A,v,w,R){if(S.visible===!1)return;if(S.layers.test(A.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&R===Ps)&&(!S.frustumCulled||S.intersectsFrustum(n))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);let B=t.update(S),D=S.material;if(Array.isArray(D)){let F=B.groups;for(let H=0,V=F.length;H=1):U.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),V=k>=2);let O=null,Y={},G=i.getParameter(i.SCISSOR_BOX),J=i.getParameter(i.VIEWPORT),rt=new ve().fromArray(G),nt=new ve().fromArray(J);function it(X,Mt,lt,bt){let Rt=new Uint8Array(4),ut=i.createTexture();i.bindTexture(X,ut),i.texParameteri(X,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(X,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ht=0;Ht"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new qt,h=new WeakMap,d=new Set,u,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(I,b){return m?new OffscreenCanvas(I,b):ys("canvas")}function g(I,b,Z){let tt=1,ot=Tt(I);if((ot.width>Z||ot.height>Z)&&(tt=Z/Math.max(ot.width,ot.height)),tt<1)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap||typeof VideoFrame<"u"&&I instanceof VideoFrame){let mt=Math.floor(tt*ot.width),xt=Math.floor(tt*ot.height);u===void 0&&(u=_(mt,xt));let at=b?_(mt,xt):u;return at.width=mt,at.height=xt,at.getContext("2d").drawImage(I,0,0,mt,xt),Gt("WebGLRenderer: Texture has been resized from ("+ot.width+"x"+ot.height+") to ("+mt+"x"+xt+")."),at}else return"data"in I&&Gt("WebGLRenderer: Image in DataTexture is too big ("+ot.width+"x"+ot.height+")."),I;return I}function p(I){return I.generateMipmaps}function y(I){i.generateMipmap(I)}function E(I){return I.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:I.isWebGL3DRenderTarget?i.TEXTURE_3D:I.isWebGLArrayRenderTarget||I.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(I,b,Z,tt,ot,mt=!1){if(I!==null){if(i[I]!==void 0)return i[I];Gt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let xt;tt&&(xt=t.get("EXT_texture_norm16"),xt||Gt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let at=b;if(b===i.RED&&(Z===i.FLOAT&&(at=i.R32F),Z===i.HALF_FLOAT&&(at=i.R16F),Z===i.UNSIGNED_BYTE&&(at=i.R8),Z===i.UNSIGNED_SHORT&&xt&&(at=xt.R16_EXT),Z===i.SHORT&&xt&&(at=xt.R16_SNORM_EXT)),b===i.RED_INTEGER&&(Z===i.UNSIGNED_BYTE&&(at=i.R8UI),Z===i.UNSIGNED_SHORT&&(at=i.R16UI),Z===i.UNSIGNED_INT&&(at=i.R32UI),Z===i.BYTE&&(at=i.R8I),Z===i.SHORT&&(at=i.R16I),Z===i.INT&&(at=i.R32I)),b===i.RG&&(Z===i.FLOAT&&(at=i.RG32F),Z===i.HALF_FLOAT&&(at=i.RG16F),Z===i.UNSIGNED_BYTE&&(at=i.RG8),Z===i.UNSIGNED_SHORT&&xt&&(at=xt.RG16_EXT),Z===i.SHORT&&xt&&(at=xt.RG16_SNORM_EXT)),b===i.RG_INTEGER&&(Z===i.UNSIGNED_BYTE&&(at=i.RG8UI),Z===i.UNSIGNED_SHORT&&(at=i.RG16UI),Z===i.UNSIGNED_INT&&(at=i.RG32UI),Z===i.BYTE&&(at=i.RG8I),Z===i.SHORT&&(at=i.RG16I),Z===i.INT&&(at=i.RG32I)),b===i.RGB_INTEGER&&(Z===i.UNSIGNED_BYTE&&(at=i.RGB8UI),Z===i.UNSIGNED_SHORT&&(at=i.RGB16UI),Z===i.UNSIGNED_INT&&(at=i.RGB32UI),Z===i.BYTE&&(at=i.RGB8I),Z===i.SHORT&&(at=i.RGB16I),Z===i.INT&&(at=i.RGB32I)),b===i.RGBA_INTEGER&&(Z===i.UNSIGNED_BYTE&&(at=i.RGBA8UI),Z===i.UNSIGNED_SHORT&&(at=i.RGBA16UI),Z===i.UNSIGNED_INT&&(at=i.RGBA32UI),Z===i.BYTE&&(at=i.RGBA8I),Z===i.SHORT&&(at=i.RGBA16I),Z===i.INT&&(at=i.RGBA32I)),b===i.RGB&&(Z===i.UNSIGNED_SHORT&&xt&&(at=xt.RGB16_EXT),Z===i.SHORT&&xt&&(at=xt.RGB16_SNORM_EXT),Z===i.UNSIGNED_INT_5_9_9_9_REV&&(at=i.RGB9_E5),Z===i.UNSIGNED_INT_10F_11F_11F_REV&&(at=i.R11F_G11F_B10F)),b===i.RGBA){let ct=mt?sr:ie.getTransfer(ot);Z===i.FLOAT&&(at=i.RGBA32F),Z===i.HALF_FLOAT&&(at=i.RGBA16F),Z===i.UNSIGNED_BYTE&&(at=ct===fe?i.SRGB8_ALPHA8:i.RGBA8),Z===i.UNSIGNED_SHORT&&xt&&(at=xt.RGBA16_EXT),Z===i.SHORT&&xt&&(at=xt.RGBA16_SNORM_EXT),Z===i.UNSIGNED_SHORT_4_4_4_4&&(at=i.RGBA4),Z===i.UNSIGNED_SHORT_5_5_5_1&&(at=i.RGB5_A1)}return(at===i.R16F||at===i.R32F||at===i.RG16F||at===i.RG32F||at===i.RGBA16F||at===i.RGBA32F)&&t.get("EXT_color_buffer_float"),at}function x(I,b){let Z;return I?b===null||b===Tn||b===Ns?Z=i.DEPTH24_STENCIL8:b===Ye?Z=i.DEPTH32F_STENCIL8:b===Ds&&(Z=i.DEPTH24_STENCIL8,Gt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===Tn||b===Ns?Z=i.DEPTH_COMPONENT24:b===Ye?Z=i.DEPTH_COMPONENT32F:b===Ds&&(Z=i.DEPTH_COMPONENT16),Z}function S(I,b){return p(I)===!0||I.isFramebufferTexture&&I.minFilter!==Le&&I.minFilter!==qe?Math.log2(Math.max(b.width,b.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?b.mipmaps.length:1}function A(I){let b=I.target;b.removeEventListener("dispose",A),w(b),b.isVideoTexture&&h.delete(b),b.isHTMLTexture&&d.delete(b)}function v(I){let b=I.target;b.removeEventListener("dispose",v),L(b)}function w(I){let b=n.get(I);if(b.__webglInit===void 0)return;let Z=I.source,tt=f.get(Z);if(tt){let ot=tt[b.__cacheKey];ot.usedTimes--,ot.usedTimes===0&&R(I),Object.keys(tt).length===0&&f.delete(Z)}n.remove(I)}function R(I){let b=n.get(I);i.deleteTexture(b.__webglTexture);let Z=I.source,tt=f.get(Z);delete tt[b.__cacheKey],o.memory.textures--}function L(I){let b=n.get(I);if(I.depthTexture&&(I.depthTexture.dispose(),n.remove(I.depthTexture)),I.isWebGLCubeRenderTarget)for(let tt=0;tt<6;tt++){if(Array.isArray(b.__webglFramebuffer[tt]))for(let ot=0;ot=s.maxTextures&&Gt("WebGLTextures: Trying to use "+(I+1)+" texture units while this GPU supports only "+s.maxTextures),N+=1,I}function V(I){let b=[];return b.push(I.wrapS),b.push(I.wrapT),b.push(I.wrapR||0),b.push(I.magFilter),b.push(I.minFilter),b.push(I.anisotropy),b.push(I.internalFormat),b.push(I.format),b.push(I.type),b.push(I.generateMipmaps),b.push(I.premultiplyAlpha),b.push(I.flipY),b.push(I.unpackAlignment),b.push(I.colorSpace),b.join()}function k(I,b){let Z=n.get(I);if(I.isVideoTexture&&P(I),I.isRenderTargetTexture===!1&&I.isExternalTexture!==!0&&I.version>0&&Z.__version!==I.version){let tt=I.image;if(tt===null)Gt("WebGLRenderer: Texture marked for update but no image data found.");else if(tt.complete===!1)Gt("WebGLRenderer: Texture marked for update but image is incomplete");else{st(Z,I,b);return}}else I.isExternalTexture&&(Z.__webglTexture=I.sourceTexture?I.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,Z.__webglTexture,i.TEXTURE0+b)}function U(I,b){let Z=n.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&Z.__version!==I.version){st(Z,I,b);return}else I.isExternalTexture&&(Z.__webglTexture=I.sourceTexture?I.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,Z.__webglTexture,i.TEXTURE0+b)}function O(I,b){let Z=n.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&Z.__version!==I.version){st(Z,I,b);return}e.bindTexture(i.TEXTURE_3D,Z.__webglTexture,i.TEXTURE0+b)}function Y(I,b){let Z=n.get(I);if(I.isCubeDepthTexture!==!0&&I.version>0&&Z.__version!==I.version){gt(Z,I,b);return}e.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture,i.TEXTURE0+b)}let G={[xs]:i.REPEAT,[Bn]:i.CLAMP_TO_EDGE,[zo]:i.MIRRORED_REPEAT},J={[Le]:i.NEAREST,[xd]:i.NEAREST_MIPMAP_NEAREST,[Sr]:i.NEAREST_MIPMAP_LINEAR,[qe]:i.LINEAR,[fa]:i.LINEAR_MIPMAP_NEAREST,[Si]:i.LINEAR_MIPMAP_LINEAR},rt={[bd]:i.NEVER,[Ad]:i.ALWAYS,[Sd]:i.LESS,[Ka]:i.LEQUAL,[wd]:i.EQUAL,[Ja]:i.GEQUAL,[Ed]:i.GREATER,[Td]:i.NOTEQUAL};function nt(I,b){if(b.type===Ye&&t.has("OES_texture_float_linear")===!1&&(b.magFilter===qe||b.magFilter===fa||b.magFilter===Sr||b.magFilter===Si||b.minFilter===qe||b.minFilter===fa||b.minFilter===Sr||b.minFilter===Si)&&Gt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(I,i.TEXTURE_WRAP_S,G[b.wrapS]),i.texParameteri(I,i.TEXTURE_WRAP_T,G[b.wrapT]),(I===i.TEXTURE_3D||I===i.TEXTURE_2D_ARRAY)&&i.texParameteri(I,i.TEXTURE_WRAP_R,G[b.wrapR]),i.texParameteri(I,i.TEXTURE_MAG_FILTER,J[b.magFilter]),i.texParameteri(I,i.TEXTURE_MIN_FILTER,J[b.minFilter]),b.compareFunction&&(i.texParameteri(I,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(I,i.TEXTURE_COMPARE_FUNC,rt[b.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Le||b.minFilter!==Sr&&b.minFilter!==Si||b.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){let Z=t.get("EXT_texture_filter_anisotropic");i.texParameterf(I,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,s.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function it(I,b){let Z=!1;I.__webglInit===void 0&&(I.__webglInit=!0,b.addEventListener("dispose",A));let tt=b.source,ot=f.get(tt);ot===void 0&&(ot={},f.set(tt,ot));let mt=V(b);if(mt!==I.__cacheKey){ot[mt]===void 0&&(ot[mt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),ot[mt].usedTimes++;let xt=ot[I.__cacheKey];xt!==void 0&&(ot[I.__cacheKey].usedTimes--,xt.usedTimes===0&&R(b)),I.__cacheKey=mt,I.__webglTexture=ot[mt].texture}return Z}function z(I,b,Z){return Math.floor(Math.floor(I/Z)/b)}function $(I,b,Z,tt){let mt=I.updateRanges;if(mt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,b.width,b.height,Z,tt,b.data);else{mt.sort((Ot,St)=>Ot.start-St.start);let xt=0;for(let Ot=1;Ot0){Xt&&Jt&&e.texStorage2D(i.TEXTURE_2D,Mt,St,zt[0].width,zt[0].height);for(let lt=0,bt=zt.length;lt0){let Rt=Kc(yt.width,yt.height,b.format,b.type);for(let ut of b.layerUpdates){let Ht=yt.data.subarray(ut*Rt/yt.data.BYTES_PER_ELEMENT,(ut+1)*Rt/yt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,lt,0,0,ut,yt.width,yt.height,1,vt,Ht)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,lt,0,0,0,yt.width,yt.height,ct.depth,vt,yt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,lt,St,yt.width,yt.height,ct.depth,0,yt.data,0,0);else Gt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Xt?X&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,lt,0,0,0,yt.width,yt.height,ct.depth,vt,Ot,yt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,lt,St,yt.width,yt.height,ct.depth,0,vt,Ot,yt.data);b.layerUpdates.size>0&&b.clearLayerUpdates()}else{Xt&&Jt&&e.texStorage2D(i.TEXTURE_2D,Mt,St,zt[0].width,zt[0].height);for(let lt=0,bt=zt.length;lt0){let lt=Kc(ct.width,ct.height,b.format,b.type);for(let bt of b.layerUpdates){let Rt=ct.data.subarray(bt*lt/ct.data.BYTES_PER_ELEMENT,(bt+1)*lt/ct.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,bt,ct.width,ct.height,1,vt,Ot,Rt)}b.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ct.width,ct.height,ct.depth,vt,Ot,ct.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,St,ct.width,ct.height,ct.depth,0,vt,Ot,ct.data);else if(b.isData3DTexture)Xt?(Jt&&e.texStorage3D(i.TEXTURE_3D,Mt,St,ct.width,ct.height,ct.depth),X&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ct.width,ct.height,ct.depth,vt,Ot,ct.data)):e.texImage3D(i.TEXTURE_3D,0,St,ct.width,ct.height,ct.depth,0,vt,Ot,ct.data);else if(b.isFramebufferTexture){if(Jt)if(Xt)e.texStorage2D(i.TEXTURE_2D,Mt,St,ct.width,ct.height);else{let lt=ct.width,bt=ct.height;for(let Rt=0;Rt>=1,bt>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in i){let lt=i.canvas;if(lt.hasAttribute("layoutsubtree")||lt.setAttribute("layoutsubtree","true"),ct.parentNode!==lt){lt.appendChild(ct),d.add(b),lt.onpaint=bt=>{let Rt=bt.changedElements;for(let ut of d)Rt.includes(ut.image)&&(ut.needsUpdate=!0)},lt.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,ct);else{let Rt=i.RGBA,ut=i.RGBA,Ht=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Rt,ut,Ht,ct)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(zt.length>0){if(Xt&&Jt){let lt=Tt(zt[0]);e.texStorage2D(i.TEXTURE_2D,Mt,St,lt.width,lt.height)}for(let lt=0,bt=zt.length;lt0&&bt++;let ut=Tt(St[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,bt,Jt,ut.width,ut.height)}for(let ut=0;ut<6;ut++)if(Ot){X?lt&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,0,0,St[ut].width,St[ut].height,zt,Xt,St[ut].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,Jt,St[ut].width,St[ut].height,0,zt,Xt,St[ut].data);for(let Ht=0;Ht>mt),yt=Math.max(1,b.height>>mt);ot===i.TEXTURE_3D||ot===i.TEXTURE_2D_ARRAY?e.texImage3D(ot,mt,ct,St,yt,b.depth,0,xt,at,null):e.texImage2D(ot,mt,ct,St,yt,0,xt,at,null)}e.bindFramebuffer(i.FRAMEBUFFER,I),Dt(b)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,tt,ot,Ot.__webglTexture,0,ft(b)):(ot===i.TEXTURE_2D||ot>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ot<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,tt,ot,Ot.__webglTexture,mt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function _t(I,b,Z){if(i.bindRenderbuffer(i.RENDERBUFFER,I),b.depthBuffer){let tt=b.depthTexture,ot=tt&&tt.isDepthTexture?tt.type:null,mt=x(b.stencilBuffer,ot),xt=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Dt(b)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ft(b),mt,b.width,b.height):Z?i.renderbufferStorageMultisample(i.RENDERBUFFER,ft(b),mt,b.width,b.height):i.renderbufferStorage(i.RENDERBUFFER,mt,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,xt,i.RENDERBUFFER,I)}else{let tt=b.textures;for(let ot=0;ot{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,tt.removeEventListener("dispose",ot)};tt.addEventListener("dispose",ot),b.__depthDisposeCallback=ot}b.__boundDepthTexture=tt}if(I.depthTexture&&!b.__autoAllocateDepthBuffer)if(Z)for(let tt=0;tt<6;tt++)Bt(b.__webglFramebuffer[tt],I,tt);else{let tt=I.texture.mipmaps;tt&&tt.length>0?Bt(b.__webglFramebuffer[0],I,0):Bt(b.__webglFramebuffer,I,0)}else if(Z){b.__webglDepthbuffer=[];for(let tt=0;tt<6;tt++)if(e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[tt]),b.__webglDepthbuffer[tt]===void 0)b.__webglDepthbuffer[tt]=i.createRenderbuffer(),_t(b.__webglDepthbuffer[tt],I,!1);else{let ot=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=b.__webglDepthbuffer[tt];i.bindRenderbuffer(i.RENDERBUFFER,mt),i.framebufferRenderbuffer(i.FRAMEBUFFER,ot,i.RENDERBUFFER,mt)}}else{let tt=I.texture.mipmaps;if(tt&&tt.length>0?e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=i.createRenderbuffer(),_t(b.__webglDepthbuffer,I,!1);else{let ot=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=b.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,mt),i.framebufferRenderbuffer(i.FRAMEBUFFER,ot,i.RENDERBUFFER,mt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Wt(I,b,Z){let tt=n.get(I);b!==void 0&&ht(tt.__webglFramebuffer,I,I.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Z!==void 0&&Ft(I)}function te(I){let b=I.texture,Z=n.get(I),tt=n.get(b);I.addEventListener("dispose",v);let ot=I.textures,mt=I.isWebGLCubeRenderTarget===!0,xt=ot.length>1;if(xt||(tt.__webglTexture===void 0&&(tt.__webglTexture=i.createTexture()),tt.__version=b.version,o.memory.textures++),mt){Z.__webglFramebuffer=[];for(let at=0;at<6;at++)if(b.mipmaps&&b.mipmaps.length>0){Z.__webglFramebuffer[at]=[];for(let ct=0;ct0){Z.__webglFramebuffer=[];for(let at=0;at0&&Dt(I)===!1){Z.__webglMultisampledFramebuffer=i.createFramebuffer(),Z.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let at=0;at0)for(let ct=0;ct0)for(let ct=0;ct0){if(Dt(I)===!1){let b=I.textures,Z=I.width,tt=I.height,ot=i.COLOR_BUFFER_BIT,mt=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,xt=n.get(I),at=b.length>1;if(at)for(let vt=0;vt0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,xt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,xt.__webglFramebuffer);for(let vt=0;vt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function P(I){let b=o.render.frame;h.get(I)!==b&&(h.set(I,b),I.update())}function dt(I,b){let Z=I.colorSpace,tt=I.format,ot=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||Z!==ir&&Z!==ai&&(ie.getTransfer(Z)===fe?(tt!==je||ot!==rn)&&Gt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Yt("WebGLTextures: Unsupported texture color space:",Z)),b}function Tt(I){return typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement?(c.width=I.naturalWidth||I.width,c.height=I.naturalHeight||I.height):typeof VideoFrame<"u"&&I instanceof VideoFrame?(c.width=I.displayWidth,c.height=I.displayHeight):(c.width=I.width,c.height=I.height),c}this.allocateTextureUnit=H,this.resetTextureUnits=B,this.getTextureUnits=D,this.setTextureUnits=F,this.setTexture2D=k,this.setTexture2DArray=U,this.setTexture3D=O,this.setTextureCube=Y,this.rebindTextures=Wt,this.setupRenderTarget=te,this.updateRenderTargetMipmap=pt,this.updateMultisampleRenderTarget=le,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=ht,this.useMultisampledRTT=Dt,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function ty(i,t){function e(n,s=ai){let r,o=ie.getTransfer(s);if(n===rn)return i.UNSIGNED_BYTE;if(n===ma)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ga)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Bc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Oc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Uc)return i.BYTE;if(n===Fc)return i.SHORT;if(n===Ds)return i.UNSIGNED_SHORT;if(n===pa)return i.INT;if(n===Tn)return i.UNSIGNED_INT;if(n===Ye)return i.FLOAT;if(n===An)return i.HALF_FLOAT;if(n===zc)return i.ALPHA;if(n===kc)return i.RGB;if(n===je)return i.RGBA;if(n===On)return i.DEPTH_COMPONENT;if(n===wi)return i.DEPTH_STENCIL;if(n===Us)return i.RED;if(n===_a)return i.RED_INTEGER;if(n===Ei)return i.RG;if(n===xa)return i.RG_INTEGER;if(n===va)return i.RGBA_INTEGER;if(n===wr||n===Er||n===Tr||n===Ar)if(o===fe)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===wr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===wr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ya||n===Ma||n===ba||n===Sa)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ya)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ma)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ba)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Sa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===wa||n===Ea||n===Ta||n===Aa||n===Ra||n===Rr||n===Ca)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===wa||n===Ea)return o===fe?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ta)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Aa)return r.COMPRESSED_R11_EAC;if(n===Ra)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Rr)return r.COMPRESSED_RG11_EAC;if(n===Ca)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ia||n===Pa||n===La||n===Da||n===Na||n===Ua||n===Fa||n===Ba||n===Oa||n===za||n===ka||n===Ha||n===Va||n===Ga)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ia)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Pa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===La)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Da)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Na)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ua)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Fa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ba)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Oa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===za)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ka)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ha)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Va)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ga)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Wa||n===Xa||n===qa)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Wa)return o===fe?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Xa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===qa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ya||n===$a||n===Cr||n===Za)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ya)return r.COMPRESSED_RED_RGTC1_EXT;if(n===$a)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Cr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Za)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ns?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var ey=` +}`,Kv=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],Jv=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],rf=new Kt,Dr=new C,ah=new C;function jv(i,t,e){let n=new Hn,s=new qt,r=new qt,o=new ve,a=new Zo,l=new Ko,c={},h=e.maxTextureSize,d={[Yn]:ze,[ze]:Yn,[ke]:ke},u=new Ie({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qt},radius:{value:4}},vertexShader:$v,fragmentShader:Zv}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let m=new he;m.setAttribute("position",new xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new ge(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yr;let p=this.type;this.render=function(S,A,v){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;this.type===Qu&&(Wt("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=yr);let E=i.getRenderTarget(),R=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),N=i.state;N.setBlending($n),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let B=p!==this.type;B&&A.traverse(function(D){D.material&&(Array.isArray(D.material)?D.material.forEach(F=>F.needsUpdate=!0):D.material.needsUpdate=!0)});for(let D=0,F=S.length;Dh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/z.x),s.x=r.x*z.x,V.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/z.y),s.y=r.y*z.y,V.mapSize.y=r.y));let U=i.state.buffers.depth.getReversed();if(V.camera._reversedDepth=U,V.map===null||B===!0){if(V.map!==null&&(V.map.depthTexture!==null&&(V.map.depthTexture.dispose(),V.map.depthTexture=null),V.map.dispose()),this.type===Ps){if(H.isPointLight){Wt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new Be(s.x,s.y,{format:Ei,type:An,minFilter:qe,magFilter:qe,generateMipmaps:!1}),V.map.texture.name=H.name+".shadowMap",V.map.depthTexture=new Gn(s.x,s.y,Ye),V.map.depthTexture.name=H.name+".shadowMapDepth",V.map.depthTexture.format=On,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Le,V.map.depthTexture.magFilter=Le}else H.isPointLight?(V.map=new el(s.x),V.map.depthTexture=new Yo(s.x,Tn)):(V.map=new Be(s.x,s.y),V.map.depthTexture=new Gn(s.x,s.y,Tn)),V.map.depthTexture.name=H.name+".shadowMap",V.map.depthTexture.format=On,this.type===yr?(V.map.depthTexture.compareFunction=U?Ja:Ka,V.map.depthTexture.minFilter=qe,V.map.depthTexture.magFilter=qe):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Le,V.map.depthTexture.magFilter=Le);V.camera.updateProjectionMatrix()}V.map.isWebGLCubeRenderTarget!==!0&&(V.map.width!==s.x||V.map.height!==s.y)&&V.map.setSize(s.x,s.y);let k=V.map.isWebGLCubeRenderTarget?6:V.getViewportCount();H.isPointLight!==!0&&V.updateMatrices(H,v);for(let Y=0;Y0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let N=R.uuid,B=A.uuid,D=c[N];D===void 0&&(D={},c[N]=D);let F=D[B];F===void 0&&(F=R.clone(),D[B]=F,A.addEventListener("dispose",x)),R=F}if(R.visible=A.visible,R.wireframe=A.wireframe,E===Ps?R.side=A.shadowSide!==null?A.shadowSide:A.side:R.side=A.shadowSide!==null?A.shadowSide:d[A.side],R.alphaMap=A.alphaMap,R.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,R.map=A.map,R.clipShadows=A.clipShadows,R.clippingPlanes=A.clippingPlanes,R.clipIntersection=A.clipIntersection,R.displacementMap=A.displacementMap,R.displacementScale=A.displacementScale,R.displacementBias=A.displacementBias,R.wireframeLinewidth=A.wireframeLinewidth,R.linewidth=A.linewidth,v.isPointLight===!0&&R.isMeshDistanceMaterial===!0){let N=i.properties.get(R);N.light=v}return R}function M(S,A,v,E,R){if(S.visible===!1)return;if(S.layers.test(A.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&R===Ps)&&(!S.frustumCulled||S.intersectsFrustum(n))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);let B=t.update(S),D=S.material;if(Array.isArray(D)){let F=B.groups;for(let H=0,V=F.length;H=1):U.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),V=z>=2);let k=null,Y={},G=i.getParameter(i.SCISSOR_BOX),J=i.getParameter(i.VIEWPORT),it=new ve().fromArray(G),nt=new ve().fromArray(J);function at(X,yt,lt,Mt){let Rt=new Uint8Array(4),ut=i.createTexture();i.bindTexture(X,ut),i.texParameteri(X,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(X,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let kt=0;kt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new qt,h=new WeakMap,d=new Set,u,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(I,b){return m?new OffscreenCanvas(I,b):ys("canvas")}function g(I,b,Z){let tt=1,st=Tt(I);if((st.width>Z||st.height>Z)&&(tt=Z/Math.max(st.width,st.height)),tt<1)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap||typeof VideoFrame<"u"&&I instanceof VideoFrame){let gt=Math.floor(tt*st.width),_t=Math.floor(tt*st.height);u===void 0&&(u=_(gt,_t));let ot=b?_(gt,_t):u;return ot.width=gt,ot.height=_t,ot.getContext("2d").drawImage(I,0,0,gt,_t),Wt("WebGLRenderer: Texture has been resized from ("+st.width+"x"+st.height+") to ("+gt+"x"+_t+")."),ot}else return"data"in I&&Wt("WebGLRenderer: Image in DataTexture is too big ("+st.width+"x"+st.height+")."),I;return I}function p(I){return I.generateMipmaps}function y(I){i.generateMipmap(I)}function w(I){return I.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:I.isWebGL3DRenderTarget?i.TEXTURE_3D:I.isWebGLArrayRenderTarget||I.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(I,b,Z,tt,st,gt=!1){if(I!==null){if(i[I]!==void 0)return i[I];Wt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let _t;tt&&(_t=t.get("EXT_texture_norm16"),_t||Wt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ot=b;if(b===i.RED&&(Z===i.FLOAT&&(ot=i.R32F),Z===i.HALF_FLOAT&&(ot=i.R16F),Z===i.UNSIGNED_BYTE&&(ot=i.R8),Z===i.UNSIGNED_SHORT&&_t&&(ot=_t.R16_EXT),Z===i.SHORT&&_t&&(ot=_t.R16_SNORM_EXT)),b===i.RED_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ot=i.R8UI),Z===i.UNSIGNED_SHORT&&(ot=i.R16UI),Z===i.UNSIGNED_INT&&(ot=i.R32UI),Z===i.BYTE&&(ot=i.R8I),Z===i.SHORT&&(ot=i.R16I),Z===i.INT&&(ot=i.R32I)),b===i.RG&&(Z===i.FLOAT&&(ot=i.RG32F),Z===i.HALF_FLOAT&&(ot=i.RG16F),Z===i.UNSIGNED_BYTE&&(ot=i.RG8),Z===i.UNSIGNED_SHORT&&_t&&(ot=_t.RG16_EXT),Z===i.SHORT&&_t&&(ot=_t.RG16_SNORM_EXT)),b===i.RG_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ot=i.RG8UI),Z===i.UNSIGNED_SHORT&&(ot=i.RG16UI),Z===i.UNSIGNED_INT&&(ot=i.RG32UI),Z===i.BYTE&&(ot=i.RG8I),Z===i.SHORT&&(ot=i.RG16I),Z===i.INT&&(ot=i.RG32I)),b===i.RGB_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ot=i.RGB8UI),Z===i.UNSIGNED_SHORT&&(ot=i.RGB16UI),Z===i.UNSIGNED_INT&&(ot=i.RGB32UI),Z===i.BYTE&&(ot=i.RGB8I),Z===i.SHORT&&(ot=i.RGB16I),Z===i.INT&&(ot=i.RGB32I)),b===i.RGBA_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ot=i.RGBA8UI),Z===i.UNSIGNED_SHORT&&(ot=i.RGBA16UI),Z===i.UNSIGNED_INT&&(ot=i.RGBA32UI),Z===i.BYTE&&(ot=i.RGBA8I),Z===i.SHORT&&(ot=i.RGBA16I),Z===i.INT&&(ot=i.RGBA32I)),b===i.RGB&&(Z===i.UNSIGNED_SHORT&&_t&&(ot=_t.RGB16_EXT),Z===i.SHORT&&_t&&(ot=_t.RGB16_SNORM_EXT),Z===i.UNSIGNED_INT_5_9_9_9_REV&&(ot=i.RGB9_E5),Z===i.UNSIGNED_INT_10F_11F_11F_REV&&(ot=i.R11F_G11F_B10F)),b===i.RGBA){let ct=gt?sr:se.getTransfer(st);Z===i.FLOAT&&(ot=i.RGBA32F),Z===i.HALF_FLOAT&&(ot=i.RGBA16F),Z===i.UNSIGNED_BYTE&&(ot=ct===fe?i.SRGB8_ALPHA8:i.RGBA8),Z===i.UNSIGNED_SHORT&&_t&&(ot=_t.RGBA16_EXT),Z===i.SHORT&&_t&&(ot=_t.RGBA16_SNORM_EXT),Z===i.UNSIGNED_SHORT_4_4_4_4&&(ot=i.RGBA4),Z===i.UNSIGNED_SHORT_5_5_5_1&&(ot=i.RGB5_A1)}return(ot===i.R16F||ot===i.R32F||ot===i.RG16F||ot===i.RG32F||ot===i.RGBA16F||ot===i.RGBA32F)&&t.get("EXT_color_buffer_float"),ot}function x(I,b){let Z;return I?b===null||b===Tn||b===Ns?Z=i.DEPTH24_STENCIL8:b===Ye?Z=i.DEPTH32F_STENCIL8:b===Ds&&(Z=i.DEPTH24_STENCIL8,Wt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===Tn||b===Ns?Z=i.DEPTH_COMPONENT24:b===Ye?Z=i.DEPTH_COMPONENT32F:b===Ds&&(Z=i.DEPTH_COMPONENT16),Z}function S(I,b){return p(I)===!0||I.isFramebufferTexture&&I.minFilter!==Le&&I.minFilter!==qe?Math.log2(Math.max(b.width,b.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?b.mipmaps.length:1}function A(I){let b=I.target;b.removeEventListener("dispose",A),E(b),b.isVideoTexture&&h.delete(b),b.isHTMLTexture&&d.delete(b)}function v(I){let b=I.target;b.removeEventListener("dispose",v),L(b)}function E(I){let b=n.get(I);if(b.__webglInit===void 0)return;let Z=I.source,tt=f.get(Z);if(tt){let st=tt[b.__cacheKey];st.usedTimes--,st.usedTimes===0&&R(I),Object.keys(tt).length===0&&f.delete(Z)}n.remove(I)}function R(I){let b=n.get(I);i.deleteTexture(b.__webglTexture);let Z=I.source,tt=f.get(Z);delete tt[b.__cacheKey],o.memory.textures--}function L(I){let b=n.get(I);if(I.depthTexture&&(I.depthTexture.dispose(),n.remove(I.depthTexture)),I.isWebGLCubeRenderTarget)for(let tt=0;tt<6;tt++){if(Array.isArray(b.__webglFramebuffer[tt]))for(let st=0;st=s.maxTextures&&Wt("WebGLTextures: Trying to use "+(I+1)+" texture units while this GPU supports only "+s.maxTextures),N+=1,I}function V(I){let b=[];return b.push(I.wrapS),b.push(I.wrapT),b.push(I.wrapR||0),b.push(I.magFilter),b.push(I.minFilter),b.push(I.anisotropy),b.push(I.internalFormat),b.push(I.format),b.push(I.type),b.push(I.generateMipmaps),b.push(I.premultiplyAlpha),b.push(I.flipY),b.push(I.unpackAlignment),b.push(I.colorSpace),b.join()}function z(I,b){let Z=n.get(I);if(I.isVideoTexture&&P(I),I.isRenderTargetTexture===!1&&I.isExternalTexture!==!0&&I.version>0&&Z.__version!==I.version){let tt=I.image;if(tt===null)Wt("WebGLRenderer: Texture marked for update but no image data found.");else if(tt.complete===!1)Wt("WebGLRenderer: Texture marked for update but image is incomplete");else{rt(Z,I,b);return}}else I.isExternalTexture&&(Z.__webglTexture=I.sourceTexture?I.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,Z.__webglTexture,i.TEXTURE0+b)}function U(I,b){let Z=n.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&Z.__version!==I.version){rt(Z,I,b);return}else I.isExternalTexture&&(Z.__webglTexture=I.sourceTexture?I.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,Z.__webglTexture,i.TEXTURE0+b)}function k(I,b){let Z=n.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&Z.__version!==I.version){rt(Z,I,b);return}e.bindTexture(i.TEXTURE_3D,Z.__webglTexture,i.TEXTURE0+b)}function Y(I,b){let Z=n.get(I);if(I.isCubeDepthTexture!==!0&&I.version>0&&Z.__version!==I.version){mt(Z,I,b);return}e.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture,i.TEXTURE0+b)}let G={[xs]:i.REPEAT,[Bn]:i.CLAMP_TO_EDGE,[zo]:i.MIRRORED_REPEAT},J={[Le]:i.NEAREST,[yd]:i.NEAREST_MIPMAP_NEAREST,[Sr]:i.NEAREST_MIPMAP_LINEAR,[qe]:i.LINEAR,[fa]:i.LINEAR_MIPMAP_NEAREST,[Si]:i.LINEAR_MIPMAP_LINEAR},it={[wd]:i.NEVER,[Cd]:i.ALWAYS,[Ed]:i.LESS,[Ka]:i.LEQUAL,[Td]:i.EQUAL,[Ja]:i.GEQUAL,[Ad]:i.GREATER,[Rd]:i.NOTEQUAL};function nt(I,b){if(b.type===Ye&&t.has("OES_texture_float_linear")===!1&&(b.magFilter===qe||b.magFilter===fa||b.magFilter===Sr||b.magFilter===Si||b.minFilter===qe||b.minFilter===fa||b.minFilter===Sr||b.minFilter===Si)&&Wt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(I,i.TEXTURE_WRAP_S,G[b.wrapS]),i.texParameteri(I,i.TEXTURE_WRAP_T,G[b.wrapT]),(I===i.TEXTURE_3D||I===i.TEXTURE_2D_ARRAY)&&i.texParameteri(I,i.TEXTURE_WRAP_R,G[b.wrapR]),i.texParameteri(I,i.TEXTURE_MAG_FILTER,J[b.magFilter]),i.texParameteri(I,i.TEXTURE_MIN_FILTER,J[b.minFilter]),b.compareFunction&&(i.texParameteri(I,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(I,i.TEXTURE_COMPARE_FUNC,it[b.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Le||b.minFilter!==Sr&&b.minFilter!==Si||b.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){let Z=t.get("EXT_texture_filter_anisotropic");i.texParameterf(I,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,s.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function at(I,b){let Z=!1;I.__webglInit===void 0&&(I.__webglInit=!0,b.addEventListener("dispose",A));let tt=b.source,st=f.get(tt);st===void 0&&(st={},f.set(tt,st));let gt=V(b);if(gt!==I.__cacheKey){st[gt]===void 0&&(st[gt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),st[gt].usedTimes++;let _t=st[I.__cacheKey];_t!==void 0&&(st[I.__cacheKey].usedTimes--,_t.usedTimes===0&&R(b)),I.__cacheKey=gt,I.__webglTexture=st[gt].texture}return Z}function O(I,b,Z){return Math.floor(Math.floor(I/Z)/b)}function $(I,b,Z,tt){let gt=I.updateRanges;if(gt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,b.width,b.height,Z,tt,b.data);else{gt.sort((Ot,bt)=>Ot.start-bt.start);let _t=0;for(let Ot=1;Ot0){Xt&&jt&&e.texStorage2D(i.TEXTURE_2D,yt,bt,zt[0].width,zt[0].height);for(let lt=0,Mt=zt.length;lt0){let Rt=Kc(vt.width,vt.height,b.format,b.type);for(let ut of b.layerUpdates){let kt=vt.data.subarray(ut*Rt/vt.data.BYTES_PER_ELEMENT,(ut+1)*Rt/vt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,lt,0,0,ut,vt.width,vt.height,1,xt,kt)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,lt,0,0,0,vt.width,vt.height,ct.depth,xt,vt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,lt,bt,vt.width,vt.height,ct.depth,0,vt.data,0,0);else Wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Xt?X&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,lt,0,0,0,vt.width,vt.height,ct.depth,xt,Ot,vt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,lt,bt,vt.width,vt.height,ct.depth,0,xt,Ot,vt.data);b.layerUpdates.size>0&&b.clearLayerUpdates()}else{Xt&&jt&&e.texStorage2D(i.TEXTURE_2D,yt,bt,zt[0].width,zt[0].height);for(let lt=0,Mt=zt.length;lt0){let lt=Kc(ct.width,ct.height,b.format,b.type);for(let Mt of b.layerUpdates){let Rt=ct.data.subarray(Mt*lt/ct.data.BYTES_PER_ELEMENT,(Mt+1)*lt/ct.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Mt,ct.width,ct.height,1,xt,Ot,Rt)}b.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ct.width,ct.height,ct.depth,xt,Ot,ct.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,bt,ct.width,ct.height,ct.depth,0,xt,Ot,ct.data);else if(b.isData3DTexture)Xt?(jt&&e.texStorage3D(i.TEXTURE_3D,yt,bt,ct.width,ct.height,ct.depth),X&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ct.width,ct.height,ct.depth,xt,Ot,ct.data)):e.texImage3D(i.TEXTURE_3D,0,bt,ct.width,ct.height,ct.depth,0,xt,Ot,ct.data);else if(b.isFramebufferTexture){if(jt)if(Xt)e.texStorage2D(i.TEXTURE_2D,yt,bt,ct.width,ct.height);else{let lt=ct.width,Mt=ct.height;for(let Rt=0;Rt>=1,Mt>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in i){let lt=i.canvas;if(lt.hasAttribute("layoutsubtree")||lt.setAttribute("layoutsubtree","true"),ct.parentNode!==lt){lt.appendChild(ct),d.add(b),lt.onpaint=Mt=>{let Rt=Mt.changedElements;for(let ut of d)Rt.includes(ut.image)&&(ut.needsUpdate=!0)},lt.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,ct);else{let Rt=i.RGBA,ut=i.RGBA,kt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Rt,ut,kt,ct)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(zt.length>0){if(Xt&&jt){let lt=Tt(zt[0]);e.texStorage2D(i.TEXTURE_2D,yt,bt,lt.width,lt.height)}for(let lt=0,Mt=zt.length;lt0&&Mt++;let ut=Tt(bt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,Mt,jt,ut.width,ut.height)}for(let ut=0;ut<6;ut++)if(Ot){X?lt&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,0,0,bt[ut].width,bt[ut].height,zt,Xt,bt[ut].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,jt,bt[ut].width,bt[ut].height,0,zt,Xt,bt[ut].data);for(let kt=0;kt>gt),vt=Math.max(1,b.height>>gt);st===i.TEXTURE_3D||st===i.TEXTURE_2D_ARRAY?e.texImage3D(st,gt,ct,bt,vt,b.depth,0,_t,ot,null):e.texImage2D(st,gt,ct,bt,vt,0,_t,ot,null)}e.bindFramebuffer(i.FRAMEBUFFER,I),Ut(b)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,tt,st,Ot.__webglTexture,0,pt(b)):(st===i.TEXTURE_2D||st>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&st<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,tt,st,Ot.__webglTexture,gt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Et(I,b,Z){if(i.bindRenderbuffer(i.RENDERBUFFER,I),b.depthBuffer){let tt=b.depthTexture,st=tt&&tt.isDepthTexture?tt.type:null,gt=x(b.stencilBuffer,st),_t=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Ut(b)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,pt(b),gt,b.width,b.height):Z?i.renderbufferStorageMultisample(i.RENDERBUFFER,pt(b),gt,b.width,b.height):i.renderbufferStorage(i.RENDERBUFFER,gt,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,_t,i.RENDERBUFFER,I)}else{let tt=b.textures;for(let st=0;st{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,tt.removeEventListener("dispose",st)};tt.addEventListener("dispose",st),b.__depthDisposeCallback=st}b.__boundDepthTexture=tt}if(I.depthTexture&&!b.__autoAllocateDepthBuffer)if(Z)for(let tt=0;tt<6;tt++)Zt(b.__webglFramebuffer[tt],I,tt);else{let tt=I.texture.mipmaps;tt&&tt.length>0?Zt(b.__webglFramebuffer[0],I,0):Zt(b.__webglFramebuffer,I,0)}else if(Z){b.__webglDepthbuffer=[];for(let tt=0;tt<6;tt++)if(e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[tt]),b.__webglDepthbuffer[tt]===void 0)b.__webglDepthbuffer[tt]=i.createRenderbuffer(),Et(b.__webglDepthbuffer[tt],I,!1);else{let st=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,gt=b.__webglDepthbuffer[tt];i.bindRenderbuffer(i.RENDERBUFFER,gt),i.framebufferRenderbuffer(i.FRAMEBUFFER,st,i.RENDERBUFFER,gt)}}else{let tt=I.texture.mipmaps;if(tt&&tt.length>0?e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=i.createRenderbuffer(),Et(b.__webglDepthbuffer,I,!1);else{let st=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,gt=b.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,gt),i.framebufferRenderbuffer(i.FRAMEBUFFER,st,i.RENDERBUFFER,gt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Yt(I,b,Z){let tt=n.get(I);b!==void 0&&ht(tt.__webglFramebuffer,I,I.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Z!==void 0&&Ct(I)}function Ht(I){let b=I.texture,Z=n.get(I),tt=n.get(b);I.addEventListener("dispose",v);let st=I.textures,gt=I.isWebGLCubeRenderTarget===!0,_t=st.length>1;if(_t||(tt.__webglTexture===void 0&&(tt.__webglTexture=i.createTexture()),tt.__version=b.version,o.memory.textures++),gt){Z.__webglFramebuffer=[];for(let ot=0;ot<6;ot++)if(b.mipmaps&&b.mipmaps.length>0){Z.__webglFramebuffer[ot]=[];for(let ct=0;ct0){Z.__webglFramebuffer=[];for(let ot=0;ot0&&Ut(I)===!1){Z.__webglMultisampledFramebuffer=i.createFramebuffer(),Z.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let ot=0;ot0)for(let ct=0;ct0)for(let ct=0;ct0){if(Ut(I)===!1){let b=I.textures,Z=I.width,tt=I.height,st=i.COLOR_BUFFER_BIT,gt=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,_t=n.get(I),ot=b.length>1;if(ot)for(let xt=0;xt0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,_t.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,_t.__webglFramebuffer);for(let xt=0;xt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&b.__useRenderToTexture!==!1}function P(I){let b=o.render.frame;h.get(I)!==b&&(h.set(I,b),I.update())}function ft(I,b){let Z=I.colorSpace,tt=I.format,st=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||Z!==ir&&Z!==ai&&(se.getTransfer(Z)===fe?(tt!==je||st!==rn)&&Wt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):$t("WebGLTextures: Unsupported texture color space:",Z)),b}function Tt(I){return typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement?(c.width=I.naturalWidth||I.width,c.height=I.naturalHeight||I.height):typeof VideoFrame<"u"&&I instanceof VideoFrame?(c.width=I.displayWidth,c.height=I.displayHeight):(c.width=I.width,c.height=I.height),c}this.allocateTextureUnit=H,this.resetTextureUnits=B,this.getTextureUnits=D,this.setTextureUnits=F,this.setTexture2D=z,this.setTexture2DArray=U,this.setTexture3D=k,this.setTextureCube=Y,this.rebindTextures=Yt,this.setupRenderTarget=Ht,this.updateRenderTargetMipmap=dt,this.updateMultisampleRenderTarget=ne,this.setupDepthRenderbuffer=Ct,this.setupFrameBufferTexture=ht,this.useMultisampledRTT=Ut,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function ey(i,t){function e(n,s=ai){let r,o=se.getTransfer(s);if(n===rn)return i.UNSIGNED_BYTE;if(n===ma)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ga)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Bc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Oc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Uc)return i.BYTE;if(n===Fc)return i.SHORT;if(n===Ds)return i.UNSIGNED_SHORT;if(n===pa)return i.INT;if(n===Tn)return i.UNSIGNED_INT;if(n===Ye)return i.FLOAT;if(n===An)return i.HALF_FLOAT;if(n===zc)return i.ALPHA;if(n===kc)return i.RGB;if(n===je)return i.RGBA;if(n===On)return i.DEPTH_COMPONENT;if(n===wi)return i.DEPTH_STENCIL;if(n===Us)return i.RED;if(n===_a)return i.RED_INTEGER;if(n===Ei)return i.RG;if(n===xa)return i.RG_INTEGER;if(n===va)return i.RGBA_INTEGER;if(n===wr||n===Er||n===Tr||n===Ar)if(o===fe)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===wr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===wr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ya||n===Ma||n===ba||n===Sa)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ya)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ma)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ba)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Sa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===wa||n===Ea||n===Ta||n===Aa||n===Ra||n===Rr||n===Ca)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===wa||n===Ea)return o===fe?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ta)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Aa)return r.COMPRESSED_R11_EAC;if(n===Ra)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Rr)return r.COMPRESSED_RG11_EAC;if(n===Ca)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ia||n===Pa||n===La||n===Da||n===Na||n===Ua||n===Fa||n===Ba||n===Oa||n===za||n===ka||n===Ha||n===Va||n===Ga)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ia)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Pa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===La)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Da)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Na)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ua)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Fa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ba)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Oa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===za)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ka)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ha)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Va)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ga)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Wa||n===Xa||n===qa)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Wa)return o===fe?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Xa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===qa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ya||n===$a||n===Cr||n===Za)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ya)return r.COMPRESSED_RED_RGTC1_EXT;if(n===$a)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Cr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Za)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ns?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var ny=` void main() { gl_Position = vec4( position, 1.0 ); -}`,ny=` +}`,iy=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4217,7 +4217,7 @@ void main() { } -}`,mh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ur(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new Ie({vertexShader:ey,fragmentShader:ny,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new ge(new cn(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},gh=class extends zn{constructor(t,e){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,m=null,_=typeof XRWebGLBinding<"u",g=new mh,p={},y=e.getContextAttributes(),E=null,M=null,x=[],S=[],A=new qt,v=null,w=null,R=new Ue;R.viewport=new ve;let L=new Ue;L.viewport=new ve;let N=[R,L],B=new ca,D=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let $=x[z];return $===void 0&&($=new Es,x[z]=$),$.getTargetRaySpace()},this.getControllerGrip=function(z){let $=x[z];return $===void 0&&($=new Es,x[z]=$),$.getGripSpace()},this.getHand=function(z){let $=x[z];return $===void 0&&($=new Es,x[z]=$),$.getHandSpace()};function H(z){let $=S.indexOf(z.inputSource);if($===-1)return;let st=x[$];st!==void 0&&(st.update(z.inputSource,z.frame,c||o),st.dispatchEvent({type:z.type,data:z.inputSource}))}function V(){s.removeEventListener("select",H),s.removeEventListener("selectstart",H),s.removeEventListener("selectend",H),s.removeEventListener("squeeze",H),s.removeEventListener("squeezestart",H),s.removeEventListener("squeezeend",H),s.removeEventListener("end",V),s.removeEventListener("inputsourceschange",k);for(let z=0;z=0&&(S[gt]=null,x[gt].disconnect(st))}for(let $=0;$=S.length){S.push(st),gt=_t;break}else if(S[_t]===null){S[_t]=st,gt=_t;break}if(gt===-1)break}let ht=x[gt];ht&&ht.connect(st)}}let U=new C,O=new C;function Y(z,$,st){U.setFromMatrixPosition($.matrixWorld),O.setFromMatrixPosition(st.matrixWorld);let gt=U.distanceTo(O),ht=$.projectionMatrix.elements,_t=st.projectionMatrix.elements,Bt=ht[14]/(ht[10]-1),Ft=ht[14]/(ht[10]+1),Wt=(ht[9]+1)/ht[5],te=(ht[9]-1)/ht[5],pt=(ht[8]-1)/ht[0],kt=(_t[8]+1)/_t[0],$t=Bt*pt,le=Bt*kt,ft=gt/(-pt+kt),Dt=ft*-pt;if($.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(Dt),z.translateZ(ft),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),ht[10]===-1)z.projectionMatrix.copy($.projectionMatrix),z.projectionMatrixInverse.copy($.projectionMatrixInverse);else{let P=Bt+ft,dt=Ft+ft,Tt=$t-Dt,I=le+(gt-Dt),b=Wt*Ft/dt*P,Z=te*Ft/dt*P;z.projectionMatrix.makePerspective(Tt,I,b,Z,P,dt),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function G(z,$){$===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices($.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let $=z.near,st=z.far;g.texture!==null&&(g.depthNear>0&&($=g.depthNear),g.depthFar>0&&(st=g.depthFar)),B.near=L.near=R.near=$,B.far=L.far=R.far=st,(D!==B.near||F!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),D=B.near,F=B.far),B.layers.mask=z.layers.mask|6,R.layers.mask=B.layers.mask&-5,L.layers.mask=B.layers.mask&-3;let gt=z.parent,ht=B.cameras;G(B,gt);for(let _t=0;_t0&&(g.alphaTest.value=p.alphaTest);let y=t.get(p),E=y.envMap,M=y.envMapRotation;E&&(g.envMap.value=E,g.envMapRotation.value.setFromMatrix4(iy.makeRotationFromEuler(M)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(hf),g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function o(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,y,E){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*y,g.scale.value=E*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function d(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function u(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,y){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===ze&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.retroreflectivity>0&&(g.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function _(g,p){let y=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function ry(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,x){let S=x.program;n.uniformBlockBinding(M,S)}function c(M,x){let S=s[M.id];S===void 0&&(g(M),S=h(M),s[M.id]=S,M.addEventListener("dispose",y));let A=x.program;n.updateUBOMapping(M,A);let v=t.render.frame;r[M.id]!==v&&(u(M),r[M.id]=v)}function h(M){let x=d();M.__bindingPointIndex=x;let S=i.createBuffer(),A=M.__size,v=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,A,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,S),S}function d(){for(let M=0;M0&&(S+=A-v),M.__size=S,M.__cache={},this}function p(M){let x={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(x.boundary=4,x.storage=4):M.isVector2?(x.boundary=8,x.storage=8):M.isVector3||M.isColor?(x.boundary=16,x.storage=12):M.isVector4?(x.boundary=16,x.storage=16):M.isMatrix3?(x.boundary=48,x.storage=48):M.isMatrix4?(x.boundary=64,x.storage=64):M.isTexture?Gt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(x.boundary=16,x.storage=M.byteLength):Gt("WebGLRenderer: Unsupported uniform value type.",M),x}function y(M){let x=M.target;x.removeEventListener("dispose",y);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete r[x.id]}function E(){for(let M in s)i.deleteBuffer(s[M]);o=[],s={},r={}}return{bind:l,update:c,dispose:E}}var oy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Zn=null;function ay(){return Zn===null&&(Zn=new mn(oy,16,16,Ei,An),Zn.name="DFG_LUT",Zn.minFilter=qe,Zn.magFilter=qe,Zn.wrapS=Bn,Zn.wrapT=Bn,Zn.generateMipmaps=!1,Zn.needsUpdate=!0),Zn}var Ti=class{constructor(t={}){let{canvas:e=Rd(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=rn}=t;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;let _=f,g=new Set([va,xa,_a]),p=new Set([rn,Tn,Ds,Ns,ma,ga]),y=new Uint32Array(4),E=new Int32Array(4),M=new C,x=null,S=null,A=[],v=[],w=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=En,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let R=this,L=!1,N=null,B=null,D=null,F=null;this._outputColorSpace=me;let H=0,V=0,k=null,U=-1,O=null,Y=new ve,G=new ve,J=null,rt=new Vt(0),nt=0,it=e.width,z=e.height,$=1,st=null,gt=null,ht=new ve(0,0,it,z),_t=new ve(0,0,it,z),Bt=!1,Ft=new Hn,Wt=!1,te=!1,pt=new Zt,kt=new C,$t=new ve,le={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ft=!1;function Dt(){return k===null?$:1}let P=n;function dt(T,W){return e.getContext(T,W)}let Tt,I,b,Z,tt,ot,mt,xt,at,ct,vt,Ot,St,yt,zt,Xt,Jt,X,Mt,lt,bt,Rt,ut;try{let T={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",be,!1),e.addEventListener("webglcontextrestored",ue,!1),e.addEventListener("webglcontextcreationerror",_n,!1),P===null){let W="webgl2";if(P=dt(W,T),P===null)throw dt(W)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Ht()}catch(T){throw e.removeEventListener("webglcontextlost",be,!1),e.removeEventListener("webglcontextrestored",ue,!1),e.removeEventListener("webglcontextcreationerror",_n,!1),Yt("WebGLRenderer: "+T.message),T}function Ht(){Tt=new px(P),Tt.init(),bt=new ty(P,Tt),I=new sx(P,Tt,t,bt),b=new jv(P,Tt),I.reversedDepthBuffer&&u&&b.buffers.depth.setReversed(!0),B=P.createFramebuffer(),D=P.createFramebuffer(),F=P.createFramebuffer(),Z=new _x(P),tt=new Ov,ot=new Qv(P,Tt,b,tt,I,bt,Z),mt=new fx(R),xt=new vg(P),Rt=new nx(P,xt),at=new mx(P,xt,Z,Rt),ct=new vx(P,at,xt,Rt,Z),X=new xx(P,I,ot),zt=new rx(tt),vt=new Bv(R,mt,Tt,I,Rt,zt),Ot=new sy(R,tt),St=new kv,yt=new qv(Tt),Jt=new ex(R,mt,b,ct,m,l),Xt=new Jv(R,ct,I),ut=new ry(P,Z,I,b),Mt=new ix(P,Tt,Z),lt=new gx(P,Tt,Z),Z.programs=vt.programs,R.capabilities=I,R.extensions=Tt,R.properties=tt,R.renderLists=St,R.shadowMap=Xt,R.state=b,R.info=Z}_!==rn&&(w=new Mx(_,e.width,e.height,a,s,r));let Nt=new gh(R,P);this.xr=Nt,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let T=Tt.get("WEBGL_lose_context");T&&T.loseContext()},this.forceContextRestore=function(){let T=Tt.get("WEBGL_lose_context");T&&T.restoreContext()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(T){T!==void 0&&($=T,this.setSize(it,z,!1))},this.getSize=function(T){return T.set(it,z)},this.setSize=function(T,W,et=!0){if(Nt.isPresenting){Gt("WebGLRenderer: Can't change size while VR device is presenting.");return}it=T,z=W,e.width=Math.floor(T*$),e.height=Math.floor(W*$),et===!0&&(e.style.width=T+"px",e.style.height=W+"px"),w!==null&&w.setSize(e.width,e.height),this.setViewport(0,0,T,W)},this.getDrawingBufferSize=function(T){return T.set(it*$,z*$).floor()},this.setDrawingBufferSize=function(T,W,et){it=T,z=W,$=et,e.width=Math.floor(T*et),e.height=Math.floor(W*et),this.setViewport(0,0,T,W)},this.setEffects=function(T){if(_===rn){Yt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(T){for(let W=0;W{function At(){if(j.forEach(function(It){let Pt=tt.get(It).currentProgram;(Pt===void 0||Pt.isReady())&&j.delete(It)}),j.size===0){Q(T);return}setTimeout(At,10)}Tt.get("KHR_parallel_shader_compile")!==null?At():setTimeout(At,10)})};let zl=null;function gm(T){zl&&zl(T)}function ru(){Pi.stop()}function ou(){Pi.start()}let Pi=new sf;Pi.setAnimationLoop(gm),typeof self<"u"&&Pi.setContext(self),this.setAnimationLoop=function(T){zl=T,Nt.setAnimationLoop(T),T===null?Pi.stop():Pi.start()},Nt.addEventListener("sessionstart",ru),Nt.addEventListener("sessionend",ou),this.render=function(T,W){if(W!==void 0&&W.isCamera!==!0){Yt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;N!==null&&N.renderStart(T,W);let et=Nt.enabled===!0&&Nt.isPresenting===!0,j=w!==null&&(k===null||et)&&w.begin(R,k);if(T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),W.parent===null&&W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),Nt.enabled===!0&&Nt.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Nt.cameraAutoUpdate===!0&&Nt.updateCamera(W),W=Nt.getCamera()),T.isScene===!0&&T.onBeforeRender(R,T,W,k),S=yt.get(T,v.length),S.init(W),S.state.textureUnits=ot.getTextureUnits(),v.push(S),pt.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),Ft.setFromProjectionMatrix(pt,bn,W.reversedDepth),te=this.localClippingEnabled,Wt=zt.init(this.clippingPlanes,te),x=St.get(T,A.length),x.init(),A.push(x),Nt.enabled===!0&&Nt.isPresenting===!0){let It=R.xr.getDepthSensingMesh();It!==null&&kl(It,W,-1/0,R.sortObjects)}kl(T,W,0,R.sortObjects),x.finish(),N!==null&&N.updateLights(S.state.lightsArray),R.sortObjects===!0&&x.sort(st,gt),ft=Nt.enabled===!1||Nt.isPresenting===!1||Nt.hasDepthSensing()===!1,ft&&Jt.addToRenderList(x,T),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Wt===!0&&zt.beginShadows();let Q=S.state.shadowsArray;if(Xt.render(Q,T,W),Wt===!0&&zt.endShadows(),(j&&w.hasRenderPass())===!1){let It=x.opaque,Et=x.transmissive;if(S.setupLights(),W.isArrayCamera){let Pt=W.cameras;if(Et.length>0)for(let Ut=0,jt=Pt.length;Ut0&&lu(It,Et,T,W),ft&&Jt.render(T),au(x,T,W)}k!==null&&V===0&&(ot.updateMultisampleRenderTarget(k),ot.updateRenderTargetMipmap(k)),j&&w.end(R),T.isScene===!0&&T.onAfterRender(R,T,W),Rt.resetDefaultState(),U=-1,O=null,v.pop(),v.length>0?(S=v[v.length-1],ot.setTextureUnits(S.state.textureUnits),Wt===!0&&zt.setGlobalState(R.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?x=A[A.length-1]:x=null,N!==null&&N.renderEnd()};function kl(T,W,et,j){if(T.visible===!1)return;if(T.layers.test(W.layers)){if(T.isGroup)et=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(W);else if(T.isLightProbeGrid)S.pushLightProbeGrid(T);else if(T.isLight)S.pushLight(T),T.castShadow&&S.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||T.intersectsFrustum(Ft)){j&&$t.setFromMatrixPosition(T.matrixWorld).applyMatrix4(pt);let It=ct.update(T),Et=T.material;Et.visible&&x.push(T,It,Et,et,$t.z,null,W)}}else if((T.isMesh||T.isLine||T.isPoints)&&(!T.frustumCulled||T.intersectsFrustum(Ft))){let It=ct.update(T),Et=T.material;if(j&&(T.boundingSphere!==void 0?(T.boundingSphere===null&&T.computeBoundingSphere(),$t.copy(T.boundingSphere.center)):(It.boundingSphere===null&&It.computeBoundingSphere(),$t.copy(It.boundingSphere.center)),$t.applyMatrix4(T.matrixWorld).applyMatrix4(pt)),Array.isArray(Et)){let Pt=It.groups;for(let Ut=0,jt=Pt.length;Ut0&&jr(Q,W,et),At.length>0&&jr(At,W,et),It.length>0&&jr(It,W,et),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function lu(T,W,et,j){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){let Lt=Tt.has("EXT_color_buffer_half_float")||Tt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new Be(1,1,{generateMipmaps:!0,type:Lt?An:rn,minFilter:Si,samples:Math.max(4,I.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ie.workingColorSpace})}let At=S.state.transmissionRenderTarget[j.id],It=j.viewport||Y;At.setSize(It.z*R.transmissionResolutionScale,It.w*R.transmissionResolutionScale);let Et=R.getRenderTarget(),Pt=R.getActiveCubeFace(),Ut=R.getActiveMipmapLevel();R.setRenderTarget(At),R.getClearColor(rt),nt=R.getClearAlpha(),nt<1&&R.setClearColor(16777215,.5),R.clear(),ft&&Jt.render(et);let jt=R.toneMapping;R.toneMapping=En;let ne=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Wt===!0&&zt.setGlobalState(R.clippingPlanes,j),jr(T,et,j),ot.updateMultisampleRenderTarget(At),ot.updateRenderTargetMipmap(At),Tt.has("WEBGL_multisampled_render_to_texture")===!1){let Lt=!1;for(let de=0,De=W.length;de0,j.currentProgram=ne,j.uniformsList=null,ne}function hu(T){if(T.uniformsList===null){let W=T.currentProgram.getUniforms();T.uniformsList=Os.seqWithValue(W.seq,T.uniforms)}return T.uniformsList}function uu(T,W){let et=tt.get(T);et.outputColorSpace=W.outputColorSpace,et.batching=W.batching,et.batchingColor=W.batchingColor,et.instancing=W.instancing,et.instancingColor=W.instancingColor,et.instancingMorph=W.instancingMorph,et.skinning=W.skinning,et.morphTargets=W.morphTargets,et.morphNormals=W.morphNormals,et.morphColors=W.morphColors,et.morphTargetsCount=W.morphTargetsCount,et.numClippingPlanes=W.numClippingPlanes,et.numIntersection=W.numClipIntersection,et.vertexAlphas=W.vertexAlphas,et.vertexTangents=W.vertexTangents,et.toneMapping=W.toneMapping}function _m(T,W){if(T.length===0)return null;if(T.length===1)return T[0].texture!==null?T[0]:null;M.setFromMatrixPosition(W.matrixWorld);for(let et=0,j=T.length;et0),Lt=!!et.morphAttributes.position,de=!!et.morphAttributes.normal,De=!!et.morphAttributes.color,Ee=En;j.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(Ee=R.toneMapping);let Me=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,$e=Me!==void 0?Me.length:0,Ct=tt.get(j),en=S.state.lights;if(Wt===!0&&(te===!0||T!==O)){let Se=T===O&&j.id===U;zt.setState(j,T,Se)}let ce=!1;j.version===Ct.__version?(Ct.needsLights&&Ct.lightsStateVersion!==en.state.version||Ct.outputColorSpace!==Et||Q.isBatchedMesh&&Ct.batching===!1||!Q.isBatchedMesh&&Ct.batching===!0||Q.isBatchedMesh&&Ct.batchingColor===!0&&Q._colorsTexture===null||Q.isBatchedMesh&&Ct.batchingColor===!1&&Q._colorsTexture!==null||Q.isInstancedMesh&&Ct.instancing===!1||!Q.isInstancedMesh&&Ct.instancing===!0||Q.isSkinnedMesh&&Ct.skinning===!1||!Q.isSkinnedMesh&&Ct.skinning===!0||Q.isInstancedMesh&&Ct.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Ct.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Ct.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Ct.instancingMorph===!1&&Q.morphTexture!==null||Ct.envMap!==Ut||j.fog===!0&&Ct.fog!==At||Ct.numClippingPlanes!==void 0&&(Ct.numClippingPlanes!==zt.numPlanes||Ct.numIntersection!==zt.numIntersection)||Ct.vertexAlphas!==jt||Ct.vertexTangents!==ne||Ct.morphTargets!==Lt||Ct.morphNormals!==de||Ct.morphColors!==De||Ct.toneMapping!==Ee||Ct.morphTargetsCount!==$e||!!Ct.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ce=!0):(ce=!0,Ct.__version=j.version);let dn=Ct.currentProgram;ce===!0&&(dn=Qr(j,W,Q),N&&j.isNodeMaterial&&N.onUpdateProgram(j,dn,Ct));let Un=!1,ci=!1,ji=!1,_e=dn.getUniforms(),Pe=Ct.uniforms;if(b.useProgram(dn.program)&&(Un=!0,ci=!0,ji=!0),j.id!==U&&(U=j.id,ci=!0),Ct.needsLights){let Se=_m(S.state.lightProbeGridArray,Q);Ct.lightProbeGrid!==Se&&(Ct.lightProbeGrid=Se,ci=!0)}if(Un||O!==T){b.buffers.depth.getReversed()&&T.reversedDepth!==!0&&(T._reversedDepth=!0,T.updateProjectionMatrix()),_e.setValue(P,"projectionMatrix",T.projectionMatrix),_e.setValue(P,"viewMatrix",T.matrixWorldInverse);let ui=_e.map.cameraPosition;ui!==void 0&&ui.setValue(P,kt.setFromMatrixPosition(T.matrixWorld)),I.logarithmicDepthBuffer&&_e.setValue(P,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&_e.setValue(P,"isOrthographic",T.isOrthographicCamera===!0),O!==T&&(O=T,ci=!0,ji=!0)}if(Ct.needsLights&&(en.state.sunShadowMap.length>0&&_e.setValue(P,"sunShadowMap",en.state.sunShadowMap,ot),en.state.directionalShadowMap.length>0&&_e.setValue(P,"directionalShadowMap",en.state.directionalShadowMap,ot),en.state.spotShadowMap.length>0&&_e.setValue(P,"spotShadowMap",en.state.spotShadowMap,ot),en.state.pointShadowMap.length>0&&_e.setValue(P,"pointShadowMap",en.state.pointShadowMap,ot)),Q.isSkinnedMesh){_e.setOptional(P,Q,"bindMatrix"),_e.setOptional(P,Q,"bindMatrixInverse");let Se=Q.skeleton;Se&&(Se.boneTexture===null&&Se.computeBoneTexture(),_e.setValue(P,"boneTexture",Se.boneTexture,ot))}Q.isBatchedMesh&&(_e.setOptional(P,Q,"batchingTexture"),_e.setValue(P,"batchingTexture",Q._matricesTexture,ot),_e.setOptional(P,Q,"batchingIdTexture"),_e.setValue(P,"batchingIdTexture",Q._indirectTexture,ot),_e.setOptional(P,Q,"batchingColorTexture"),Q._colorsTexture!==null&&_e.setValue(P,"batchingColorTexture",Q._colorsTexture,ot));let hi=et.morphAttributes;if((hi.position!==void 0||hi.normal!==void 0||hi.color!==void 0)&&X.update(Q,et,dn),(ci||Ct.receiveShadow!==Q.receiveShadow)&&(Ct.receiveShadow=Q.receiveShadow,_e.setValue(P,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&W.environment!==null&&(Pe.envMapIntensity.value=W.environmentIntensity),Pe.dfgLUT!==void 0&&(Pe.dfgLUT.value=ay()),ci){if(_e.setValue(P,"toneMappingExposure",R.toneMappingExposure),Ct.needsLights&&vm(Pe,ji),At&&j.fog===!0&&Ot.refreshFogUniforms(Pe,At),Ot.refreshMaterialUniforms(Pe,j,$,z,S.state.transmissionRenderTarget[T.id]),Ct.needsLights&&Ct.lightProbeGrid){let Se=Ct.lightProbeGrid;Pe.probesSH.value=Se.texture,Pe.probesMin.value.copy(Se.boundingBox.min),Pe.probesMax.value.copy(Se.boundingBox.max),Pe.probesResolution.value.copy(Se.resolution)}Os.upload(P,hu(Ct),Pe,ot)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Os.upload(P,hu(Ct),Pe,ot),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&_e.setValue(P,"center",Q.center),_e.setValue(P,"modelViewMatrix",Q.modelViewMatrix),_e.setValue(P,"normalMatrix",Q.normalMatrix),_e.setValue(P,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){let Se=j.uniformsGroups;for(let ui=0,Qi=Se.length;ui0&&ot.useMultisampledRTT(T)===!1?j=tt.get(T).__webglMultisampledFramebuffer:Array.isArray(Ut)?j=Ut[et]:j=Ut,Y.copy(T.viewport),G.copy(T.scissor),J=T.scissorTest}else Y.copy(ht).multiplyScalar($).floor(),G.copy(_t).multiplyScalar($).floor(),J=Bt;if(et!==0&&(j=B),b.bindFramebuffer(P.FRAMEBUFFER,j)&&b.drawBuffers(T,j),b.viewport(Y),b.scissor(G),b.setScissorTest(J),Q){let Et=tt.get(T.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+W,Et.__webglTexture,et)}else if(At){let Et=W;for(let Pt=0;Pt1&&P.readBuffer(P.COLOR_ATTACHMENT0+Et);let Lt=du(Ut);if(Lt.__formatReadable===!1){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Lt.__typeReadable===!1){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}W>=0&&W<=T.width-j&&et>=0&&et<=T.height-Q&&P.readPixels(W,et,j,Q,bt.convert(jt),bt.convert(ne),At)}finally{let Ut=k!==null?tt.get(k).__webglFramebuffer:null;b.bindFramebuffer(P.FRAMEBUFFER,Ut)}}},this.readRenderTargetPixelsAsync=async function(T,W,et,j,Q,At,It,Et=0){if(!(T&&T.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pt=tt.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&It!==void 0&&(Pt=Pt[It]),Pt)if(W>=0&&W<=T.width-j&&et>=0&&et<=T.height-Q){b.bindFramebuffer(P.FRAMEBUFFER,Pt);let Ut=T.textures[Et],jt=Ut.format,ne=Ut.type;T.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+Et);let Lt=du(Ut);if(Lt.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Lt.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let de=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.bufferData(P.PIXEL_PACK_BUFFER,At.byteLength,P.STREAM_READ),P.readPixels(W,et,j,Q,bt.convert(jt),bt.convert(ne),0),P.bindBuffer(P.PIXEL_PACK_BUFFER,null);let De=k!==null?tt.get(k).__webglFramebuffer:null;b.bindFramebuffer(P.FRAMEBUFFER,De);let Ee=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await Id(P,Ee,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,At),P.bindBuffer(P.PIXEL_PACK_BUFFER,null),P.deleteBuffer(de),P.deleteSync(Ee),At}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,W=null,et=0){let j=Math.pow(2,-et),Q=Math.floor(T.image.width*j),At=Math.floor(T.image.height*j),It=W!==null?W.x:0,Et=W!==null?W.y:0;ot.setTexture2D(T,0),P.copyTexSubImage2D(P.TEXTURE_2D,et,0,0,It,Et,Q,At),b.unbindTexture()},this.copyTextureToTexture=function(T,W,et=null,j=null,Q=0,At=0){let It,Et,Pt,Ut,jt,ne,Lt,de,De,Ee=T.isCompressedTexture?T.mipmaps[At]:T.image;if(et!==null)It=et.max.x-et.min.x,Et=et.max.y-et.min.y,Pt=et.isBox3?et.max.z-et.min.z:1,Ut=et.min.x,jt=et.min.y,ne=et.isBox3?et.min.z:0;else{let Pe=Math.pow(2,-Q);It=Math.floor(Ee.width*Pe),Et=Math.floor(Ee.height*Pe),T.isDataArrayTexture?Pt=Ee.depth:T.isData3DTexture?Pt=Math.floor(Ee.depth*Pe):Pt=1,Ut=0,jt=0,ne=0}j!==null?(Lt=j.x,de=j.y,De=j.z):(Lt=0,de=0,De=0);let Me=bt.convert(W.format),$e=bt.convert(W.type),Ct;W.isData3DTexture?(ot.setTexture3D(W,0),Ct=P.TEXTURE_3D):W.isDataArrayTexture||W.isCompressedArrayTexture?(ot.setTexture2DArray(W,0),Ct=P.TEXTURE_2D_ARRAY):(ot.setTexture2D(W,0),Ct=P.TEXTURE_2D),b.activeTexture(P.TEXTURE0),b.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,W.flipY),b.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,W.premultiplyAlpha),b.pixelStorei(P.UNPACK_ALIGNMENT,W.unpackAlignment);let en=b.getParameter(P.UNPACK_ROW_LENGTH),ce=b.getParameter(P.UNPACK_IMAGE_HEIGHT),dn=b.getParameter(P.UNPACK_SKIP_PIXELS),Un=b.getParameter(P.UNPACK_SKIP_ROWS),ci=b.getParameter(P.UNPACK_SKIP_IMAGES);b.pixelStorei(P.UNPACK_ROW_LENGTH,Ee.width),b.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Ee.height),b.pixelStorei(P.UNPACK_SKIP_PIXELS,Ut),b.pixelStorei(P.UNPACK_SKIP_ROWS,jt),b.pixelStorei(P.UNPACK_SKIP_IMAGES,ne);let ji=T.isDataArrayTexture||T.isData3DTexture,_e=W.isDataArrayTexture||W.isData3DTexture;if(T.isDepthTexture){let Pe=tt.get(T),hi=tt.get(W),Se=tt.get(Pe.__renderTarget),ui=tt.get(hi.__renderTarget);b.bindFramebuffer(P.READ_FRAMEBUFFER,Se.__webglFramebuffer),b.bindFramebuffer(P.DRAW_FRAMEBUFFER,ui.__webglFramebuffer);for(let Qi=0;Qi=c.length){s-=c.length;continue}let h=Math.min(o,c.length-s);if(a.push(c.substringData(s,h)),o-=h,s=0,!o)break}let l=new Uint8Array(Math.ceil((r+e)/3)*3);if(_h(l,0,a.join(""))i!==null&&typeof i=="object"&&!Array.isArray(i),Rn=i=>Array.isArray(i)&&i.every(Yi),Ai=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number"),gf=i=>Yi(i)&&Ai(i.min)&&Ai(i.max),ff=i=>i==null||Yi(i)&&Rn(i.planes)&&i.planes.every(t=>Ai(t.normal)&&t.normal.every(Number.isFinite)&&t.normal.some(e=>e!==0)&&Number.isFinite(t.offset))&&(i.box==null||gf(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function hy(i){if(!Yi(i)||!Rn(i.elements)||!Rn(i.geometries)||!Rn(i.materials)||!Yi(i.instances))throw new ee("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new ee("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new ee("Invalid META instance count.");for(let[n,s,r]of[["geometry","u32",t.count],["material","u32",t.count],["element","i32",t.count],["matrix","f32",t.count*12]])if(t[n]?.t!==s||t[n].n!==r)throw new ee(`Invalid META instance ${n} view.`);for(let n of i.geometries){let s=n.q;if(!gf(n.bbox)||!["u16","u32"].includes(n.indices?.t)||n.positions?.t!==(s?"u16":"f32")||s&&(!Ai(s.o)||typeof s.s!="number")||n.normals!=null&&!["f32","i16"].includes(n.normals.t)||n.uvs!=null&&n.uvs.t!=="f32"||n.kind!=null&&n.kind!=="points"&&n.kind!=="lines"||n.colors!=null&&(n.kind!=="points"||n.colors.t!=="u8"||n.colors.n!==n.positions.n)||n.intensities!=null&&(n.kind!=="points"||n.intensities.t!=="u8"||3*n.intensities.n!==n.positions.n))throw new ee("Invalid META geometry.")}for(let n of["points","lines"])if(i[n]!=null){let s=i[n];if(!Yi(s)||!Number.isSafeInteger(s.count)||s.count<0)throw new ee(`Invalid META ${n} count.`);for(let[r,o,a]of[["geometry","u32",s.count],["material","u32",s.count],["element","i32",s.count],["matrix","f32",s.count*12]])if(s[r]?.t!==o||s[r].n!==a)throw new ee(`Invalid META ${n} ${r} view.`)}if(i.annotations!=null&&!Rn(i.annotations))throw new ee("Invalid META annotations.");if(i.sheets!=null&&!Rn(i.sheets))throw new ee("Invalid META sheets.");if(i.panoramas!=null&&(!Rn(i.panoramas)||i.panoramas.some(n=>!Number.isInteger(n.element)||n.element<0||n.element>=i.elements.length||n.name!=null&&typeof n.name!="string"||!Ai(n.position)||!n.position.every(Number.isFinite)||!Number.isFinite(n.yaw)||!e(n.image)||n.intensity!=null&&!e(n.intensity))))throw new ee("Invalid META panorama.");function e(n){return n?.t==="u8"&&Number.isSafeInteger(n.n)&&n.n>=4&&n.n<=16*1024*1024}uy(i);for(let n of i.materials){let s=n.texture;if(!Ai(n.color)||typeof n.opacity!="number"||s!=null&&(!Number.isInteger(s)||s<0||s>=(i.textures?.length??0)))throw new ee("Invalid META material.")}}function uy(i){if(!Yi(i)||!Rn(i.elements)||i.title!=null&&typeof i.title!="string")throw new ee("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!Rn(i[l]))throw new ee(`Invalid META ${l} list.`);if(i.models?.some(({id:l,name:c})=>!Number.isSafeInteger(l)||typeof c!="string")||i.elements.some(({modelId:l,levelId:c})=>l!=null&&!Number.isSafeInteger(l)||c!=null&&!Number.isSafeInteger(c)))throw new ee("Invalid META model or level identity.");let t=l=>l==null||Array.isArray(l)&&l.every(c=>Number.isInteger(c)&&c>=0&&cAi(l)&&l.every(Number.isFinite),n=l=>l==null||typeof l=="string",s=l=>e(l.camera?.position)&&e(l.camera?.target)&&ff(l.sections)&&t(l.hiddenElements)&&t(l.visibleElements)&&t(l.selectedElements)&&(l.hiddenElements==null||l.visibleElements==null)&&(l.hiddenModelKeys==null||Array.isArray(l.hiddenModelKeys)&&l.hiddenModelKeys.every(c=>typeof c=="string")),r=l=>Number.isSafeInteger(l)&&l>=0,o=l=>s(l)&&e(l.camera.up)&&l.camera.up.some(c=>c!==0)&&(l.camera.projection==="orthographic"?Number.isFinite(l.camera.orthographicHeight)&&l.camera.orthographicHeight>0:l.camera.projection==="perspective"&&Number.isFinite(l.camera.fov)&&l.camera.fov>0&&l.camera.fov<180)&&r(l.missingComponents)&&r(l.ambiguousComponents),a=l=>{let c=Ur(l);return Array.isArray(c)&&c.length>=2&&c.every(e)};if(i.grids?.some(l=>!a(l))||i.viewpoints?.some(l=>!s(l))||i.clashTests?.some(l=>!Rn(l.clashes)||l.clashes.some(c=>!Ai(c.point))))throw new ee("Invalid META grids, viewpoints or clashes.");if(i.bcfTopics?.some(l=>typeof l.title!="string"||!n(l.description)||!n(l.status)||!Rn(l.viewpoints)||l.viewpoints.some(c=>!o(c))))throw new ee("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new ee("Invalid META linked file members.");if(!ff(i.sections))throw new ee("Invalid META sections.")}function dy(i){let t;try{t=JSON.parse(i)}catch(e){throw new ee(e.message,{cause:e})}return hy(t),t}function xh(i=document,t){t?.("metadataStart");let e;try{e=mf(i,"ioviewer-meta")}catch(s){throw s instanceof ee?s:new ee(s.message,{cause:s})}let n=dy(e);return t?.("metadataEnd"),n}function pf(i,t){let e=ly[i?.t];if(!e)throw new ee(`Unknown view type '${i?.t}'.`);let n=e.BYTES_PER_ELEMENT;if(!(Number.isSafeInteger(i.o)&&Number.isSafeInteger(i.n)&&i.o>=0&&i.n>=0&&i.o%n===0&&i.o+i.n*n<=t))throw new ee(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function _f(i=document,t,e=xh(i,t)){let n,s,r,o;try{if(t?.("binaryStart"),s=i.getElementById("ioviewer-bin"),!s)throw new Error("Data block 'ioviewer-bin' is missing.");({bytes:n,canonical:r}=df(s)),t?.("binaryEnd")}catch(c){throw new ee(c.message,{cause:c})}let a=n.length,l=null;return{meta:e,view(c){if(!n)throw new Error("The binary data has been released.");let h=pf(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=pf(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=df(s).bytes));let d=n??o;return d?new h(d.buffer,c.o,c.n):new h(cy(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(mf(i,"ioviewer-props"))),l[c]??null}}}var xf=new Zt,vf=new Hn,vh=32;function yh(i,t=new Float64Array(24)){return xf.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),vf.setFromProjectionMatrix(xf,i.coordinateSystem,i.reversedDepth),vf.planes.forEach(({normal:e,constant:n},s)=>t.set([e.x,e.y,e.z,n],s*4)),t}function Mh(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]<-s)return!0;return!1}function yf(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]=0;r--)if(i[r]!==0){if(n+=i[r],n>e)return s?r===0?0:2**(r/2-4):2**((r+1)/2-4);s=!1}return 0}var Cn=.0009765625,Sh=32767,Fr=i=>i<0?-1:1;function bf(i){let t=Math.min(Math.max(i,-1),1)*Sh;return Fr(t)*Math.round(Math.abs(t))}function Br(i,t,e,n,s){let r=Math.abs(e)+Math.abs(n)+Math.abs(s);if(!(r>0)){i[t]=i[t+1]=0;return}let o=e/r,a=n/r;s<0&&([o,a]=[(1-Math.abs(a))*Fr(o),(1-Math.abs(o))*Fr(a)]),i[t]=bf(o),i[t+1]=bf(a)}function Sf(i,t,e,n){let s=Math.max(e/Sh,-1),r=Math.max(n/Sh,-1),o=1-Math.abs(s)-Math.abs(r);o<0&&([s,r]=[(1-Math.abs(r))*Fr(s),(1-Math.abs(s))*Fr(r)]);let a=Math.sqrt(s*s+r*r+o*o);i[t]=s/a,i[t+1]=r/a,i[t+2]=o/a}function Or(i,t){let e=i.view(t.positions);if(!t.q){if(!(e instanceof Float32Array))throw new Error(`Geometry positions of type '${t.positions.t}' need a "q" origin and step.`);return e}if(!(e instanceof Uint16Array))throw new Error(`Quantized geometry positions must be u16, got '${t.positions.t}'.`);return e}function Hs(i,t){let e=Or(i,t);if(!t.q)return e;let[n,s,r]=t.q.o,o=t.q.s,a=new Float32Array(e.length);for(let l=0;ls[d]&&(s[d]=u))}let r=0;for(let h=1;h<3;h++)s[h]-n[h]>s[r]-n[r]&&(r=h);let o=s[r]-n[r],a=2**20-1,l=new Float64Array(i.length);for(let h=0;h0&&Number.isFinite(u)?Math.round((u-n[r])/o*a):0;l[h]=f*2**32+d}let c=0;e<0?l.sort():c=py(l,e);for(let h=0;hr)return i.subarray(e,n+1).sort(),a+l*Math.ceil(Math.log2(l));a+=l,s=Math.imul(s,1664525)+1013904223>>>0;let c=i[e+s%(n-e+1)],h=e,d=n;for(;h<=d;){for(;i[h]c;)d--;if(h<=d){let u=i[h];i[h++]=i[d],i[d--]=u}}if(t<=d)n=d;else if(t>=h)e=h;else return a}return a}function If(i,t,e,n=1/0){let s=[];s.scanned=0;let r=[Uint32Array.from(t)];for(;r.length;){let o=r.pop(),a=Math.ceil(o.length/e);if(o.length<=1||a<=1&&my(o,i)<=n){o.length&&s.push(o);continue}let l=a>1?Math.ceil(o.length*Math.floor(a/2)/a):Math.ceil(o.length/2);s.scanned+=Cf(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function my(i,t){let e=1/0,n=1/0,s=1/0,r=-1/0,o=-1/0,a=-1/0;for(let l of i){let c=t[l*3],h=t[l*3+1],d=t[l*3+2];cr&&(r=c),ho&&(o=h),da&&(a=d)}return Math.hypot(r-e,o-n,a-s)/2}function Pf(i,t){let e=new Float64Array(6).fill(-1/0),n=new Float64Array(6).fill(-1/0),s=new Int32Array(6);for(let o=0;oe[a]?(n[a]=e[a],e[a]=c,s[a]=o):c>n[a]&&(n[a]=c)}if(e[0]===-1/0)return 0;let r=Math.hypot(e[0]+e[3],e[1]+e[4],e[2]+e[5]);if(n[0]===-1/0)return r;for(let o of s){let a=c=>s[c]===o?n[c]:e[c],l=Math.hypot(a(0)+a(3),a(1)+a(4),a(2)+a(5));r=Math.min(r,2*l)}return r}var Eh=384*2**20;function Lf(i,{cap:t=Eh,minRepeats:e=16,perCell:n=1024,maxDraws:s=1024}={}){let r=new Uint8Array(i.length),o=0;for(let h of i)o+=h.k*h.bytes;if(o<=t)return r;let a=h=>(i[h].k-1)*i[h].bytes,l=[...i.keys()].filter(h=>i[h].k>=e);l.sort((h,d)=>a(d)-a(h)||i[d].k-i[h].k||h-d);let c=0;for(let h of l){let d=i[h].cells??Math.ceil(i[h].k/n);c+d>s||(r[h]=1,c+=d)}return r}function sl(i,t){return i>65535?new Uint32Array(t):new Uint16Array(t)}function Th(i,t){return i.sort((e,n)=>t[n]-t[e]||e-n)}function Df(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function Nf(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function Uf(i,t,e,n){let s=i.subarray(t*12,t*12+12);if(s[0]===1&&s[1]===0&&s[2]===0&&s[3]===0&&s[4]===1&&s[5]===0&&s[6]===0&&s[7]===0&&s[8]===1&&e.q&&e.q.s===Cn){for(let a=0;a<3;a++)n[a]=s[9+a]+e.q.o[a];return Tf}let o=!0;for(let a=0;a<3;a++){let l=s[9+a],c=s[9+a];for(let h=0;h<3;h++){let d=s[h*3+a]*e.min[h],u=s[h*3+a]*e.max[h];l+=Math.min(d,u),c+=Math.max(d,u)}n[a]=Math.floor(l/Cn)*Cn,Math.ceil((c-n[a])/Cn)<=Af||(o=!1)}return o||n.fill(0),o?fy:Vs}function Ff(i,t){let e=i.length,n=0,s=0;for(let g of i){let p=t.source(t.geometryOf[g]);n+=p.vertices,s+=p.indices.length}let r=t.kind[i[0]]===Vs,o=r?new Float32Array(n*4):new Uint16Array(n*4),a=new Int16Array(n*2),l=t.textured?new Float32Array(n*2):null,c=sl(n,s),h=new Uint32Array(e+1),d=new Float32Array(e*3),u=new Float32Array(e),f=new Float64Array(3),m=0,_=0;for(let g=0;gMath.min(Math.max(Math.round(i/Cn),0),Af);function Bf(i,t,e,n,s){let r=i.length/3,o=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];for(let c=0;ca[h]&&(a[h]=d)}let l=e instanceof Int16Array?e:null;return{positions:i,q:t,oct:l,normals:l?null:e,indices:n,uvs:s,vertices:r,min:o,max:a}}function rl(i){if(!i.normals&&i.oct){i.normals=new Float32Array(i.vertices*3);for(let t=0;t=0&&(S[mt]=null,x[mt].disconnect(rt))}for(let $=0;$=S.length){S.push(rt),mt=Et;break}else if(S[Et]===null){S[Et]=rt,mt=Et;break}if(mt===-1)break}let ht=x[mt];ht&&ht.connect(rt)}}let U=new C,k=new C;function Y(O,$,rt){U.setFromMatrixPosition($.matrixWorld),k.setFromMatrixPosition(rt.matrixWorld);let mt=U.distanceTo(k),ht=$.projectionMatrix.elements,Et=rt.projectionMatrix.elements,Zt=ht[14]/(ht[10]-1),Ct=ht[14]/(ht[10]+1),Yt=(ht[9]+1)/ht[5],Ht=(ht[9]-1)/ht[5],dt=(ht[8]-1)/ht[0],Nt=(Et[8]+1)/Et[0],Gt=Zt*dt,ne=Zt*Nt,pt=mt/(-dt+Nt),Ut=pt*-dt;if($.matrixWorld.decompose(O.position,O.quaternion,O.scale),O.translateX(Ut),O.translateZ(pt),O.matrixWorld.compose(O.position,O.quaternion,O.scale),O.matrixWorldInverse.copy(O.matrixWorld).invert(),ht[10]===-1)O.projectionMatrix.copy($.projectionMatrix),O.projectionMatrixInverse.copy($.projectionMatrixInverse);else{let P=Zt+pt,ft=Ct+pt,Tt=Gt-Ut,I=ne+(mt-Ut),b=Yt*Ct/ft*P,Z=Ht*Ct/ft*P;O.projectionMatrix.makePerspective(Tt,I,b,Z,P,ft),O.projectionMatrixInverse.copy(O.projectionMatrix).invert()}}function G(O,$){$===null?O.matrixWorld.copy(O.matrix):O.matrixWorld.multiplyMatrices($.matrixWorld,O.matrix),O.matrixWorldInverse.copy(O.matrixWorld).invert()}this.updateCamera=function(O){if(s===null)return;let $=O.near,rt=O.far;g.texture!==null&&(g.depthNear>0&&($=g.depthNear),g.depthFar>0&&(rt=g.depthFar)),B.near=L.near=R.near=$,B.far=L.far=R.far=rt,(D!==B.near||F!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),D=B.near,F=B.far),B.layers.mask=O.layers.mask|6,R.layers.mask=B.layers.mask&-5,L.layers.mask=B.layers.mask&-3;let mt=O.parent,ht=B.cameras;G(B,mt);for(let Et=0;Et0&&(g.alphaTest.value=p.alphaTest);let y=t.get(p),w=y.envMap,M=y.envMapRotation;w&&(g.envMap.value=w,g.envMapRotation.value.setFromMatrix4(sy.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(df),g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function o(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,y,w){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*y,g.scale.value=w*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function d(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function u(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,y){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===ze&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.retroreflectivity>0&&(g.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function _(g,p){let y=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function oy(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,x){let S=x.program;n.uniformBlockBinding(M,S)}function c(M,x){let S=s[M.id];S===void 0&&(g(M),S=h(M),s[M.id]=S,M.addEventListener("dispose",y));let A=x.program;n.updateUBOMapping(M,A);let v=t.render.frame;r[M.id]!==v&&(u(M),r[M.id]=v)}function h(M){let x=d();M.__bindingPointIndex=x;let S=i.createBuffer(),A=M.__size,v=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,A,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,S),S}function d(){for(let M=0;M0&&(S+=A-v),M.__size=S,M.__cache={},this}function p(M){let x={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(x.boundary=4,x.storage=4):M.isVector2?(x.boundary=8,x.storage=8):M.isVector3||M.isColor?(x.boundary=16,x.storage=12):M.isVector4?(x.boundary=16,x.storage=16):M.isMatrix3?(x.boundary=48,x.storage=48):M.isMatrix4?(x.boundary=64,x.storage=64):M.isTexture?Wt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(x.boundary=16,x.storage=M.byteLength):Wt("WebGLRenderer: Unsupported uniform value type.",M),x}function y(M){let x=M.target;x.removeEventListener("dispose",y);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete r[x.id]}function w(){for(let M in s)i.deleteBuffer(s[M]);o=[],s={},r={}}return{bind:l,update:c,dispose:w}}var ay=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Zn=null;function ly(){return Zn===null&&(Zn=new mn(ay,16,16,Ei,An),Zn.name="DFG_LUT",Zn.minFilter=qe,Zn.magFilter=qe,Zn.wrapS=Bn,Zn.wrapT=Bn,Zn.generateMipmaps=!1,Zn.needsUpdate=!0),Zn}var Ti=class{constructor(t={}){let{canvas:e=Id(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=rn}=t;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;let _=f,g=new Set([va,xa,_a]),p=new Set([rn,Tn,Ds,Ns,ma,ga]),y=new Uint32Array(4),w=new Int32Array(4),M=new C,x=null,S=null,A=[],v=[],E=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=En,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let R=this,L=!1,N=null,B=null,D=null,F=null;this._outputColorSpace=me;let H=0,V=0,z=null,U=-1,k=null,Y=new ve,G=new ve,J=null,it=new Vt(0),nt=0,at=e.width,O=e.height,$=1,rt=null,mt=null,ht=new ve(0,0,at,O),Et=new ve(0,0,at,O),Zt=!1,Ct=new Hn,Yt=!1,Ht=!1,dt=new Kt,Nt=new C,Gt=new ve,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},pt=!1;function Ut(){return z===null?$:1}let P=n;function ft(T,W){return e.getContext(T,W)}let Tt,I,b,Z,tt,st,gt,_t,ot,ct,xt,Ot,bt,vt,zt,Xt,jt,X,yt,lt,Mt,Rt,ut;try{let T={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",be,!1),e.addEventListener("webglcontextrestored",ue,!1),e.addEventListener("webglcontextcreationerror",_n,!1),P===null){let W="webgl2";if(P=ft(W,T),P===null)throw ft(W)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}kt()}catch(T){throw e.removeEventListener("webglcontextlost",be,!1),e.removeEventListener("webglcontextrestored",ue,!1),e.removeEventListener("webglcontextcreationerror",_n,!1),$t("WebGLRenderer: "+T.message),T}function kt(){Tt=new mx(P),Tt.init(),Mt=new ey(P,Tt),I=new rx(P,Tt,t,Mt),b=new Qv(P,Tt),I.reversedDepthBuffer&&u&&b.buffers.depth.setReversed(!0),B=P.createFramebuffer(),D=P.createFramebuffer(),F=P.createFramebuffer(),Z=new xx(P),tt=new zv,st=new ty(P,Tt,b,tt,I,Mt,Z),gt=new px(R),_t=new yg(P),Rt=new ix(P,_t),ot=new gx(P,_t,Z,Rt),ct=new yx(P,ot,_t,Rt,Z),X=new vx(P,I,st),zt=new ox(tt),xt=new Ov(R,gt,Tt,I,Rt,zt),Ot=new ry(R,tt),bt=new Hv,vt=new Yv(Tt),jt=new nx(R,gt,b,ct,m,l),Xt=new jv(R,ct,I),ut=new oy(P,Z,I,b),yt=new sx(P,Tt,Z),lt=new _x(P,Tt,Z),Z.programs=xt.programs,R.capabilities=I,R.extensions=Tt,R.properties=tt,R.renderLists=bt,R.shadowMap=Xt,R.state=b,R.info=Z}_!==rn&&(E=new bx(_,e.width,e.height,a,s,r));let Ft=new gh(R,P);this.xr=Ft,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let T=Tt.get("WEBGL_lose_context");T&&T.loseContext()},this.forceContextRestore=function(){let T=Tt.get("WEBGL_lose_context");T&&T.restoreContext()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(T){T!==void 0&&($=T,this.setSize(at,O,!1))},this.getSize=function(T){return T.set(at,O)},this.setSize=function(T,W,et=!0){if(Ft.isPresenting){Wt("WebGLRenderer: Can't change size while VR device is presenting.");return}at=T,O=W,e.width=Math.floor(T*$),e.height=Math.floor(W*$),et===!0&&(e.style.width=T+"px",e.style.height=W+"px"),E!==null&&E.setSize(e.width,e.height),this.setViewport(0,0,T,W)},this.getDrawingBufferSize=function(T){return T.set(at*$,O*$).floor()},this.setDrawingBufferSize=function(T,W,et){at=T,O=W,$=et,e.width=Math.floor(T*et),e.height=Math.floor(W*et),this.setViewport(0,0,T,W)},this.setEffects=function(T){if(_===rn){$t("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(T){for(let W=0;W{function At(){if(j.forEach(function(Pt){let Lt=tt.get(Pt).currentProgram;(Lt===void 0||Lt.isReady())&&j.delete(Pt)}),j.size===0){Q(T);return}setTimeout(At,10)}Tt.get("KHR_parallel_shader_compile")!==null?At():setTimeout(At,10)})};let zl=null;function _m(T){zl&&zl(T)}function au(){Li.stop()}function lu(){Li.start()}let Li=new of;Li.setAnimationLoop(_m),typeof self<"u"&&Li.setContext(self),this.setAnimationLoop=function(T){zl=T,Ft.setAnimationLoop(T),T===null?Li.stop():Li.start()},Ft.addEventListener("sessionstart",au),Ft.addEventListener("sessionend",lu),this.render=function(T,W){if(W!==void 0&&W.isCamera!==!0){$t("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;N!==null&&N.renderStart(T,W);let et=Ft.enabled===!0&&Ft.isPresenting===!0,j=E!==null&&(z===null||et)&&E.begin(R,z);if(T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),W.parent===null&&W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),Ft.enabled===!0&&Ft.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Ft.cameraAutoUpdate===!0&&Ft.updateCamera(W),W=Ft.getCamera()),T.isScene===!0&&T.onBeforeRender(R,T,W,z),S=vt.get(T,v.length),S.init(W),S.state.textureUnits=st.getTextureUnits(),v.push(S),dt.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),Ct.setFromProjectionMatrix(dt,bn,W.reversedDepth),Ht=this.localClippingEnabled,Yt=zt.init(this.clippingPlanes,Ht),x=bt.get(T,A.length),x.init(),A.push(x),Ft.enabled===!0&&Ft.isPresenting===!0){let Pt=R.xr.getDepthSensingMesh();Pt!==null&&kl(Pt,W,-1/0,R.sortObjects)}kl(T,W,0,R.sortObjects),x.finish(),N!==null&&N.updateLights(S.state.lightsArray),R.sortObjects===!0&&x.sort(rt,mt),pt=Ft.enabled===!1||Ft.isPresenting===!1||Ft.hasDepthSensing()===!1,pt&&jt.addToRenderList(x,T),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Yt===!0&&zt.beginShadows();let Q=S.state.shadowsArray;if(Xt.render(Q,T,W),Yt===!0&&zt.endShadows(),(j&&E.hasRenderPass())===!1){let Pt=x.opaque,wt=x.transmissive;if(S.setupLights(),W.isArrayCamera){let Lt=W.cameras;if(wt.length>0)for(let Bt=0,Qt=Lt.length;Bt0&&hu(Pt,wt,T,W),pt&&jt.render(T),cu(x,T,W)}z!==null&&V===0&&(st.updateMultisampleRenderTarget(z),st.updateRenderTargetMipmap(z)),j&&E.end(R),T.isScene===!0&&T.onAfterRender(R,T,W),Rt.resetDefaultState(),U=-1,k=null,v.pop(),v.length>0?(S=v[v.length-1],st.setTextureUnits(S.state.textureUnits),Yt===!0&&zt.setGlobalState(R.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?x=A[A.length-1]:x=null,N!==null&&N.renderEnd()};function kl(T,W,et,j){if(T.visible===!1)return;if(T.layers.test(W.layers)){if(T.isGroup)et=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(W);else if(T.isLightProbeGrid)S.pushLightProbeGrid(T);else if(T.isLight)S.pushLight(T),T.castShadow&&S.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||T.intersectsFrustum(Ct)){j&&Gt.setFromMatrixPosition(T.matrixWorld).applyMatrix4(dt);let Pt=ct.update(T),wt=T.material;wt.visible&&x.push(T,Pt,wt,et,Gt.z,null,W)}}else if((T.isMesh||T.isLine||T.isPoints)&&(!T.frustumCulled||T.intersectsFrustum(Ct))){let Pt=ct.update(T),wt=T.material;if(j&&(T.boundingSphere!==void 0?(T.boundingSphere===null&&T.computeBoundingSphere(),Gt.copy(T.boundingSphere.center)):(Pt.boundingSphere===null&&Pt.computeBoundingSphere(),Gt.copy(Pt.boundingSphere.center)),Gt.applyMatrix4(T.matrixWorld).applyMatrix4(dt)),Array.isArray(wt)){let Lt=Pt.groups;for(let Bt=0,Qt=Lt.length;Bt0&&jr(Q,W,et),At.length>0&&jr(At,W,et),Pt.length>0&&jr(Pt,W,et),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function hu(T,W,et,j){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){let Dt=Tt.has("EXT_color_buffer_half_float")||Tt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new Be(1,1,{generateMipmaps:!0,type:Dt?An:rn,minFilter:Si,samples:Math.max(4,I.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:se.workingColorSpace})}let At=S.state.transmissionRenderTarget[j.id],Pt=j.viewport||Y;At.setSize(Pt.z*R.transmissionResolutionScale,Pt.w*R.transmissionResolutionScale);let wt=R.getRenderTarget(),Lt=R.getActiveCubeFace(),Bt=R.getActiveMipmapLevel();R.setRenderTarget(At),R.getClearColor(it),nt=R.getClearAlpha(),nt<1&&R.setClearColor(16777215,.5),R.clear(),pt&&jt.render(et);let Qt=R.toneMapping;R.toneMapping=En;let ie=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Yt===!0&&zt.setGlobalState(R.clippingPlanes,j),jr(T,et,j),st.updateMultisampleRenderTarget(At),st.updateRenderTargetMipmap(At),Tt.has("WEBGL_multisampled_render_to_texture")===!1){let Dt=!1;for(let de=0,De=W.length;de0,j.currentProgram=ie,j.uniformsList=null,ie}function du(T){if(T.uniformsList===null){let W=T.currentProgram.getUniforms();T.uniformsList=Os.seqWithValue(W.seq,T.uniforms)}return T.uniformsList}function fu(T,W){let et=tt.get(T);et.outputColorSpace=W.outputColorSpace,et.batching=W.batching,et.batchingColor=W.batchingColor,et.instancing=W.instancing,et.instancingColor=W.instancingColor,et.instancingMorph=W.instancingMorph,et.skinning=W.skinning,et.morphTargets=W.morphTargets,et.morphNormals=W.morphNormals,et.morphColors=W.morphColors,et.morphTargetsCount=W.morphTargetsCount,et.numClippingPlanes=W.numClippingPlanes,et.numIntersection=W.numClipIntersection,et.vertexAlphas=W.vertexAlphas,et.vertexTangents=W.vertexTangents,et.toneMapping=W.toneMapping}function xm(T,W){if(T.length===0)return null;if(T.length===1)return T[0].texture!==null?T[0]:null;M.setFromMatrixPosition(W.matrixWorld);for(let et=0,j=T.length;et0),Dt=!!et.morphAttributes.position,de=!!et.morphAttributes.normal,De=!!et.morphAttributes.color,Ee=En;j.toneMapped&&(z===null||z.isXRRenderTarget===!0)&&(Ee=R.toneMapping);let Me=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,$e=Me!==void 0?Me.length:0,It=tt.get(j),en=S.state.lights;if(Yt===!0&&(Ht===!0||T!==k)){let Se=T===k&&j.id===U;zt.setState(j,T,Se)}let ce=!1;j.version===It.__version?(It.needsLights&&It.lightsStateVersion!==en.state.version||It.outputColorSpace!==wt||Q.isBatchedMesh&&It.batching===!1||!Q.isBatchedMesh&&It.batching===!0||Q.isBatchedMesh&&It.batchingColor===!0&&Q._colorsTexture===null||Q.isBatchedMesh&&It.batchingColor===!1&&Q._colorsTexture!==null||Q.isInstancedMesh&&It.instancing===!1||!Q.isInstancedMesh&&It.instancing===!0||Q.isSkinnedMesh&&It.skinning===!1||!Q.isSkinnedMesh&&It.skinning===!0||Q.isInstancedMesh&&It.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&It.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&It.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&It.instancingMorph===!1&&Q.morphTexture!==null||It.envMap!==Bt||j.fog===!0&&It.fog!==At||It.numClippingPlanes!==void 0&&(It.numClippingPlanes!==zt.numPlanes||It.numIntersection!==zt.numIntersection)||It.vertexAlphas!==Qt||It.vertexTangents!==ie||It.morphTargets!==Dt||It.morphNormals!==de||It.morphColors!==De||It.toneMapping!==Ee||It.morphTargetsCount!==$e||!!It.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ce=!0):(ce=!0,It.__version=j.version);let dn=It.currentProgram;ce===!0&&(dn=Qr(j,W,Q),N&&j.isNodeMaterial&&N.onUpdateProgram(j,dn,It));let Un=!1,ci=!1,ji=!1,_e=dn.getUniforms(),Pe=It.uniforms;if(b.useProgram(dn.program)&&(Un=!0,ci=!0,ji=!0),j.id!==U&&(U=j.id,ci=!0),It.needsLights){let Se=xm(S.state.lightProbeGridArray,Q);It.lightProbeGrid!==Se&&(It.lightProbeGrid=Se,ci=!0)}if(Un||k!==T){b.buffers.depth.getReversed()&&T.reversedDepth!==!0&&(T._reversedDepth=!0,T.updateProjectionMatrix()),_e.setValue(P,"projectionMatrix",T.projectionMatrix),_e.setValue(P,"viewMatrix",T.matrixWorldInverse);let ui=_e.map.cameraPosition;ui!==void 0&&ui.setValue(P,Nt.setFromMatrixPosition(T.matrixWorld)),I.logarithmicDepthBuffer&&_e.setValue(P,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&_e.setValue(P,"isOrthographic",T.isOrthographicCamera===!0),k!==T&&(k=T,ci=!0,ji=!0)}if(It.needsLights&&(en.state.sunShadowMap.length>0&&_e.setValue(P,"sunShadowMap",en.state.sunShadowMap,st),en.state.directionalShadowMap.length>0&&_e.setValue(P,"directionalShadowMap",en.state.directionalShadowMap,st),en.state.spotShadowMap.length>0&&_e.setValue(P,"spotShadowMap",en.state.spotShadowMap,st),en.state.pointShadowMap.length>0&&_e.setValue(P,"pointShadowMap",en.state.pointShadowMap,st)),Q.isSkinnedMesh){_e.setOptional(P,Q,"bindMatrix"),_e.setOptional(P,Q,"bindMatrixInverse");let Se=Q.skeleton;Se&&(Se.boneTexture===null&&Se.computeBoneTexture(),_e.setValue(P,"boneTexture",Se.boneTexture,st))}Q.isBatchedMesh&&(_e.setOptional(P,Q,"batchingTexture"),_e.setValue(P,"batchingTexture",Q._matricesTexture,st),_e.setOptional(P,Q,"batchingIdTexture"),_e.setValue(P,"batchingIdTexture",Q._indirectTexture,st),_e.setOptional(P,Q,"batchingColorTexture"),Q._colorsTexture!==null&&_e.setValue(P,"batchingColorTexture",Q._colorsTexture,st));let hi=et.morphAttributes;if((hi.position!==void 0||hi.normal!==void 0||hi.color!==void 0)&&X.update(Q,et,dn),(ci||It.receiveShadow!==Q.receiveShadow)&&(It.receiveShadow=Q.receiveShadow,_e.setValue(P,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&W.environment!==null&&(Pe.envMapIntensity.value=W.environmentIntensity),Pe.dfgLUT!==void 0&&(Pe.dfgLUT.value=ly()),ci){if(_e.setValue(P,"toneMappingExposure",R.toneMappingExposure),It.needsLights&&ym(Pe,ji),At&&j.fog===!0&&Ot.refreshFogUniforms(Pe,At),Ot.refreshMaterialUniforms(Pe,j,$,O,S.state.transmissionRenderTarget[T.id]),It.needsLights&&It.lightProbeGrid){let Se=It.lightProbeGrid;Pe.probesSH.value=Se.texture,Pe.probesMin.value.copy(Se.boundingBox.min),Pe.probesMax.value.copy(Se.boundingBox.max),Pe.probesResolution.value.copy(Se.resolution)}Os.upload(P,du(It),Pe,st)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Os.upload(P,du(It),Pe,st),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&_e.setValue(P,"center",Q.center),_e.setValue(P,"modelViewMatrix",Q.modelViewMatrix),_e.setValue(P,"normalMatrix",Q.normalMatrix),_e.setValue(P,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){let Se=j.uniformsGroups;for(let ui=0,Qi=Se.length;ui0&&st.useMultisampledRTT(T)===!1?j=tt.get(T).__webglMultisampledFramebuffer:Array.isArray(Bt)?j=Bt[et]:j=Bt,Y.copy(T.viewport),G.copy(T.scissor),J=T.scissorTest}else Y.copy(ht).multiplyScalar($).floor(),G.copy(Et).multiplyScalar($).floor(),J=Zt;if(et!==0&&(j=B),b.bindFramebuffer(P.FRAMEBUFFER,j)&&b.drawBuffers(T,j),b.viewport(Y),b.scissor(G),b.setScissorTest(J),Q){let wt=tt.get(T.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+W,wt.__webglTexture,et)}else if(At){let wt=W;for(let Lt=0;Lt1&&P.readBuffer(P.COLOR_ATTACHMENT0+wt);let Dt=pu(Bt);if(Dt.__formatReadable===!1){$t("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Dt.__typeReadable===!1){$t("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}W>=0&&W<=T.width-j&&et>=0&&et<=T.height-Q&&P.readPixels(W,et,j,Q,Mt.convert(Qt),Mt.convert(ie),At)}finally{let Bt=z!==null?tt.get(z).__webglFramebuffer:null;b.bindFramebuffer(P.FRAMEBUFFER,Bt)}}},this.readRenderTargetPixelsAsync=async function(T,W,et,j,Q,At,Pt,wt=0){if(!(T&&T.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Lt=tt.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&Pt!==void 0&&(Lt=Lt[Pt]),Lt)if(W>=0&&W<=T.width-j&&et>=0&&et<=T.height-Q){b.bindFramebuffer(P.FRAMEBUFFER,Lt);let Bt=T.textures[wt],Qt=Bt.format,ie=Bt.type;T.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+wt);let Dt=pu(Bt);if(Dt.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Dt.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let de=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.bufferData(P.PIXEL_PACK_BUFFER,At.byteLength,P.STREAM_READ),P.readPixels(W,et,j,Q,Mt.convert(Qt),Mt.convert(ie),0),P.bindBuffer(P.PIXEL_PACK_BUFFER,null);let De=z!==null?tt.get(z).__webglFramebuffer:null;b.bindFramebuffer(P.FRAMEBUFFER,De);let Ee=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await Ld(P,Ee,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,At),P.bindBuffer(P.PIXEL_PACK_BUFFER,null),P.deleteBuffer(de),P.deleteSync(Ee),At}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,W=null,et=0){let j=Math.pow(2,-et),Q=Math.floor(T.image.width*j),At=Math.floor(T.image.height*j),Pt=W!==null?W.x:0,wt=W!==null?W.y:0;st.setTexture2D(T,0),P.copyTexSubImage2D(P.TEXTURE_2D,et,0,0,Pt,wt,Q,At),b.unbindTexture()},this.copyTextureToTexture=function(T,W,et=null,j=null,Q=0,At=0){let Pt,wt,Lt,Bt,Qt,ie,Dt,de,De,Ee=T.isCompressedTexture?T.mipmaps[At]:T.image;if(et!==null)Pt=et.max.x-et.min.x,wt=et.max.y-et.min.y,Lt=et.isBox3?et.max.z-et.min.z:1,Bt=et.min.x,Qt=et.min.y,ie=et.isBox3?et.min.z:0;else{let Pe=Math.pow(2,-Q);Pt=Math.floor(Ee.width*Pe),wt=Math.floor(Ee.height*Pe),T.isDataArrayTexture?Lt=Ee.depth:T.isData3DTexture?Lt=Math.floor(Ee.depth*Pe):Lt=1,Bt=0,Qt=0,ie=0}j!==null?(Dt=j.x,de=j.y,De=j.z):(Dt=0,de=0,De=0);let Me=Mt.convert(W.format),$e=Mt.convert(W.type),It;W.isData3DTexture?(st.setTexture3D(W,0),It=P.TEXTURE_3D):W.isDataArrayTexture||W.isCompressedArrayTexture?(st.setTexture2DArray(W,0),It=P.TEXTURE_2D_ARRAY):(st.setTexture2D(W,0),It=P.TEXTURE_2D),b.activeTexture(P.TEXTURE0),b.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,W.flipY),b.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,W.premultiplyAlpha),b.pixelStorei(P.UNPACK_ALIGNMENT,W.unpackAlignment);let en=b.getParameter(P.UNPACK_ROW_LENGTH),ce=b.getParameter(P.UNPACK_IMAGE_HEIGHT),dn=b.getParameter(P.UNPACK_SKIP_PIXELS),Un=b.getParameter(P.UNPACK_SKIP_ROWS),ci=b.getParameter(P.UNPACK_SKIP_IMAGES);b.pixelStorei(P.UNPACK_ROW_LENGTH,Ee.width),b.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Ee.height),b.pixelStorei(P.UNPACK_SKIP_PIXELS,Bt),b.pixelStorei(P.UNPACK_SKIP_ROWS,Qt),b.pixelStorei(P.UNPACK_SKIP_IMAGES,ie);let ji=T.isDataArrayTexture||T.isData3DTexture,_e=W.isDataArrayTexture||W.isData3DTexture;if(T.isDepthTexture){let Pe=tt.get(T),hi=tt.get(W),Se=tt.get(Pe.__renderTarget),ui=tt.get(hi.__renderTarget);b.bindFramebuffer(P.READ_FRAMEBUFFER,Se.__webglFramebuffer),b.bindFramebuffer(P.DRAW_FRAMEBUFFER,ui.__webglFramebuffer);for(let Qi=0;Qi=c.length){s-=c.length;continue}let h=Math.min(o,c.length-s);if(a.push(c.substringData(s,h)),o-=h,s=0,!o)break}let l=new Uint8Array(Math.ceil((r+e)/3)*3);if(_h(l,0,a.join(""))i!==null&&typeof i=="object"&&!Array.isArray(i),Rn=i=>Array.isArray(i)&&i.every($i),Ai=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number"),xf=i=>$i(i)&&Ai(i.min)&&Ai(i.max),mf=i=>i==null||$i(i)&&Rn(i.planes)&&i.planes.every(t=>Ai(t.normal)&&t.normal.every(Number.isFinite)&&t.normal.some(e=>e!==0)&&Number.isFinite(t.offset))&&(i.box==null||xf(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function uy(i){if(!$i(i)||!Rn(i.elements)||!Rn(i.geometries)||!Rn(i.materials)||!$i(i.instances))throw new ee("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new ee("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new ee("Invalid META instance count.");for(let[n,s,r]of[["geometry","u32",t.count],["material","u32",t.count],["element","i32",t.count],["matrix","f32",t.count*12]])if(t[n]?.t!==s||t[n].n!==r)throw new ee(`Invalid META instance ${n} view.`);for(let n of i.geometries){let s=n.q;if(!xf(n.bbox)||!["u16","u32"].includes(n.indices?.t)||n.positions?.t!==(s?"u16":"f32")||s&&(!Ai(s.o)||typeof s.s!="number")||n.normals!=null&&!["f32","i16"].includes(n.normals.t)||n.uvs!=null&&n.uvs.t!=="f32"||n.kind!=null&&n.kind!=="points"&&n.kind!=="lines"||n.colors!=null&&(n.kind!=="points"||n.colors.t!=="u8"||n.colors.n!==n.positions.n)||n.intensities!=null&&(n.kind!=="points"||n.intensities.t!=="u8"||3*n.intensities.n!==n.positions.n))throw new ee("Invalid META geometry.")}for(let n of["points","lines"])if(i[n]!=null){let s=i[n];if(!$i(s)||!Number.isSafeInteger(s.count)||s.count<0)throw new ee(`Invalid META ${n} count.`);for(let[r,o,a]of[["geometry","u32",s.count],["material","u32",s.count],["element","i32",s.count],["matrix","f32",s.count*12]])if(s[r]?.t!==o||s[r].n!==a)throw new ee(`Invalid META ${n} ${r} view.`)}if(i.annotations!=null&&!Rn(i.annotations))throw new ee("Invalid META annotations.");if(i.sheets!=null&&!Rn(i.sheets))throw new ee("Invalid META sheets.");if(i.panoramas!=null&&(!Rn(i.panoramas)||i.panoramas.some(n=>!Number.isInteger(n.element)||n.element<0||n.element>=i.elements.length||n.name!=null&&typeof n.name!="string"||!Ai(n.position)||!n.position.every(Number.isFinite)||!Number.isFinite(n.yaw)||!e(n.image)||n.intensity!=null&&!e(n.intensity))))throw new ee("Invalid META panorama.");function e(n){return n?.t==="u8"&&Number.isSafeInteger(n.n)&&n.n>=4&&n.n<=16*1024*1024}dy(i);for(let n of i.materials){let s=n.texture;if(!Ai(n.color)||typeof n.opacity!="number"||s!=null&&(!Number.isInteger(s)||s<0||s>=(i.textures?.length??0)))throw new ee("Invalid META material.")}}function dy(i){if(!$i(i)||!Rn(i.elements)||i.title!=null&&typeof i.title!="string")throw new ee("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!Rn(i[l]))throw new ee(`Invalid META ${l} list.`);if(i.models?.some(({id:l,name:c})=>!Number.isSafeInteger(l)||typeof c!="string")||i.elements.some(({modelId:l,levelId:c})=>l!=null&&!Number.isSafeInteger(l)||c!=null&&!Number.isSafeInteger(c)))throw new ee("Invalid META model or level identity.");let t=l=>l==null||Array.isArray(l)&&l.every(c=>Number.isInteger(c)&&c>=0&&cAi(l)&&l.every(Number.isFinite),n=l=>l==null||typeof l=="string",s=l=>e(l.camera?.position)&&e(l.camera?.target)&&mf(l.sections)&&t(l.hiddenElements)&&t(l.visibleElements)&&t(l.selectedElements)&&(l.hiddenElements==null||l.visibleElements==null)&&(l.hiddenModelKeys==null||Array.isArray(l.hiddenModelKeys)&&l.hiddenModelKeys.every(c=>typeof c=="string")),r=l=>Number.isSafeInteger(l)&&l>=0,o=l=>s(l)&&e(l.camera.up)&&l.camera.up.some(c=>c!==0)&&(l.camera.projection==="orthographic"?Number.isFinite(l.camera.orthographicHeight)&&l.camera.orthographicHeight>0:l.camera.projection==="perspective"&&Number.isFinite(l.camera.fov)&&l.camera.fov>0&&l.camera.fov<180)&&r(l.missingComponents)&&r(l.ambiguousComponents),a=l=>{let c=Ur(l);return Array.isArray(c)&&c.length>=2&&c.every(e)};if(i.grids?.some(l=>!a(l))||i.viewpoints?.some(l=>!s(l))||i.clashTests?.some(l=>!Rn(l.clashes)||l.clashes.some(c=>!Ai(c.point))))throw new ee("Invalid META grids, viewpoints or clashes.");if(i.bcfTopics?.some(l=>typeof l.title!="string"||!n(l.description)||!n(l.status)||!Rn(l.viewpoints)||l.viewpoints.some(c=>!o(c))))throw new ee("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new ee("Invalid META linked file members.");if(!mf(i.sections))throw new ee("Invalid META sections.")}function fy(i){let t;try{t=JSON.parse(i)}catch(e){throw new ee(e.message,{cause:e})}return uy(t),t}function xh(i=document,t){t?.("metadataStart");let e;try{e=_f(i,"ioviewer-meta")}catch(s){throw s instanceof ee?s:new ee(s.message,{cause:s})}let n=fy(e);return t?.("metadataEnd"),n}function gf(i,t){let e=cy[i?.t];if(!e)throw new ee(`Unknown view type '${i?.t}'.`);let n=e.BYTES_PER_ELEMENT;if(!(Number.isSafeInteger(i.o)&&Number.isSafeInteger(i.n)&&i.o>=0&&i.n>=0&&i.o%n===0&&i.o+i.n*n<=t))throw new ee(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function vf(i=document,t,e=xh(i,t)){let n,s,r,o;try{if(t?.("binaryStart"),s=i.getElementById("ioviewer-bin"),!s)throw new Error("Data block 'ioviewer-bin' is missing.");({bytes:n,canonical:r}=pf(s)),t?.("binaryEnd")}catch(c){throw new ee(c.message,{cause:c})}let a=n.length,l=null;return{meta:e,view(c){if(!n)throw new Error("The binary data has been released.");let h=gf(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=gf(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=pf(s).bytes));let d=n??o;return d?new h(d.buffer,c.o,c.n):new h(hy(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(_f(i,"ioviewer-props"))),l[c]??null}}}var yf=new Kt,Mf=new Hn,vh=32;function yh(i,t=new Float64Array(24)){return yf.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Mf.setFromProjectionMatrix(yf,i.coordinateSystem,i.reversedDepth),Mf.planes.forEach(({normal:e,constant:n},s)=>t.set([e.x,e.y,e.z,n],s*4)),t}function Mh(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]<-s)return!0;return!1}function bf(i,t,e,n,s){for(let r=0;r<24;r+=4)if(i[r]*t+i[r+1]*e+i[r+2]*n+i[r+3]=0;r--)if(i[r]!==0){if(n+=i[r],n>e)return s?r===0?0:2**(r/2-4):2**((r+1)/2-4);s=!1}return 0}var Cn=.0009765625,Sh=32767,Fr=i=>i<0?-1:1;function wf(i){let t=Math.min(Math.max(i,-1),1)*Sh;return Fr(t)*Math.round(Math.abs(t))}function Br(i,t,e,n,s){let r=Math.abs(e)+Math.abs(n)+Math.abs(s);if(!(r>0)){i[t]=i[t+1]=0;return}let o=e/r,a=n/r;s<0&&([o,a]=[(1-Math.abs(a))*Fr(o),(1-Math.abs(o))*Fr(a)]),i[t]=wf(o),i[t+1]=wf(a)}function Ef(i,t,e,n){let s=Math.max(e/Sh,-1),r=Math.max(n/Sh,-1),o=1-Math.abs(s)-Math.abs(r);o<0&&([s,r]=[(1-Math.abs(r))*Fr(s),(1-Math.abs(s))*Fr(r)]);let a=Math.sqrt(s*s+r*r+o*o);i[t]=s/a,i[t+1]=r/a,i[t+2]=o/a}function Or(i,t){let e=i.view(t.positions);if(!t.q){if(!(e instanceof Float32Array))throw new Error(`Geometry positions of type '${t.positions.t}' need a "q" origin and step.`);return e}if(!(e instanceof Uint16Array))throw new Error(`Quantized geometry positions must be u16, got '${t.positions.t}'.`);return e}function Hs(i,t){let e=Or(i,t);if(!t.q)return e;let[n,s,r]=t.q.o,o=t.q.s,a=new Float32Array(e.length);for(let l=0;ls[d]&&(s[d]=u))}let r=0;for(let h=1;h<3;h++)s[h]-n[h]>s[r]-n[r]&&(r=h);let o=s[r]-n[r],a=2**20-1,l=new Float64Array(i.length);for(let h=0;h0&&Number.isFinite(u)?Math.round((u-n[r])/o*a):0;l[h]=f*2**32+d}let c=0;e<0?l.sort():c=my(l,e);for(let h=0;hr)return i.subarray(e,n+1).sort(),a+l*Math.ceil(Math.log2(l));a+=l,s=Math.imul(s,1664525)+1013904223>>>0;let c=i[e+s%(n-e+1)],h=e,d=n;for(;h<=d;){for(;i[h]c;)d--;if(h<=d){let u=i[h];i[h++]=i[d],i[d--]=u}}if(t<=d)n=d;else if(t>=h)e=h;else return a}return a}function Lf(i,t,e,n=1/0){let s=[];s.scanned=0;let r=[Uint32Array.from(t)];for(;r.length;){let o=r.pop(),a=Math.ceil(o.length/e);if(o.length<=1||a<=1&&gy(o,i)<=n){o.length&&s.push(o);continue}let l=a>1?Math.ceil(o.length*Math.floor(a/2)/a):Math.ceil(o.length/2);s.scanned+=Pf(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function gy(i,t){let e=1/0,n=1/0,s=1/0,r=-1/0,o=-1/0,a=-1/0;for(let l of i){let c=t[l*3],h=t[l*3+1],d=t[l*3+2];cr&&(r=c),ho&&(o=h),da&&(a=d)}return Math.hypot(r-e,o-n,a-s)/2}function Df(i,t){let e=new Float64Array(6).fill(-1/0),n=new Float64Array(6).fill(-1/0),s=new Int32Array(6);for(let o=0;oe[a]?(n[a]=e[a],e[a]=c,s[a]=o):c>n[a]&&(n[a]=c)}if(e[0]===-1/0)return 0;let r=Math.hypot(e[0]+e[3],e[1]+e[4],e[2]+e[5]);if(n[0]===-1/0)return r;for(let o of s){let a=c=>s[c]===o?n[c]:e[c],l=Math.hypot(a(0)+a(3),a(1)+a(4),a(2)+a(5));r=Math.min(r,2*l)}return r}var Eh=384*2**20;function Nf(i,{cap:t=Eh,minRepeats:e=16,perCell:n=1024,maxDraws:s=1024}={}){let r=new Uint8Array(i.length),o=0;for(let h of i)o+=h.k*h.bytes;if(o<=t)return r;let a=h=>(i[h].k-1)*i[h].bytes,l=[...i.keys()].filter(h=>i[h].k>=e);l.sort((h,d)=>a(d)-a(h)||i[d].k-i[h].k||h-d);let c=0;for(let h of l){let d=i[h].cells??Math.ceil(i[h].k/n);c+d>s||(r[h]=1,c+=d)}return r}function sl(i,t){return i>65535?new Uint32Array(t):new Uint16Array(t)}function Th(i,t){return i.sort((e,n)=>t[n]-t[e]||e-n)}function Uf(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function Ff(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function Bf(i,t,e,n){let s=i.subarray(t*12,t*12+12);if(s[0]===1&&s[1]===0&&s[2]===0&&s[3]===0&&s[4]===1&&s[5]===0&&s[6]===0&&s[7]===0&&s[8]===1&&e.q&&e.q.s===Cn){for(let a=0;a<3;a++)n[a]=s[9+a]+e.q.o[a];return Rf}let o=!0;for(let a=0;a<3;a++){let l=s[9+a],c=s[9+a];for(let h=0;h<3;h++){let d=s[h*3+a]*e.min[h],u=s[h*3+a]*e.max[h];l+=Math.min(d,u),c+=Math.max(d,u)}n[a]=Math.floor(l/Cn)*Cn,Math.ceil((c-n[a])/Cn)<=Cf||(o=!1)}return o||n.fill(0),o?py:Vs}function Of(i,t){let e=i.length,n=0,s=0;for(let g of i){let p=t.source(t.geometryOf[g]);n+=p.vertices,s+=p.indices.length}let r=t.kind[i[0]]===Vs,o=r?new Float32Array(n*4):new Uint16Array(n*4),a=new Int16Array(n*2),l=t.textured?new Float32Array(n*2):null,c=sl(n,s),h=new Uint32Array(e+1),d=new Float32Array(e*3),u=new Float32Array(e),f=new Float64Array(3),m=0,_=0;for(let g=0;gMath.min(Math.max(Math.round(i/Cn),0),Cf);function zf(i,t,e,n,s){let r=i.length/3,o=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];for(let c=0;ca[h]&&(a[h]=d)}let l=e instanceof Int16Array?e:null;return{positions:i,q:t,oct:l,normals:l?null:e,indices:n,uvs:s,vertices:r,min:o,max:a}}function rl(i){if(!i.normals&&i.oct){i.normals=new Float32Array(i.vertices*3);for(let t=0;t=0)throw new Error(`The shader must contain '${t}' exactly once.`);return i.slice(0,n)+e+i.slice(n+t.length)}function yy(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ri(i.vertexShader,"#include ",`#include +#endif`;function Ri(i,t,e){let n=i.indexOf(t);if(n<0||i.indexOf(t,n+1)>=0)throw new Error(`The shader must contain '${t}' exactly once.`);return i.slice(0,n)+e+i.slice(n+t.length)}function My(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ri(i.vertexShader,"#include ",`#include ${zr}`);t=Ri(t,"#include ",`${kr} -vTint = state.rgb;`),t=Ri(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ri(t,"#include ",vy),t=Ri(t,"#include ","vec3 transformed = slotPosition;"),t=Ri(t,"#include ",`#include +vTint = state.rgb;`),t=Ri(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ri(t,"#include ",yy),t=Ri(t,"#include ","vec3 transformed = slotPosition;"),t=Ri(t,"#include ",`#include ${Ah}`),i.vertexShader=t;let e=Ri(i.fragmentShader,"#include ",`#include -varying vec3 vTint;`);e=Ri(e,"#include ","diffuseColor.rgb *= vTint;"),i.fragmentShader=e}function Rh(i,t,e=!1){return i.userData.slotUniforms=t,i.onBeforeCompile=yy,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var Dh=["materials","textures","white","wireframe"],My=[245,158,11],by=[235,235,237],Hr=4294967295,$i=2048,Ch=256,Sy=16,Ih=1024,wy=.1,Ey=8192,Ty=1.4,al=2**-20,ol=17;function Ay(i,t){let[e,n,s,r,o,a,l,c,h]=i.subarray(t*12,t*12+9);return e*(o*h-a*c)-r*(n*h-s*c)+l*(n*a-s*o)<0}function Ry(){this.array=null}function In(i,t,e=!1,n=xe){return new n(i,t,e).onUpload(Ry)}var Vr=class extends RangeError{constructor(t,e){super(`${t} drawable instances exceed the limit of ${e}.`),this.name="ModelTooLargeError",this.count=t,this.limit=e}},Of=(i,t)=>{for(let e=t*6;e=0?3:0)]+o*t[e+(o>=0?4:1)]+a*t[e+(a>=0?5:2)]+l<-(n+al*Math.abs(l)))return!0}return!1}function Ph(i,t,{min:e,max:n},s){let r=t*12,o=t*6;if(e[0]>n[0]||e[1]>n[1]||e[2]>n[2]){s.set(e,o),s.set(n,o+3);return}for(let a=0;a<3;a++){let l=i[r+a],c=i[r+a+3],h=i[r+a+6],d=i[r+a+9],u=l*e[0],f=l*n[0],m=c*e[1],_=c*n[1],g=h*e[2],p=h*n[2];s[o+a]=Math.min(u,f)+Math.min(m,_)+Math.min(g,p)+d,s[o+a+3]=Math.max(u,f)+Math.max(m,_)+Math.max(g,p)+d}}var Iy=i=>{let t=i.getHex(me);return[t>>16&255,t>>8&255,t&255]},Gr=class{constructor(t,e={}){let{meta:n}=t,s=n.instances,r=s.count,o=t.view(s.geometry),a=t.view(s.material),l=t.view(s.matrix),c=n.points,h=c?.count??0,d=n.lines,u=d?.count??0,f=n.annotations??[],m=e.annotationLayouts??[],_=r+h+u+m.length;this.root=new Re,this.elementCount=n.elements.length,this.pointOffset=r,this.lineOffset=r+h,this.annotationOffset=r+h+u,this._annotations=f,this._annotationLayouts=m,this._annotationSheet=null,this._elements=n.elements,this._meta=n,this._mode="materials",this._opacity=1,this._picking=!1,this._pickBounds=!0,this._instanceDetail=!0,this._pickFrustum=null,this._textures=new Map,this._elementOf=new Int32Array(_),this._elementOf.set(t.view(s.element)),this._bucketOf=new Uint32Array(r),this._visible=new Uint8Array(_).fill(1),this._layers=new Map,this._layerHides=new Uint8Array(_),this._highlight=new Uint8Array(_),this._highlighted=[],this._tint=new Map,this._boxes=new Float32Array(this.annotationOffset*6),this._minPixels=0,this._viewHeight=1,this.visibleCost=0;let g=!!e.noHideBranch;if(this.slotUniforms={slotInfo:{value:null},slotState:{value:null}},this._buckets=this._createBuckets(n,a,g),h){this._elementOf.set(t.view(c.element),r),this._pointMaterials=t.view(c.material).slice();let y=t.view(c.geometry),E=t.view(c.matrix),M=this._boxes.subarray(r*6);for(let x=0;xthis.isInstanceVisible(e)?1:0)}instancesOf(t){return this._checkElement(t),this._elementInstances.subarray(this._elementStart[t],this._elementStart[t+1])}isVisible(t){this._checkElement(t);for(let e=this._elementStart[t];ethis._chunkCount){this._pickFrustum=yh(n,this._planes);let{x:r,y:o,z:a}=n.position;this._pickViewPadding=al*(Math.abs(r)+Math.abs(o)+Math.abs(a))}for(let r of this._units)r.mesh.material=t,s?(r.mesh.visible=(r.mesh.visible||!!r.lines?.visible)&&r.bucket.material.opacity>0,r.lines&&(r.lines.visible=!1)):this._showUnit(r);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!1);try{return e()}finally{this._picking=!1,this._pickFrustum=null;for(let r of this._units)r.mesh.material=r.bucket.material,this._showUnit(r);for(let r of this._cut)r.mesh.visible=!1,r.lines&&(r.lines.visible=!1);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!0)}}elementBox(t,e=new oe){this._checkElement(t),e.makeEmpty();for(let n=this._elementStart[t];n=0&&t<=1))throw new RangeError(`Opacity must be within 0..1, got ${t}.`);this._opacity=t;for(let e of this._buckets)this._applyOpacity(e);this._changed("appearance")}get opacity(){return this._opacity}setDetail(t,e=1){this._minPixels=t,this._viewHeight=e;for(let s of this._cut)this._showUnit(s);this._cut.length=0;for(let s of this._detailCells)s.detailCount=null;this._detailCells.length=0;for(let s of this._compactCells)this._cellAttributes(s,!1);this._compactCells.length=0;let n=this._unitScale;this._unitScale=null,!(!(t>0)||!n)&&(this._cutInView=0,this._cutFrame=null,this._units.forEach((s,r)=>{if(!(!(n[r]>=0)||s.shown===0)){if(s.dirty&&this._span(s),s.cell&&this._detailUsesInstances){if(s.detailHigh>=t&&this._detailCell(s,t))return}else if(this._slotRadius[s.slotBase+s.first]*n[r]>=t)return;s.mesh.visible=!1,s.lines&&(s.lines.visible=!1),this._cut.push(s),this._cutInView+=Lh(s,s.first,s.last+1)}}))}_detailCell(t,e){if(t.detailLow>=e)return t.detailCount=Math.min(t.detailEnd,t.last+1),this._detailCells.push(t),!0;let{slotBase:n,last:s}=t,r=this._detailIndices,o=0,a=!1,l=!1;for(let u=0;u<=s;u++){let f=this._pixels[n+u];f<0||(fc.count;for(let u=0;u0?o[6]/g:1/0:o[6];d[f]=p;let y=m.cell&&this._detailUsesInstances,E=y&&!yf(r,_[0],_[1],_[2],_[3]+m.pickPadding),M=m.slotBase+m.n,x=-1;if(y){let R=this._slotRadius[m.slotBase],L=this._slotRadius[M-1],N=g+_[3],B=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],D=N-B-R,F=N+B-L,H=Math.fround(o[7]?D>0?R*o[6]/D:1/0:R*p),V=Math.fround(o[7]?F>0?L*o[6]/F:1/0:L*p);ks(V)===ks(H)&&(x=H)}if(x>=0&&!E){m.detailLow=m.detailHigh=x,m.detailEnd=m.n;let R=this._slotCost[m.slotBase]*m.shown;l[ks(x)]+=R,u+=R;continue}let S=0,A=1/0,v=-1,w=0;for(let R=m.slotBase;R=0){S++;continue}let U=(H-o[0])*o[3]+(V-o[1])*o[4]+(k-o[2])*o[5]-L;N=o[7]?U>0?o[6]/U:1/0:o[6]}let B=N===1/0?1/0:Math.fround(L*N);y&&(a[R]=B,A=Math.min(A,B),v=Math.max(v,B));let D=this._slotCost[R];l[ks(B)]+=D,u+=D}if(y){if(S){A=v=x;let R=S*this._slotCost[m.slotBase];l[ks(x)]+=R,u+=R}m.detailLow=A,m.detailHigh=v,m.detailEnd=w}}return this.visibleCost=u,Mf(l,u,n)}drawStats(){let t=-1/0;for(let r of this._units)t=Math.max(t,r.lastFrame);let e=0,n=this._cutFrame===t?this._cutInView:0,s=0;for(let r of this._units)r.lastFrame===t&&(n+=Lh(r,r.first,Math.max(r.last+1,r.first)),e+=Lh(r,r.first,Math.max(r.end,r.first)),s++);return{drawn:e,inView:n,draws:s}}drawnInstances(t){t.updateMatrixWorld();let e=new Hn().setFromProjectionMatrix(new Zt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),n={info:{render:{frame:-1}}},s=new Oe,r=[];for(let o of this._units){let a=this._mode==="wireframe"&&!this._picking?o.lines:o.mesh;if(!(!a?.visible||!e.intersectsSphere(s.set(s.center.fromArray(o.sphere),o.sphere[3])))){a.onBeforeRender(n,null,t,a.geometry,a.material,null);for(let l=o.first;lo-a)}memory(){let t=this._units[this._chunkCount]?.slotBase??this._slotInstance.length;return{gpuBytes:this._mergedBytes+this._instancedBytes+this._lineBytes+this._stateBytes+this._detailBytes,mergedBytes:this._mergedBytes,instancedBytes:this._instancedBytes,stateBytes:this._stateBytes,lineBytes:this._lineBytes,detailBytes:this._detailBytes,detailSourceBytes:(this._slotInstance.length-t)*48,chunks:this._chunkCount,cells:this._units.length-this._chunkCount,mergedInstances:t,instancedInstances:this._slotInstance.length-t,triangles:this._triangles}}setClipping(t,e){for(let n of this._buckets)for(let s of[n.material,n.wire])s.clippingPlanes=t.length>0?t:null,s.clipIntersection=e,s.needsUpdate=!0;this._changed("clipping")}_build(t,e,n,s,r){let o=e.length,a=this._meta,l=new Map,c=k=>{let U=l.get(k);if(!U){let O=a.geometries[k],Y=t.view(O.indices),G=O.uvs?t.view(O.uvs):null;U=Bf(Or(t,O),O.q??null,wf(t,O),Y,G),U.drawable=U.indices.length>=3&&U.min.every(Number.isFinite)&&U.max.every(Number.isFinite),l.set(k,U)}return U},h=new Uint8Array(o),d=new Float64Array(o*3),u=new Float32Array(o*3),f=new Uint32Array(o),m=new Float32Array(o),_=new Uint8Array(o),g=new Map,p=this._boxes;for(let k=0;kk-U).map(k=>{let U=g.get(k),O=c(e[U[0]]),Y=this._buckets[this._bucketOf[U[0]]].texture!==null,G=[0,1,2].every(rt=>(O.max[rt]-O.min[rt])/Cn<=65535),J=O.vertices*((G?12:20)+(Y?8:0))+O.indices.length*(O.vertices>65535?4:2);return{k:U.length,bytes:J,members:U,textured:Y}}),M=s.mergedCap??Eh,x=s.minRepeats??Sy;if(E.reduce((k,U)=>k+U.k*U.bytes,0)>M){let k=s.cellExtent==null?Pf(p,f)*wy:this.visibleBox().getSize(new C).length()*s.cellExtent;for(let U of E)U.k{if(S[U]){for(let O of k.leaves)w.push({shape:k,members:Th(O,m)});return}for(let O of k.members){v[e[O]]++;let Y=this._bucketOf[O]*2+(h[O]===Vs?1:0),G=A.get(Y);G||A.set(Y,G=[]),G.push(O)}});let R=[];for(let k of[...A.keys()].sort((U,O)=>U-O))for(let U of Rf(u,f,A.get(k),s.chunkVertices??Ef))R.push(Th(U,m));let L=[...R,...w.map(k=>k.members)].reduce((k,U)=>k+U.length,0);if(L>r)throw new Vr(L,r);let N=Math.max(1,Math.ceil(L/$i)),B=new Float32Array($i*N*4);this._state=new mn(new Uint8Array($i*N*4),$i,N),this._state.colorSpace=me,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(Ch),this._dirtyCount=0;let D=new mn(B,$i,N,je,Ye);D.needsUpdate=!0,D.onUpdate=()=>D.image.data=null,this.slotUniforms.slotInfo.value=D,this.slotUniforms.slotState.value=this._state,this._stateBytes=$i*N*20,this._slotOf=new Uint32Array(this._visible.length).fill(Hr),this._slotInstance=new Uint32Array(L),this._slotUnit=new Uint32Array(L),this._slotRadius=new Float32Array(L),this._slotCost=new Float32Array(L),this._pixels=new Float32Array(L),this._planes=new Float64Array(24),this._detailView=new Float64Array(8),this._frameView=new Float64Array(8),this._frameViewAt=NaN,this._units=[],this._cut=[],this._detailCells=[],this._compactCells=[],this._detailIndices=new Uint16Array(Ih),this._detailBins=new Float64Array(vh),this._detailBytes=0,this._unitScale=null,this._cutInView=0,this._cutFrame=-1,this._mergedBytes=0,this._instancedBytes=0,this._lineBytes=0;let F={matrices:n,geometryOf:e,mirrored:_,kind:h,origins:d,source:c,textured:!1};this._lineSources=new Map;let H=0;for(let k of R){let U=this._buckets[this._bucketOf[k[0]]];F.textured=U.texture!==null;let O=Ff(k,F);for(let Y=0;Yk+U,0);let V=new Map;for(let{shape:k,members:U}of w){let O=U[0],Y=c(e[O]),G=V.get(k);if(!G){let J=a.geometries[e[O]].bbox;G=this._shape(Y,_[O]===1,k.textured);let rt=it=>Math.max(...it.map(Math.abs)),nt=Math.max(rt(Y.min),rt(Y.max));G.pickExtent=nt,G.pickPadding=Math.max(0,...Y.min.map((it,z)=>J.min[z]-it),...Y.max.map((it,z)=>it-J.max[z]))+(Y.q?al*(rt(Y.q.o)+65535*Math.abs(Y.q.s)):0),V.set(k,G)}for(let J=0;Jk+U,0)}_shape(t,e,n){let s=t.vertices,r=t.q?new Uint16Array(s*4):new Float32Array(s*4);for(let h=0;hn+p),1,!1,oi);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=kf(this._boxes,e),h=new Oe(new C(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let d=new xi(a,t.material,0),u=new Float32Array(o*16),f=new Float32Array(o*12),m=0;for(let g=0;gthis._range(_,g,y,d),d.visible=!1,this.root.add(d),_}_chunk(t,e,n,s,r,o){let a=new Is;a.instanceCount=1,a.setAttribute("q",In(s.q,4)),a.setAttribute("normal",In(s.o,2,!0)),s.uv&&a.setAttribute("uv",In(s.uv,2)),a.setAttribute("slotBase",In(new Float32Array([n]),1,!1,oi)),a.setIndex(In(s.index,1));let l=kf(this._boxes,e);a.boundingSphere=new Oe(new C(l[0],l[1],l[2]),l[3]),this._mergedBytes+=s.q.byteLength+s.o.byteLength+(s.uv?.byteLength??0)+s.index.byteLength;let c=new ge(a,t.material),h={bucket:t,mesh:c,lines:null,slotBase:n,n:e.length,sphere:l,shown:0,first:0,last:-1,end:0,dirty:!1,cell:!1,starts:s.indexStart,vertices:s.q.length/4,f32:s.q instanceof Float32Array,members:e.slice(),lastFrame:-1/0};return c.onBeforeRender=(d,u,f)=>this._range(h,d,f,c),c.visible=!1,this.root.add(c),h}_buildLines(){if(!this._lineSources)return;let{mirrored:t,geometryOf:e}=this._lineMembers;for(let n of this._units){if(n.cell){let h=n.mesh.geometry.index;n.lines=new xi(n.mesh.geometry,n.bucket.wire,0),n.lines.instanceMatrix=n.mesh.instanceMatrix,n.lines.boundingSphere=n.mesh.boundingSphere,n.lines.onBeforeRender=(d,u,f)=>this._range(n,d,f,n.lines),this._lineBytes+=h.count*2*h.array.BYTES_PER_ELEMENT,this.root.add(n.lines);continue}let s=n.starts[n.n],r=sl(n.vertices,s*2),o=0,a=0;for(let h of n.members){let d=this._lineSources.get(e[h]),u=t[h]===1;for(let f=0;fthis._range(n,h,u,n.lines),this.root.add(n.lines),n.members=null}this._lineSources=null,this._lineMembers=null}_range(t,e,n,s){t.dirty&&this._span(t);let r=t.last+1;if(this._picking){if(t.cell&&this._pickFrustum){let o=this._state.image.data,a=t.pickPadding+this._pickViewPadding;for(;r>0;){let l=t.slotBase+r-1;if(o[l*4+3]&&!Cy(this._pickFrustum,this._boxes,this._slotInstance[l]*6,a))break;r--}}}else if(t.cell&&t.detailCount!==null)r=t.detailCount;else if(this._minPixels>0&&r>t.first){let o=e.info.render.frame;o!==this._frameViewAt&&(bh(n,this._viewHeight,this._frameView),this._frameViewAt=o);let a=this._frameView,l=zf(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,Df(this._slotRadius,t.slotBase+t.first,t.slotBase+r,c)-t.slotBase)}if(t.cell)s.count=Math.max(r,0);else{let o=s.isLineSegments?2:1,[a,l]=Nf(t.starts,t.first,r);s.geometry.setDrawRange(a*o,l*o)}this._picking||(t.end=r,t.lastFrame=e.info.render.frame,this._cutFrame===null&&this._minPixels>0&&(this._cutFrame=t.lastFrame))}_span(t){let e=this._state.image.data,n=0;for(;n=n&&e[(t.slotBase+s)*4+3]===0;)s--;t.first=n0&&!e,t.lines&&(t.lines.visible=t.shown>0&&e)}_createBuckets(t,e,n){let s=new Map,r=[];for(let o=0;oMath.round(h*255)),opacity:c.opacity,texture:c.texture??null,material:Rh(new Rs({side:ke}),this.slotUniforms,n),wire:Rh(new Rs({side:ke,wireframe:!0}),this.slotUniforms,n)},this._applyOpacity(l),s.set(a,l),r.push(l)}this._bucketOf[o]=l.index}return r}_indexElements(){let t=new Uint32Array(this.elementCount+1);for(let s of this._elementOf)s>=0&&t[s+1]++;for(let s=0;s{s>=0&&(e[n[s]++]=r)}),this._elementStart=t,this._elementInstances=e}_texture(t){let e=this._textures.get(t);if(!e){let n=this._meta.textures[t],s=new Image;e=new We(s),e.colorSpace=me,e.wrapS=e.wrapT=xs,e.repeat.set(1/n.sx,1/n.sy),s.onload=()=>{e.needsUpdate=!0,this._changed("appearance")},s.src=`data:${n.mime};base64,${n.data}`,this._textures.set(t,e)}return e}_applyOpacity(t){let e=t.opacity*this._opacity,n=e<1;for(let s of[t.material,t.wire])s.transparent!==n&&(s.needsUpdate=!0),s.opacity=e,s.transparent=n,s.depthWrite=!n}_colorOverride(t){return this._highlight[t]?My:this._tint.get(t)??(this._mode==="white"?by:null)}_colorOf(t){let e=this._colorOverride(t);if(e)return e;if(t>=this._bucketOf.length){let n=this._pointMaterials[t-this._bucketOf.length];return this._meta.materials[n].color.map(s=>Math.round(s*255))}return this._buckets[this._bucketOf[t]].bytes}_applyColor(t){let e=this._slotOf[t];e!==Hr&&(this._state.image.data.set(this._colorOf(t),e*4),this._markDirty(e))}_setInstanceVisible(t,e){this._visible[t]=e?1:0,this._draw(t)}_setLayerFlag(t,e,n){t[e]!==(n?1:0)&&(t[e]=n?1:0,this._layerHides[e]+=n?1:-1,this._draw(e))}_shown(t){return this._visible[t]===1&&this._layerHides[t]===0}_draw(t){let e=this._slotOf[t];if(e===Hr)return;let n=this._shown(t)?255:0,s=this._state.image.data;if(s[e*4+3]===n)return;s[e*4+3]=n,this._markDirty(e);let r=this._units[this._slotUnit[e]];r.shown+=n?1:-1,r.dirty=!0,this._showUnit(r)}_markDirty(t){this._dirtyCountCh)e.clearUpdateRanges(),this._fullPending=!0;else{for(let n=0;n=this.elementCount)throw new RangeError(`Element index ${t} is out of range 0..${this.elementCount-1}.`)}_expandBox(t,e){if(e>=this.annotationOffset){t.union(this._annotationLayouts[e-this.annotationOffset].box);return}if(!Of(this._boxes,e))return;let n=this._boxes,s=e*6;t.min.set(Math.min(t.min.x,n[s]),Math.min(t.min.y,n[s+1]),Math.min(t.min.z,n[s+2])),t.max.set(Math.max(t.max.x,n[s+3]),Math.max(t.max.y,n[s+4]),Math.max(t.max.z,n[s+5]))}_changed(t){this._flush(),this.root.dispatchEvent({type:"change",detail:{kind:t}})}};function Lh(i,t,e){return e<=t?0:i.cell?(e-t)*i.triangles:(i.starts[e]-i.starts[t])/3}function zf(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function kf(i,t){let e=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let a of t)for(let l=0;l<3;l++)e[l]=Math.min(e[l],i[a*6+l]),n[l]=Math.max(n[l],i[a*6+3+l]);let s=(n[0]-e[0])/2,r=(n[1]-e[1])/2,o=(n[2]-e[2])/2;return Float64Array.of((e[0]+n[0])/2,(e[1]+n[1])/2,(e[2]+n[2])/2,Math.hypot(s,r,o),s,r,o)}var ll=class{constructor(t){this.root=new Re,this._materials=[];let e=t.meta.points;if(this.count=e?.count??0,!this.count)return;let n=t.view(e.geometry),s=t.view(e.material),r=t.view(e.matrix);for(let o=0;o{y!==u&&(y.uniforms.pointIndex.value=o,y.uniforms.pointSize.value=u.opacity>0?u.size:0,y.uniformsNeedUpdate=!0)},f.matrixAutoUpdate=!1,f.matrix.fromArray(Py(r,o)),f.matrixWorldNeedsUpdate=!0,f.frustumCulled=!0,c.computeBoundingSphere(),this.root.add(f),this._materials.push({material:u,color:u.color.clone(),opacity:h?.opacity??1,vertexColors:d})}}syncVisibility(t){let e=t.pointOffset??t.instanceCount-this.count;for(let[n,s]of this.root.children.entries())s.visible=t.isInstanceVisible(e+n)}syncAppearance(t){let e=t.pointOffset??t.instanceCount-this.count;for(let[n,s]of this._materials.entries()){let{material:r}=s,o=t.instanceColorOverride(e+n,r.color);o||r.color.copy(s.color);let a=s.vertexColors&&!o,l=t.opacity*s.opacity,c=l<1;(r.vertexColors!==a||r.transparent!==c)&&(r.needsUpdate=!0),r.vertexColors=a,r.opacity=l,r.transparent=c,r.depthWrite=!c}}setClipping(t,e=!1){this.clippingPlanes=t.length>0?t:null,this.clipIntersection=e;for(let{material:n}of this._materials)n.clippingPlanes=this.clippingPlanes,n.clipIntersection=e}withPickMaterial(t,e){t.clippingPlanes=this.clippingPlanes,t.clipIntersection=this.clipIntersection;for(let n of this.root.children)n.material=t;try{e()}finally{for(let[n,s]of this.root.children.entries())s.material=this._materials[n].material}}position(t,e,n){let s=this.root.children[t];return n.fromBufferAttribute(s.geometry.attributes.position,e).applyMatrix4(s.matrixWorld)}};function Py(i,t){let e=t*12;return[i[e],i[e+1],i[e+2],0,i[e+3],i[e+4],i[e+5],0,i[e+6],i[e+7],i[e+8],0,i[e+9],i[e+10],i[e+11],1]}var Nh=2048,Ly=524288,Uh=[245,158,11],Fh=[235,235,237],Dy=` +varying vec3 vTint;`);e=Ri(e,"#include ","diffuseColor.rgb *= vTint;"),i.fragmentShader=e}function Rh(i,t,e=!1){return i.userData.slotUniforms=t,i.onBeforeCompile=My,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var Dh=["materials","textures","white","wireframe"],by=[245,158,11],Sy=[235,235,237],Hr=4294967295,Zi=2048,Ch=256,wy=16,Ih=1024,Ey=.1,Ty=8192,Ay=1.4,al=2**-20,ol=17;function Ry(i,t){let[e,n,s,r,o,a,l,c,h]=i.subarray(t*12,t*12+9);return e*(o*h-a*c)-r*(n*h-s*c)+l*(n*a-s*o)<0}function Cy(){this.array=null}function In(i,t,e=!1,n=xe){return new n(i,t,e).onUpload(Cy)}var Vr=class extends RangeError{constructor(t,e){super(`${t} drawable instances exceed the limit of ${e}.`),this.name="ModelTooLargeError",this.count=t,this.limit=e}},kf=(i,t)=>{for(let e=t*6;e=0?3:0)]+o*t[e+(o>=0?4:1)]+a*t[e+(a>=0?5:2)]+l<-(n+al*Math.abs(l)))return!0}return!1}function Ph(i,t,{min:e,max:n},s){let r=t*12,o=t*6;if(e[0]>n[0]||e[1]>n[1]||e[2]>n[2]){s.set(e,o),s.set(n,o+3);return}for(let a=0;a<3;a++){let l=i[r+a],c=i[r+a+3],h=i[r+a+6],d=i[r+a+9],u=l*e[0],f=l*n[0],m=c*e[1],_=c*n[1],g=h*e[2],p=h*n[2];s[o+a]=Math.min(u,f)+Math.min(m,_)+Math.min(g,p)+d,s[o+a+3]=Math.max(u,f)+Math.max(m,_)+Math.max(g,p)+d}}var Py=i=>{let t=i.getHex(me);return[t>>16&255,t>>8&255,t&255]},Gr=class{constructor(t,e={}){let{meta:n}=t,s=n.instances,r=s.count,o=t.view(s.geometry),a=t.view(s.material),l=t.view(s.matrix),c=n.points,h=c?.count??0,d=n.lines,u=d?.count??0,f=n.annotations??[],m=e.annotationLayouts??[],_=r+h+u+m.length;this.root=new Re,this.elementCount=n.elements.length,this.pointOffset=r,this.lineOffset=r+h,this.annotationOffset=r+h+u,this._annotations=f,this._annotationLayouts=m,this._annotationSheet=null,this._elements=n.elements,this._meta=n,this._mode="materials",this._opacity=1,this._picking=!1,this._pickBounds=!0,this._instanceDetail=!0,this._pickFrustum=null,this._textures=new Map,this._elementOf=new Int32Array(_),this._elementOf.set(t.view(s.element)),this._bucketOf=new Uint32Array(r),this._visible=new Uint8Array(_).fill(1),this._layers=new Map,this._layerHides=new Uint8Array(_),this._highlight=new Uint8Array(_),this._highlighted=[],this._tint=new Map,this._boxes=new Float32Array(this.annotationOffset*6),this._minPixels=0,this._viewHeight=1,this.visibleCost=0;let g=!!e.noHideBranch;if(this.slotUniforms={slotInfo:{value:null},slotState:{value:null}},this._buckets=this._createBuckets(n,a,g),h){this._elementOf.set(t.view(c.element),r),this._pointMaterials=t.view(c.material).slice();let y=t.view(c.geometry),w=t.view(c.matrix),M=this._boxes.subarray(r*6);for(let x=0;xthis.isInstanceVisible(e)?1:0)}instancesOf(t){return this._checkElement(t),this._elementInstances.subarray(this._elementStart[t],this._elementStart[t+1])}isVisible(t){this._checkElement(t);for(let e=this._elementStart[t];ethis._chunkCount){this._pickFrustum=yh(n,this._planes);let{x:r,y:o,z:a}=n.position;this._pickViewPadding=al*(Math.abs(r)+Math.abs(o)+Math.abs(a))}for(let r of this._units)r.mesh.material=t,s?(r.mesh.visible=(r.mesh.visible||!!r.lines?.visible)&&r.bucket.material.opacity>0,r.lines&&(r.lines.visible=!1)):this._showUnit(r);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!1);try{return e()}finally{this._picking=!1,this._pickFrustum=null;for(let r of this._units)r.mesh.material=r.bucket.material,this._showUnit(r);for(let r of this._cut)r.mesh.visible=!1,r.lines&&(r.lines.visible=!1);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!0)}}elementBox(t,e=new ae){this._checkElement(t),e.makeEmpty();for(let n=this._elementStart[t];n=0&&t<=1))throw new RangeError(`Opacity must be within 0..1, got ${t}.`);this._opacity=t;for(let e of this._buckets)this._applyOpacity(e);this._changed("appearance")}get opacity(){return this._opacity}setDetail(t,e=1){this._minPixels=t,this._viewHeight=e;for(let s of this._cut)this._showUnit(s);this._cut.length=0;for(let s of this._detailCells)s.detailCount=null;this._detailCells.length=0;for(let s of this._compactCells)this._cellAttributes(s,!1);this._compactCells.length=0;let n=this._unitScale;this._unitScale=null,!(!(t>0)||!n)&&(this._cutInView=0,this._cutFrame=null,this._units.forEach((s,r)=>{if(!(!(n[r]>=0)||s.shown===0)){if(s.dirty&&this._span(s),s.cell&&this._detailUsesInstances){if(s.detailHigh>=t&&this._detailCell(s,t))return}else if(this._slotRadius[s.slotBase+s.first]*n[r]>=t)return;s.mesh.visible=!1,s.lines&&(s.lines.visible=!1),this._cut.push(s),this._cutInView+=Lh(s,s.first,s.last+1)}}))}_detailCell(t,e){if(t.detailLow>=e)return t.detailCount=Math.min(t.detailEnd,t.last+1),this._detailCells.push(t),!0;let{slotBase:n,last:s}=t,r=this._detailIndices,o=0,a=!1,l=!1;for(let u=0;u<=s;u++){let f=this._pixels[n+u];f<0||(fc.count;for(let u=0;u0?o[6]/g:1/0:o[6];d[f]=p;let y=m.cell&&this._detailUsesInstances,w=y&&!bf(r,_[0],_[1],_[2],_[3]+m.pickPadding),M=m.slotBase+m.n,x=-1;if(y){let R=this._slotRadius[m.slotBase],L=this._slotRadius[M-1],N=g+_[3],B=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],D=N-B-R,F=N+B-L,H=Math.fround(o[7]?D>0?R*o[6]/D:1/0:R*p),V=Math.fround(o[7]?F>0?L*o[6]/F:1/0:L*p);ks(V)===ks(H)&&(x=H)}if(x>=0&&!w){m.detailLow=m.detailHigh=x,m.detailEnd=m.n;let R=this._slotCost[m.slotBase]*m.shown;l[ks(x)]+=R,u+=R;continue}let S=0,A=1/0,v=-1,E=0;for(let R=m.slotBase;R=0){S++;continue}let U=(H-o[0])*o[3]+(V-o[1])*o[4]+(z-o[2])*o[5]-L;N=o[7]?U>0?o[6]/U:1/0:o[6]}let B=N===1/0?1/0:Math.fround(L*N);y&&(a[R]=B,A=Math.min(A,B),v=Math.max(v,B));let D=this._slotCost[R];l[ks(B)]+=D,u+=D}if(y){if(S){A=v=x;let R=S*this._slotCost[m.slotBase];l[ks(x)]+=R,u+=R}m.detailLow=A,m.detailHigh=v,m.detailEnd=E}}return this.visibleCost=u,Sf(l,u,n)}drawStats(){let t=-1/0;for(let r of this._units)t=Math.max(t,r.lastFrame);let e=0,n=this._cutFrame===t?this._cutInView:0,s=0;for(let r of this._units)r.lastFrame===t&&(n+=Lh(r,r.first,Math.max(r.last+1,r.first)),e+=Lh(r,r.first,Math.max(r.end,r.first)),s++);return{drawn:e,inView:n,draws:s}}drawnInstances(t){t.updateMatrixWorld();let e=new Hn().setFromProjectionMatrix(new Kt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),n={info:{render:{frame:-1}}},s=new Oe,r=[];for(let o of this._units){let a=this._mode==="wireframe"&&!this._picking?o.lines:o.mesh;if(!(!a?.visible||!e.intersectsSphere(s.set(s.center.fromArray(o.sphere),o.sphere[3])))){a.onBeforeRender(n,null,t,a.geometry,a.material,null);for(let l=o.first;lo-a)}memory(){let t=this._units[this._chunkCount]?.slotBase??this._slotInstance.length;return{gpuBytes:this._mergedBytes+this._instancedBytes+this._lineBytes+this._stateBytes+this._detailBytes,mergedBytes:this._mergedBytes,instancedBytes:this._instancedBytes,stateBytes:this._stateBytes,lineBytes:this._lineBytes,detailBytes:this._detailBytes,detailSourceBytes:(this._slotInstance.length-t)*48,chunks:this._chunkCount,cells:this._units.length-this._chunkCount,mergedInstances:t,instancedInstances:this._slotInstance.length-t,triangles:this._triangles}}setClipping(t,e){for(let n of this._buckets)for(let s of[n.material,n.wire])s.clippingPlanes=t.length>0?t:null,s.clipIntersection=e,s.needsUpdate=!0;this._changed("clipping")}_build(t,e,n,s,r){let o=e.length,a=this._meta,l=new Map,c=z=>{let U=l.get(z);if(!U){let k=a.geometries[z],Y=t.view(k.indices),G=k.uvs?t.view(k.uvs):null;U=zf(Or(t,k),k.q??null,Tf(t,k),Y,G),U.drawable=U.indices.length>=3&&U.min.every(Number.isFinite)&&U.max.every(Number.isFinite),l.set(z,U)}return U},h=new Uint8Array(o),d=new Float64Array(o*3),u=new Float32Array(o*3),f=new Uint32Array(o),m=new Float32Array(o),_=new Uint8Array(o),g=new Map,p=this._boxes;for(let z=0;zz-U).map(z=>{let U=g.get(z),k=c(e[U[0]]),Y=this._buckets[this._bucketOf[U[0]]].texture!==null,G=[0,1,2].every(it=>(k.max[it]-k.min[it])/Cn<=65535),J=k.vertices*((G?12:20)+(Y?8:0))+k.indices.length*(k.vertices>65535?4:2);return{k:U.length,bytes:J,members:U,textured:Y}}),M=s.mergedCap??Eh,x=s.minRepeats??wy;if(w.reduce((z,U)=>z+U.k*U.bytes,0)>M){let z=s.cellExtent==null?Df(p,f)*Ey:this.visibleBox().getSize(new C).length()*s.cellExtent;for(let U of w)U.k{if(S[U]){for(let k of z.leaves)E.push({shape:z,members:Th(k,m)});return}for(let k of z.members){v[e[k]]++;let Y=this._bucketOf[k]*2+(h[k]===Vs?1:0),G=A.get(Y);G||A.set(Y,G=[]),G.push(k)}});let R=[];for(let z of[...A.keys()].sort((U,k)=>U-k))for(let U of If(u,f,A.get(z),s.chunkVertices??Af))R.push(Th(U,m));let L=[...R,...E.map(z=>z.members)].reduce((z,U)=>z+U.length,0);if(L>r)throw new Vr(L,r);let N=Math.max(1,Math.ceil(L/Zi)),B=new Float32Array(Zi*N*4);this._state=new mn(new Uint8Array(Zi*N*4),Zi,N),this._state.colorSpace=me,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(Ch),this._dirtyCount=0;let D=new mn(B,Zi,N,je,Ye);D.needsUpdate=!0,D.onUpdate=()=>D.image.data=null,this.slotUniforms.slotInfo.value=D,this.slotUniforms.slotState.value=this._state,this._stateBytes=Zi*N*20,this._slotOf=new Uint32Array(this._visible.length).fill(Hr),this._slotInstance=new Uint32Array(L),this._slotUnit=new Uint32Array(L),this._slotRadius=new Float32Array(L),this._slotCost=new Float32Array(L),this._pixels=new Float32Array(L),this._planes=new Float64Array(24),this._detailView=new Float64Array(8),this._frameView=new Float64Array(8),this._frameViewAt=NaN,this._units=[],this._cut=[],this._detailCells=[],this._compactCells=[],this._detailIndices=new Uint16Array(Ih),this._detailBins=new Float64Array(vh),this._detailBytes=0,this._unitScale=null,this._cutInView=0,this._cutFrame=-1,this._mergedBytes=0,this._instancedBytes=0,this._lineBytes=0;let F={matrices:n,geometryOf:e,mirrored:_,kind:h,origins:d,source:c,textured:!1};this._lineSources=new Map;let H=0;for(let z of R){let U=this._buckets[this._bucketOf[z[0]]];F.textured=U.texture!==null;let k=Of(z,F);for(let Y=0;Yz+U,0);let V=new Map;for(let{shape:z,members:U}of E){let k=U[0],Y=c(e[k]),G=V.get(z);if(!G){let J=a.geometries[e[k]].bbox;G=this._shape(Y,_[k]===1,z.textured);let it=at=>Math.max(...at.map(Math.abs)),nt=Math.max(it(Y.min),it(Y.max));G.pickExtent=nt,G.pickPadding=Math.max(0,...Y.min.map((at,O)=>J.min[O]-at),...Y.max.map((at,O)=>at-J.max[O]))+(Y.q?al*(it(Y.q.o)+65535*Math.abs(Y.q.s)):0),V.set(z,G)}for(let J=0;Jz+U,0)}_shape(t,e,n){let s=t.vertices,r=t.q?new Uint16Array(s*4):new Float32Array(s*4);for(let h=0;hn+p),1,!1,oi);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Vf(this._boxes,e),h=new Oe(new C(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let d=new xi(a,t.material,0),u=new Float32Array(o*16),f=new Float32Array(o*12),m=0;for(let g=0;gthis._range(_,g,y,d),d.visible=!1,this.root.add(d),_}_chunk(t,e,n,s,r,o){let a=new Is;a.instanceCount=1,a.setAttribute("q",In(s.q,4)),a.setAttribute("normal",In(s.o,2,!0)),s.uv&&a.setAttribute("uv",In(s.uv,2)),a.setAttribute("slotBase",In(new Float32Array([n]),1,!1,oi)),a.setIndex(In(s.index,1));let l=Vf(this._boxes,e);a.boundingSphere=new Oe(new C(l[0],l[1],l[2]),l[3]),this._mergedBytes+=s.q.byteLength+s.o.byteLength+(s.uv?.byteLength??0)+s.index.byteLength;let c=new ge(a,t.material),h={bucket:t,mesh:c,lines:null,slotBase:n,n:e.length,sphere:l,shown:0,first:0,last:-1,end:0,dirty:!1,cell:!1,starts:s.indexStart,vertices:s.q.length/4,f32:s.q instanceof Float32Array,members:e.slice(),lastFrame:-1/0};return c.onBeforeRender=(d,u,f)=>this._range(h,d,f,c),c.visible=!1,this.root.add(c),h}_buildLines(){if(!this._lineSources)return;let{mirrored:t,geometryOf:e}=this._lineMembers;for(let n of this._units){if(n.cell){let h=n.mesh.geometry.index;n.lines=new xi(n.mesh.geometry,n.bucket.wire,0),n.lines.instanceMatrix=n.mesh.instanceMatrix,n.lines.boundingSphere=n.mesh.boundingSphere,n.lines.onBeforeRender=(d,u,f)=>this._range(n,d,f,n.lines),this._lineBytes+=h.count*2*h.array.BYTES_PER_ELEMENT,this.root.add(n.lines);continue}let s=n.starts[n.n],r=sl(n.vertices,s*2),o=0,a=0;for(let h of n.members){let d=this._lineSources.get(e[h]),u=t[h]===1;for(let f=0;fthis._range(n,h,u,n.lines),this.root.add(n.lines),n.members=null}this._lineSources=null,this._lineMembers=null}_range(t,e,n,s){t.dirty&&this._span(t);let r=t.last+1;if(this._picking){if(t.cell&&this._pickFrustum){let o=this._state.image.data,a=t.pickPadding+this._pickViewPadding;for(;r>0;){let l=t.slotBase+r-1;if(o[l*4+3]&&!Iy(this._pickFrustum,this._boxes,this._slotInstance[l]*6,a))break;r--}}}else if(t.cell&&t.detailCount!==null)r=t.detailCount;else if(this._minPixels>0&&r>t.first){let o=e.info.render.frame;o!==this._frameViewAt&&(bh(n,this._viewHeight,this._frameView),this._frameViewAt=o);let a=this._frameView,l=Hf(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,Uf(this._slotRadius,t.slotBase+t.first,t.slotBase+r,c)-t.slotBase)}if(t.cell)s.count=Math.max(r,0);else{let o=s.isLineSegments?2:1,[a,l]=Ff(t.starts,t.first,r);s.geometry.setDrawRange(a*o,l*o)}this._picking||(t.end=r,t.lastFrame=e.info.render.frame,this._cutFrame===null&&this._minPixels>0&&(this._cutFrame=t.lastFrame))}_span(t){let e=this._state.image.data,n=0;for(;n=n&&e[(t.slotBase+s)*4+3]===0;)s--;t.first=n0&&!e,t.lines&&(t.lines.visible=t.shown>0&&e)}_createBuckets(t,e,n){let s=new Map,r=[];for(let o=0;oMath.round(h*255)),opacity:c.opacity,texture:c.texture??null,material:Rh(new Rs({side:ke}),this.slotUniforms,n),wire:Rh(new Rs({side:ke,wireframe:!0}),this.slotUniforms,n)},this._applyOpacity(l),s.set(a,l),r.push(l)}this._bucketOf[o]=l.index}return r}_indexElements(){let t=new Uint32Array(this.elementCount+1);for(let s of this._elementOf)s>=0&&t[s+1]++;for(let s=0;s{s>=0&&(e[n[s]++]=r)}),this._elementStart=t,this._elementInstances=e}_texture(t){let e=this._textures.get(t);if(!e){let n=this._meta.textures[t],s=new Image;e=new We(s),e.colorSpace=me,e.wrapS=e.wrapT=xs,e.repeat.set(1/n.sx,1/n.sy),s.onload=()=>{e.needsUpdate=!0,this._changed("appearance")},s.src=`data:${n.mime};base64,${n.data}`,this._textures.set(t,e)}return e}_applyOpacity(t){let e=t.opacity*this._opacity,n=e<1;for(let s of[t.material,t.wire])s.transparent!==n&&(s.needsUpdate=!0),s.opacity=e,s.transparent=n,s.depthWrite=!n}_colorOverride(t){return this._highlight[t]?by:this._tint.get(t)??(this._mode==="white"?Sy:null)}_colorOf(t){let e=this._colorOverride(t);if(e)return e;if(t>=this._bucketOf.length){let n=this._pointMaterials[t-this._bucketOf.length];return this._meta.materials[n].color.map(s=>Math.round(s*255))}return this._buckets[this._bucketOf[t]].bytes}_applyColor(t){let e=this._slotOf[t];e!==Hr&&(this._state.image.data.set(this._colorOf(t),e*4),this._markDirty(e))}_setInstanceVisible(t,e){this._visible[t]=e?1:0,this._draw(t)}_setLayerFlag(t,e,n){t[e]!==(n?1:0)&&(t[e]=n?1:0,this._layerHides[e]+=n?1:-1,this._draw(e))}_shown(t){return this._visible[t]===1&&this._layerHides[t]===0}_draw(t){let e=this._slotOf[t];if(e===Hr)return;let n=this._shown(t)?255:0,s=this._state.image.data;if(s[e*4+3]===n)return;s[e*4+3]=n,this._markDirty(e);let r=this._units[this._slotUnit[e]];r.shown+=n?1:-1,r.dirty=!0,this._showUnit(r)}_markDirty(t){this._dirtyCountCh)e.clearUpdateRanges(),this._fullPending=!0;else{for(let n=0;n=this.elementCount)throw new RangeError(`Element index ${t} is out of range 0..${this.elementCount-1}.`)}_expandBox(t,e){if(e>=this.annotationOffset){t.union(this._annotationLayouts[e-this.annotationOffset].box);return}if(!kf(this._boxes,e))return;let n=this._boxes,s=e*6;t.min.set(Math.min(t.min.x,n[s]),Math.min(t.min.y,n[s+1]),Math.min(t.min.z,n[s+2])),t.max.set(Math.max(t.max.x,n[s+3]),Math.max(t.max.y,n[s+4]),Math.max(t.max.z,n[s+5]))}_changed(t){this._flush(),this.root.dispatchEvent({type:"change",detail:{kind:t}})}};function Lh(i,t,e){return e<=t?0:i.cell?(e-t)*i.triangles:(i.starts[e]-i.starts[t])/3}function Hf(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function Vf(i,t){let e=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let a of t)for(let l=0;l<3;l++)e[l]=Math.min(e[l],i[a*6+l]),n[l]=Math.max(n[l],i[a*6+3+l]);let s=(n[0]-e[0])/2,r=(n[1]-e[1])/2,o=(n[2]-e[2])/2;return Float64Array.of((e[0]+n[0])/2,(e[1]+n[1])/2,(e[2]+n[2])/2,Math.hypot(s,r,o),s,r,o)}var ll=class{constructor(t){this.root=new Re,this._materials=[];let e=t.meta.points;if(this.count=e?.count??0,!this.count)return;let n=t.view(e.geometry),s=t.view(e.material),r=t.view(e.matrix);for(let o=0;o{y!==u&&(y.uniforms.pointIndex.value=o,y.uniforms.pointSize.value=u.opacity>0?u.size:0,y.uniformsNeedUpdate=!0)},f.matrixAutoUpdate=!1,f.matrix.fromArray(Ly(r,o)),f.matrixWorldNeedsUpdate=!0,f.frustumCulled=!0,c.computeBoundingSphere(),this.root.add(f),this._materials.push({material:u,color:u.color.clone(),opacity:h?.opacity??1,vertexColors:d})}}syncVisibility(t){let e=t.pointOffset??t.instanceCount-this.count;for(let[n,s]of this.root.children.entries())s.visible=t.isInstanceVisible(e+n)}syncAppearance(t){let e=t.pointOffset??t.instanceCount-this.count;for(let[n,s]of this._materials.entries()){let{material:r}=s,o=t.instanceColorOverride(e+n,r.color);o||r.color.copy(s.color);let a=s.vertexColors&&!o,l=t.opacity*s.opacity,c=l<1;(r.vertexColors!==a||r.transparent!==c)&&(r.needsUpdate=!0),r.vertexColors=a,r.opacity=l,r.transparent=c,r.depthWrite=!c}}setClipping(t,e=!1){this.clippingPlanes=t.length>0?t:null,this.clipIntersection=e;for(let{material:n}of this._materials)n.clippingPlanes=this.clippingPlanes,n.clipIntersection=e}withPickMaterial(t,e){t.clippingPlanes=this.clippingPlanes,t.clipIntersection=this.clipIntersection;for(let n of this.root.children)n.material=t;try{e()}finally{for(let[n,s]of this.root.children.entries())s.material=this._materials[n].material}}position(t,e,n){let s=this.root.children[t];return n.fromBufferAttribute(s.geometry.attributes.position,e).applyMatrix4(s.matrixWorld)}};function Ly(i,t){let e=t*12;return[i[e],i[e+1],i[e+2],0,i[e+3],i[e+4],i[e+5],0,i[e+6],i[e+7],i[e+8],0,i[e+9],i[e+10],i[e+11],1]}var Nh=2048,Dy=524288,Uh=[245,158,11],Fh=[235,235,237],Ny=` #include attribute float lineSlot; uniform sampler2D lineState; @@ -4268,7 +4268,7 @@ void main() { #include #include if (state.a < 0.5) gl_Position = vec4(0.0, 0.0, 2.0, 1.0); -}`,Ny=` +}`,Uy=` #include #include #include @@ -4286,7 +4286,7 @@ void main() { c = vec3(0.95, 0.96, 0.98); } gl_FragColor = vec4(c, opacity); -}`,cl=class{constructor(t){this.root=new Re;let e=t.meta.lines;if(this.count=e?.count??0,this.clippingPlanes=null,this.clipIntersection=!1,this._lightBg=!1,!this.count)return;let n=t.view(e.geometry),s=t.view(e.material),r=t.view(e.matrix),o=Math.ceil(this.count/Nh);this._stateData=new Uint8Array(Nh*o*4),this._state=new mn(this._stateData,Nh,o,je),this._state.colorSpace=me,this._state.minFilter=Le,this._state.magFilter=Le,this._state.generateMipmaps=!1,this._baseColors=new Array(this.count);for(let f=0;f{if(!a.has(f)){let m=t.meta.geometries[f];if(!m||m.kind!=="lines")throw new ee(`Line instance references a geometry (${f}) that is not lines.`);a.set(f,Hs(t,m)),l.set(f,t.view(m.indices))}return{positions:a.get(f),indices:l.get(f)}},h=[],d=[],u=()=>{if(h.length===0)return;let f=new he;f.setAttribute("position",new xe(new Float32Array(h),3)),f.setAttribute("lineSlot",new xe(new Float32Array(d),1)),f.computeBoundingSphere();let m=new ln(f,this._material);m.frustumCulled=!1,this.root.add(m),h=[],d=[]};for(let f=0;fLy&&d.length>0&&u();for(let D=0;D>16&255,this._stateData[l+1]=h>>8&255,this._stateData[l+2]=h&255}else if(n)this._stateData[l]=Fh[0],this._stateData[l+1]=Fh[1],this._stateData[l+2]=Fh[2];else{let h=this._baseColors[a];this._stateData[l]=h[0],this._stateData[l+1]=h[1],this._stateData[l+2]=h[2]}}this._state.needsUpdate=!0;let r=t._opacity??1;this._uniforms.opacity.value=r;let o=r<1;this._material.transparent!==o&&(this._material.transparent=o,this._material.needsUpdate=!0)}setClipping(t,e=!1){this.clippingPlanes=t.length>0?t:null,this.clipIntersection=e,this._material&&(this._material.clippingPlanes=this.clippingPlanes,this._material.clipIntersection=e)}withPickMaterial(t,e){t.clippingPlanes=this.clippingPlanes,t.clipIntersection=this.clipIntersection,t.uniforms?.lineState&&(t.uniforms.lineState.value=this._state);for(let n of this.root.children)n.material=t;try{e()}finally{for(let n of this.root.children)n.material=this._material}}};var Uy={ru:{elements:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",noGeometry:"\u041D\u0435\u0442 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0438",contextLost:"\u0412\u0438\u0434\u0435\u043E\u043A\u0430\u0440\u0442\u0430 \u0441\u0431\u0440\u043E\u0448\u0435\u043D\u0430 \u2014 \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443",noWebGL:"\u041D\u0443\u0436\u0435\u043D \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0441 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u043E\u0439 WebGL 2",badData:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435 \u043C\u043E\u0434\u0435\u043B\u0438",tooLarge:"\u041C\u043E\u0434\u0435\u043B\u044C \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u0430\u044F \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0449\u0438\u043A\u0430: \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 \u0441 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0435\u0439 \u2014 {count}, \u043F\u0440\u0435\u0434\u0435\u043B \u2014 {limit}",selected:"\u0412\u044B\u0431\u0440\u0430\u043D\u043E",close:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","scanMap.title":"\u041C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0430","scanMap.plan":"\u041F\u043B\u0430\u043D \u043E\u0431\u043B\u0430\u043A\u0430 \u0442\u043E\u0447\u0435\u043A","scanMap.metres":"\u043C","scanMap.choosePhoto":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0444\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0443\u2026","scanMap.spheres":"\u0421\u0444\u0435\u0440\u044B \u043F\u0430\u043D\u043E\u0440\u0430\u043C \u0432 3D","scanMap.photo":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","scanMap.intensity":"\u0418\u043D\u0442\u0435\u043D\u0441\u0438\u0432\u043D\u043E\u0441\u0442\u044C","scanMap.goToStation":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043A \u0441\u0442\u0430\u043D\u0446\u0438\u0438 {name}","scanMap.photoControls":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430. \u0421\u0442\u0440\u0435\u043B\u043A\u0438 \u043F\u043E\u0432\u043E\u0440\u0430\u0447\u0438\u0432\u0430\u044E\u0442 \u043A\u0430\u043C\u0435\u0440\u0443, \u043A\u043E\u043B\u0435\u0441\u043E \u043C\u0435\u043D\u044F\u0435\u0442 \u043C\u0430\u0441\u0448\u0442\u0430\u0431.","scanMap.loading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0438\u2026","scanMap.photoError":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043A\u0443\u044E \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044E.","scanMap.enlargePhoto":"\u0423\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C","scanMap.shrinkPhoto":"\u0423\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C","scanMap.size":"\u0420\u0430\u0437\u043C\u0435\u0440 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.small":"\u041C\u0430\u043B\u0430\u044F","scanMap.medium":"\u0421\u0440\u0435\u0434\u043D\u044F\u044F","scanMap.large":"\u0411\u043E\u043B\u044C\u0448\u0430\u044F","scanMap.zoomIn":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.zoomOut":"\u041E\u0442\u0434\u0430\u043B\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.reset":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0435\u0441\u044C \u043F\u043B\u0430\u043D","scanMap.levels":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.allLevels":"\u0412\u0441\u0435 \u0432\u044B\u0441\u043E\u0442\u044B","scanMap.level":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C {n}","scanMap.addLevel":"\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0443\u0440\u043E\u0432\u0435\u043D\u044C \u043F\u043E \u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0435","scanMap.removeLevel":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0439 \u0443\u0440\u043E\u0432\u0435\u043D\u044C","scanMap.autoButton":"\u0410\u0432\u0442\u043E","scanMap.autoLevels":"\u041E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0443\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439","scanMap.noLevels":"\u041D\u0435\u0442 \u044F\u0432\u043D\u043E \u0440\u0430\u0437\u0434\u0435\u043B\u0451\u043D\u043D\u044B\u0445 \u0433\u0440\u0443\u043F\u043F \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0435.","scanMap.levelsAdded":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B.","scanMap.levelsExist":"\u042D\u0442\u0438 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u044B \u0443\u0436\u0435 \u043E\u0445\u0432\u0430\u0447\u0435\u043D\u044B \u0443\u0440\u043E\u0432\u043D\u044F\u043C\u0438.","scanMap.levelAdded":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C \u0441\u043E\u0437\u0434\u0430\u043D.","scanMap.levelTemporary":"\u0423\u0440\u043E\u0432\u043D\u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0434\u043E \u0437\u0430\u043A\u0440\u044B\u0442\u0438\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B.","scanMap.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","scanMap.pickLower":"\u0429\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u043D\u0438\u0436\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435 \u0443\u0440\u043E\u0432\u043D\u044F.","scanMap.pickUpper":"\u041D\u0438\u0437 {z}. \u0422\u0435\u043F\u0435\u0440\u044C \u0449\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u0432\u0435\u0440\u0445\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435.","scanMap.noLowerHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043D\u0438\u0436\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.noUpperHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0435\u0440\u0445\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.upperAboveLower":"\u0412\u0435\u0440\u0445\u043D\u044F\u044F \u043E\u0442\u043C\u0435\u0442\u043A\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0432\u044B\u0448\u0435 {z}.",elementGroup:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442",id:"Id",category:"\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F",type:"\u0422\u0438\u043F",level:"\u0423\u0440\u043E\u0432\u0435\u043D\u044C",sourceId:"ID \u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A\u0430",link:"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0439 \u0444\u0430\u0439\u043B",panels:"\u041F\u0430\u043D\u0435\u043B\u0438","panel.model":"\u041C\u043E\u0434\u0435\u043B\u044C","panel.elements":"\u0422\u0430\u0431\u043B\u0438\u0446\u0430 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432","csv.open":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C CSV \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432","csv.download":"\u0421\u043A\u0430\u0447\u0430\u0442\u044C CSV","csv.choose":"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 CSV, \u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0432\u043C\u0435\u0441\u0442\u0435 \u0441 \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u044C\u044E.","csv.loading":"\u0427\u0442\u0435\u043D\u0438\u0435 CSV\u2026","csv.loaded":"{file} \xB7 \u0421\u0432\u044F\u0437\u0430\u043D\u043E \u0441 3D: {matched} \u0438\u0437 {total}","csv.noMatch":"{file} \xB7 \u041D\u0435\u0442 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0439. \u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435, \u0447\u0442\u043E CSV \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0441\u044F \u043A \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u0438.","csv.invalid":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C CSV. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0442\u0430\u0431\u043B\u0438\u0446\u0443 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432 RvtIO \u0441 \u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u043C elementId.","csv.noGeometry":"\u0423 \u044D\u0442\u043E\u0433\u043E \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430 \u043D\u0435\u0442 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0438 \u0432 \u043C\u043E\u0434\u0435\u043B\u0438.","csv.search":"\u041F\u043E\u0438\u0441\u043A \u043F\u043E ID \u0438 \u0438\u043C\u0435\u043D\u0438","csv.searchPlaceholder":"ID \u0438\u043B\u0438 \u0438\u043C\u044F","csv.allCategories":"\u0412\u0441\u0435 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438","csv.groupByCategory":"\u0413\u0440\u0443\u043F\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u043E \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F\u043C","csv.categoryTotals":"\u0418\u0442\u043E\u0433\u0438 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438","csv.totals":"\u0418\u0442\u043E\u0433\u0438 \u0432\u044B\u0431\u043E\u0440\u043A\u0438","csv.quantity.length_m":"\u0414\u043B\u0438\u043D\u0430","csv.quantity.area_m2":"\u041F\u043B\u043E\u0449\u0430\u0434\u044C","csv.quantity.volume_m3":"\u041E\u0431\u044A\u0451\u043C","csv.unit.length_m":"\u043C","csv.unit.area_m2":"\u043C\xB2","csv.unit.volume_m3":"\u043C\xB3","csv.outsideFilters":"\u0412\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0439 \u044D\u043B\u0435\u043C\u0435\u043D\u0442 \u0432\u043D\u0435 \u0444\u0438\u043B\u044C\u0442\u0440\u0430.","csv.noResults":"\u041F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0438\u0445 \u0441\u0442\u0440\u043E\u043A \u043D\u0435\u0442.","csv.previous":"\u041D\u0430\u0437\u0430\u0434","csv.next":"\u0414\u0430\u043B\u0435\u0435","csv.range":"{first}\u2013{last} \u0438\u0437 {total}","panel.views":"\u0412\u0438\u0434\u044B","panel.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","panel.clashes":"\u041A\u043E\u043B\u043B\u0438\u0437\u0438\u0438","panel.bcf":"\u0422\u0435\u043C\u044B BCF","bcf.noView":"\u041D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E \u0432\u0438\u0434\u0430","bcf.viewpoint":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432\u0438\u0434 {index}","bcf.components":"\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u043E\u0432 \u2014 {missing}, \u043D\u0435\u043E\u0434\u043D\u043E\u0437\u043D\u0430\u0447\u043D\u044B\u0445 \u2014 {ambiguous}","panel.timeliner":"4D-\u0433\u0440\u0430\u0444\u0438\u043A","panel.links":"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B","group.navigation":"\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F","group.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","group.measure":"\u0418\u0437\u043C\u0435\u0440\u0435\u043D\u0438\u044F","group.display":"\u041E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","group.view":"\u0412\u0438\u0434","tool.orbit":"\u0412\u0440\u0430\u0449\u0435\u043D\u0438\u0435","tool.pan":"\u041F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","tool.fit":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","tool.projection":"\u041F\u0435\u0440\u0441\u043F\u0435\u043A\u0442\u0438\u0432\u0430 / \u043E\u0440\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F","tool.mode2d":"\u0420\u0435\u0436\u0438\u043C 2D / 3D","sheets.label":"\u041B\u0438\u0441\u0442\u044B \u0438 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u043E \u043C\u043E\u0434\u0435\u043B\u0438","tool.plane":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.box":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.distance":"\u0420\u0430\u0441\u0441\u0442\u043E\u044F\u043D\u0438\u0435","tool.displayMode":"\u0420\u0435\u0436\u0438\u043C \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","tool.grids":"\u041E\u0441\u0438","tool.opacity":"\u041F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","tool.fullscreen":"\u041F\u043E\u043B\u043D\u044B\u0439 \u044D\u043A\u0440\u0430\u043D",contextMenu:"\u041A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u043D\u043E\u0435 \u043C\u0435\u043D\u044E","menu.properties":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430","menu.hide":"\u0421\u043A\u0440\u044B\u0442\u044C","menu.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C","menu.showAll":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0441\u0451","menu.zoomTo":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043A \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.sectionBox":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F \u043F\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.copyId":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id","menu.fitAll":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","menu.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","menu.unavailable":"\u041D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0434\u043B\u044F \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u0438",searchPlaceholder:"\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0438\u043C\u0435\u043D\u0438, \u0442\u0438\u043F\u0443, Id\u2026",noCategory:"\u0411\u0435\u0437 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",noMatches:"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","filters.title":"\u0424\u0438\u043B\u044C\u0442\u0440\u044B","filters.model":"\u041C\u043E\u0434\u0435\u043B\u044C-\u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A","filters.noLevel":"\u0411\u0435\u0437 \u0443\u0440\u043E\u0432\u043D\u044F","filters.all":"\u0412\u0441\u0435","filters.clear":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C","filters.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u044F",idCopied:"Id \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D",copyFailed:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id",fullscreenUnavailable:"\u041F\u043E\u043B\u043D\u043E\u044D\u043A\u0440\u0430\u043D\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D","face.front":"\u0421\u043F\u0435\u0440\u0435\u0434\u0438","face.back":"\u0421\u0437\u0430\u0434\u0438","face.left":"\u0421\u043B\u0435\u0432\u0430","face.right":"\u0421\u043F\u0440\u0430\u0432\u0430","face.top":"\u0421\u0432\u0435\u0440\u0445\u0443","face.bottom":"\u0421\u043D\u0438\u0437\u0443","cube.title":"\u041A\u0443\u0431 \u0432\u0438\u0434\u0430","cube.up":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u0432\u0435\u0440\u0445","cube.down":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043D\u0438\u0437","cube.left":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043B\u0435\u0432\u043E","cube.right":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043F\u0440\u0430\u0432\u043E","cube.home":"\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0432\u0438\u0434","sections.mode":"\u0420\u0435\u0436\u0438\u043C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","sections.planes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.box":"\u0411\u043E\u043A\u0441","sections.off":"\u0412\u044B\u043A\u043B","sections.axis":"\u041E\u0441\u044C","sections.addPlane":"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.noPlanes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439 \u043D\u0435\u0442","sections.rotated":"\u043F\u043E\u0432\u0451\u0440\u043D\u0443\u0442\u0430","sections.custom":"\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u043B\u044C\u043D\u0430\u044F","sections.position":"\u041F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.flip":"\u0421\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0442\u043E\u0440\u043E\u043D\u0443","sections.enabled":"\u0412\u043A\u043B","sections.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.keepInside":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.cutInside":"\u0412\u044B\u0440\u0435\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.fitSelection":"\u041F\u043E \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u043D\u043E\u043C\u0443","sections.showGizmo":"\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043C\u0430\u043D\u0438\u043F\u0443\u043B\u044F\u0442\u043E\u0440","sections.boxYaw":"\u041F\u043E\u0432\u043E\u0440\u043E\u0442 \u0432\u043E\u043A\u0440\u0443\u0433 Z","sections.fill":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u0441\u0440\u0435\u0437\u043E\u0432","sections.fillUnavailable":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430 \u0431\u0435\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u0442\u0440\u0430\u0444\u0430\u0440\u0435\u0442\u0430 WebGL","sections.fillNeedsMeshes":"\u0414\u043B\u044F \u0437\u0430\u043B\u0438\u0432\u043A\u0438 \u0441\u0435\u0447\u0435\u043D\u0438\u0439 \u043D\u0443\u0436\u043D\u0430 \u0437\u0430\u043C\u043A\u043D\u0443\u0442\u0430\u044F \u043F\u043E\u043B\u0438\u0433\u043E\u043D\u0430\u043B\u044C\u043D\u0430\u044F \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u044F","sections.maxPlanes":"\u041D\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 6 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439","unit.m":"\u043C","display.materials":"\u041C\u0430\u0442\u0435\u0440\u0438\u0430\u043B\u044B","display.textures":"\u0422\u0435\u043A\u0441\u0442\u0443\u0440\u044B","display.white":"\u0411\u0435\u043B\u044B\u0439","display.wireframe":"\u041A\u0430\u0440\u043A\u0430\u0441","display.background":"\u0426\u0432\u0435\u0442 \u0444\u043E\u043D\u0430","display.backgroundReset":"\u0424\u043E\u043D \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","display.bgCadDark":"CAD \u0442\u0451\u043C\u043D\u044B\u0439","display.bgPaper":"\u041B\u0438\u0441\u0442 \u0431\u0435\u043B\u044B\u0439","opacity.label":"\u041D\u0435\u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","opacity.value":"{value} %","views.tour":"\u0422\u0443\u0440 \u043F\u043E \u0432\u0438\u0434\u0430\u043C","views.stop":"\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0442\u0443\u0440","clash.New":"\u041D\u043E\u0432\u0430\u044F","clash.Active":"\u0410\u043A\u0442\u0438\u0432\u043D\u0430\u044F","clash.Reviewed":"\u041F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u0430","clash.Approved":"\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0430","clash.Resolved":"\u0423\u0441\u0442\u0440\u0430\u043D\u0435\u043D\u0430","task.construct":"\u0421\u0442\u0440\u043E\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u043E","task.demolish":"\u0421\u043D\u043E\u0441","task.temporary":"\u0412\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0435","player.title":"4D-\u043F\u0440\u043E\u0438\u0433\u0440\u044B\u0432\u0430\u0442\u0435\u043B\u044C","player.play":"\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438","player.pause":"\u041F\u0430\u0443\u0437\u0430","player.date":"\u0414\u0430\u0442\u0430 \u0433\u0440\u0430\u0444\u0438\u043A\u0430","player.speed":"\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C",truncated:"\u041F\u043E\u043A\u0430\u0437\u0430\u043D\u043E {meshes} \u0438\u0437 {total} \u043C\u0435\u0448\u0435\u0439: \u043C\u043E\u0434\u0435\u043B\u044C \u043E\u0431\u0440\u0435\u0437\u0430\u043D\u0430 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u043E\u0439 MaxMeshVertices"},en:{elements:"Elements",noGeometry:"No geometry",contextLost:"The graphics context was lost \u2014 reload the page",noWebGL:"This page needs a browser with WebGL 2",badData:"The model data could not be read",tooLarge:"The model is too large for this viewer: {count} objects with geometry, the limit is {limit}",selected:"Selected",close:"Close","scanMap.title":"Minimap","scanMap.plan":"Point cloud floor plan","scanMap.metres":"m","scanMap.choosePhoto":"Open photo panorama\u2026","scanMap.spheres":"Panorama spheres in 3D","scanMap.photo":"Photo panorama","scanMap.intensity":"Intensity","scanMap.goToStation":"Move to station {name}","scanMap.photoControls":"Photo panorama. Arrow keys turn the camera, the wheel zooms.","scanMap.loading":"Loading photograph\u2026","scanMap.photoError":"Could not open the spherical photograph.","scanMap.enlargePhoto":"Enlarge","scanMap.shrinkPhoto":"Restore size","scanMap.size":"Minimap size","scanMap.small":"Small","scanMap.medium":"Medium","scanMap.large":"Large","scanMap.zoomIn":"Zoom in on minimap","scanMap.zoomOut":"Zoom out on minimap","scanMap.reset":"Fit the whole plan","scanMap.levels":"Minimap levels","scanMap.allLevels":"All heights","scanMap.level":"Level {n}","scanMap.addLevel":"Create level from panorama","scanMap.removeLevel":"Remove selected level","scanMap.autoButton":"Auto","scanMap.autoLevels":"Detect levels by station height","scanMap.noLevels":"Station heights have no clear groups.","scanMap.levelsAdded":"Levels added from station heights.","scanMap.levelsExist":"Existing levels already cover these height ranges.","scanMap.levelAdded":"Level created.","scanMap.levelTemporary":"Levels will stay available until you close this page.","scanMap.cancel":"Cancel","scanMap.pickLower":"Click the lower level elevation.","scanMap.pickUpper":"Lower elevation {z}. Now click the upper elevation.","scanMap.noLowerHit":"No scan points along that ray. Choose a nearby lower elevation.","scanMap.noUpperHit":"No scan points along that ray. Choose a nearby upper elevation.","scanMap.upperAboveLower":"The upper elevation must be above {z}.",elementGroup:"Element",id:"Id",category:"Category",type:"Type",level:"Level",sourceId:"Source ID",link:"Link",panels:"Panels","panel.model":"Model","panel.elements":"Element table","csv.open":"Open element CSV","csv.download":"Download CSV","csv.choose":"Choose the CSV exported with this model.","csv.loading":"Reading CSV\u2026","csv.loaded":"{file} \xB7 Linked to 3D: {matched} of {total}","csv.noMatch":"{file} \xB7 No matches. Check that the CSV belongs to this model.","csv.invalid":"Could not read the CSV. Choose an RvtIO element table with unique elementId values.","csv.noGeometry":"This element has no geometry in the model.","csv.search":"Search by ID and name","csv.searchPlaceholder":"ID or name","csv.allCategories":"All categories","csv.groupByCategory":"Group by category","csv.categoryTotals":"Category totals","csv.totals":"Filtered totals","csv.quantity.length_m":"Length","csv.quantity.area_m2":"Area","csv.quantity.volume_m3":"Volume","csv.unit.length_m":"m","csv.unit.area_m2":"m\xB2","csv.unit.volume_m3":"m\xB3","csv.outsideFilters":"The selected element is outside the filter.","csv.noResults":"No matching rows.","csv.previous":"Previous","csv.next":"Next","csv.range":"{first}\u2013{last} of {total}","panel.views":"Views","panel.sections":"Sections","panel.clashes":"Clashes","panel.bcf":"BCF topics","bcf.noView":"No view available","bcf.viewpoint":"Open viewpoint {index}","bcf.components":"Components missing \u2014 {missing}, ambiguous \u2014 {ambiguous}","panel.timeliner":"4D schedule","panel.links":"Linked files","group.navigation":"Navigation","group.sections":"Sections","group.measure":"Measure","group.display":"Display","group.view":"View","tool.orbit":"Orbit","tool.pan":"Pan","tool.fit":"Fit all","tool.projection":"Perspective / orthographic","tool.mode2d":"2D / 3D mode","sheets.label":"Sheets and Model Space","tool.plane":"Section plane","tool.box":"Section box","tool.resetSections":"Reset sections","tool.distance":"Distance","tool.displayMode":"Display mode","tool.grids":"Grids","tool.opacity":"Transparency","tool.fullscreen":"Full screen",contextMenu:"Context menu","menu.properties":"Properties","menu.hide":"Hide","menu.isolate":"Isolate","menu.showAll":"Show all","menu.zoomTo":"Zoom to object","menu.sectionBox":"Section box around object","menu.copyId":"Copy Id","menu.fitAll":"Fit all","menu.resetSections":"Reset sections","menu.unavailable":"Unavailable for this model",searchPlaceholder:"Search by name, type, Id\u2026",noCategory:"No category",noMatches:"No matches","filters.title":"Filters","filters.model":"Source model","filters.noLevel":"No level","filters.all":"All","filters.clear":"Clear","filters.isolate":"Isolate matches",idCopied:"Id copied",copyFailed:"Could not copy Id",fullscreenUnavailable:"Fullscreen is not available","face.front":"Front","face.back":"Back","face.left":"Left","face.right":"Right","face.top":"Top","face.bottom":"Bottom","cube.title":"View cube","cube.up":"Rotate up","cube.down":"Rotate down","cube.left":"Rotate left","cube.right":"Rotate right","cube.home":"Home view","sections.mode":"Section mode","sections.planes":"Planes","sections.box":"Box","sections.off":"Off","sections.axis":"Axis","sections.addPlane":"Add plane","sections.noPlanes":"No planes","sections.rotated":"rotated","sections.custom":"Custom","sections.position":"Plane position","sections.flip":"Flip side","sections.enabled":"On","sections.delete":"Delete plane","sections.keepInside":"Show inside","sections.cutInside":"Cut inside","sections.fitSelection":"Fit to selection","sections.showGizmo":"Show gizmo","sections.boxYaw":"Rotation around Z","sections.fill":"Fill cut faces","sections.fillUnavailable":"Section fill requires a WebGL stencil buffer","sections.fillNeedsMeshes":"Section fill requires closed mesh geometry","sections.maxPlanes":"At most 6 planes","unit.m":"m","display.materials":"Materials","display.textures":"Textures","display.white":"White","display.wireframe":"Wireframe","display.background":"Background color","display.backgroundReset":"Reset background","display.bgCadDark":"CAD dark","display.bgPaper":"Paper white","opacity.label":"Opacity","opacity.value":"{value}%","views.tour":"Play tour","views.stop":"Stop tour","clash.New":"New","clash.Active":"Active","clash.Reviewed":"Reviewed","clash.Approved":"Approved","clash.Resolved":"Resolved","task.construct":"Construct","task.demolish":"Demolish","task.temporary":"Temporary","player.title":"4D player","player.play":"Play","player.pause":"Pause","player.date":"Schedule date","player.speed":"Speed",truncated:"Showing {meshes} of {total} meshes: the model was truncated by the MaxMeshVertices setting"}},Pn=(globalThis.navigator?.language??"").toLowerCase().startsWith("ru")?"ru":"en",Zi=new Intl.NumberFormat(Pn).format;function q(i,t=Pn){let e=Uy[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Hf=new C(0,0,1),hl=Math.PI/2-.01;function Gf(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function Wf(i,t,e,n,s,r){let o=i.clone().sub(e),a=t.clone().sub(e),l=d=>(o.applyQuaternion(d),a.applyQuaternion(d));l(new Fe().setFromAxisAngle(Hf,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Hf);if(h.lengthSq()>1e-12){let d=Math.asin(ae.clamp(c.z,-1,1)),u=ae.clamp(s*r,d-hl,d+hl);l(new Fe().setFromAxisAngle(h.normalize(),-u))}return{position:o.add(e),target:a.add(e)}}function Xf(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var Fy=.85,By=100/3;function qf(i,t,e){let n=i*(t===1?By:t===2?e:1);return ae.clamp(Fy**(-n/100),.5,2)}var Bh=(i,t)=>t>=i?"window":"crossing";function Yf(i,t,e){let n=Vf(i.position,i.target),s=Vf(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=ae.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,g)=>_+(g-_)*e,c=r+a*e,h=ae.clamp(l(n.elevation,s.elevation),-hl,hl),d=l(n.distance,s.distance),u=i.target.clone().lerp(t.target,e),f=Math.cos(h)*d;return{position:u.clone().add(new C(f*Math.cos(c),f*Math.sin(c),Math.sin(h)*d)),target:u}}function $f(i,t,e,n){let s=i.position.clone().sub(i.target),r=t.position.clone().sub(t.target),o=s.length(),a=r.length();s.normalize(),r.normalize();let l=new Fe().setFromUnitVectors(s,r),c=e.clone().applyQuaternion(l),h=new C().setFromMatrixColumn(new Zt().lookAt(t.position,t.target,n),1),d=r.dot(new C().crossVectors(c,h)),u=Math.atan2(Math.abs(d)<1e-9?0:d,c.dot(h)),f=new Fe;return m=>{f.identity().slerp(l,m);let _=s.clone().applyQuaternion(f),g=i.target.clone().lerp(t.target,m),p=_.clone().multiplyScalar(ae.lerp(o,a,m)).add(g),y=e.clone().applyQuaternion(f).applyAxisAngle(_,u*m);return{position:p,target:g,up:y}}}function Vf(i,t){let e=i.clone().sub(t),n=e.length(),s=Math.hypot(e.x,e.y);return{distance:n,elevation:n>1e-12?Math.asin(ae.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var Oy=.005,Zf=new C(1,-1,.8).normalize(),Oh=.01,Kf=1e-6,zy=64,Jf=1.05,ky=5e3,ul=(i,t)=>new CustomEvent(i,{detail:t});function jf({bbox:i,grids:t}){let e=r=>Array.isArray(r)&&r.length===3&&r.every(Number.isFinite);if(!e(i?.min)||!e(i?.max))return!0;let n=new oe(new C(...i.min),new C(...i.max));if(n.isEmpty())return!0;let s=new C;for(let r of t??[])for(let o of Ur(r)){if(!e(o))return!0;n.expandByPoint(s.fromArray(o))}return n.getSize(s).length()*Jf>Oh*ky}var dl=class extends EventTarget{constructor(t,e,{pick:n=()=>null,visibleBox:s=()=>new oe}={}){super(),this.dom=e,this.pick=n,this.visibleBox=s,this.target=new C,this.leftButtonMode="orbit",this.is2D=!1,this._saved3D=null,this._perspective=t,this._defaultFov=t.fov,this._orthographic=new Xn(-1,1,1,-1),this.camera=t,this._drag=null,this._wheelPick=null,this._animation=0,this._overlay=null,this._bounds=null,this._extraBounds=new Map,e.style.touchAction="none",e.addEventListener("pointerdown",r=>this._down(r)),e.addEventListener("pointermove",r=>this._move(r)),e.addEventListener("pointerup",r=>this._up(r)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",r=>this._lostCapture(r)),window.addEventListener("blur",()=>this._end()),e.addEventListener("wheel",r=>this._wheel(r),{passive:!1}),e.addEventListener("contextmenu",r=>r.preventDefault())}setLeftButtonMode(t){if(t!=="orbit"&&t!=="pan")throw new RangeError(`Unknown left button mode: ${t}`);this.leftButtonMode=t}setProjection(t){if(t!=="perspective"&&t!=="orthographic")throw new RangeError(`Unknown projection: ${t}`);let e=t==="perspective"?this._perspective:this._orthographic,n=this.camera;if(e!==n){this._stopAnimation(),e.position.copy(n.position),n.isOrthographicCamera&&e.position.sub(this.target).divideScalar(n.zoom).add(this.target),e.zoom=1,e.quaternion.copy(n.quaternion),e.up.copy(n.up),n.parent?.add(e),n.parent?.remove(n);for(let s of[...n.children])e.add(s);this.camera=e,this.resize()}}resize(){let t=this.camera,e=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),n=Math.max(t.position.distanceTo(this.target),1e-6);if(t.isPerspectiveCamera)t.aspect=e;else{let r=n*Math.tan(ae.degToRad(this._perspective.fov/2));Object.assign(t,{top:r,bottom:-r,left:-r*e,right:r*e})}let s=this._rangeSphere();if(s){let r=s.center.clone().sub(t.position),o=new C(0,0,-1).applyQuaternion(t.quaternion);t.far=Math.max(1e-6,(r.length()+s.radius)*Jf);let a=r.dot(o)-s.radius;t.near=Math.max(a*.95,Math.min(Oh,t.far/2))}t.updateProjectionMatrix(),this.dispatchEvent(new Event("change"))}setExtraBounds(t,e){e&&!e.isEmpty()?this._extraBounds.set(t,e.clone()):this._extraBounds.delete(t),this.resize()}_rangeSphere(){let t=this._visibleBounds()?.sphere??null;if(this._extraBounds.size===0)return t;let e=t?this._bounds.box.clone():new oe;for(let n of this._extraBounds.values())e.union(n);return e.getBoundingSphere(new Oe)}invalidateBounds(){this._bounds=null}_visibleBounds(){if(!this._bounds){let t=this.visibleBox();this._bounds={box:t,sphere:t.isEmpty()?null:t.getBoundingSphere(new Oe)}}return this._bounds.sphere&&this._bounds}fitBox(t,e=!0){if(t.isEmpty())return;let n=t.getBoundingSphere(new Oe);if(this.is2D){this.setProjection("orthographic"),this.camera.up.set(0,1,0);let h=t.getSize(new C),d=Math.max(h.x,h.y,n.radius*2,.01),u=t.getCenter(new C),f=new C(u.x,u.y,t.max.z+d*2);this._set(f,u);let m=Math.max(this.dom.clientWidth/Math.max(this.dom.clientHeight,1),.001),_=Math.max(this.camera.top,1e-6),g=Math.max(h.y/2,h.x/(2*m),1e-4)*1.06;this.camera.zoom=_/g,this.resize();return}let s=Math.max(n.radius,.001),r=ae.degToRad(this._perspective.fov/2),o=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),a=s/Math.sin(Math.min(r,Math.atan(Math.tan(r)*o))),l=this.camera.position.clone().sub(this.target);l.lengthSq()<1e-12&&l.copy(Zf);let c=l.normalize().multiplyScalar(a).add(n.center);e?this.animateTo({position:c,target:n.center}):(this.camera.zoom=1,this._set(c,n.center))}set2DMode(t,e=null,n=!1){let s=!!t;if(s===this.is2D){s&&e&&!e.isEmpty()&&this.fitBox(e,n);return}if(this._stopAnimation(),s){this._saved3D={projection:this.camera.isOrthographicCamera?"orthographic":"perspective",position:this.camera.position.clone(),target:this.target.clone(),zoom:this.camera.zoom,leftButtonMode:this.leftButtonMode},this.is2D=!0,this.setProjection("orthographic"),this.leftButtonMode="pan";let r=e&&!e.isEmpty()?e:this.visibleBox();this.fitBox(r,!1)}else{this.is2D=!1,this.camera.up.set(0,0,1);let r=this._saved3D;if(this._saved3D=null,r)this.setProjection(r.projection),this.leftButtonMode=r.leftButtonMode,this.camera.zoom=r.zoom,this._set(r.position,r.target);else{this.setProjection("perspective"),this.leftButtonMode="orbit";let o=e&&!e.isEmpty()?e:this.visibleBox();if(!o.isEmpty()){let a=o.getCenter(new C),l=Math.max(o.getBoundingSphere(new Oe).radius,1);this._set(a.clone().addScaledVector(Zf,l*2.5),a),this.fitBox(o,!1)}}}this.dispatchEvent(ul("mode2d",{enabled:this.is2D}))}zoomToBox(t){this.fitBox(t,!0)}resetCameraStyle(){this._perspective.fov=this._defaultFov,this.camera.up.set(0,0,1)}restoreViewCamera({position:t,target:e,up:n,fov:s,orthographicHeight:r}){let o=new C(...t),a=new C(...e);if(this.resetCameraStyle(),!n){this.animateTo({position:o,target:a});return}this._stopAnimation(),this.camera.up.fromArray(n),this._perspective.fov=s??this._defaultFov;let l=Math.max(o.distanceTo(a),1e-6);this.camera.zoom=r==null?1:2*l*Math.tan(ae.degToRad(this._perspective.fov/2))/r,this._set(o,a)}animateTo({position:t,target:e,zoom:n=1,overPole:s=!1},r=400){this._stopAnimation();let o={position:this.camera.position.clone(),target:this.target.clone()},a={position:t??o.position,target:e??o.target},l=this.camera.zoom,c=s?$f(o,a,new C(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):u=>Yf(o,a,u),h=performance.now(),d=u=>{let f=Math.min((u-h)/r,1),m=f*f*(3-2*f),_=c(m);this.camera.isOrthographicCamera&&(this.camera.zoom=ae.lerp(l,n,m)),this._set(_.position,_.target,_.up),this._animation=f<1?requestAnimationFrame(d):0};this._animation=requestAnimationFrame(d)}get animating(){return this._animation!==0}_stopAnimation(){cancelAnimationFrame(this._animation),this._animation=0}_set(t,e,n){if(this.camera.position.copy(t),this.target.copy(e),n){let s=this.camera.up.clone();this.camera.up.copy(n),this.camera.lookAt(e),this.camera.up.copy(s)}else this.camera.lookAt(e);this.resize()}_down(t){this._end(),this._stopAnimation(),this.dom.setPointerCapture(t.pointerId),t.preventDefault();let e=t.button===0&&t.shiftKey?"box":t.button===0&&!this.is2D&&this.leftButtonMode==="orbit"?"orbit":"pan",n={x:t.clientX,y:t.clientY},s=null;e==="orbit"&&(s=this.pick(n.x,n.y),s||(s=this._visibleBounds()?.sphere.center.clone()??this.target.clone())),this._drag={id:t.pointerId,button:t.button,mode:e,pivot:s,down:n,last:n,moved:!1}}_anchor(t,e){let n=this.pick(t,e);if(n)return n;let s=this.dom.getBoundingClientRect(),r=s.left+s.width/2,o=s.top+s.height/2;return t===r&&e===o?null:this.pick(r,o)}_gestureDepth(t,e){let n=this.camera,s=t?t.clone().sub(n.position).dot(e):0;return Math.max(Kf,n.position.distanceTo(this.target),s)}_move(t){let e=this._drag;if(!e||t.pointerId!==e.id)return;if(t.buttons===0)return this._end();let n={x:t.clientX,y:t.clientY};if(!e.moved&&Gf(e.down,n))return;e.moved=!0;let s=n.x-e.last.x,r=n.y-e.last.y;if(e.last=n,e.mode==="box")this._drawRect(e.down,n);else if(e.mode==="orbit"){let o=Wf(this.camera.position,this.target,e.pivot,s,r,Oy);this._set(o.position,o.target)}else this._pan(s,r)}_pan(t,e){let n=this.camera,s=Math.max(this.dom.clientHeight,1);if(n.isPerspectiveCamera&&this._drag.depth===void 0){let{x:c,y:h}=this._drag.down;this._drag.depth=this._gestureDepth(this._anchor(c,h),n.getWorldDirection(new C))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(ae.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new C(1,0,0).applyQuaternion(n.quaternion),a=new C(0,1,0).applyQuaternion(n.quaternion),l=o.multiplyScalar(-t*r).addScaledVector(a,e*r);this._set(n.position.clone().add(l),this.target.clone().add(l))}_up(t){let e=this._drag;if(!e||t.pointerId!==e.id||t.button!==e.button)return;let n={x:t.clientX,y:t.clientY};if(this._end(),e.mode==="box"&&e.moved){let s={x:Math.min(e.down.x,n.x),y:Math.min(e.down.y,n.y),width:Math.abs(n.x-e.down.x),height:Math.abs(n.y-e.down.y)},r=Bh(e.down.x,n.x);this.dispatchEvent(ul("boxselect",{rect:s,mode:r,ctrl:t.ctrlKey,shift:t.shiftKey}))}else!e.moved&&e.button===0?this.dispatchEvent(ul("click",{x:n.x,y:n.y,button:0,ctrl:t.ctrlKey,shift:t.shiftKey})):!e.moved&&e.button===2&&this.dispatchEvent(ul("contextmenu",{x:n.x,y:n.y}))}_lostCapture(t){this._drag&&t.buttons?this.dom.setPointerCapture(this._drag.id):this._end()}_end(){this._drag=null,this._overlay?.remove(),this._overlay=null}_drawRect(t,e){this._overlay||(this._overlay=document.createElement("div"),Object.assign(this._overlay.style,{position:"fixed",pointerEvents:"none",border:"1px solid #2563eb",background:"rgba(37,99,235,0.12)"}),(this.dom.parentElement??document.body).appendChild(this._overlay)),Object.assign(this._overlay.style,{borderStyle:Bh(t.x,e.x)==="window"?"solid":"dashed",left:`${Math.min(t.x,e.x)}px`,top:`${Math.min(t.y,e.y)}px`,width:`${Math.abs(e.x-t.x)}px`,height:`${Math.abs(e.y-t.y)}px`})}_wheel(t){if(t.preventDefault(),t.deltaY===0)return;this._stopAnimation();let e=qf(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=zy*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:g,width:p,height:y}=this.dom.getBoundingClientRect();if(!p||!y)return;let E=ae.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(E===n.zoom)return;let M=new C((2*(t.clientX-_)/p-1)*n.right,(1-2*(t.clientY-g)/y)*n.top,0).multiplyScalar(1/n.zoom-1/E).applyQuaternion(n.quaternion);n.zoom=E,this._set(n.position.clone().add(M),this.target.clone().add(M));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new C),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Oh,Math.max(Kf,r)),h=ae.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let d=n.position.clone().addScaledVector(a,l),u=this._wheelPick.point,f=u&&u.clone().sub(n.position).dot(a)>=c?u:d,m=Xf(n.position,d,f,h);this._set(m.position,m.target)}};function K(i,t,e){let n=document.createElement(i);return t&&(n.className=t),e!==void 0&&(n.textContent=e),n}function tn(i,t,e){let n=K("button",i);return n.type="button",n.innerHTML=t,n.title=e,n.setAttribute("aria-label",e),n}function Gs(i){i.preventDefault(),i.stopPropagation()}function fl(i){Gs(i);let t=i.button===2,e=()=>{window.removeEventListener("pointerup",n,!0),setTimeout(()=>{window.removeEventListener("click",Gs,!0),t&&window.removeEventListener("contextmenu",Gs,!0)})},n=s=>{Gs(s),e()};window.addEventListener("pointerup",n,!0),window.addEventListener("click",Gs,!0),t&&window.addEventListener("contextmenu",Gs,!0)}function Wr(i,t,e,n){let s=t.clone().applyMatrix4(e.matrixWorldInverse).z<0,r=t.clone().project(e);i.hidden=!(s&&Math.abs(r.x)<=1&&Math.abs(r.y)<=1),!i.hidden&&(i.style.left=`${n.left+(r.x+1)/2*n.width}px`,i.style.top=`${n.top+(1-r.y)/2*n.height}px`)}var ye=i=>``,Qf='',re={model:ye(''),elements:ye(''),views:ye(''),sections:ye(''),clashes:ye(''),bcf:ye(''),timeliner:ye(''),links:ye(''),orbit:ye(''),pan:ye(''),fit:ye(''),projection:ye(Qf),mode2d:ye(''),plane:ye(''),box:ye(`${Qf}`),resetSections:ye(''),distance:ye(''),displayMode:ye(''),grids:ye(''),opacity:ye(''),fullscreen:ye(''),close:ye(''),chevron:ye(''),flip:ye(''),remove:ye(''),play:ye(''),pause:ye(''),home:ye('')};var Xr=new C(0,0,1),un={right:new C(1,0,0),left:new C(-1,0,0),back:new C(0,1,0),front:new C(0,-1,0),top:new C(0,0,1),bottom:new C(0,0,-1)},Hy={right:Xr,left:Xr,back:Xr,front:Xr,top:un.back,bottom:un.front},Ki=.7,Vy=ae.degToRad(1),tp=.01,ep=96,pl=1.75;function np(i){let t=i.split("-"),e=new C;for(let n of t){if(!Object.hasOwn(un,n))throw new RangeError(`Unknown view cube region: ${i}`);e.add(un[n])}if(new Set(t).size!==t.length||e.lengthSq()!==t.length)throw new RangeError(`Unknown view cube region: ${i}`);return e.normalize()}function Gy(i){let t=[];return Math.abs(i.z)>=Ki&&t.push(i.z>0?"top":"bottom"),Math.abs(i.y)>=Ki&&t.push(i.y>0?"back":"front"),Math.abs(i.x)>=Ki&&t.push(i.x>0?"right":"left"),t.join("-")}function zh(i,t=Vy){let e=i.clone().normalize(),n=Math.cos(t);return Object.keys(un).find(s=>e.dot(un[s])>=n)??null}function ip(i){let t=new C(i.x,i.y,0);if(t.lengthSq()<1e-24)return"front";t.normalize();let e=["front","right","back","left"],n=Math.max(...e.map(s=>t.dot(un[s])));return e.find(s=>t.dot(un[s])>=n-1e-9)}function kh(i,t){return un[ip(t)].clone().multiplyScalar(Math.sin(tp)).addScaledVector(un[i],Math.cos(tp))}function Wy(i,t){let e=zh(i);if(!e)return null;let n=e==="top"||e==="bottom";if(t==="left"||t==="right")return(n?kh(e,i):np(e)).applyAxisAngle(Xr,t==="right"?Math.PI/2:-Math.PI/2);if(t!=="up"&&t!=="down")throw new RangeError(`Unknown arrow: ${t}`);if(!n)return kh(t==="up"?"top":"bottom",i);let s=un[ip(i)];return t==="up"==(e==="top")?s.clone().negate():s.clone()}function Xy(i,t){let e=document.createElement("canvas");e.width=e.height=128;let n=e.getContext("2d");n.fillStyle="#2a2f38",n.fillRect(0,0,128,128),n.fillStyle="#cbd5e1",n.textAlign="center",n.textBaseline="middle",n.font=`600 26px ${t}`;let s=n.measureText(i).width;s>112&&(n.font=`600 ${Math.floor(2912/s)}px ${t}`),n.fillText(i,64,64);let r=new hr(e);return r.colorSpace=me,r}var ml=class{constructor(t,e,n){this.controls=n,this.home={position:e.position.clone(),target:n.target.clone()},this.element=K("div","ioviewer-viewcube"),this.canvas=K("canvas","ioviewer-viewcube-canvas"),this.canvas.title=q("cube.title"),this.canvas.setAttribute("aria-label",q("cube.title")),this.element.append(this.canvas),this.error=null,this.renderer=this._createRenderer(),this.scene=new pn,this.camera=new Xn(-pl,pl,pl,-pl,.1,10),this.faces=new Re;let s=getComputedStyle(t).fontFamily;for(let[l,c]of Object.entries(un)){let h=q(`face.${l}`),d=new ge(new cn(2,2),new Je({map:Xy(h,s)})),u=Hy[l];d.quaternion.setFromRotationMatrix(new Zt().makeBasis(u.clone().cross(c),u,c)),d.position.copy(c),d.name=l,d.userData.label=h,this.faces.add(d)}let r=new ln(new Hi(new gn(2,2,2)),new sn({color:"#5b6575"}));this.highlight=new ge(new gn(1,1,1),new Je({color:"#2563eb",transparent:!0,opacity:.6})),this.highlight.visible=!1,this.scene.add(this.faces,r,this.highlight),this._raycaster=new qn,this.hovered=null,this._pointer=null,this.element.addEventListener("contextmenu",l=>l.preventDefault());let o=l=>{this._pointer=[l.clientX,l.clientY],this._hover(this.regionAtClient(...this._pointer))&&this._render()};this.canvas.addEventListener("pointerenter",o),this.canvas.addEventListener("pointermove",o),this.canvas.addEventListener("pointerleave",()=>{this._pointer=null,this._hover(null)&&this._render()}),this.canvas.addEventListener("click",l=>{let c=this.regionAtClient(l.clientX,l.clientY);if(!c)return;let h=c==="top"||c==="bottom";this._look(h?kh(c,n.camera.position.clone().sub(n.target)):np(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=tn("ioviewer-viewcube-arrow",re.chevron,q(`cube.${l}`));return c.dataset.arrow=l,c.addEventListener("click",h=>{h.detail&&c.blur(),this._arrow(l)}),c});let a=tn("ioviewer-viewcube-home",re.home,q("cube.home"));a.addEventListener("click",l=>{l.detail&&a.blur(),n.resetCameraStyle(),n.animateTo({position:this.home.position.clone(),target:this.home.target.clone()})}),this.element.append(...this.arrows,a),t.append(this.element),this.update()}_createRenderer(){this.canvas.addEventListener("webglcontextlost",e=>{e.stopImmediatePropagation(),this._fail(new Error("The view cube lost its WebGL context."))});let t=this.canvas.getContext("webgl2",{alpha:!0,antialias:!0});if(!t)return this._fail(new Error("WebGL 2 is not available for the view cube."));try{let e=new Ti({canvas:this.canvas,context:t,alpha:!0,antialias:!0});return e.setPixelRatio(window.devicePixelRatio),e.setSize(ep,ep),e}catch(e){return this._fail(e)}}_fail(t){return this.error=t,this.renderer=null,this.element.hidden=!0,null}_render(){if(this.renderer)try{this.renderer.render(this.scene,this.camera)}catch(t){this._fail(t)}}set2D(t){this.element.classList.toggle("ioviewer-viewcube-2d",!!t)}update(){if(!this.renderer)return;let t=this.controls.camera,e=!this.camera.quaternion.equals(t.quaternion);this.camera.quaternion.copy(t.quaternion),this.camera.position.set(0,0,5).applyQuaternion(t.quaternion),this.camera.updateMatrixWorld();let n=zh(t.position.clone().sub(this.controls.target))!==null;for(let s of this.arrows)s.hidden=!n;e&&this._pointer&&this._hover(this.regionAtClient(...this._pointer)),this._render()}regionAtClient(t,e){let n=this.canvas.getBoundingClientRect(),s=new qt((t-n.left)/n.width*2-1,1-(e-n.top)/n.height*2);this._raycaster.setFromCamera(s,this.camera);let r=this._raycaster.intersectObjects(this.faces.children)[0];return r?Gy(r.point):null}_hover(t){if(t===this.hovered)return!1;if(this.hovered=t,this.highlight.visible=!!t,t){let e=t.split("-").reduce((a,l)=>a.add(un[l]),new C),n=a=>a===0?[-Ki,Ki]:a>0?[Ki,1.02]:[-1.02,-Ki],[s,r,o]=e.toArray().map(n);this.highlight.scale.set(s[1]-s[0],r[1]-r[0],o[1]-o[0]),this.highlight.position.set((s[0]+s[1])/2,(r[0]+r[1])/2,(o[0]+o[1])/2)}return!0}_arrow(t){let n=this.controls.camera.position.clone().sub(this.controls.target),s=Wy(n,t);if(!s)return;let r=zh(n),o=r==="top"&&t==="up"||r==="bottom"&&t==="down";this._look(s,o)}_look(t,e=!1){let{controls:n}=this,s=n.camera.position.distanceTo(n.target);n.animateTo({position:t.clone().multiplyScalar(s).add(n.target),target:n.target.clone(),zoom:n.camera.zoom,overPole:e})}};var qy=` +}`,cl=class{constructor(t){this.root=new Re;let e=t.meta.lines;if(this.count=e?.count??0,this.clippingPlanes=null,this.clipIntersection=!1,this._lightBg=!1,!this.count)return;let n=t.view(e.geometry),s=t.view(e.material),r=t.view(e.matrix),o=Math.ceil(this.count/Nh);this._stateData=new Uint8Array(Nh*o*4),this._state=new mn(this._stateData,Nh,o,je),this._state.colorSpace=me,this._state.minFilter=Le,this._state.magFilter=Le,this._state.generateMipmaps=!1,this._baseColors=new Array(this.count);for(let f=0;f{if(!a.has(f)){let m=t.meta.geometries[f];if(!m||m.kind!=="lines")throw new ee(`Line instance references a geometry (${f}) that is not lines.`);a.set(f,Hs(t,m)),l.set(f,t.view(m.indices))}return{positions:a.get(f),indices:l.get(f)}},h=[],d=[],u=()=>{if(h.length===0)return;let f=new he;f.setAttribute("position",new xe(new Float32Array(h),3)),f.setAttribute("lineSlot",new xe(new Float32Array(d),1)),f.computeBoundingSphere();let m=new ln(f,this._material);m.frustumCulled=!1,this.root.add(m),h=[],d=[]};for(let f=0;fDy&&d.length>0&&u();for(let D=0;D>16&255,this._stateData[l+1]=h>>8&255,this._stateData[l+2]=h&255}else if(n)this._stateData[l]=Fh[0],this._stateData[l+1]=Fh[1],this._stateData[l+2]=Fh[2];else{let h=this._baseColors[a];this._stateData[l]=h[0],this._stateData[l+1]=h[1],this._stateData[l+2]=h[2]}}this._state.needsUpdate=!0;let r=t._opacity??1;this._uniforms.opacity.value=r;let o=r<1;this._material.transparent!==o&&(this._material.transparent=o,this._material.needsUpdate=!0)}setClipping(t,e=!1){this.clippingPlanes=t.length>0?t:null,this.clipIntersection=e,this._material&&(this._material.clippingPlanes=this.clippingPlanes,this._material.clipIntersection=e)}withPickMaterial(t,e){t.clippingPlanes=this.clippingPlanes,t.clipIntersection=this.clipIntersection,t.uniforms?.lineState&&(t.uniforms.lineState.value=this._state);for(let n of this.root.children)n.material=t;try{e()}finally{for(let n of this.root.children)n.material=this._material}}};var Fy={ru:{elements:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",noGeometry:"\u041D\u0435\u0442 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0438",contextLost:"\u0412\u0438\u0434\u0435\u043E\u043A\u0430\u0440\u0442\u0430 \u0441\u0431\u0440\u043E\u0448\u0435\u043D\u0430 \u2014 \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443",noWebGL:"\u041D\u0443\u0436\u0435\u043D \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0441 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u043E\u0439 WebGL 2",badData:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435 \u043C\u043E\u0434\u0435\u043B\u0438",tooLarge:"\u041C\u043E\u0434\u0435\u043B\u044C \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u0430\u044F \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0449\u0438\u043A\u0430: \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 \u0441 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0435\u0439 \u2014 {count}, \u043F\u0440\u0435\u0434\u0435\u043B \u2014 {limit}",selected:"\u0412\u044B\u0431\u0440\u0430\u043D\u043E",close:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","scanMap.title":"\u041C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0430","scanMap.plan":"\u041F\u043B\u0430\u043D \u043E\u0431\u043B\u0430\u043A\u0430 \u0442\u043E\u0447\u0435\u043A","scanMap.metres":"\u043C","scanMap.choosePhoto":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0444\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0443\u2026","scanMap.spheres":"\u0421\u0444\u0435\u0440\u044B \u043F\u0430\u043D\u043E\u0440\u0430\u043C \u0432 3D","scanMap.photo":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","scanMap.intensity":"\u0418\u043D\u0442\u0435\u043D\u0441\u0438\u0432\u043D\u043E\u0441\u0442\u044C","scanMap.goToStation":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043A \u0441\u0442\u0430\u043D\u0446\u0438\u0438 {name}","scanMap.photoControls":"\u0424\u043E\u0442\u043E\u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0430. \u0421\u0442\u0440\u0435\u043B\u043A\u0438 \u043F\u043E\u0432\u043E\u0440\u0430\u0447\u0438\u0432\u0430\u044E\u0442 \u043A\u0430\u043C\u0435\u0440\u0443, \u043A\u043E\u043B\u0435\u0441\u043E \u043C\u0435\u043D\u044F\u0435\u0442 \u043C\u0430\u0441\u0448\u0442\u0430\u0431.","scanMap.loading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0438\u2026","scanMap.photoError":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043A\u0443\u044E \u0444\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044E.","scanMap.enlargePhoto":"\u0423\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C","scanMap.shrinkPhoto":"\u0423\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C","scanMap.size":"\u0420\u0430\u0437\u043C\u0435\u0440 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.small":"\u041C\u0430\u043B\u0430\u044F","scanMap.medium":"\u0421\u0440\u0435\u0434\u043D\u044F\u044F","scanMap.large":"\u0411\u043E\u043B\u044C\u0448\u0430\u044F","scanMap.zoomIn":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.zoomOut":"\u041E\u0442\u0434\u0430\u043B\u0438\u0442\u044C \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u0443","scanMap.reset":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0435\u0441\u044C \u043F\u043B\u0430\u043D","scanMap.levels":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043C\u0438\u043D\u0438\u043A\u0430\u0440\u0442\u044B","scanMap.allLevels":"\u0412\u0441\u0435 \u0432\u044B\u0441\u043E\u0442\u044B","scanMap.level":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C {n}","scanMap.addLevel":"\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0443\u0440\u043E\u0432\u0435\u043D\u044C \u043F\u043E \u043F\u0430\u043D\u043E\u0440\u0430\u043C\u0435","scanMap.removeLevel":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0439 \u0443\u0440\u043E\u0432\u0435\u043D\u044C","scanMap.autoButton":"\u0410\u0432\u0442\u043E","scanMap.autoLevels":"\u041E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0443\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439","scanMap.noLevels":"\u041D\u0435\u0442 \u044F\u0432\u043D\u043E \u0440\u0430\u0437\u0434\u0435\u043B\u0451\u043D\u043D\u044B\u0445 \u0433\u0440\u0443\u043F\u043F \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0435.","scanMap.levelsAdded":"\u0423\u0440\u043E\u0432\u043D\u0438 \u043F\u043E \u0432\u044B\u0441\u043E\u0442\u0430\u043C \u0441\u0442\u0430\u043D\u0446\u0438\u0439 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B.","scanMap.levelsExist":"\u042D\u0442\u0438 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u044B \u0443\u0436\u0435 \u043E\u0445\u0432\u0430\u0447\u0435\u043D\u044B \u0443\u0440\u043E\u0432\u043D\u044F\u043C\u0438.","scanMap.levelAdded":"\u0423\u0440\u043E\u0432\u0435\u043D\u044C \u0441\u043E\u0437\u0434\u0430\u043D.","scanMap.levelTemporary":"\u0423\u0440\u043E\u0432\u043D\u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0434\u043E \u0437\u0430\u043A\u0440\u044B\u0442\u0438\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B.","scanMap.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","scanMap.pickLower":"\u0429\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u043D\u0438\u0436\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435 \u0443\u0440\u043E\u0432\u043D\u044F.","scanMap.pickUpper":"\u041D\u0438\u0437 {z}. \u0422\u0435\u043F\u0435\u0440\u044C \u0449\u0451\u043B\u043A\u043D\u0438\u0442\u0435 \u043F\u043E \u0432\u0435\u0440\u0445\u043D\u0435\u0439 \u043E\u0442\u043C\u0435\u0442\u043A\u0435.","scanMap.noLowerHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043D\u0438\u0436\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.noUpperHit":"\u041D\u0430 \u043B\u0443\u0447\u0435 \u043D\u0435\u0442 \u0442\u043E\u0447\u0435\u043A \u043E\u0431\u043B\u0430\u043A\u0430. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0435\u0440\u0445\u043D\u044E\u044E \u043E\u0442\u043C\u0435\u0442\u043A\u0443 \u0440\u044F\u0434\u043E\u043C.","scanMap.upperAboveLower":"\u0412\u0435\u0440\u0445\u043D\u044F\u044F \u043E\u0442\u043C\u0435\u0442\u043A\u0430 \u0434\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0432\u044B\u0448\u0435 {z}.",elementGroup:"\u042D\u043B\u0435\u043C\u0435\u043D\u0442",id:"Id",category:"\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F",type:"\u0422\u0438\u043F",level:"\u0423\u0440\u043E\u0432\u0435\u043D\u044C",sourceId:"ID \u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A\u0430",link:"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0439 \u0444\u0430\u0439\u043B",panels:"\u041F\u0430\u043D\u0435\u043B\u0438","panel.model":"\u041C\u043E\u0434\u0435\u043B\u044C","panel.elements":"\u0422\u0430\u0431\u043B\u0438\u0446\u0430 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432","csv.open":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C CSV \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432","csv.download":"\u0421\u043A\u0430\u0447\u0430\u0442\u044C CSV","csv.choose":"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 CSV, \u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0432\u043C\u0435\u0441\u0442\u0435 \u0441 \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u044C\u044E.","csv.loading":"\u0427\u0442\u0435\u043D\u0438\u0435 CSV\u2026","csv.loaded":"{file} \xB7 \u0421\u0432\u044F\u0437\u0430\u043D\u043E \u0441 3D: {matched} \u0438\u0437 {total}","csv.noMatch":"{file} \xB7 \u041D\u0435\u0442 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0439. \u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435, \u0447\u0442\u043E CSV \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0441\u044F \u043A \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u0438.","csv.conflicts":"\u0418\u0441\u043A\u043B\u044E\u0447\u0435\u043D\u043E \u0441\u0442\u0440\u043E\u043A \u0438\u0437-\u0437\u0430 \u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442\u0430 uniqueId: {count}. \u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435, \u0447\u0442\u043E \u0444\u0430\u0439\u043B\u044B \u043E\u0442\u043D\u043E\u0441\u044F\u0442\u0441\u044F \u043A \u043E\u0434\u043D\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u0438.","csv.invalid":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C CSV. \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0442\u0430\u0431\u043B\u0438\u0446\u0443 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432 RvtIO \u0441 \u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u043C elementId.","csv.noGeometry":"\u0423 \u044D\u0442\u043E\u0433\u043E \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430 \u043D\u0435\u0442 \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u0438 \u0432 \u043C\u043E\u0434\u0435\u043B\u0438.","csv.search":"\u041F\u043E\u0438\u0441\u043A \u043F\u043E ID \u0438 \u0438\u043C\u0435\u043D\u0438","csv.searchPlaceholder":"ID \u0438\u043B\u0438 \u0438\u043C\u044F","csv.allCategories":"\u0412\u0441\u0435 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438","csv.groupByCategory":"\u0413\u0440\u0443\u043F\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u043E \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F\u043C","csv.categoryTotals":"\u0418\u0442\u043E\u0433\u0438 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438","csv.totals":"\u0418\u0442\u043E\u0433\u0438 \u0432\u044B\u0431\u043E\u0440\u043A\u0438","csv.quantity.length_m":"\u0414\u043B\u0438\u043D\u0430","csv.quantity.area_m2":"\u041F\u043B\u043E\u0449\u0430\u0434\u044C","csv.quantity.volume_m3":"\u041E\u0431\u044A\u0451\u043C","csv.unit.length_m":"\u043C","csv.unit.area_m2":"\u043C\xB2","csv.unit.volume_m3":"\u043C\xB3","csv.outsideFilters":"\u0412\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0439 \u044D\u043B\u0435\u043C\u0435\u043D\u0442 \u0432\u043D\u0435 \u0444\u0438\u043B\u044C\u0442\u0440\u0430.","csv.noResults":"\u041F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0438\u0445 \u0441\u0442\u0440\u043E\u043A \u043D\u0435\u0442.","csv.previous":"\u041D\u0430\u0437\u0430\u0434","csv.next":"\u0414\u0430\u043B\u0435\u0435","csv.range":"{first}\u2013{last} \u0438\u0437 {total}","panel.views":"\u0412\u0438\u0434\u044B","panel.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","panel.clashes":"\u041A\u043E\u043B\u043B\u0438\u0437\u0438\u0438","panel.bcf":"\u0422\u0435\u043C\u044B BCF","bcf.noView":"\u041D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E \u0432\u0438\u0434\u0430","bcf.viewpoint":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432\u0438\u0434 {index}","bcf.components":"\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u043E\u0432 \u2014 {missing}, \u043D\u0435\u043E\u0434\u043D\u043E\u0437\u043D\u0430\u0447\u043D\u044B\u0445 \u2014 {ambiguous}","panel.timeliner":"4D-\u0433\u0440\u0430\u0444\u0438\u043A","panel.links":"\u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B","group.navigation":"\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F","group.sections":"\u0421\u0435\u0447\u0435\u043D\u0438\u044F","group.measure":"\u0418\u0437\u043C\u0435\u0440\u0435\u043D\u0438\u044F","group.display":"\u041E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","group.view":"\u0412\u0438\u0434","tool.orbit":"\u0412\u0440\u0430\u0449\u0435\u043D\u0438\u0435","tool.pan":"\u041F\u0430\u043D\u043E\u0440\u0430\u043C\u0430","tool.fit":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","tool.projection":"\u041F\u0435\u0440\u0441\u043F\u0435\u043A\u0442\u0438\u0432\u0430 / \u043E\u0440\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F","tool.mode2d":"\u0420\u0435\u0436\u0438\u043C 2D / 3D","sheets.label":"\u041B\u0438\u0441\u0442\u044B \u0438 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u043E \u043C\u043E\u0434\u0435\u043B\u0438","tool.plane":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.box":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","tool.distance":"\u0420\u0430\u0441\u0441\u0442\u043E\u044F\u043D\u0438\u0435","tool.displayMode":"\u0420\u0435\u0436\u0438\u043C \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","tool.grids":"\u041E\u0441\u0438","tool.opacity":"\u041F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","tool.fullscreen":"\u041F\u043E\u043B\u043D\u044B\u0439 \u044D\u043A\u0440\u0430\u043D",contextMenu:"\u041A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u043D\u043E\u0435 \u043C\u0435\u043D\u044E","menu.properties":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430","menu.hide":"\u0421\u043A\u0440\u044B\u0442\u044C","menu.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C","menu.showAll":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u0441\u0451","menu.zoomTo":"\u041F\u0440\u0438\u0431\u043B\u0438\u0437\u0438\u0442\u044C \u043A \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.sectionBox":"\u0411\u043E\u043A\u0441 \u0441\u0435\u0447\u0435\u043D\u0438\u044F \u043F\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u0443","menu.copyId":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id","menu.fitAll":"\u0412\u043F\u0438\u0441\u0430\u0442\u044C \u0432\u0441\u0451","menu.resetSections":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","menu.unavailable":"\u041D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0434\u043B\u044F \u044D\u0442\u043E\u0439 \u043C\u043E\u0434\u0435\u043B\u0438",searchPlaceholder:"\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0438\u043C\u0435\u043D\u0438, \u0442\u0438\u043F\u0443, Id\u2026",noCategory:"\u0411\u0435\u0437 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",noMatches:"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","filters.title":"\u0424\u0438\u043B\u044C\u0442\u0440\u044B","filters.model":"\u041C\u043E\u0434\u0435\u043B\u044C-\u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A","filters.noLevel":"\u0411\u0435\u0437 \u0443\u0440\u043E\u0432\u043D\u044F","filters.all":"\u0412\u0441\u0435","filters.clear":"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C","filters.isolate":"\u0418\u0437\u043E\u043B\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u044F",idCopied:"Id \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D",copyFailed:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C Id",fullscreenUnavailable:"\u041F\u043E\u043B\u043D\u043E\u044D\u043A\u0440\u0430\u043D\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D","face.front":"\u0421\u043F\u0435\u0440\u0435\u0434\u0438","face.back":"\u0421\u0437\u0430\u0434\u0438","face.left":"\u0421\u043B\u0435\u0432\u0430","face.right":"\u0421\u043F\u0440\u0430\u0432\u0430","face.top":"\u0421\u0432\u0435\u0440\u0445\u0443","face.bottom":"\u0421\u043D\u0438\u0437\u0443","cube.title":"\u041A\u0443\u0431 \u0432\u0438\u0434\u0430","cube.up":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u0432\u0435\u0440\u0445","cube.down":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043D\u0438\u0437","cube.left":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043B\u0435\u0432\u043E","cube.right":"\u041F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0432\u043F\u0440\u0430\u0432\u043E","cube.home":"\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0432\u0438\u0434","sections.mode":"\u0420\u0435\u0436\u0438\u043C \u0441\u0435\u0447\u0435\u043D\u0438\u044F","sections.planes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.box":"\u0411\u043E\u043A\u0441","sections.off":"\u0412\u044B\u043A\u043B","sections.axis":"\u041E\u0441\u044C","sections.addPlane":"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.noPlanes":"\u041F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439 \u043D\u0435\u0442","sections.rotated":"\u043F\u043E\u0432\u0451\u0440\u043D\u0443\u0442\u0430","sections.custom":"\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u043B\u044C\u043D\u0430\u044F","sections.position":"\u041F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0438","sections.flip":"\u0421\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0442\u043E\u0440\u043E\u043D\u0443","sections.enabled":"\u0412\u043A\u043B","sections.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u044C","sections.keepInside":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.cutInside":"\u0412\u044B\u0440\u0435\u0437\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u0438","sections.fitSelection":"\u041F\u043E \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u043D\u043E\u043C\u0443","sections.showGizmo":"\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043C\u0430\u043D\u0438\u043F\u0443\u043B\u044F\u0442\u043E\u0440","sections.boxYaw":"\u041F\u043E\u0432\u043E\u0440\u043E\u0442 \u0432\u043E\u043A\u0440\u0443\u0433 Z","sections.fill":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u0441\u0440\u0435\u0437\u043E\u0432","sections.fillUnavailable":"\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430 \u0431\u0435\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u0442\u0440\u0430\u0444\u0430\u0440\u0435\u0442\u0430 WebGL","sections.fillNeedsMeshes":"\u0414\u043B\u044F \u0437\u0430\u043B\u0438\u0432\u043A\u0438 \u0441\u0435\u0447\u0435\u043D\u0438\u0439 \u043D\u0443\u0436\u043D\u0430 \u0437\u0430\u043C\u043A\u043D\u0443\u0442\u0430\u044F \u043F\u043E\u043B\u0438\u0433\u043E\u043D\u0430\u043B\u044C\u043D\u0430\u044F \u0433\u0435\u043E\u043C\u0435\u0442\u0440\u0438\u044F","sections.maxPlanes":"\u041D\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 6 \u043F\u043B\u043E\u0441\u043A\u043E\u0441\u0442\u0435\u0439","unit.m":"\u043C","display.materials":"\u041C\u0430\u0442\u0435\u0440\u0438\u0430\u043B\u044B","display.textures":"\u0422\u0435\u043A\u0441\u0442\u0443\u0440\u044B","display.white":"\u0411\u0435\u043B\u044B\u0439","display.wireframe":"\u041A\u0430\u0440\u043A\u0430\u0441","display.background":"\u0426\u0432\u0435\u0442 \u0444\u043E\u043D\u0430","display.backgroundReset":"\u0424\u043E\u043D \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","display.bgCadDark":"CAD \u0442\u0451\u043C\u043D\u044B\u0439","display.bgPaper":"\u041B\u0438\u0441\u0442 \u0431\u0435\u043B\u044B\u0439","opacity.label":"\u041D\u0435\u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u043E\u0441\u0442\u044C","opacity.value":"{value} %","views.tour":"\u0422\u0443\u0440 \u043F\u043E \u0432\u0438\u0434\u0430\u043C","views.stop":"\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0442\u0443\u0440","clash.New":"\u041D\u043E\u0432\u0430\u044F","clash.Active":"\u0410\u043A\u0442\u0438\u0432\u043D\u0430\u044F","clash.Reviewed":"\u041F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u0430","clash.Approved":"\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0430","clash.Resolved":"\u0423\u0441\u0442\u0440\u0430\u043D\u0435\u043D\u0430","task.construct":"\u0421\u0442\u0440\u043E\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u043E","task.demolish":"\u0421\u043D\u043E\u0441","task.temporary":"\u0412\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0435","player.title":"4D-\u043F\u0440\u043E\u0438\u0433\u0440\u044B\u0432\u0430\u0442\u0435\u043B\u044C","player.play":"\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438","player.pause":"\u041F\u0430\u0443\u0437\u0430","player.date":"\u0414\u0430\u0442\u0430 \u0433\u0440\u0430\u0444\u0438\u043A\u0430","player.speed":"\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C",truncated:"\u041F\u043E\u043A\u0430\u0437\u0430\u043D\u043E {meshes} \u0438\u0437 {total} \u043C\u0435\u0448\u0435\u0439: \u043C\u043E\u0434\u0435\u043B\u044C \u043E\u0431\u0440\u0435\u0437\u0430\u043D\u0430 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u043E\u0439 MaxMeshVertices"},en:{elements:"Elements",noGeometry:"No geometry",contextLost:"The graphics context was lost \u2014 reload the page",noWebGL:"This page needs a browser with WebGL 2",badData:"The model data could not be read",tooLarge:"The model is too large for this viewer: {count} objects with geometry, the limit is {limit}",selected:"Selected",close:"Close","scanMap.title":"Minimap","scanMap.plan":"Point cloud floor plan","scanMap.metres":"m","scanMap.choosePhoto":"Open photo panorama\u2026","scanMap.spheres":"Panorama spheres in 3D","scanMap.photo":"Photo panorama","scanMap.intensity":"Intensity","scanMap.goToStation":"Move to station {name}","scanMap.photoControls":"Photo panorama. Arrow keys turn the camera, the wheel zooms.","scanMap.loading":"Loading photograph\u2026","scanMap.photoError":"Could not open the spherical photograph.","scanMap.enlargePhoto":"Enlarge","scanMap.shrinkPhoto":"Restore size","scanMap.size":"Minimap size","scanMap.small":"Small","scanMap.medium":"Medium","scanMap.large":"Large","scanMap.zoomIn":"Zoom in on minimap","scanMap.zoomOut":"Zoom out on minimap","scanMap.reset":"Fit the whole plan","scanMap.levels":"Minimap levels","scanMap.allLevels":"All heights","scanMap.level":"Level {n}","scanMap.addLevel":"Create level from panorama","scanMap.removeLevel":"Remove selected level","scanMap.autoButton":"Auto","scanMap.autoLevels":"Detect levels by station height","scanMap.noLevels":"Station heights have no clear groups.","scanMap.levelsAdded":"Levels added from station heights.","scanMap.levelsExist":"Existing levels already cover these height ranges.","scanMap.levelAdded":"Level created.","scanMap.levelTemporary":"Levels will stay available until you close this page.","scanMap.cancel":"Cancel","scanMap.pickLower":"Click the lower level elevation.","scanMap.pickUpper":"Lower elevation {z}. Now click the upper elevation.","scanMap.noLowerHit":"No scan points along that ray. Choose a nearby lower elevation.","scanMap.noUpperHit":"No scan points along that ray. Choose a nearby upper elevation.","scanMap.upperAboveLower":"The upper elevation must be above {z}.",elementGroup:"Element",id:"Id",category:"Category",type:"Type",level:"Level",sourceId:"Source ID",link:"Link",panels:"Panels","panel.model":"Model","panel.elements":"Element table","csv.open":"Open element CSV","csv.download":"Download CSV","csv.choose":"Choose the CSV exported with this model.","csv.loading":"Reading CSV\u2026","csv.loaded":"{file} \xB7 Linked to 3D: {matched} of {total}","csv.noMatch":"{file} \xB7 No matches. Check that the CSV belongs to this model.","csv.conflicts":"Rows excluded due to conflicting uniqueId values: {count}. Check that the files belong to the same model.","csv.invalid":"Could not read the CSV. Choose an RvtIO element table with unique elementId values.","csv.noGeometry":"This element has no geometry in the model.","csv.search":"Search by ID and name","csv.searchPlaceholder":"ID or name","csv.allCategories":"All categories","csv.groupByCategory":"Group by category","csv.categoryTotals":"Category totals","csv.totals":"Filtered totals","csv.quantity.length_m":"Length","csv.quantity.area_m2":"Area","csv.quantity.volume_m3":"Volume","csv.unit.length_m":"m","csv.unit.area_m2":"m\xB2","csv.unit.volume_m3":"m\xB3","csv.outsideFilters":"The selected element is outside the filter.","csv.noResults":"No matching rows.","csv.previous":"Previous","csv.next":"Next","csv.range":"{first}\u2013{last} of {total}","panel.views":"Views","panel.sections":"Sections","panel.clashes":"Clashes","panel.bcf":"BCF topics","bcf.noView":"No view available","bcf.viewpoint":"Open viewpoint {index}","bcf.components":"Components missing \u2014 {missing}, ambiguous \u2014 {ambiguous}","panel.timeliner":"4D schedule","panel.links":"Linked files","group.navigation":"Navigation","group.sections":"Sections","group.measure":"Measure","group.display":"Display","group.view":"View","tool.orbit":"Orbit","tool.pan":"Pan","tool.fit":"Fit all","tool.projection":"Perspective / orthographic","tool.mode2d":"2D / 3D mode","sheets.label":"Sheets and Model Space","tool.plane":"Section plane","tool.box":"Section box","tool.resetSections":"Reset sections","tool.distance":"Distance","tool.displayMode":"Display mode","tool.grids":"Grids","tool.opacity":"Transparency","tool.fullscreen":"Full screen",contextMenu:"Context menu","menu.properties":"Properties","menu.hide":"Hide","menu.isolate":"Isolate","menu.showAll":"Show all","menu.zoomTo":"Zoom to object","menu.sectionBox":"Section box around object","menu.copyId":"Copy Id","menu.fitAll":"Fit all","menu.resetSections":"Reset sections","menu.unavailable":"Unavailable for this model",searchPlaceholder:"Search by name, type, Id\u2026",noCategory:"No category",noMatches:"No matches","filters.title":"Filters","filters.model":"Source model","filters.noLevel":"No level","filters.all":"All","filters.clear":"Clear","filters.isolate":"Isolate matches",idCopied:"Id copied",copyFailed:"Could not copy Id",fullscreenUnavailable:"Fullscreen is not available","face.front":"Front","face.back":"Back","face.left":"Left","face.right":"Right","face.top":"Top","face.bottom":"Bottom","cube.title":"View cube","cube.up":"Rotate up","cube.down":"Rotate down","cube.left":"Rotate left","cube.right":"Rotate right","cube.home":"Home view","sections.mode":"Section mode","sections.planes":"Planes","sections.box":"Box","sections.off":"Off","sections.axis":"Axis","sections.addPlane":"Add plane","sections.noPlanes":"No planes","sections.rotated":"rotated","sections.custom":"Custom","sections.position":"Plane position","sections.flip":"Flip side","sections.enabled":"On","sections.delete":"Delete plane","sections.keepInside":"Show inside","sections.cutInside":"Cut inside","sections.fitSelection":"Fit to selection","sections.showGizmo":"Show gizmo","sections.boxYaw":"Rotation around Z","sections.fill":"Fill cut faces","sections.fillUnavailable":"Section fill requires a WebGL stencil buffer","sections.fillNeedsMeshes":"Section fill requires closed mesh geometry","sections.maxPlanes":"At most 6 planes","unit.m":"m","display.materials":"Materials","display.textures":"Textures","display.white":"White","display.wireframe":"Wireframe","display.background":"Background color","display.backgroundReset":"Reset background","display.bgCadDark":"CAD dark","display.bgPaper":"Paper white","opacity.label":"Opacity","opacity.value":"{value}%","views.tour":"Play tour","views.stop":"Stop tour","clash.New":"New","clash.Active":"Active","clash.Reviewed":"Reviewed","clash.Approved":"Approved","clash.Resolved":"Resolved","task.construct":"Construct","task.demolish":"Demolish","task.temporary":"Temporary","player.title":"4D player","player.play":"Play","player.pause":"Pause","player.date":"Schedule date","player.speed":"Speed",truncated:"Showing {meshes} of {total} meshes: the model was truncated by the MaxMeshVertices setting"}},Pn=(globalThis.navigator?.language??"").toLowerCase().startsWith("ru")?"ru":"en",Ci=new Intl.NumberFormat(Pn).format;function q(i,t=Pn){let e=Fy[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Gf=new C(0,0,1),hl=Math.PI/2-.01;function Xf(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function qf(i,t,e,n,s,r){let o=i.clone().sub(e),a=t.clone().sub(e),l=d=>(o.applyQuaternion(d),a.applyQuaternion(d));l(new Fe().setFromAxisAngle(Gf,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Gf);if(h.lengthSq()>1e-12){let d=Math.asin(le.clamp(c.z,-1,1)),u=le.clamp(s*r,d-hl,d+hl);l(new Fe().setFromAxisAngle(h.normalize(),-u))}return{position:o.add(e),target:a.add(e)}}function Yf(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var By=.85,Oy=100/3;function $f(i,t,e){let n=i*(t===1?Oy:t===2?e:1);return le.clamp(By**(-n/100),.5,2)}var Bh=(i,t)=>t>=i?"window":"crossing";function Zf(i,t,e){let n=Wf(i.position,i.target),s=Wf(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=le.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,g)=>_+(g-_)*e,c=r+a*e,h=le.clamp(l(n.elevation,s.elevation),-hl,hl),d=l(n.distance,s.distance),u=i.target.clone().lerp(t.target,e),f=Math.cos(h)*d;return{position:u.clone().add(new C(f*Math.cos(c),f*Math.sin(c),Math.sin(h)*d)),target:u}}function Kf(i,t,e,n){let s=i.position.clone().sub(i.target),r=t.position.clone().sub(t.target),o=s.length(),a=r.length();s.normalize(),r.normalize();let l=new Fe().setFromUnitVectors(s,r),c=e.clone().applyQuaternion(l),h=new C().setFromMatrixColumn(new Kt().lookAt(t.position,t.target,n),1),d=r.dot(new C().crossVectors(c,h)),u=Math.atan2(Math.abs(d)<1e-9?0:d,c.dot(h)),f=new Fe;return m=>{f.identity().slerp(l,m);let _=s.clone().applyQuaternion(f),g=i.target.clone().lerp(t.target,m),p=_.clone().multiplyScalar(le.lerp(o,a,m)).add(g),y=e.clone().applyQuaternion(f).applyAxisAngle(_,u*m);return{position:p,target:g,up:y}}}function Wf(i,t){let e=i.clone().sub(t),n=e.length(),s=Math.hypot(e.x,e.y);return{distance:n,elevation:n>1e-12?Math.asin(le.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var zy=.005,Jf=new C(1,-1,.8).normalize(),Oh=.01,jf=1e-6,ky=64,Qf=1.05,Hy=5e3,ul=(i,t)=>new CustomEvent(i,{detail:t});function tp({bbox:i,grids:t}){let e=r=>Array.isArray(r)&&r.length===3&&r.every(Number.isFinite);if(!e(i?.min)||!e(i?.max))return!0;let n=new ae(new C(...i.min),new C(...i.max));if(n.isEmpty())return!0;let s=new C;for(let r of t??[])for(let o of Ur(r)){if(!e(o))return!0;n.expandByPoint(s.fromArray(o))}return n.getSize(s).length()*Qf>Oh*Hy}var dl=class extends EventTarget{constructor(t,e,{pick:n=()=>null,visibleBox:s=()=>new ae}={}){super(),this.dom=e,this.pick=n,this.visibleBox=s,this.target=new C,this.leftButtonMode="orbit",this.is2D=!1,this._saved3D=null,this._perspective=t,this._defaultFov=t.fov,this._orthographic=new Xn(-1,1,1,-1),this.camera=t,this._drag=null,this._wheelPick=null,this._animation=0,this._overlay=null,this._bounds=null,this._extraBounds=new Map,e.style.touchAction="none",e.addEventListener("pointerdown",r=>this._down(r)),e.addEventListener("pointermove",r=>this._move(r)),e.addEventListener("pointerup",r=>this._up(r)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",r=>this._lostCapture(r)),window.addEventListener("blur",()=>this._end()),e.addEventListener("wheel",r=>this._wheel(r),{passive:!1}),e.addEventListener("contextmenu",r=>r.preventDefault())}setLeftButtonMode(t){if(t!=="orbit"&&t!=="pan")throw new RangeError(`Unknown left button mode: ${t}`);this.leftButtonMode=t}setProjection(t){if(t!=="perspective"&&t!=="orthographic")throw new RangeError(`Unknown projection: ${t}`);let e=t==="perspective"?this._perspective:this._orthographic,n=this.camera;if(e!==n){this._stopAnimation(),e.position.copy(n.position),n.isOrthographicCamera&&e.position.sub(this.target).divideScalar(n.zoom).add(this.target),e.zoom=1,e.quaternion.copy(n.quaternion),e.up.copy(n.up),n.parent?.add(e),n.parent?.remove(n);for(let s of[...n.children])e.add(s);this.camera=e,this.resize()}}resize(){let t=this.camera,e=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),n=Math.max(t.position.distanceTo(this.target),1e-6);if(t.isPerspectiveCamera)t.aspect=e;else{let r=n*Math.tan(le.degToRad(this._perspective.fov/2));Object.assign(t,{top:r,bottom:-r,left:-r*e,right:r*e})}let s=this._rangeSphere();if(s){let r=s.center.clone().sub(t.position),o=new C(0,0,-1).applyQuaternion(t.quaternion);t.far=Math.max(1e-6,(r.length()+s.radius)*Qf);let a=r.dot(o)-s.radius;t.near=Math.max(a*.95,Math.min(Oh,t.far/2))}t.updateProjectionMatrix(),this.dispatchEvent(new Event("change"))}setExtraBounds(t,e){e&&!e.isEmpty()?this._extraBounds.set(t,e.clone()):this._extraBounds.delete(t),this.resize()}_rangeSphere(){let t=this._visibleBounds()?.sphere??null;if(this._extraBounds.size===0)return t;let e=t?this._bounds.box.clone():new ae;for(let n of this._extraBounds.values())e.union(n);return e.getBoundingSphere(new Oe)}invalidateBounds(){this._bounds=null}_visibleBounds(){if(!this._bounds){let t=this.visibleBox();this._bounds={box:t,sphere:t.isEmpty()?null:t.getBoundingSphere(new Oe)}}return this._bounds.sphere&&this._bounds}fitBox(t,e=!0){if(t.isEmpty())return;let n=t.getBoundingSphere(new Oe);if(this.is2D){this.setProjection("orthographic"),this.camera.up.set(0,1,0);let h=t.getSize(new C),d=Math.max(h.x,h.y,n.radius*2,.01),u=t.getCenter(new C),f=new C(u.x,u.y,t.max.z+d*2);this._set(f,u);let m=Math.max(this.dom.clientWidth/Math.max(this.dom.clientHeight,1),.001),_=Math.max(this.camera.top,1e-6),g=Math.max(h.y/2,h.x/(2*m),1e-4)*1.06;this.camera.zoom=_/g,this.resize();return}let s=Math.max(n.radius,.001),r=le.degToRad(this._perspective.fov/2),o=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),a=s/Math.sin(Math.min(r,Math.atan(Math.tan(r)*o))),l=this.camera.position.clone().sub(this.target);l.lengthSq()<1e-12&&l.copy(Jf);let c=l.normalize().multiplyScalar(a).add(n.center);e?this.animateTo({position:c,target:n.center}):(this.camera.zoom=1,this._set(c,n.center))}set2DMode(t,e=null,n=!1){let s=!!t;if(s===this.is2D){s&&e&&!e.isEmpty()&&this.fitBox(e,n);return}if(this._stopAnimation(),s){this._saved3D={projection:this.camera.isOrthographicCamera?"orthographic":"perspective",position:this.camera.position.clone(),target:this.target.clone(),zoom:this.camera.zoom,leftButtonMode:this.leftButtonMode},this.is2D=!0,this.setProjection("orthographic"),this.leftButtonMode="pan";let r=e&&!e.isEmpty()?e:this.visibleBox();this.fitBox(r,!1)}else{this.is2D=!1,this.camera.up.set(0,0,1);let r=this._saved3D;if(this._saved3D=null,r)this.setProjection(r.projection),this.leftButtonMode=r.leftButtonMode,this.camera.zoom=r.zoom,this._set(r.position,r.target);else{this.setProjection("perspective"),this.leftButtonMode="orbit";let o=e&&!e.isEmpty()?e:this.visibleBox();if(!o.isEmpty()){let a=o.getCenter(new C),l=Math.max(o.getBoundingSphere(new Oe).radius,1);this._set(a.clone().addScaledVector(Jf,l*2.5),a),this.fitBox(o,!1)}}}this.dispatchEvent(ul("mode2d",{enabled:this.is2D}))}zoomToBox(t){this.fitBox(t,!0)}resetCameraStyle(){this._perspective.fov=this._defaultFov,this.camera.up.set(0,0,1)}restoreViewCamera({position:t,target:e,up:n,fov:s,orthographicHeight:r}){let o=new C(...t),a=new C(...e);if(this.resetCameraStyle(),!n){this.animateTo({position:o,target:a});return}this._stopAnimation(),this.camera.up.fromArray(n),this._perspective.fov=s??this._defaultFov;let l=Math.max(o.distanceTo(a),1e-6);this.camera.zoom=r==null?1:2*l*Math.tan(le.degToRad(this._perspective.fov/2))/r,this._set(o,a)}animateTo({position:t,target:e,zoom:n=1,overPole:s=!1},r=400){this._stopAnimation();let o={position:this.camera.position.clone(),target:this.target.clone()},a={position:t??o.position,target:e??o.target},l=this.camera.zoom,c=s?Kf(o,a,new C(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):u=>Zf(o,a,u),h=performance.now(),d=u=>{let f=Math.min((u-h)/r,1),m=f*f*(3-2*f),_=c(m);this.camera.isOrthographicCamera&&(this.camera.zoom=le.lerp(l,n,m)),this._set(_.position,_.target,_.up),this._animation=f<1?requestAnimationFrame(d):0};this._animation=requestAnimationFrame(d)}get animating(){return this._animation!==0}_stopAnimation(){cancelAnimationFrame(this._animation),this._animation=0}_set(t,e,n){if(this.camera.position.copy(t),this.target.copy(e),n){let s=this.camera.up.clone();this.camera.up.copy(n),this.camera.lookAt(e),this.camera.up.copy(s)}else this.camera.lookAt(e);this.resize()}_down(t){this._end(),this._stopAnimation(),this.dom.setPointerCapture(t.pointerId),t.preventDefault();let e=t.button===0&&t.shiftKey?"box":t.button===0&&!this.is2D&&this.leftButtonMode==="orbit"?"orbit":"pan",n={x:t.clientX,y:t.clientY},s=null;e==="orbit"&&(s=this.pick(n.x,n.y),s||(s=this._visibleBounds()?.sphere.center.clone()??this.target.clone())),this._drag={id:t.pointerId,button:t.button,mode:e,pivot:s,down:n,last:n,moved:!1}}_anchor(t,e){let n=this.pick(t,e);if(n)return n;let s=this.dom.getBoundingClientRect(),r=s.left+s.width/2,o=s.top+s.height/2;return t===r&&e===o?null:this.pick(r,o)}_gestureDepth(t,e){let n=this.camera,s=t?t.clone().sub(n.position).dot(e):0;return Math.max(jf,n.position.distanceTo(this.target),s)}_move(t){let e=this._drag;if(!e||t.pointerId!==e.id)return;if(t.buttons===0)return this._end();let n={x:t.clientX,y:t.clientY};if(!e.moved&&Xf(e.down,n))return;e.moved=!0;let s=n.x-e.last.x,r=n.y-e.last.y;if(e.last=n,e.mode==="box")this._drawRect(e.down,n);else if(e.mode==="orbit"){let o=qf(this.camera.position,this.target,e.pivot,s,r,zy);this._set(o.position,o.target)}else this._pan(s,r)}_pan(t,e){let n=this.camera,s=Math.max(this.dom.clientHeight,1);if(n.isPerspectiveCamera&&this._drag.depth===void 0){let{x:c,y:h}=this._drag.down;this._drag.depth=this._gestureDepth(this._anchor(c,h),n.getWorldDirection(new C))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(le.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new C(1,0,0).applyQuaternion(n.quaternion),a=new C(0,1,0).applyQuaternion(n.quaternion),l=o.multiplyScalar(-t*r).addScaledVector(a,e*r);this._set(n.position.clone().add(l),this.target.clone().add(l))}_up(t){let e=this._drag;if(!e||t.pointerId!==e.id||t.button!==e.button)return;let n={x:t.clientX,y:t.clientY};if(this._end(),e.mode==="box"&&e.moved){let s={x:Math.min(e.down.x,n.x),y:Math.min(e.down.y,n.y),width:Math.abs(n.x-e.down.x),height:Math.abs(n.y-e.down.y)},r=Bh(e.down.x,n.x);this.dispatchEvent(ul("boxselect",{rect:s,mode:r,ctrl:t.ctrlKey,shift:t.shiftKey}))}else!e.moved&&e.button===0?this.dispatchEvent(ul("click",{x:n.x,y:n.y,button:0,ctrl:t.ctrlKey,shift:t.shiftKey})):!e.moved&&e.button===2&&this.dispatchEvent(ul("contextmenu",{x:n.x,y:n.y}))}_lostCapture(t){this._drag&&t.buttons?this.dom.setPointerCapture(this._drag.id):this._end()}_end(){this._drag=null,this._overlay?.remove(),this._overlay=null}_drawRect(t,e){this._overlay||(this._overlay=document.createElement("div"),Object.assign(this._overlay.style,{position:"fixed",pointerEvents:"none",border:"1px solid #2563eb",background:"rgba(37,99,235,0.12)"}),(this.dom.parentElement??document.body).appendChild(this._overlay)),Object.assign(this._overlay.style,{borderStyle:Bh(t.x,e.x)==="window"?"solid":"dashed",left:`${Math.min(t.x,e.x)}px`,top:`${Math.min(t.y,e.y)}px`,width:`${Math.abs(e.x-t.x)}px`,height:`${Math.abs(e.y-t.y)}px`})}_wheel(t){if(t.preventDefault(),t.deltaY===0)return;this._stopAnimation();let e=$f(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=ky*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:g,width:p,height:y}=this.dom.getBoundingClientRect();if(!p||!y)return;let w=le.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(w===n.zoom)return;let M=new C((2*(t.clientX-_)/p-1)*n.right,(1-2*(t.clientY-g)/y)*n.top,0).multiplyScalar(1/n.zoom-1/w).applyQuaternion(n.quaternion);n.zoom=w,this._set(n.position.clone().add(M),this.target.clone().add(M));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new C),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Oh,Math.max(jf,r)),h=le.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let d=n.position.clone().addScaledVector(a,l),u=this._wheelPick.point,f=u&&u.clone().sub(n.position).dot(a)>=c?u:d,m=Yf(n.position,d,f,h);this._set(m.position,m.target)}};function K(i,t,e){let n=document.createElement(i);return t&&(n.className=t),e!==void 0&&(n.textContent=e),n}function tn(i,t,e){let n=K("button",i);return n.type="button",n.innerHTML=t,n.title=e,n.setAttribute("aria-label",e),n}function Gs(i){i.preventDefault(),i.stopPropagation()}function fl(i){Gs(i);let t=i.button===2,e=()=>{window.removeEventListener("pointerup",n,!0),setTimeout(()=>{window.removeEventListener("click",Gs,!0),t&&window.removeEventListener("contextmenu",Gs,!0)})},n=s=>{Gs(s),e()};window.addEventListener("pointerup",n,!0),window.addEventListener("click",Gs,!0),t&&window.addEventListener("contextmenu",Gs,!0)}function Wr(i,t,e,n){let s=t.clone().applyMatrix4(e.matrixWorldInverse).z<0,r=t.clone().project(e);i.hidden=!(s&&Math.abs(r.x)<=1&&Math.abs(r.y)<=1),!i.hidden&&(i.style.left=`${n.left+(r.x+1)/2*n.width}px`,i.style.top=`${n.top+(1-r.y)/2*n.height}px`)}var ye=i=>``,ep='',oe={model:ye(''),elements:ye(''),views:ye(''),sections:ye(''),clashes:ye(''),bcf:ye(''),timeliner:ye(''),links:ye(''),orbit:ye(''),pan:ye(''),fit:ye(''),projection:ye(ep),mode2d:ye(''),plane:ye(''),box:ye(`${ep}`),resetSections:ye(''),distance:ye(''),displayMode:ye(''),grids:ye(''),opacity:ye(''),fullscreen:ye(''),close:ye(''),chevron:ye(''),flip:ye(''),remove:ye(''),play:ye(''),pause:ye(''),home:ye('')};var Xr=new C(0,0,1),un={right:new C(1,0,0),left:new C(-1,0,0),back:new C(0,1,0),front:new C(0,-1,0),top:new C(0,0,1),bottom:new C(0,0,-1)},Vy={right:Xr,left:Xr,back:Xr,front:Xr,top:un.back,bottom:un.front},Ki=.7,Gy=le.degToRad(1),np=.01,ip=96,pl=1.75;function sp(i){let t=i.split("-"),e=new C;for(let n of t){if(!Object.hasOwn(un,n))throw new RangeError(`Unknown view cube region: ${i}`);e.add(un[n])}if(new Set(t).size!==t.length||e.lengthSq()!==t.length)throw new RangeError(`Unknown view cube region: ${i}`);return e.normalize()}function Wy(i){let t=[];return Math.abs(i.z)>=Ki&&t.push(i.z>0?"top":"bottom"),Math.abs(i.y)>=Ki&&t.push(i.y>0?"back":"front"),Math.abs(i.x)>=Ki&&t.push(i.x>0?"right":"left"),t.join("-")}function zh(i,t=Gy){let e=i.clone().normalize(),n=Math.cos(t);return Object.keys(un).find(s=>e.dot(un[s])>=n)??null}function rp(i){let t=new C(i.x,i.y,0);if(t.lengthSq()<1e-24)return"front";t.normalize();let e=["front","right","back","left"],n=Math.max(...e.map(s=>t.dot(un[s])));return e.find(s=>t.dot(un[s])>=n-1e-9)}function kh(i,t){return un[rp(t)].clone().multiplyScalar(Math.sin(np)).addScaledVector(un[i],Math.cos(np))}function Xy(i,t){let e=zh(i);if(!e)return null;let n=e==="top"||e==="bottom";if(t==="left"||t==="right")return(n?kh(e,i):sp(e)).applyAxisAngle(Xr,t==="right"?Math.PI/2:-Math.PI/2);if(t!=="up"&&t!=="down")throw new RangeError(`Unknown arrow: ${t}`);if(!n)return kh(t==="up"?"top":"bottom",i);let s=un[rp(i)];return t==="up"==(e==="top")?s.clone().negate():s.clone()}function qy(i,t){let e=document.createElement("canvas");e.width=e.height=128;let n=e.getContext("2d");n.fillStyle="#2a2f38",n.fillRect(0,0,128,128),n.fillStyle="#cbd5e1",n.textAlign="center",n.textBaseline="middle",n.font=`600 26px ${t}`;let s=n.measureText(i).width;s>112&&(n.font=`600 ${Math.floor(2912/s)}px ${t}`),n.fillText(i,64,64);let r=new hr(e);return r.colorSpace=me,r}var ml=class{constructor(t,e,n){this.controls=n,this.home={position:e.position.clone(),target:n.target.clone()},this.element=K("div","ioviewer-viewcube"),this.canvas=K("canvas","ioviewer-viewcube-canvas"),this.canvas.title=q("cube.title"),this.canvas.setAttribute("aria-label",q("cube.title")),this.element.append(this.canvas),this.error=null,this.renderer=this._createRenderer(),this.scene=new pn,this.camera=new Xn(-pl,pl,pl,-pl,.1,10),this.faces=new Re;let s=getComputedStyle(t).fontFamily;for(let[l,c]of Object.entries(un)){let h=q(`face.${l}`),d=new ge(new cn(2,2),new Je({map:qy(h,s)})),u=Vy[l];d.quaternion.setFromRotationMatrix(new Kt().makeBasis(u.clone().cross(c),u,c)),d.position.copy(c),d.name=l,d.userData.label=h,this.faces.add(d)}let r=new ln(new Vi(new gn(2,2,2)),new sn({color:"#5b6575"}));this.highlight=new ge(new gn(1,1,1),new Je({color:"#2563eb",transparent:!0,opacity:.6})),this.highlight.visible=!1,this.scene.add(this.faces,r,this.highlight),this._raycaster=new qn,this.hovered=null,this._pointer=null,this.element.addEventListener("contextmenu",l=>l.preventDefault());let o=l=>{this._pointer=[l.clientX,l.clientY],this._hover(this.regionAtClient(...this._pointer))&&this._render()};this.canvas.addEventListener("pointerenter",o),this.canvas.addEventListener("pointermove",o),this.canvas.addEventListener("pointerleave",()=>{this._pointer=null,this._hover(null)&&this._render()}),this.canvas.addEventListener("click",l=>{let c=this.regionAtClient(l.clientX,l.clientY);if(!c)return;let h=c==="top"||c==="bottom";this._look(h?kh(c,n.camera.position.clone().sub(n.target)):sp(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=tn("ioviewer-viewcube-arrow",oe.chevron,q(`cube.${l}`));return c.dataset.arrow=l,c.addEventListener("click",h=>{h.detail&&c.blur(),this._arrow(l)}),c});let a=tn("ioviewer-viewcube-home",oe.home,q("cube.home"));a.addEventListener("click",l=>{l.detail&&a.blur(),n.resetCameraStyle(),n.animateTo({position:this.home.position.clone(),target:this.home.target.clone()})}),this.element.append(...this.arrows,a),t.append(this.element),this.update()}_createRenderer(){this.canvas.addEventListener("webglcontextlost",e=>{e.stopImmediatePropagation(),this._fail(new Error("The view cube lost its WebGL context."))});let t=this.canvas.getContext("webgl2",{alpha:!0,antialias:!0});if(!t)return this._fail(new Error("WebGL 2 is not available for the view cube."));try{let e=new Ti({canvas:this.canvas,context:t,alpha:!0,antialias:!0});return e.setPixelRatio(window.devicePixelRatio),e.setSize(ip,ip),e}catch(e){return this._fail(e)}}_fail(t){return this.error=t,this.renderer=null,this.element.hidden=!0,null}_render(){if(this.renderer)try{this.renderer.render(this.scene,this.camera)}catch(t){this._fail(t)}}set2D(t){this.element.classList.toggle("ioviewer-viewcube-2d",!!t)}update(){if(!this.renderer)return;let t=this.controls.camera,e=!this.camera.quaternion.equals(t.quaternion);this.camera.quaternion.copy(t.quaternion),this.camera.position.set(0,0,5).applyQuaternion(t.quaternion),this.camera.updateMatrixWorld();let n=zh(t.position.clone().sub(this.controls.target))!==null;for(let s of this.arrows)s.hidden=!n;e&&this._pointer&&this._hover(this.regionAtClient(...this._pointer)),this._render()}regionAtClient(t,e){let n=this.canvas.getBoundingClientRect(),s=new qt((t-n.left)/n.width*2-1,1-(e-n.top)/n.height*2);this._raycaster.setFromCamera(s,this.camera);let r=this._raycaster.intersectObjects(this.faces.children)[0];return r?Wy(r.point):null}_hover(t){if(t===this.hovered)return!1;if(this.hovered=t,this.highlight.visible=!!t,t){let e=t.split("-").reduce((a,l)=>a.add(un[l]),new C),n=a=>a===0?[-Ki,Ki]:a>0?[Ki,1.02]:[-1.02,-Ki],[s,r,o]=e.toArray().map(n);this.highlight.scale.set(s[1]-s[0],r[1]-r[0],o[1]-o[0]),this.highlight.position.set((s[0]+s[1])/2,(r[0]+r[1])/2,(o[0]+o[1])/2)}return!0}_arrow(t){let n=this.controls.camera.position.clone().sub(this.controls.target),s=Xy(n,t);if(!s)return;let r=zh(n),o=r==="top"&&t==="up"||r==="bottom"&&t==="down";this._look(s,o)}_look(t,e=!1){let{controls:n}=this,s=n.camera.position.distanceTo(n.target);n.animateTo({position:t.clone().multiplyScalar(s).add(n.target),target:n.target.clone(),zoom:n.camera.zoom,overPole:e})}};var Yy=` #include #ifdef IO_PICK_POINTS uniform uint pointIndex; @@ -4341,7 +4341,7 @@ void main() { vSlot = vec2( float( slot >> 12 ), float( slot & 4095 ) ); if ( state.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); #endif -}`,Yy=` +}`,$y=` #include #include #include @@ -4390,14 +4390,14 @@ void main() { uvec4 bytes = ( uvec4( bits ) >> uvec4( 0u, 8u, 16u, 24u ) ) & 255u; gl_FragColor = vec4( bytes ) / 255.0; #endif -}`,sp=i=>i&&{element:i.element,point:i.point.clone()};function li(i,t,e=null){let n=new Ie({vertexShader:qy,fragmentShader:Yy,uniforms:i,defines:t?{[t]:""}:{},side:ke,clipping:!0});return e==="points"?n.defines.IO_PICK_POINTS="":e==="lines"?n.defines.IO_PICK_LINES="":n.index0AttributeName="q",n}var gl=class{constructor(t,e,n,s={}){this.renderer=t,this.scene=e,this.points=s.points?.count?s.points:null,this.lines=s.lines?.count?s.lines:null,this.camera=n,this._lost=!1,t.domElement.addEventListener("webglcontextlost",()=>this._lost=!0),this._last=null,this._lastTile=null,this._key=new Float64Array(36),e.root.addEventListener("change",c=>{c.detail.kind!=="appearance"&&(this._last=this._lastTile=null)});let r=e.slotUniforms,o={pointIndex:{value:0},pointSize:{value:0}},a={lineState:{value:null},pointCount:{value:this.points?.count??0}};this._float=s.pickFloat!==!1&&t.extensions.has("EXT_color_buffer_float");let l=this.lines?5:this.points?3:1;this._float?(this._material=li(r,null),this._target=new Be(l,l,{type:Ye}),this._pixel=new Float32Array(l*l*4),this.points&&(this._pointMaterial=li(o,null,"points")),this.lines&&(this._lineMaterial=li(a,null,"lines"))):(this._material=li(r,"IO_PICK_RGBA8"),this._depthMaterial=li(r,"IO_PICK_DEPTH"),this._target=new Be(l,l),this._pixel=new Uint8Array(l*l*4),this.points&&(this._pointMaterial=li(o,"IO_PICK_RGBA8","points"),this._pointDepthMaterial=li(o,"IO_PICK_DEPTH","points")),this.lines&&(this._lineMaterial=li(a,"IO_PICK_RGBA8","lines"),this._lineDepthMaterial=li(a,"IO_PICK_DEPTH","lines")))}pick(t,e){let n=this.renderer.domElement.getBoundingClientRect(),s=Math.floor(t-n.left),r=Math.floor(e-n.top);if(this._lost||!(s>=0&&r>=0&&sh===o[d]))return sp(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},sp(c)}_sampleKey(t,e,n){this.camera.updateMatrixWorld();let s=this._key;return s.set([t,e,n.width,n.height]),s.set(this.camera.matrixWorld.elements,4),s.set(this.camera.projectionMatrix.elements,20),s}measureTile(t,e,n){let s=this.renderer.domElement.getBoundingClientRect(),r=Math.floor(t-s.left),o=Math.floor(e-s.top);if(this._lost||!(r>=0&&o>=0&&rv===a[w]))return c.tile;let h=n*2+1;(!this._measure||this._measure.target.width!==h)&&(this._measure?.target.dispose(),this._measure={target:new Be(h,h,this._float?{type:Ye}:{}),ids:this._float?new Float32Array(h*h*4):new Uint8Array(h*h*4),depths:this._float?null:new Uint8Array(h*h*4)});let{target:d,ids:u,depths:f}=this._measure,m=r-n,_=o-n;this._render(this._material,m,_,s,d,u);let g=(v,w)=>{let R=Math.floor(v)-m,L=Math.floor(w)-_;return R>=0&&R=0&&Lthis._slotAt(p,v),E=g(r,o),M=y(E),x=E;if(M<0&&(this.points||this.lines)){let v=(n+1)**2;for(let w=0;wv||(v=L,x=w)}}let S=null,A=y(x);if(A>=0){f&&this._render(this._depthMaterial,m,_,s,d,f);let v=f&&new DataView(f.buffer),w=l.matrixWorldInverse.elements.slice(),R=new C,L=U=>{let O=this._vertexAt(y(U),u,v,U,R);return O?-(w[2]*O.x+w[6]*O.y+w[10]*O.z+w[14]):v.getFloat32(U*4,!0)},N=this._vertexAt(A,u,v,x)??this._depthPoint(r,o,s,L(x)),B=this._isPoint(A),D=this._isLine(A)?A-this.scene.slotCount-(this.points?.count??0):-1,F=new Set,H=this._elementAt(A),V=new Set(B||D>=0?[]:[A]);if(D>=0&&F.add(D),!B)for(let U=0;U=0&&!this._isPoint(O)&&(this._isLine(O)?F.add(O-this.scene.slotCount-(this.points?.count??0)):H>=0&&!V.has(O)&&this.scene.slotElement(O)===H&&V.add(O))}let k=l.isPerspectiveCamera;S={rect:s,point:N,element:H,slots:V,lineInstances:F,pointSample:B,depthAt(U,O,Y){let G=g(U,O),J=G<0?-1:y(G);if(J<0)return 1/0;if(J!==Y)return L(G);let rt=$=>k?1/L($):L($),nt=rt(G);function it($,st,gt){let ht=Math.sign(gt),_t=g(U+ht*$,O+ht*st);if(_t>=0&&y(_t)===J)return(rt(_t)-nt)*Math.abs(gt);let Bt=g(U-ht*$,O-ht*st);return Bt>=0&&y(Bt)===J?(nt-rt(Bt))*Math.abs(gt):0}let z=nt+it(1,0,U-Math.floor(U)-.5)+it(0,1,O-Math.floor(O)-.5);return z>0?k?1/z:z:L(G)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:S},this._last={camera:l,key:this._lastTile.key,hit:M>=0?S:null},S}_pick(t,e,n){let s=this._target.width,r=(s-1)/2,o=(s**2-1)/2,a=this._render(this._material,t-r,e-r,n),l=this._float?a:new Uint32Array(a.buffer),c=o,h=this._slotAt(l,o);if(h<0&&s>1){let p=1/0;for(let y=0;y=this.scene.slotCount&&t=this.scene.slotCount+(this.points?.count??0)}_elementAt(t){if(this._isPoint(t)){let e=this.scene.pointOffset??this.scene.instanceCount-this.points.count-(this.lines?.count??0);return this.scene.instance(e+t-this.scene.slotCount).element}if(this._isLine(t)){let e=this.scene.lineOffset??this.scene.instanceCount-this.lines.count;return this.scene.instance(e+t-this.scene.slotCount-(this.points?.count??0)).element}return this.scene.slotElement(t)}_vertexAt(t,e,n,s,r=new C){return this._float?r.fromArray(e,s*4):this._isPoint(t)?this.points.position(t-this.scene.slotCount,n.getUint32(s*4,!0),r):null}_depthPoint(t,e,n,s){let r=this.camera,o=new C((t+.5)/n.width*2-1,1-(e+.5)/n.height*2,-1).applyMatrix4(r.projectionMatrixInverse);return r.isPerspectiveCamera?o.multiplyScalar(-s/o.z):o.z=-s,o.applyMatrix4(r.matrixWorld)}_render(t,e,n,s,r=this._target,o=this._pixel){let{renderer:a,camera:l}=this,c={target:a.getRenderTarget(),color:a.getClearColor(new Vt),alpha:a.getClearAlpha(),autoClear:a.autoClear},h=this.scene._buckets[0]?.material;t.clippingPlanes=h?.clippingPlanes??null,t.clipIntersection=h?.clipIntersection??!1,l.updateMatrixWorld(),l.setViewOffset(s.width,s.height,e,n,r.width,r.height);try{if(a.setRenderTarget(r),a.setClearColor(0,0),this.scene.withMaterial(t,()=>a.render(this.scene.root,l),{pickCamera:l}),this.points){a.autoClear=!1;let d=t===this._depthMaterial?this._pointDepthMaterial:this._pointMaterial;this.points.withPickMaterial(d,()=>a.render(this.points.root,l))}if(this.lines){a.autoClear=!1;let d=t===this._depthMaterial?this._lineDepthMaterial:this._lineMaterial;this.lines.withPickMaterial(d,()=>a.render(this.lines.root,l))}a.readRenderTargetPixels(r,0,0,r.width,r.height,o)}finally{a.setRenderTarget(c.target),a.setClearColor(c.color,c.alpha),a.autoClear=c.autoClear,l.clearViewOffset()}return o}};var _l=33.333333333333336,$y=200,rp=1e6,Zy=20,xl=class{constructor(t,e,n=1e7){this.scene=t,this.budget=n,this.minPixels=0,this._requestRender=e,this._last=new Float64Array(32),this._seen=!1,this._requestedAt=null,this._frame=null,this._cost=0,this._fastFrames=0,this._refine=!1,this._settle=0}requested(t){this._requestedAt??(this._requestedAt=t)}begin(t,e,n){t.updateMatrixWorld();let s=this._requestedAt===null?0:Math.max(n-this._requestedAt,0);this._requestedAt=null;let r=this._moved(t);this._frame=r?{start:n,waited:s}:null,this.minPixels=r?this.scene.detailThreshold(t,e,this.budget,this._refine):0,r||(this._fastFrames=0),this.scene.setDetail(this.minPixels,e),r&&(clearTimeout(this._settle),this.minPixels>0&&(this._settle=setTimeout(this._requestRender,$y)))}end(t){this.scene.setDetail(0),this._frame&&this._adapt(this._frame.waited+(t-this._frame.start)),this._frame=null}_adapt(t){this._cost=this._cost?this._cost*.8+t*.2:t,t>_l*1.1?(this._refine=!1,this._fastFrames=0):this._refine||(this._fastFrames=this.minPixels>0&&t<_l*.7?this._fastFrames+1:0,this._refine=this._fastFrames>=Zy),this._cost>_l*1.1?this.budget=Math.max(this.budget*.9,rp):this._cost<_l*.7&&this.minPixels>0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),rp))}_moved(t){let e=this._last,n=[...t.matrixWorld.elements,...t.projectionMatrix.elements],s=(o,a)=>a!==26&&a!==30&&Math.abs(o-e[a])>1e-9*Math.max(1,Math.abs(o)),r=this._seen&&n.some(s);return this._seen=!0,e.set(n),r}};var Ln,Ws,vl,yl=class extends EventTarget{constructor(){super(...arguments);Vl(this,Ws);Vl(this,Ln,new Set)}get size(){return di(this,Ln).size}has(e){return di(this,Ln).has(e)}values(){return di(this,Ln).values()}set(e){mu(this,Ln,new Set(e)),to(this,Ws,vl).call(this)}toggle(e){di(this,Ln).delete(e)||di(this,Ln).add(e),to(this,Ws,vl).call(this)}clear(){di(this,Ln).size!==0&&(di(this,Ln).clear(),to(this,Ws,vl).call(this))}};Ln=new WeakMap,Ws=new WeakSet,vl=function(){this.dispatchEvent(new Event("change"))};function op(i,t,e){if(t!=="window"&&t!=="crossing")throw new RangeError(`Unknown box select mode: ${t}`);let n=i.x+i.width,s=i.y+i.height,r=t==="window"?o=>o.minX>=i.x&&o.maxX<=n&&o.minY>=i.y&&o.maxY<=s:o=>o.maxX>=i.x&&o.minX<=n&&o.maxY>=i.y&&o.minY<=s;return e.filter(r).map(o=>o.index)}function ap(i,t,e){let n=new Zt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse).elements,{left:s,top:r,width:o,height:a}=e,l=new oe,c=[];for(let h=0;hn===l?r(l):o(l));let g=[...t.children].find(x=>lp.indexOf(x.dataset.panel)>m);t.insertBefore(_,g??null);let p=K("section","ioviewer-side-panel ioviewer-floating");p.dataset.panel=l,p.hidden=!0,p.setAttribute("aria-label",h);let y=tn("ioviewer-panel-close",re.close,q("close"));y.addEventListener("click",()=>r(l));let E=K("header","ioviewer-panel-header");E.append(K("h2","",h),y);let M=K("div","ioviewer-panel-body");p.append(E,M),i.append(p),e.set(l,{button:_,panel:p,onClose:f}),d(M)}return{rail:t,openPanel:o,closePanel:r,registerPanel:a}}var hp=[{id:"navigation",items:["orbit","pan","fit","projection","mode2d"]},{id:"sections",items:["plane","box","resetSections"]},{id:"measure",items:["distance"]},{id:"display",items:["displayMode","grids","opacity"]},{id:"view",items:["fullscreen"]}];function up(i,t){let e=K("div","ioviewer-toolbar ioviewer-floating");e.setAttribute("role","toolbar");let n=new Map;for(let a of t){let l=K("div","ioviewer-toolbar-group");l.setAttribute("role","group"),l.setAttribute("aria-label",q(`group.${a.id}`));let c=K("div","ioviewer-toolbar-row");for(let h of a.items){let d=tn("ioviewer-tool",re[h],q(`tool.${h}`));d.dataset.tool=h,d.setAttribute("aria-disabled","true");let u={button:d,handler:null};d.addEventListener("click",()=>{d.getAttribute("aria-disabled")!=="true"&&u.handler?.()}),n.set(h,u),c.append(d)}l.append(c,K("div","ioviewer-toolbar-label",q(`group.${a.id}`))),e.append(l)}i.append(e),new ResizeObserver(()=>i.style.setProperty("--toolbar-height",`${e.offsetHeight}px`)).observe(e);function r(a){let l=n.get(a);if(!l)throw new RangeError(`Unknown tool: ${a}`);return l}function o(a,l){r(a).button.setAttribute("aria-disabled",String(!l))}return{element:e,setHandler(a,l){r(a).handler=l,o(a,!0)},setEnabled:o,setActive(a,l){let{button:c}=r(a);c.classList.toggle("active",l),c.setAttribute("aria-pressed",String(l))}}}var Ky="input, textarea, select, [contenteditable]";function Hh(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function dp(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(Ky))return null;if(Hh(i))return"contextMenu";switch(i.code){case"KeyH":return i.shiftKey?"showAll":"hide";case"KeyI":return i.shiftKey?null:"isolate";case"KeyF":return i.shiftKey?null:"zoomTo";case"Escape":return"escape";default:return null}}function fp(i,t,e,n,s){let r=K("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=K("summary","",q("filters.title")),a=K("div","ioviewer-filter-fields"),l=new Map(t.map(({id:x,name:S})=>[x,S||`#${x}`])),c=x=>x.modelId??t[0]?.id??null,h=x=>x.levelId??(x.level||null),d=x=>x.category??"",u=[{name:q("filters.model"),key:c,labels:new Map},{name:q("level"),key:h,labels:new Map},{name:q("category"),key:d,labels:new Map}],[f,m,_]=u,g=K("div","ioviewer-filter-actions"),p=K("button","ioviewer-text-button",q("filters.clear"));p.type="button",p.addEventListener("click",()=>{for(let x of u)x.select&&(x.select.selectedIndex=0);e.value="",n(),e.focus()});let y=K("button","ioviewer-text-button",q("filters.isolate"));y.type="button",y.addEventListener("click",s),g.append(p,y),r.append(o,a,g);function E(){if(r.open){r.removeEventListener("toggle",E);for(let x of i){let S=c(x),A=l.get(S)??(S==null?"":`#${S}`);S!=null&&f.labels.set(S,A);let v=h(x);if(!m.labels.has(v)){let R=x.level||(v==null?q("filters.noLevel"):`#${v}`);m.labels.set(v,v!=null&&t.length>1&&A?`${R} \xB7 ${A}`:R)}let w=d(x);_.labels.set(w,w||q("noCategory"))}for(let x of u){if(!x.labels.size)continue;let S=new Map;for(let R of x.labels.values())S.set(R,(S.get(R)??0)+1);let A=[...x.labels].map(([R,L])=>[R,S.get(L)>1?`${L} (#${R})`:L]);A.sort((R,L)=>R[1].localeCompare(L[1])),x.keys=A.map(([R])=>R);let v=x.select=K("select");v.append(new Option(q("filters.all"),""));for(let[R,[,L]]of A.entries())v.append(new Option(L,String(R+1)));v.addEventListener("change",n);let w=K("label","ioviewer-filter-field");w.append(K("span","",x.name),v),a.append(w)}}}r.addEventListener("toggle",E);function M(){return u.filter(x=>x.select?.selectedIndex>0)}return{element:r,predicate(){let x=M().map(({select:S,keys:A,key:v})=>({key:v,value:A[S.selectedIndex-1]}));return x.length?S=>x.every(({key:A,value:v})=>A(S)===v):null},update(x,S){let A=M().length;o.textContent=A?`${q("filters.title")} (${A})`:q("filters.title"),p.disabled=!A&&!x,y.disabled=!S}}}var Ci=24,Jy=8;function Vh(i,t,e,n,s){let r=Math.min(n,Math.max(0,Math.floor(i/t)-s)),o=Math.min(n,Math.ceil((i+e)/t)+s);return{start:r,end:Math.max(r,o)}}function jy(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} +}`,op=i=>i&&{element:i.element,point:i.point.clone()};function li(i,t,e=null){let n=new Ie({vertexShader:Yy,fragmentShader:$y,uniforms:i,defines:t?{[t]:""}:{},side:ke,clipping:!0});return e==="points"?n.defines.IO_PICK_POINTS="":e==="lines"?n.defines.IO_PICK_LINES="":n.index0AttributeName="q",n}var gl=class{constructor(t,e,n,s={}){this.renderer=t,this.scene=e,this.points=s.points?.count?s.points:null,this.lines=s.lines?.count?s.lines:null,this.camera=n,this._lost=!1,t.domElement.addEventListener("webglcontextlost",()=>this._lost=!0),this._last=null,this._lastTile=null,this._key=new Float64Array(36),e.root.addEventListener("change",c=>{c.detail.kind!=="appearance"&&(this._last=this._lastTile=null)});let r=e.slotUniforms,o={pointIndex:{value:0},pointSize:{value:0}},a={lineState:{value:null},pointCount:{value:this.points?.count??0}};this._float=s.pickFloat!==!1&&t.extensions.has("EXT_color_buffer_float");let l=this.lines?5:this.points?3:1;this._float?(this._material=li(r,null),this._target=new Be(l,l,{type:Ye}),this._pixel=new Float32Array(l*l*4),this.points&&(this._pointMaterial=li(o,null,"points")),this.lines&&(this._lineMaterial=li(a,null,"lines"))):(this._material=li(r,"IO_PICK_RGBA8"),this._depthMaterial=li(r,"IO_PICK_DEPTH"),this._target=new Be(l,l),this._pixel=new Uint8Array(l*l*4),this.points&&(this._pointMaterial=li(o,"IO_PICK_RGBA8","points"),this._pointDepthMaterial=li(o,"IO_PICK_DEPTH","points")),this.lines&&(this._lineMaterial=li(a,"IO_PICK_RGBA8","lines"),this._lineDepthMaterial=li(a,"IO_PICK_DEPTH","lines")))}pick(t,e){let n=this.renderer.domElement.getBoundingClientRect(),s=Math.floor(t-n.left),r=Math.floor(e-n.top);if(this._lost||!(s>=0&&r>=0&&sh===o[d]))return op(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},op(c)}_sampleKey(t,e,n){this.camera.updateMatrixWorld();let s=this._key;return s.set([t,e,n.width,n.height]),s.set(this.camera.matrixWorld.elements,4),s.set(this.camera.projectionMatrix.elements,20),s}measureTile(t,e,n){let s=this.renderer.domElement.getBoundingClientRect(),r=Math.floor(t-s.left),o=Math.floor(e-s.top);if(this._lost||!(r>=0&&o>=0&&rv===a[E]))return c.tile;let h=n*2+1;(!this._measure||this._measure.target.width!==h)&&(this._measure?.target.dispose(),this._measure={target:new Be(h,h,this._float?{type:Ye}:{}),ids:this._float?new Float32Array(h*h*4):new Uint8Array(h*h*4),depths:this._float?null:new Uint8Array(h*h*4)});let{target:d,ids:u,depths:f}=this._measure,m=r-n,_=o-n;this._render(this._material,m,_,s,d,u);let g=(v,E)=>{let R=Math.floor(v)-m,L=Math.floor(E)-_;return R>=0&&R=0&&Lthis._slotAt(p,v),w=g(r,o),M=y(w),x=w;if(M<0&&(this.points||this.lines)){let v=(n+1)**2;for(let E=0;Ev||(v=L,x=E)}}let S=null,A=y(x);if(A>=0){f&&this._render(this._depthMaterial,m,_,s,d,f);let v=f&&new DataView(f.buffer),E=l.matrixWorldInverse.elements.slice(),R=new C,L=U=>{let k=this._vertexAt(y(U),u,v,U,R);return k?-(E[2]*k.x+E[6]*k.y+E[10]*k.z+E[14]):v.getFloat32(U*4,!0)},N=this._vertexAt(A,u,v,x)??this._depthPoint(r,o,s,L(x)),B=this._isPoint(A),D=this._isLine(A)?A-this.scene.slotCount-(this.points?.count??0):-1,F=new Set,H=this._elementAt(A),V=new Set(B||D>=0?[]:[A]);if(D>=0&&F.add(D),!B)for(let U=0;U=0&&!this._isPoint(k)&&(this._isLine(k)?F.add(k-this.scene.slotCount-(this.points?.count??0)):H>=0&&!V.has(k)&&this.scene.slotElement(k)===H&&V.add(k))}let z=l.isPerspectiveCamera;S={rect:s,point:N,element:H,slots:V,lineInstances:F,pointSample:B,depthAt(U,k,Y){let G=g(U,k),J=G<0?-1:y(G);if(J<0)return 1/0;if(J!==Y)return L(G);let it=$=>z?1/L($):L($),nt=it(G);function at($,rt,mt){let ht=Math.sign(mt),Et=g(U+ht*$,k+ht*rt);if(Et>=0&&y(Et)===J)return(it(Et)-nt)*Math.abs(mt);let Zt=g(U-ht*$,k-ht*rt);return Zt>=0&&y(Zt)===J?(nt-it(Zt))*Math.abs(mt):0}let O=nt+at(1,0,U-Math.floor(U)-.5)+at(0,1,k-Math.floor(k)-.5);return O>0?z?1/O:O:L(G)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:S},this._last={camera:l,key:this._lastTile.key,hit:M>=0?S:null},S}_pick(t,e,n){let s=this._target.width,r=(s-1)/2,o=(s**2-1)/2,a=this._render(this._material,t-r,e-r,n),l=this._float?a:new Uint32Array(a.buffer),c=o,h=this._slotAt(l,o);if(h<0&&s>1){let p=1/0;for(let y=0;y=this.scene.slotCount&&t=this.scene.slotCount+(this.points?.count??0)}_elementAt(t){if(this._isPoint(t)){let e=this.scene.pointOffset??this.scene.instanceCount-this.points.count-(this.lines?.count??0);return this.scene.instance(e+t-this.scene.slotCount).element}if(this._isLine(t)){let e=this.scene.lineOffset??this.scene.instanceCount-this.lines.count;return this.scene.instance(e+t-this.scene.slotCount-(this.points?.count??0)).element}return this.scene.slotElement(t)}_vertexAt(t,e,n,s,r=new C){return this._float?r.fromArray(e,s*4):this._isPoint(t)?this.points.position(t-this.scene.slotCount,n.getUint32(s*4,!0),r):null}_depthPoint(t,e,n,s){let r=this.camera,o=new C((t+.5)/n.width*2-1,1-(e+.5)/n.height*2,-1).applyMatrix4(r.projectionMatrixInverse);return r.isPerspectiveCamera?o.multiplyScalar(-s/o.z):o.z=-s,o.applyMatrix4(r.matrixWorld)}_render(t,e,n,s,r=this._target,o=this._pixel){let{renderer:a,camera:l}=this,c={target:a.getRenderTarget(),color:a.getClearColor(new Vt),alpha:a.getClearAlpha(),autoClear:a.autoClear},h=this.scene._buckets[0]?.material;t.clippingPlanes=h?.clippingPlanes??null,t.clipIntersection=h?.clipIntersection??!1,l.updateMatrixWorld(),l.setViewOffset(s.width,s.height,e,n,r.width,r.height);try{if(a.setRenderTarget(r),a.setClearColor(0,0),this.scene.withMaterial(t,()=>a.render(this.scene.root,l),{pickCamera:l}),this.points){a.autoClear=!1;let d=t===this._depthMaterial?this._pointDepthMaterial:this._pointMaterial;this.points.withPickMaterial(d,()=>a.render(this.points.root,l))}if(this.lines){a.autoClear=!1;let d=t===this._depthMaterial?this._lineDepthMaterial:this._lineMaterial;this.lines.withPickMaterial(d,()=>a.render(this.lines.root,l))}a.readRenderTargetPixels(r,0,0,r.width,r.height,o)}finally{a.setRenderTarget(c.target),a.setClearColor(c.color,c.alpha),a.autoClear=c.autoClear,l.clearViewOffset()}return o}};var _l=33.333333333333336,Zy=200,ap=1e6,Ky=20,xl=class{constructor(t,e,n=1e7){this.scene=t,this.budget=n,this.minPixels=0,this._requestRender=e,this._last=new Float64Array(32),this._seen=!1,this._requestedAt=null,this._frame=null,this._cost=0,this._fastFrames=0,this._refine=!1,this._settle=0}requested(t){this._requestedAt??(this._requestedAt=t)}begin(t,e,n){t.updateMatrixWorld();let s=this._requestedAt===null?0:Math.max(n-this._requestedAt,0);this._requestedAt=null;let r=this._moved(t);this._frame=r?{start:n,waited:s}:null,this.minPixels=r?this.scene.detailThreshold(t,e,this.budget,this._refine):0,r||(this._fastFrames=0),this.scene.setDetail(this.minPixels,e),r&&(clearTimeout(this._settle),this.minPixels>0&&(this._settle=setTimeout(this._requestRender,Zy)))}end(t){this.scene.setDetail(0),this._frame&&this._adapt(this._frame.waited+(t-this._frame.start)),this._frame=null}_adapt(t){this._cost=this._cost?this._cost*.8+t*.2:t,t>_l*1.1?(this._refine=!1,this._fastFrames=0):this._refine||(this._fastFrames=this.minPixels>0&&t<_l*.7?this._fastFrames+1:0,this._refine=this._fastFrames>=Ky),this._cost>_l*1.1?this.budget=Math.max(this.budget*.9,ap):this._cost<_l*.7&&this.minPixels>0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),ap))}_moved(t){let e=this._last,n=[...t.matrixWorld.elements,...t.projectionMatrix.elements],s=(o,a)=>a!==26&&a!==30&&Math.abs(o-e[a])>1e-9*Math.max(1,Math.abs(o)),r=this._seen&&n.some(s);return this._seen=!0,e.set(n),r}};var Ln,Ws,vl,yl=class extends EventTarget{constructor(){super(...arguments);Vl(this,Ws);Vl(this,Ln,new Set)}get size(){return di(this,Ln).size}has(e){return di(this,Ln).has(e)}values(){return di(this,Ln).values()}set(e){_u(this,Ln,new Set(e)),to(this,Ws,vl).call(this)}toggle(e){di(this,Ln).delete(e)||di(this,Ln).add(e),to(this,Ws,vl).call(this)}clear(){di(this,Ln).size!==0&&(di(this,Ln).clear(),to(this,Ws,vl).call(this))}};Ln=new WeakMap,Ws=new WeakSet,vl=function(){this.dispatchEvent(new Event("change"))};function lp(i,t,e){if(t!=="window"&&t!=="crossing")throw new RangeError(`Unknown box select mode: ${t}`);let n=i.x+i.width,s=i.y+i.height,r=t==="window"?o=>o.minX>=i.x&&o.maxX<=n&&o.minY>=i.y&&o.maxY<=s:o=>o.maxX>=i.x&&o.minX<=n&&o.maxY>=i.y&&o.minY<=s;return e.filter(r).map(o=>o.index)}function cp(i,t,e){let n=new Kt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse).elements,{left:s,top:r,width:o,height:a}=e,l=new ae,c=[];for(let h=0;hn===l?r(l):o(l));let g=[...t.children].find(x=>hp.indexOf(x.dataset.panel)>m);t.insertBefore(_,g??null);let p=K("section","ioviewer-side-panel ioviewer-floating");p.dataset.panel=l,p.hidden=!0,p.setAttribute("aria-label",h);let y=tn("ioviewer-panel-close",oe.close,q("close"));y.addEventListener("click",()=>r(l));let w=K("header","ioviewer-panel-header");w.append(K("h2","",h),y);let M=K("div","ioviewer-panel-body");p.append(w,M),i.append(p),e.set(l,{button:_,panel:p,onClose:f}),d(M)}return{rail:t,openPanel:o,closePanel:r,registerPanel:a}}var dp=[{id:"navigation",items:["orbit","pan","fit","projection","mode2d"]},{id:"sections",items:["plane","box","resetSections"]},{id:"measure",items:["distance"]},{id:"display",items:["displayMode","grids","opacity"]},{id:"view",items:["fullscreen"]}];function fp(i,t){let e=K("div","ioviewer-toolbar ioviewer-floating");e.setAttribute("role","toolbar");let n=new Map;for(let a of t){let l=K("div","ioviewer-toolbar-group");l.setAttribute("role","group"),l.setAttribute("aria-label",q(`group.${a.id}`));let c=K("div","ioviewer-toolbar-row");for(let h of a.items){let d=tn("ioviewer-tool",oe[h],q(`tool.${h}`));d.dataset.tool=h,d.setAttribute("aria-disabled","true");let u={button:d,handler:null};d.addEventListener("click",()=>{d.getAttribute("aria-disabled")!=="true"&&u.handler?.()}),n.set(h,u),c.append(d)}l.append(c,K("div","ioviewer-toolbar-label",q(`group.${a.id}`))),e.append(l)}i.append(e),new ResizeObserver(()=>i.style.setProperty("--toolbar-height",`${e.offsetHeight}px`)).observe(e);function r(a){let l=n.get(a);if(!l)throw new RangeError(`Unknown tool: ${a}`);return l}function o(a,l){r(a).button.setAttribute("aria-disabled",String(!l))}return{element:e,setHandler(a,l){r(a).handler=l,o(a,!0)},setEnabled:o,setActive(a,l){let{button:c}=r(a);c.classList.toggle("active",l),c.setAttribute("aria-pressed",String(l))}}}var Jy="input, textarea, select, [contenteditable]";function Hh(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function pp(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(Jy))return null;if(Hh(i))return"contextMenu";switch(i.code){case"KeyH":return i.shiftKey?"showAll":"hide";case"KeyI":return i.shiftKey?null:"isolate";case"KeyF":return i.shiftKey?null:"zoomTo";case"Escape":return"escape";default:return null}}function mp(i,t,e,n,s){let r=K("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=K("summary","",q("filters.title")),a=K("div","ioviewer-filter-fields"),l=new Map(t.map(({id:x,name:S})=>[x,S||`#${x}`])),c=x=>x.modelId??t[0]?.id??null,h=x=>x.levelId??(x.level||null),d=x=>x.category??"",u=[{name:q("filters.model"),key:c,labels:new Map},{name:q("level"),key:h,labels:new Map},{name:q("category"),key:d,labels:new Map}],[f,m,_]=u,g=K("div","ioviewer-filter-actions"),p=K("button","ioviewer-text-button",q("filters.clear"));p.type="button",p.addEventListener("click",()=>{for(let x of u)x.select&&(x.select.selectedIndex=0);e.value="",n(),e.focus()});let y=K("button","ioviewer-text-button",q("filters.isolate"));y.type="button",y.addEventListener("click",s),g.append(p,y),r.append(o,a,g);function w(){if(r.open){r.removeEventListener("toggle",w);for(let x of i){let S=c(x),A=l.get(S)??(S==null?"":`#${S}`);S!=null&&f.labels.set(S,A);let v=h(x);if(!m.labels.has(v)){let R=x.level||(v==null?q("filters.noLevel"):`#${v}`);m.labels.set(v,v!=null&&t.length>1&&A?`${R} \xB7 ${A}`:R)}let E=d(x);_.labels.set(E,E||q("noCategory"))}for(let x of u){if(!x.labels.size)continue;let S=new Map;for(let R of x.labels.values())S.set(R,(S.get(R)??0)+1);let A=[...x.labels].map(([R,L])=>[R,S.get(L)>1?`${L} (#${R})`:L]);A.sort((R,L)=>R[1].localeCompare(L[1])),x.keys=A.map(([R])=>R);let v=x.select=K("select");v.append(new Option(q("filters.all"),""));for(let[R,[,L]]of A.entries())v.append(new Option(L,String(R+1)));v.addEventListener("change",n);let E=K("label","ioviewer-filter-field");E.append(K("span","",x.name),v),a.append(E)}}}r.addEventListener("toggle",w);function M(){return u.filter(x=>x.select?.selectedIndex>0)}return{element:r,predicate(){let x=M().map(({select:S,keys:A,key:v})=>({key:v,value:A[S.selectedIndex-1]}));return x.length?S=>x.every(({key:A,value:v})=>A(S)===v):null},update(x,S){let A=M().length;o.textContent=A?`${q("filters.title")} (${A})`:q("filters.title"),p.disabled=!A&&!x,y.disabled=!S}}}var Ii=24,jy=8;function Vh(i,t,e,n,s){let r=Math.min(n,Math.max(0,Math.floor(i/t)-s)),o=Math.min(n,Math.ceil((i+e)/t)+s);return{start:r,end:Math.max(r,o)}}function Qy(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} ${r.type??""} ${r.id} -${r.sourceId??""}`.toLowerCase()));let s=[];for(let r=0;r{let s=e.category??"";t.has(s)||t.set(s,[]),t.get(s).push(n)}),[...t].map(([e,n])=>({name:e,indices:n})).sort((e,n)=>e.name.localeCompare(n.name))}function pp(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=Qy(t),l=new Int32Array(t.length);a.forEach((G,J)=>G.indices.forEach(rt=>l[rt]=J));let c=new Uint8Array(a.length),h=new Int32Array(a.length),d=new Uint32Array(a.length),u=jy(t),f="",m=!1,_=new Int32Array(0),g=0,p=-1,y=null,E=!1,M=K("input","ioviewer-tree-search");M.type="search",M.placeholder=q("searchPlaceholder"),M.setAttribute("aria-label",q("searchPlaceholder"));let x=K("div","ioviewer-tree");x.setAttribute("role","tree"),x.setAttribute("aria-label",q("panel.model")),x.setAttribute("aria-multiselectable","true"),x.tabIndex=-1;let S=K("div","ioviewer-tree-spacer");S.setAttribute("role","presentation"),x.append(S);let A=K("div","ioviewer-tree-empty",q("noMatches")),v=fp(t,e,M,U,()=>s.isolate(_));i.append(v.element,M,x,A);function w(){let G=_[g],J=v.predicate();if(m=!!(f||J),m){let nt=f?u(f):t.keys();if(J){let it=[];for(let z of nt)J(t[z])&&it.push(z);_=Int32Array.from(it)}else _=Int32Array.from(nt)}else{let nt=a.length;a.forEach((z,$)=>c[$]&&(nt+=z.indices.length)),_=new Int32Array(nt);let it=0;a.forEach((z,$)=>{if(h[$]=it,_[it++]=-($+1),c[$])for(let st of z.indices)_[it++]=st})}let rt=_.indexOf(G);g=rt>=0?rt:0,S.style.height=`${_.length*Ci}px`,A.hidden=_.length>0||!m,v.update(f,!!s.isolate&&m&&_.some(nt=>s.instancesOf(nt).length>0)),R()}function R(G=x.contains(document.activeElement)){let J=x.clientHeight;if(J===0||_.length===0){S.replaceChildren();return}let rt=x.scrollTop,{start:nt,end:it}=Vh(rt,Ci,J,_.length,Jy);!G&&(g=it)&&(g=Math.min(_.length-1,Math.floor(rt/Ci)));let z=[];g=it&&z.push(L(g)),S.replaceChildren(...z),G&&S.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function L(G){let J=_[G],rt=J<0?-J-1:l[J],nt=J<0?d[rt]===a[rt].indices.length:n.has(J),it=K("div","tree-row");if(it.style.top=`${G*Ci}px`,it.style.height=`${Ci}px`,it.dataset.row=G,it.tabIndex=G===g?0:-1,it.setAttribute("role","treeitem"),it.classList.toggle("selected",nt),it.setAttribute("aria-selected",String(nt)),J<0){it.classList.add("tree-category"),it.setAttribute("aria-level","1"),it.setAttribute("aria-posinset",String(rt+1)),it.setAttribute("aria-setsize",String(a.length)),it.setAttribute("aria-expanded",String(!!c[rt]));let z=K("span","tree-chevron");z.innerHTML=re.chevron;let{name:$,indices:st}=a[rt];it.append(z,K("span","tree-name",$||q("noCategory")),K("span","tree-count",Zi(st.length)))}else{let z=t[J];it.classList.add("tree-element"),it.setAttribute("aria-level",m?"1":"2"),it.setAttribute("aria-posinset",String(m?G+1:G-h[rt])),it.setAttribute("aria-setsize",String(m?_.length:a[rt].indices.length)),it.classList.toggle("tree-child",!m),it.classList.toggle("tree-hidden",s.isVisible?.(J)===!1),it.append(K("span","tree-name",z.name||`#${z.id}`),K("span","tree-type",z.type??""))}return it}function N(G){let J=x.clientHeight;if(J===0){p=G;return}let rt=G*Ci;rtx.scrollTop+J&&(x.scrollTop=rt+Ci-J)}function B(G){g=G,N(G),R(!0)}function D(G){let J=l[G];!m&&!c[J]&&(c[J]=1,w());let rt=_.indexOf(G);rt>=0&&(x.contains(document.activeElement)||(g=rt),N(rt)),R()}function F(G){E=!0;try{n.set(G)}finally{E=!1}}function H(G,J){let rt=_.indexOf(y);rt<0&&(rt=G,y=_[G]);let nt=_.subarray(Math.min(rt,G),Math.max(rt,G)+1).filter(it=>it>=0);nt.length>0&&F(J?[...n.values(),...nt]:nt)}function V(G){y=G;let J=-G-1,rt=G<0?a[J].indices:[G],nt=G<0?d[J]===rt.length:n.has(G),it=new Set(n.values());for(let z of rt)nt?it.delete(z):it.add(z);F(it)}function k(G,J,rt){G>=0&&!n.has(G)&&(y=G,F([G]));let nt=G>=0?G:n.values().next().value??null;o(J,rt,nt,()=>{let it=_.indexOf(G);it>=0?B(it):M.focus()})}M.addEventListener("focus",()=>{S.firstElementChild||Y()});function U(){f=M.value.trim(),x.scrollTop=0,p=-1,g=-1,w()}M.addEventListener("input",U),x.addEventListener("scroll",()=>R()),x.addEventListener("focusin",G=>{let J=G.target.closest(".tree-row");!J||J.tabIndex===0||(S.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),g=Number(J.dataset.row),J.tabIndex=0)}),x.addEventListener("keydown",G=>{let J=G.target.closest(".tree-row");if(!J||G.ctrlKey||G.altKey||G.metaKey)return;let rt=Number(J.dataset.row),nt=_[rt];if(Hh(G)){if(G.preventDefault(),!G.repeat){let{left:z,bottom:$}=J.getBoundingClientRect();k(nt,z,$)}return}if(G.key===" "){G.preventDefault(),G.repeat||(G.shiftKey?H(rt,!1):V(nt));return}if(G.shiftKey)return;let it=rt;switch(G.key){case"ArrowUp":it=Math.max(0,rt-1);break;case"ArrowDown":it=Math.min(_.length-1,rt+1);break;case"Home":it=0;break;case"End":it=_.length-1;break;case"ArrowRight":nt<0&&(c[-nt-1]?it=rt+1:(c[-nt-1]=1,w()));break;case"ArrowLeft":nt>=0&&!m?it=h[l[nt]]:nt<0&&c[-nt-1]&&(c[-nt-1]=0,w());break;case"Enter":G.repeat||O(nt);break;default:return}G.preventDefault(),it!==rt&&B(it)});function O(G){if(G>=0){y=G,F([G]),r(G);return}c[-G-1]^=1,w()}x.addEventListener("click",G=>{let J=G.target.closest(".tree-row");if(!J)return;let rt=Number(J.dataset.row),nt=G.ctrlKey||G.metaKey;G.shiftKey?H(rt,nt):nt?V(_[rt]):O(_[rt])}),x.addEventListener("contextmenu",G=>{let J=G.target.closest(".tree-row");J&&(G.preventDefault(),k(_[Number(J.dataset.row)],G.clientX,G.clientY))});function Y(){p>=0&&x.clientHeight>0&&(N(p),p=-1),R()}new ResizeObserver(Y).observe(x),n.addEventListener("change",()=>{let G=-1;d.fill(0);for(let J of n.values())d[l[J]]++,G=J;if(E){R();return}y=null,G>=0?D(G):R()}),s.root?.addEventListener("change",G=>G.detail.kind==="visibility"&&R()),w()}var mp={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},tM={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},Ml=4;function gp(i){let t=K("div","ioviewer-context-menu");t.setAttribute("role","menu"),t.setAttribute("aria-label",q("contextMenu")),t.hidden=!0,i.append(t);let e=new Map(Object.values(mp).flat().filter(c=>c!=="-").map(c=>[c,{enabled:!1,handler:null}])),n=null;function s(){if(t.hidden)return;let c=t.contains(document.activeElement)?n:null;n=null,t.hidden=!0,t.replaceChildren(),window.removeEventListener("pointerdown",o,!0),window.removeEventListener("wheel",s,!0),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",s),c?.()}function r(c){i.contains(c.target)||s()}function o(c){t.contains(c.target)||(s(),fl(c))}function a(c,h,d,u,f=null){let m=mp[c];if(!m)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let p of m){if(p==="-"){let M=K("div","ioviewer-menu-separator");M.setAttribute("role","separator"),t.append(M);continue}let y=e.get(p),E=K("button","ioviewer-menu-item");E.type="button",E.tabIndex=-1,E.dataset.item=p,E.setAttribute("role","menuitem"),E.setAttribute("aria-disabled",String(!y.enabled)),y.enabled||(E.title=q("menu.unavailable")),E.append(K("span","",q(`menu.${p}`)),K("kbd","",tM[p]??"")),E.addEventListener("click",()=>{y.enabled&&(s(),y.handler(u))}),t.append(E)}t.hidden=!1;let{width:_,height:g}=t.getBoundingClientRect();t.style.left=`${Math.max(Ml,Math.min(h,innerWidth-_-Ml))}px`,t.style.top=`${Math.max(Ml,Math.min(d,innerHeight-g-Ml))}px`,window.addEventListener("pointerdown",o,!0),window.addEventListener("wheel",s,!0),window.addEventListener("scroll",r,!0),window.addEventListener("resize",s),f&&t.querySelector("button")?.focus({preventScroll:!0})}t.addEventListener("keydown",c=>{if(c.key==="Tab"){s();return}if(c.key==="Escape"){c.preventDefault(),s();return}let h=[...t.querySelectorAll("button")],d=h.indexOf(document.activeElement),u;switch(c.key){case"ArrowDown":u=(d+1)%h.length;break;case"ArrowUp":u=(d+h.length-1)%h.length;break;case"Home":u=0;break;case"End":u=h.length-1;break;default:return}c.preventDefault(),h[u]?.focus({preventScroll:!0})});function l(c,{enabled:h=!0,handler:d}){let u=e.get(c);if(!u)throw new RangeError(`Unknown menu item: ${c}`);d&&(u.handler=d),u.enabled=h&&!!u.handler}return{element:t,open:a,close:s,setItem:l,get isOpen(){return!t.hidden}}}var eM=1600;function _p(i,t,e){let n=()=>i.textContent=`${q("selected")}: ${Zi(t.size)} \xB7 ${q("elements")}: ${Zi(e)}`;t.addEventListener("change",n),n()}function xp(i,t){if(!t)return;let e=K("div","ioviewer-banner ioviewer-floating");e.setAttribute("role","status");let n=q("truncated").replace("{meshes}",t.meshes).replace("{total}",t.totalMeshes),s=tn("ioviewer-panel-close",re.close,q("close")),r=new ResizeObserver(()=>i.style.setProperty("--banner-height",`${e.offsetHeight}px`));s.addEventListener("click",()=>{r.disconnect(),i.style.removeProperty("--banner-height"),e.remove()}),e.append(K("span","",n),s),i.append(e),r.observe(e)}function Xs(i,t){let e=K("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),eM)}function vp(i,t){let e=K("table");for(let[s,r]of t)e.insertRow().append(K("th","",s),K("td","",String(r??"")));let n=K("section");return n.append(K("h3","",i),e),n}function yp(i,t,e){let n=K("h2","ioviewer-properties-title"),s=K("button","ioviewer-properties-close","\xD7");s.type="button",s.title=q("close"),s.setAttribute("aria-label",q("close")),s.addEventListener("click",()=>t.clear());let r=K("header");r.append(n,s);let o=K("div","ioviewer-properties-body");i.replaceChildren(r,o),i.hidden=!0;let a=h=>{let d=[[q("id"),h.id],[q("category"),h.category],[q("type"),h.type],[q("level"),h.level]];return h.sourceId&&d.push([q("sourceId"),h.sourceId]),h.link&&d.push([q("link"),h.link]),vp(q("elementGroup"),d)},l=h=>{for(let[d,u]of Object.entries(h??{}))o.append(vp(d,Object.entries(u)))},c;t.addEventListener("change",()=>{if(c?.abort(),c=void 0,o.removeAttribute("aria-busy"),i.hidden=t.size===0,o.replaceChildren(),t.size!==1){n.textContent=`${q("selected")}: ${t.size}`;return}let[h]=t.values(),d=e.meta.elements[h];if(n.textContent=d.name||`#${d.id}`,o.append(a(d)),!e.loadProperties){l(e.props(d.id));return}let u=new AbortController;c=u,o.setAttribute("aria-busy","true"),e.loadProperties(h,u.signal).then(f=>{u.signal.aborted||!f||(n.textContent=f.name||d.name||`#${d.id}`,o.replaceChildren(a({...d,...f})),l(f.properties))}).catch(()=>{u.signal.aborted||o.append(K("p","",q("badData")))}).finally(()=>{c===u&&o.removeAttribute("aria-busy")})})}var Ji=["length_m","area_m2","volume_m3"],nM=new Set(["elementId","categoryId","typeId",...Ji]),Mp=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,bp=new Intl.Collator(void 0,{sensitivity:"base"}),Sp="TOTAL",wp="SUBTOTAL",bl="element_count";function iM(i){let t=[],e=[],n="",s=!1,r=!1;for(let o=0;o{let s=e.category??"";t.has(s)||t.set(s,[]),t.get(s).push(n)}),[...t].map(([e,n])=>({name:e,indices:n})).sort((e,n)=>e.name.localeCompare(n.name))}function gp(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=tM(t),l=new Int32Array(t.length);a.forEach((G,J)=>G.indices.forEach(it=>l[it]=J));let c=new Uint8Array(a.length),h=new Int32Array(a.length),d=new Uint32Array(a.length),u=Qy(t),f="",m=!1,_=new Int32Array(0),g=0,p=-1,y=null,w=!1,M=K("input","ioviewer-tree-search");M.type="search",M.placeholder=q("searchPlaceholder"),M.setAttribute("aria-label",q("searchPlaceholder"));let x=K("div","ioviewer-tree");x.setAttribute("role","tree"),x.setAttribute("aria-label",q("panel.model")),x.setAttribute("aria-multiselectable","true"),x.tabIndex=-1;let S=K("div","ioviewer-tree-spacer");S.setAttribute("role","presentation"),x.append(S);let A=K("div","ioviewer-tree-empty",q("noMatches")),v=mp(t,e,M,U,()=>s.isolate(_));i.append(v.element,M,x,A);function E(){let G=_[g],J=v.predicate();if(m=!!(f||J),m){let nt=f?u(f):t.keys();if(J){let at=[];for(let O of nt)J(t[O])&&at.push(O);_=Int32Array.from(at)}else _=Int32Array.from(nt)}else{let nt=a.length;a.forEach((O,$)=>c[$]&&(nt+=O.indices.length)),_=new Int32Array(nt);let at=0;a.forEach((O,$)=>{if(h[$]=at,_[at++]=-($+1),c[$])for(let rt of O.indices)_[at++]=rt})}let it=_.indexOf(G);g=it>=0?it:0,S.style.height=`${_.length*Ii}px`,A.hidden=_.length>0||!m,v.update(f,!!s.isolate&&m&&_.some(nt=>s.instancesOf(nt).length>0)),R()}function R(G=x.contains(document.activeElement)){let J=x.clientHeight;if(J===0||_.length===0){S.replaceChildren();return}let it=x.scrollTop,{start:nt,end:at}=Vh(it,Ii,J,_.length,jy);!G&&(g=at)&&(g=Math.min(_.length-1,Math.floor(it/Ii)));let O=[];g=at&&O.push(L(g)),S.replaceChildren(...O),G&&S.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function L(G){let J=_[G],it=J<0?-J-1:l[J],nt=J<0?d[it]===a[it].indices.length:n.has(J),at=K("div","tree-row");if(at.style.top=`${G*Ii}px`,at.style.height=`${Ii}px`,at.dataset.row=G,at.tabIndex=G===g?0:-1,at.setAttribute("role","treeitem"),at.classList.toggle("selected",nt),at.setAttribute("aria-selected",String(nt)),J<0){at.classList.add("tree-category"),at.setAttribute("aria-level","1"),at.setAttribute("aria-posinset",String(it+1)),at.setAttribute("aria-setsize",String(a.length)),at.setAttribute("aria-expanded",String(!!c[it]));let O=K("span","tree-chevron");O.innerHTML=oe.chevron;let{name:$,indices:rt}=a[it];at.append(O,K("span","tree-name",$||q("noCategory")),K("span","tree-count",Ci(rt.length)))}else{let O=t[J];at.classList.add("tree-element"),at.setAttribute("aria-level",m?"1":"2"),at.setAttribute("aria-posinset",String(m?G+1:G-h[it])),at.setAttribute("aria-setsize",String(m?_.length:a[it].indices.length)),at.classList.toggle("tree-child",!m),at.classList.toggle("tree-hidden",s.isVisible?.(J)===!1),at.append(K("span","tree-name",O.name||`#${O.id}`),K("span","tree-type",O.type??""))}return at}function N(G){let J=x.clientHeight;if(J===0){p=G;return}let it=G*Ii;itx.scrollTop+J&&(x.scrollTop=it+Ii-J)}function B(G){g=G,N(G),R(!0)}function D(G){let J=l[G];!m&&!c[J]&&(c[J]=1,E());let it=_.indexOf(G);it>=0&&(x.contains(document.activeElement)||(g=it),N(it)),R()}function F(G){w=!0;try{n.set(G)}finally{w=!1}}function H(G,J){let it=_.indexOf(y);it<0&&(it=G,y=_[G]);let nt=_.subarray(Math.min(it,G),Math.max(it,G)+1).filter(at=>at>=0);nt.length>0&&F(J?[...n.values(),...nt]:nt)}function V(G){y=G;let J=-G-1,it=G<0?a[J].indices:[G],nt=G<0?d[J]===it.length:n.has(G),at=new Set(n.values());for(let O of it)nt?at.delete(O):at.add(O);F(at)}function z(G,J,it){G>=0&&!n.has(G)&&(y=G,F([G]));let nt=G>=0?G:n.values().next().value??null;o(J,it,nt,()=>{let at=_.indexOf(G);at>=0?B(at):M.focus()})}M.addEventListener("focus",()=>{S.firstElementChild||Y()});function U(){f=M.value.trim(),x.scrollTop=0,p=-1,g=-1,E()}M.addEventListener("input",U),x.addEventListener("scroll",()=>R()),x.addEventListener("focusin",G=>{let J=G.target.closest(".tree-row");!J||J.tabIndex===0||(S.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),g=Number(J.dataset.row),J.tabIndex=0)}),x.addEventListener("keydown",G=>{let J=G.target.closest(".tree-row");if(!J||G.ctrlKey||G.altKey||G.metaKey)return;let it=Number(J.dataset.row),nt=_[it];if(Hh(G)){if(G.preventDefault(),!G.repeat){let{left:O,bottom:$}=J.getBoundingClientRect();z(nt,O,$)}return}if(G.key===" "){G.preventDefault(),G.repeat||(G.shiftKey?H(it,!1):V(nt));return}if(G.shiftKey)return;let at=it;switch(G.key){case"ArrowUp":at=Math.max(0,it-1);break;case"ArrowDown":at=Math.min(_.length-1,it+1);break;case"Home":at=0;break;case"End":at=_.length-1;break;case"ArrowRight":nt<0&&(c[-nt-1]?at=it+1:(c[-nt-1]=1,E()));break;case"ArrowLeft":nt>=0&&!m?at=h[l[nt]]:nt<0&&c[-nt-1]&&(c[-nt-1]=0,E());break;case"Enter":G.repeat||k(nt);break;default:return}G.preventDefault(),at!==it&&B(at)});function k(G){if(G>=0){y=G,F([G]),r(G);return}c[-G-1]^=1,E()}x.addEventListener("click",G=>{let J=G.target.closest(".tree-row");if(!J)return;let it=Number(J.dataset.row),nt=G.ctrlKey||G.metaKey;G.shiftKey?H(it,nt):nt?V(_[it]):k(_[it])}),x.addEventListener("contextmenu",G=>{let J=G.target.closest(".tree-row");J&&(G.preventDefault(),z(_[Number(J.dataset.row)],G.clientX,G.clientY))});function Y(){p>=0&&x.clientHeight>0&&(N(p),p=-1),R()}new ResizeObserver(Y).observe(x),n.addEventListener("change",()=>{let G=-1;d.fill(0);for(let J of n.values())d[l[J]]++,G=J;if(w){R();return}y=null,G>=0?D(G):R()}),s.root?.addEventListener("change",G=>G.detail.kind==="visibility"&&R()),E()}var _p={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},eM={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},Ml=4;function xp(i){let t=K("div","ioviewer-context-menu");t.setAttribute("role","menu"),t.setAttribute("aria-label",q("contextMenu")),t.hidden=!0,i.append(t);let e=new Map(Object.values(_p).flat().filter(c=>c!=="-").map(c=>[c,{enabled:!1,handler:null}])),n=null;function s(){if(t.hidden)return;let c=t.contains(document.activeElement)?n:null;n=null,t.hidden=!0,t.replaceChildren(),window.removeEventListener("pointerdown",o,!0),window.removeEventListener("wheel",s,!0),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",s),c?.()}function r(c){i.contains(c.target)||s()}function o(c){t.contains(c.target)||(s(),fl(c))}function a(c,h,d,u,f=null){let m=_p[c];if(!m)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let p of m){if(p==="-"){let M=K("div","ioviewer-menu-separator");M.setAttribute("role","separator"),t.append(M);continue}let y=e.get(p),w=K("button","ioviewer-menu-item");w.type="button",w.tabIndex=-1,w.dataset.item=p,w.setAttribute("role","menuitem"),w.setAttribute("aria-disabled",String(!y.enabled)),y.enabled||(w.title=q("menu.unavailable")),w.append(K("span","",q(`menu.${p}`)),K("kbd","",eM[p]??"")),w.addEventListener("click",()=>{y.enabled&&(s(),y.handler(u))}),t.append(w)}t.hidden=!1;let{width:_,height:g}=t.getBoundingClientRect();t.style.left=`${Math.max(Ml,Math.min(h,innerWidth-_-Ml))}px`,t.style.top=`${Math.max(Ml,Math.min(d,innerHeight-g-Ml))}px`,window.addEventListener("pointerdown",o,!0),window.addEventListener("wheel",s,!0),window.addEventListener("scroll",r,!0),window.addEventListener("resize",s),f&&t.querySelector("button")?.focus({preventScroll:!0})}t.addEventListener("keydown",c=>{if(c.key==="Tab"){s();return}if(c.key==="Escape"){c.preventDefault(),s();return}let h=[...t.querySelectorAll("button")],d=h.indexOf(document.activeElement),u;switch(c.key){case"ArrowDown":u=(d+1)%h.length;break;case"ArrowUp":u=(d+h.length-1)%h.length;break;case"Home":u=0;break;case"End":u=h.length-1;break;default:return}c.preventDefault(),h[u]?.focus({preventScroll:!0})});function l(c,{enabled:h=!0,handler:d}){let u=e.get(c);if(!u)throw new RangeError(`Unknown menu item: ${c}`);d&&(u.handler=d),u.enabled=h&&!!u.handler}return{element:t,open:a,close:s,setItem:l,get isOpen(){return!t.hidden}}}var nM=1600;function vp(i,t,e){let n=()=>i.textContent=`${q("selected")}: ${Ci(t.size)} \xB7 ${q("elements")}: ${Ci(e)}`;t.addEventListener("change",n),n()}function yp(i,t){if(!t)return;let e=K("div","ioviewer-banner ioviewer-floating");e.setAttribute("role","status");let n=q("truncated").replace("{meshes}",t.meshes).replace("{total}",t.totalMeshes),s=tn("ioviewer-panel-close",oe.close,q("close")),r=new ResizeObserver(()=>i.style.setProperty("--banner-height",`${e.offsetHeight}px`));s.addEventListener("click",()=>{r.disconnect(),i.style.removeProperty("--banner-height"),e.remove()}),e.append(K("span","",n),s),i.append(e),r.observe(e)}function Xs(i,t){let e=K("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),nM)}function Mp(i,t){let e=K("table");for(let[s,r]of t)e.insertRow().append(K("th","",s),K("td","",String(r??"")));let n=K("section");return n.append(K("h3","",i),e),n}function bp(i,t,e){let n=K("h2","ioviewer-properties-title"),s=K("button","ioviewer-properties-close","\xD7");s.type="button",s.title=q("close"),s.setAttribute("aria-label",q("close")),s.addEventListener("click",()=>t.clear());let r=K("header");r.append(n,s);let o=K("div","ioviewer-properties-body");i.replaceChildren(r,o),i.hidden=!0;let a=h=>{let d=[[q("id"),h.id],[q("category"),h.category],[q("type"),h.type],[q("level"),h.level]];return h.sourceId&&d.push([q("sourceId"),h.sourceId]),h.link&&d.push([q("link"),h.link]),Mp(q("elementGroup"),d)},l=h=>{for(let[d,u]of Object.entries(h??{}))o.append(Mp(d,Object.entries(u)))},c;t.addEventListener("change",()=>{if(c?.abort(),c=void 0,o.removeAttribute("aria-busy"),i.hidden=t.size===0,o.replaceChildren(),t.size!==1){n.textContent=`${q("selected")}: ${t.size}`;return}let[h]=t.values(),d=e.meta.elements[h];if(n.textContent=d.name||`#${d.id}`,o.append(a(d)),!e.loadProperties){l(e.props(d.id));return}let u=new AbortController;c=u,o.setAttribute("aria-busy","true"),e.loadProperties(h,u.signal).then(f=>{u.signal.aborted||!f||(n.textContent=f.name||d.name||`#${d.id}`,o.replaceChildren(a({...d,...f})),l(f.properties))}).catch(()=>{u.signal.aborted||o.append(K("p","",q("badData")))}).finally(()=>{c===u&&o.removeAttribute("aria-busy")})})}var Ji=["length_m","area_m2","volume_m3"],iM=new Set(["elementId","categoryId","typeId",...Ji]),Sp=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,wp=new Intl.Collator(void 0,{sensitivity:"base"}),Ep="TOTAL",Tp="SUBTOTAL",bl="element_count";function sM(i){let t=[],e=[],n="",s=!1,r=!1;for(let o=0;oh!==e.length-1&&!(o&&c[n]===wp&&c.length===t.length)):e,l=new Map;for(let c=0;c{let a=o[t].trim(),l=s?Pp(a):a;return{row:o,key:l,missing:s?!Number.isFinite(l):!a}});return r.sort((o,a)=>{if(o.missing||a.missing)return Number(o.missing)-Number(a.missing);let l=s?o.key-a.key:bp.compare(o.key,a.key);return n?l:-l}),r.map(({row:o})=>o)}function Cp(i,t){let e=new Map;return t.forEach((n,s)=>e.set(n[i.idColumn],s)),{rows:t,rowById:e}}function Ip(i,t,e=-1,n=!0){let s=i.columns.indexOf("category");if(s<0)return t;let r=new Map;for(let l of t.rows){let c=l[s];r.has(c)||r.set(c,[]),r.get(c).push(l)}let o=[...r].sort(([l],[c])=>{if(!l||!c)return+!l-+!c;let h=bp.compare(l,c);return e===s&&!n?-h:h}).map(([l,c])=>{let h=Wh(i,c);return e>=0&&e!==s&&(c=Rp(c,e,i.columns[e],n)),{category:l,rows:c,totals:h}}),a=0;for(let l of o)l.start=a,a+=l.rows.length;return{...Cp(i,o.flatMap(l=>l.rows)),groups:o}}function Wh(i,t){return Ji.map(e=>{let n=i.columns.indexOf(e);if(n<0)return null;let s=0,r=!1;for(let o of t){let a=Pp(o[n].trim());Number.isFinite(a)&&(s+=a,r=!0)}return r&&Number.isFinite(s)?s:null})}function Pp(i){return Mp.test(i)?Number(i):NaN}function Lp(i,t,e=null,n=null){let s=e!==null&&!i.includes(bl),r=s?[...i,bl]:i,o=[r.map(Gh).join(",")],a=c=>{for(let h of c)o.push(h.map(Gh).join(",")+(s?",":""))},l=(c,h,d,u="")=>{let f=r.map(m=>{if(m==="elementId")return c;if(m===bl)return String(h);if(m==="category")return u;let _=d[Ji.indexOf(m)];return _==null?"":String(_)});o.push(f.map(Gh).join(","))};if(n)for(let c of n)a(c.rows),l(wp,c.rows.length,c.totals,c.category);else a(t);return e!==null&&l(Sp,t.length,e),"\uFEFF"+o.join(`\r +`&&o++,t.push(e),e=[]}else if(a==='"'&&!n&&!r)s=!0;else{if(r||a==='"')throw new Error("Invalid CSV quoting");n+=a}}if(s)throw new Error("Unclosed CSV field");return(e.length||n||r)&&t.push([...e,n]),t}function Ap(i){let[t,...e]=sM(i.replace(/^\uFEFF/,"")),n=t?.indexOf("elementId")??-1;if(n<0||new Set(t).size!==t.length)throw new Error("Missing or duplicate CSV columns");let s=e[e.length-1],r=s?.[n]===Ep&&s.length===t.length&&t.includes(bl),o=t.includes("category"),a=r?e.filter((c,h)=>h!==e.length-1&&!(o&&c[n]===Tp&&c.length===t.length)):e,l=new Map;for(let c=0;c{let o=t[r[i.idColumn]],a=r[e];return o!==null&&(o===void 0||!a?.trim()||o===a)}),s=i.rows.length-n.length;return{csv:s?{...i,...Wh(i,n)}:i,conflicts:s}}function Cp(i,t,e){let n=t.trim().toLowerCase();if(!n&&e===null)return i;let s=i.columns.indexOf("name"),r=i.columns.indexOf("category"),o=[],a=new Map;for(let l of i.rows){let c=l[i.idColumn];e!==null&&l[r]!==e||n&&!c.includes(n)&&!l[s]?.toLowerCase().includes(n)||(a.set(c,o.length),o.push(l))}return{rows:o,rowById:a}}function Ip(i,t,e,n){return Wh(i,Pp(t.rows,e,i.columns[e],n))}function Pp(i,t,e,n){let s=iM.has(e),r=i.map(o=>{let a=o[t].trim(),l=s?Dp(a):a;return{row:o,key:l,missing:s?!Number.isFinite(l):!a}});return r.sort((o,a)=>{if(o.missing||a.missing)return Number(o.missing)-Number(a.missing);let l=s?o.key-a.key:wp.compare(o.key,a.key);return n?l:-l}),r.map(({row:o})=>o)}function Wh(i,t){let e=new Map;return t.forEach((n,s)=>e.set(n[i.idColumn],s)),{rows:t,rowById:e}}function Lp(i,t,e=-1,n=!0){let s=i.columns.indexOf("category");if(s<0)return t;let r=new Map;for(let l of t.rows){let c=l[s];r.has(c)||r.set(c,[]),r.get(c).push(l)}let o=[...r].sort(([l],[c])=>{if(!l||!c)return+!l-+!c;let h=wp.compare(l,c);return e===s&&!n?-h:h}).map(([l,c])=>{let h=Xh(i,c);return e>=0&&e!==s&&(c=Pp(c,e,i.columns[e],n)),{category:l,rows:c,totals:h}}),a=0;for(let l of o)l.start=a,a+=l.rows.length;return{...Wh(i,o.flatMap(l=>l.rows)),groups:o}}function Xh(i,t){return Ji.map(e=>{let n=i.columns.indexOf(e);if(n<0)return null;let s=0,r=!1;for(let o of t){let a=Dp(o[n].trim());Number.isFinite(a)&&(s+=a,r=!0)}return r&&Number.isFinite(s)?s:null})}function Dp(i){return Sp.test(i)?Number(i):NaN}function Np(i,t,e=null,n=null){let s=e!==null&&!i.includes(bl),r=s?[...i,bl]:i,o=[r.map(Gh).join(",")],a=c=>{for(let h of c)o.push(h.map(Gh).join(",")+(s?",":""))},l=(c,h,d,u="")=>{let f=r.map(m=>{if(m==="elementId")return c;if(m===bl)return String(h);if(m==="category")return u;let _=d[Ji.indexOf(m)];return _==null?"":String(_)});o.push(f.map(Gh).join(","))};if(n)for(let c of n)a(c.rows),l(Tp,c.rows.length,c.totals,c.category);else a(t);return e!==null&&l(Ep,t.length,e),"\uFEFF"+o.join(`\r `)+`\r -`}function Gh(i){let t=i.trimStart(),e=/^[+-]/.test(t)&&Mp.test(t.trimEnd());return(/^[\t\r\n]/.test(i)||!e&&/^[=+@-]/.test(t))&&(i="'"+i),/[",\r\n]/.test(i)?'"'+i.replace(/"/g,'""')+'"':i}var Sl=100,Dp=["elementId","name","category",...Ji],sM=new Intl.NumberFormat(Pn,{maximumSignificantDigits:6}).format,Np=(i,t)=>q(i).replace(/\{(\w+)\}/g,(e,n)=>t[n]);function Up(i){let t=K("dl","ioviewer-csv-totals");t.setAttribute("aria-label",i);let e=["elements",...Ji.map(n=>`csv.quantity.${n}`)].map(n=>{let s=K("dd"),r=K("div");return r.append(K("dt","",q(n)),s),t.append(r),s});return{element:t,update(n,s){e[0].textContent=Zi(n),s.forEach((r,o)=>{e[o+1].textContent=r===null?"\u2014":`${sM(r)} ${q(`csv.unit.${Ji[o]}`)}`})}}}function Fp(i,t,e){let n=new Map;t.forEach((it,z)=>{it.sourceId!=null&&n.set(it.sourceId,z)});let s=K("input");s.type="file",s.accept=".csv,text/csv",s.hidden=!0,s.setAttribute("aria-label",q("csv.open"));let r=K("div","ioviewer-csv-actions"),o=K("button","ioviewer-text-button",q("csv.open")),a=K("button","ioviewer-text-button",q("csv.download"));o.type=a.type="button",a.disabled=!0,o.addEventListener("click",()=>s.click()),r.append(o,a);let l=K("p","ioviewer-csv-status",q("csv.choose"));l.setAttribute("role","status");let c=K("div","ioviewer-csv-filters"),h=K("input");h.type="search",h.placeholder=q("csv.searchPlaceholder"),h.setAttribute("aria-label",q("csv.search"));let d=K("select");d.setAttribute("aria-label",q("category"));let u=K("label","ioviewer-csv-group-toggle"),f=K("input");f.type="checkbox",u.append(f,K("span","",q("csv.groupByCategory"))),c.append(h,d,u);let m=Up(q("csv.totals"));m.element.setAttribute("aria-live","polite"),m.element.setAttribute("aria-atomic","true");let _=K("p","ioviewer-csv-feedback",q("csv.outsideFilters"));_.setAttribute("aria-live","polite");let g=K("p","ioviewer-csv-feedback",q("csv.noResults")),p=K("div","ioviewer-csv-scroll"),y=K("table");y.setAttribute("aria-label",q("panel.elements"));let E=y.createTHead(),M=y.createTBody();p.append(y);let x=K("div","ioviewer-csv-pagination"),S=K("button","ioviewer-text-button",q("csv.previous")),A=K("button","ioviewer-text-button",q("csv.next"));S.type=A.type="button";let v=K("span");x.append(S,v,A),c.hidden=m.element.hidden=_.hidden=g.hidden=p.hidden=x.hidden=!0,i.append(r,s,l,c,m.element,_,p,g,x);let w,R,L,N,B,D=-1,F=!0,H=0,V=0,k=new Map,U=[],O;function Y(){let it=O?[...k.values(),O]:k.values();for(let{index:z,row:$,button:st}of it){let gt=String(e.has(z));$.dataset.selected=gt,st.setAttribute("aria-pressed",gt)}}function G(it,z){let $=z[w.idColumn],st=n.get($),gt=it.insertRow(),ht;for(let _t of B){let Bt=gt.insertCell();_t===w.idColumn&&st!==void 0?(ht=K("button","ioviewer-csv-element",$),ht.type="button",Bt.append(ht)):(Bt.textContent=z[_t],Bt.title=z[_t])}return st===void 0?gt.title=q("csv.noGeometry"):(gt.dataset.linked="true",gt.addEventListener("click",()=>e.set([st]))),{id:$,index:st,row:gt,button:ht}}function J(){for(let st of U)st.remove();U=[],k=new Map;let it=H*Sl,z=Math.min(it+Sl,L.rows.length);function $(st,gt,ht){for(let _t=gt;_t=ht)continue;let _t=y.createTBody();U.push(_t);let Bt=K("th","ioviewer-csv-group-heading");Bt.scope="rowgroup",Bt.colSpan=B.length;let Ft=K("div","ioviewer-csv-group-summary"),Wt=Up(q("csv.categoryTotals"));Wt.update(st.rows.length,st.totals),Ft.append(K("strong","",st.category||q("noCategory")),Wt.element),Bt.append(Ft),_t.insertRow().append(Bt),$(_t,gt,ht)}else{let st=y.createTBody();U.push(st),$(st,it,z)}Y(),g.hidden=L.rows.length!==0,x.hidden=L.rows.length<=Sl,v.textContent=Np("csv.range",{first:it+1,last:z,total:L.rows.length}),S.disabled=H===0,A.disabled=z===L.rows.length}function rt(){if(!w)return;let it,z;for(let $ of e.values()){let st=t[$]?.sourceId;if(!w.rowById.has(st))continue;let gt=L.rowById.get(st);if(gt===void 0){z=st;break}let ht=Math.floor(gt/Sl);ht!==H&&(H=ht,J()),it=k.get($)?.row;break}z!==O?.id&&(M.replaceChildren(),O=z===void 0?void 0:G(M,w.rows[w.rowById.get(z)])),_.hidden=!O,p.hidden=!O&&L.rows.length===0,Y(),(O?.row??it)?.scrollIntoView({block:"nearest",inline:"nearest"})}function nt(){L=Tp(w,h.value,d.selectedIndex>0?d.value:null),N=Wh(w,L.rows),m.update(L.rows.length,N),m.element.hidden=!1,f.checked?L=Ip(w,L,D,F):D!==-1&&(L=Ap(w,L,D,F)),H=0,J(),p.scrollTop=0,rt()}a.addEventListener("click",()=>{let it=new Blob([Lp(w.columns,L.rows,N,L.groups)],{type:"text/csv;charset=utf-8"}),z=URL.createObjectURL(it),$=K("a");$.href=z,$.download=R,$.hidden=!0,document.body.append($);try{$.click()}finally{$.remove(),setTimeout(()=>URL.revokeObjectURL(z),1e3)}}),S.addEventListener("click",()=>{H--,J(),p.scrollTop=0}),A.addEventListener("click",()=>{H++,J(),p.scrollTop=0}),h.addEventListener("input",nt),d.addEventListener("change",nt),f.addEventListener("change",nt),e.addEventListener("change",rt),s.addEventListener("change",async()=>{let it=s.files[0];if(!it)return;let z=++V;s.value="",a.disabled=!0,l.textContent=q("csv.loading");try{let $=await it.text();if(z!==V)return;w=Ep($),R=it.name.replace(/\.csv$/i,"")+"-filtered.csv",D=-1,F=!0,B=[...Dp.filter(_t=>w.columns.includes(_t)),...w.columns.filter(_t=>!Dp.includes(_t))].map(_t=>w.columns.indexOf(_t)),E.replaceChildren();let st=E.insertRow();for(let _t of B){let Bt=K("th");Bt.scope="col";let Ft=w.columns[_t],Wt=K("button","ioviewer-csv-sort");Wt.type="button",Wt.title=Ft;let te=K("span","ioviewer-csv-sort-indicator");te.setAttribute("aria-hidden","true"),Wt.append(K("span","ioviewer-csv-sort-label",Ft),te),Wt.addEventListener("click",()=>{F=D!==_t||!F,D=_t,st.querySelector("[aria-sort]")?.removeAttribute("aria-sort"),Bt.setAttribute("aria-sort",F?"ascending":"descending"),nt()}),Bt.append(Wt),st.append(Bt)}let gt=0;for(let _t of n.keys())w.rowById.has(_t)&>++;l.textContent=Np(gt?"csv.loaded":"csv.noMatch",{file:it.name,matched:gt,total:w.rows.length});let ht=w.columns.indexOf("category");if(d.hidden=ht<0,u.hidden=d.hidden,f.checked=!1,d.replaceChildren(new Option(q("csv.allCategories"),"")),ht>=0){let _t=[...new Set(w.rows.map(Bt=>Bt[ht]))];_t.sort((Bt,Ft)=>Bt.localeCompare(Ft));for(let Bt of _t)d.add(new Option(Bt||q("noCategory"),Bt))}c.hidden=w.rows.length===0,h.value="",M.replaceChildren(),O=void 0,nt(),a.disabled=!1}catch{z===V&&(l.textContent=q("csv.invalid"),a.disabled=!w)}})}async function rM(i){if(await navigator.clipboard?.writeText(i).then(()=>!0,()=>!1))return!0;let t=document.createElement("textarea");t.value=i,t.setAttribute("readonly",""),t.className="ioviewer-offscreen",document.body.append(t),t.select();try{return document.execCommand("copy")}finally{t.remove()}}function Bp({root:i,data:t,scene:e,controls:n,picker:s,selection:r,measure:o}){let{meta:a}=t,l=()=>n.fitBox(e.visibleBox()),c={hide:e.setVisible&&(()=>r.size&&e.setVisible([...r.values()],!1)),isolate:e.isolate&&(()=>r.size&&e.isolate([...r.values()])),showAll:e.showAll&&(()=>e.showAll()),zoomTo:()=>{if(!r.size)return l();let[E,...M]=r.values(),x=e.elementBox(E);for(let S of M)x.union(e.elementBox(S));n.zoomToBox(x)},fitAll:l},h=cp(i);h.registerPanel("model",{icon:re.model,title:q("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:E=>pp(E,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:g,zoomToElement:M=>n.zoomToBox(e.elementBox(M))})}),a.elementCsv&&h.registerPanel("elements",{icon:re.elements,title:q("panel.elements"),render:E=>Fp(E,a.elements,r)});let d=document.createElement("aside");d.id="ioviewer-properties",d.className="ioviewer-floating",i.append(d),yp(d,r,t);let u=up(i,hp),f=E=>{n.is2D&&E==="orbit"||(n.setLeftButtonMode(E),u.setActive("orbit",E==="orbit"),u.setActive("pan",E==="pan"))};u.setHandler("orbit",()=>f("orbit")),u.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),u.setHandler("fit",l),u.setHandler("projection",()=>{if(n.is2D)return;let E=!n.camera.isOrthographicCamera;n.setProjection(E?"orthographic":"perspective"),u.setActive("projection",E)}),u.setActive("projection",!1);let m=()=>{let E=!!n.is2D;u.setActive("mode2d",E),u.setEnabled("orbit",!E),u.setEnabled("projection",!E),u.setActive("projection",E||n.camera.isOrthographicCamera),u.setActive("orbit",!E&&n.leftButtonMode==="orbit"),u.setActive("pan",E||n.leftButtonMode==="pan")};u.setHandler("mode2d",()=>{n.set2DMode(!n.is2D,e.visibleBox(),!1),m()}),m(),document.fullscreenEnabled&&(u.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{u.setActive("fullscreen",!!document.fullscreenElement),Xs(i,q("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>u.setActive("fullscreen",!!document.fullscreenElement)));let _=gp(i);function g(E,M,x,S){_.open(x===null?"empty":"element",E,M,x,S)}function p(E){if(_.isOpen)return;let M=E===document.body,x=(M?n.dom:E).getBoundingClientRect(),S=M?x.left+x.width/2:x.left,A=M?x.top+x.height/2:x.bottom;g(S,A,r.values().next().value??null,()=>E.focus({preventScroll:!0}))}_.setItem("properties",{handler:E=>r.set([E])});for(let E of["hide","isolate","showAll","zoomTo","fitAll"])_.setItem(E,{handler:c[E]});_.setItem("copyId",{handler:E=>rM(String(a.elements[E].id)).then(M=>Xs(i,q(M?"idCopied":"copyFailed")),()=>Xs(i,q("copyFailed")))}),n.addEventListener("contextmenu",async E=>{let{x:M,y:x}=E.detail;if(o?.active)return g(M,x,r.values().next().value??null);let S=s.pick(M,x),A=S?.then?await S:S;if(A!==void 0){if(!A||A.element<0)return g(M,x,null);r.has(A.element)||r.set([A.element]),g(M,x,A.element)}});let y=[];return window.addEventListener("keydown",E=>{if(E.defaultPrevented)return;let M=dp(E);if(M){if(E.preventDefault(),M==="contextMenu")return p(document.activeElement??document.body);if(M==="escape"&&!_.isOpen){y.some(x=>x())||r.clear();return}_.close(),M!=="escape"&&c[M]?.()}}),_p(document.getElementById("ioviewer-status"),r,e.elementCount),xp(i,a.truncated),{shell:h,toolbar:u,contextMenu:_,sync2DState:m,onEscape:E=>y.push(E)}}var Xh={x:new C(1,0,0),y:new C(0,1,0),z:new C(0,0,1)};function qh(i){let t=Xh[i];if(!t)throw new RangeError(`Unknown axis: ${i}`);return t.clone()}function wl(i,t,e){if(t.length===0)return!1;let n=s=>s.distanceToPoint(i)<0;return e?t.every(n):t.some(n)}function Op(i,t,e,n){let s=i.clone().normalize(),r=s.dot(t)+e;return n?new Ae(s,-r):new Ae(s.negate(),r)}function zp(i,t,e=0){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);let{min:n,max:s}=i,r=[new Ae(new C(1,0,0),-n.x),new Ae(new C(-1,0,0),s.x),new Ae(new C(0,1,0),-n.y),new Ae(new C(0,-1,0),s.y),new Ae(new C(0,0,1),-n.z),new Ae(new C(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new C);for(let a of r){let l=a.distanceToPoint(o);a.normal.applyAxisAngle(Xh.z,e),a.constant=l-a.normal.dot(o)}}return t==="keepInside"?{planes:r,intersection:!1}:{planes:r.map(o=>o.negate()),intersection:!0}}function kp(i,t,e,n,s,r){let o=i.clone();if(n>0?o.max[e]=Math.max(i.max[e]+s,i.min[e]+r):o.min[e]=Math.min(i.min[e]-s,i.max[e]-r),t!==0){let a=o.getCenter(new C).sub(i.getCenter(new C));o.translate(a.clone().applyAxisAngle(Xh.z,t).sub(a))}return o}function Hp(i){let{min:t,max:e}=i;return Array.from({length:8},(n,s)=>new C(s&1?e.x:t.x,s&2?e.y:t.y,s&4?e.z:t.z))}function Vp(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=Hp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function El(i,t){let e=i.getSize(new C).multiplyScalar(.5);return Math.abs(t.x)*e.x+Math.abs(t.y)*e.y+Math.abs(t.z)*e.z}function qr(i,t,e){let n=t.clone().sub(i.origin),s=e.dot(i.direction),r=1-s*s;return r<.03?null:(s*i.direction.dot(n)-e.dot(n))/r}function Tl(i,t,e){let n=new C(1,0,0).applyQuaternion(t),s=new C(0,1,0).applyQuaternion(t),[r,o,a,l]=[1/0,-1/0,1/0,-1/0];for(let h of Hp(i)){h.sub(e);let d=h.dot(n),u=h.dot(s);[r,o,a,l]=[Math.min(r,d),Math.max(o,d),Math.min(a,u),Math.max(l,u)]}return{center:e.clone().addScaledVector(n,(r+o)/2).addScaledVector(s,(a+l)/2),width:(o-r)*1.1,height:(l-a)*1.1}}var Yr=6,oM=["off","planes","box"],aM=.05,Yh=new C(0,0,1),Al=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new C),this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this.boxMode="keepInside",this.fill=!1,this.gizmoVisible=!0,this._mode="off",n&&this.restore(n)}restore({planes:t,box:e,cutInside:n}){this.modelBox.isEmpty()||(this.planes=t.map(({axis:s,normal:r,offset:o,flipped:a})=>{let l=new C().fromArray(r),c=new Fe().setFromUnitVectors(Yh,l);return{axis:s,quaternion:c,offset:o-l.dot(this.center),flipped:a,enabled:!0,rotated:!1}}),this.active=this.planes.length?0:-1,this.box=e?new oe(new C().fromArray(e.min),new C().fromArray(e.max)):null,this.boxYaw=0,this.boxMode=n?"cutInside":"keepInside",this.gizmoVisible=!1,this.setMode(this.box?"box":this.planes.length?"planes":"off"))}get mode(){return this._mode}setMode(t){if(!oM.includes(t))throw new RangeError(`Unknown section mode: ${t}`);t==="box"&&!this.box&&this.fitBoxToShown()||(this._mode=t,this._changed(!0))}addPlane(t){let e=qh(t);if(this.planes.length>=Yr||this.modelBox.isEmpty())return null;let n=new Fe().setFromUnitVectors(Yh,e);return this.planes.push({axis:t,quaternion:n,offset:0,flipped:!1,enabled:!0,rotated:!1}),this.active=this.planes.length-1,this._mode="planes",this._changed(!0),this.active}removePlane(t){this._plane(t),this.planes.splice(t,1),(this.active>=this.planes.length||this.active>t)&&this.active--,this._changed(!0)}updatePlane(t,{offset:e,flipped:n,enabled:s,quaternion:r}){let o=this._plane(t);if(e!==void 0){if(!Number.isFinite(e))throw new RangeError(`Offset must be a finite number, got ${e}.`);o.offset=e}n!==void 0&&(o.flipped=!!n),s!==void 0&&(o.enabled=!!s),r&&(o.quaternion.copy(r).normalize(),o.rotated=o.axis!=="custom"&&this.normal(t).angleTo(qh(o.axis))>1e-6),this._changed(!0)}setActivePlane(t){this._plane(t),this.active=t,this._changed(!1)}normal(t){return Yh.clone().applyQuaternion(this._plane(t).quaternion)}extent(t){return El(this.modelBox,this.normal(t))}origin(t){return this.center.clone().addScaledVector(this.normal(t),this._plane(t).offset)}clipPlane(t){let e=this._plane(t);return Op(this.normal(t),this.center,e.offset,e.flipped)}setBox(t,e=0){if(t.isEmpty())throw new RangeError("The section box is empty.");e=Gp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=Gp(t),this._changed(this.mode==="box"))}setBoxMode(t){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);this.boxMode=t,this._changed(!0)}fitBoxToElements(t){let e=new oe;for(let s of t)e.union(this.scene.elementBox(s));if(e.isEmpty())return!1;let n=e.getSize(new C);return this.setBox(e.expandByScalar(aM*Math.max(n.x,n.y,n.z))),!0}fitBoxToShown(){let t=this.scene.visibleBox();if(t.isEmpty())return!1;let e=t.getSize(new C);return this.setBox(t.expandByScalar(.001*Math.max(e.x,e.y,e.z))),!0}setGizmoVisible(t){this.gizmoVisible=!!t,this._changed(!1)}setFill(t){this.fill=!!t,this._changed(!1)}reset(){this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this._mode="off",this._changed(!0)}clipping(){if(this._mode==="planes")return{planes:this.planes.flatMap((e,n)=>e.enabled?[this.clipPlane(n)]:[]),intersection:!1};if(this._mode==="box"&&this.box){let t=zp(this.box,this.boxMode,this.boxYaw);if(!t.intersection&&this.boxYaw!==0){let e=this.box.getCenter(new C),n=this.box.getSize(new C).multiplyScalar(.5),s=Math.abs(Math.cos(this.boxYaw)),r=Math.abs(Math.sin(this.boxYaw));n.set(s*n.x+r*n.y,r*n.x+s*n.y,n.z),t.bounds=new oe(e.clone().sub(n),e.add(n))}return t}return{planes:[],intersection:!1}}isCut(t,{planes:e,intersection:n,bounds:s}=this.clipping()){return s&&!t.isEmpty()&&!s.intersectsBox(t)||Vp(t,e,n)}_plane(t){let e=this.planes[t];if(!Number.isInteger(t)||!e)throw new RangeError(`Plane index ${t} is out of range 0..${this.planes.length-1}.`);return e}_changed(t){if(t){let{planes:e,intersection:n}=this.clipping();this.scene.setClipping(e,n)}this.dispatchEvent(new Event("change"))}};function Gp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:ae.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var $h=80,lM=8,Jh=.8,cM=Math.sin(ae.degToRad(12)),Ii={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Zh=["x","y","z"],hM=Math.cos(ae.degToRad(12)),Rl=new C(0,0,1),uM=i=>new Je({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),dM=new Je({visible:!1});function Cl(i,t,e,n){let s=new Re,r=uM(t);for(let a of e)s.add(new ge(a,r));let o=new ge(n,dM);return o.userData.handle=s,s.add(o),s.userData={kind:i,color:t,material:r,proxy:o},s.traverse(a=>a.renderOrder=1e3),s}function Kh(i,t,e=n=>n){let n=Cl("rotate",Ii[t],[e(new As(Jh,.018,8,64))],e(new As(Jh,.09,8,48)));return n.name=i,n.userData.axis=t,n}var Il=class extends EventTarget{constructor(t,e){super(),this.sections=t,this.dom=e,this.camera=null,this.group=new Re,this.group.name="sections",this._raycaster=new qn,this._drag=null,this._hovered=null,this._buildPlanes(),this._buildPlaneGizmo(),this._buildBox(),t.addEventListener("change",()=>this._sync()),(e.parentElement??e).addEventListener("pointerdown",n=>this._down(n),!0),e.addEventListener("pointermove",n=>this._move(n)),e.addEventListener("pointerup",n=>this._up(n)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",()=>this._end()),this._sync()}get dragging(){return this._drag!==null}update(t){this.camera=t;let e=this.planeGizmo;e.visible&&(e.scale.setScalar(this._worldPerPixel(e.position)*$h),this.arrow.visible=this._across(Rl.clone().applyQuaternion(e.quaternion),e.position));for(let s of this.boxHandles){let{shown:r,normal:o}=s.userData;s.visible=r&&(!o||this._across(o,s.position)),s.visible&&s.scale.setScalar(this._worldPerPixel(s.position)*lM)}let n=this.boxRing;n.visible&&n.scale.setScalar(this._worldPerPixel(n.position)*$h)}_across(t,e){let n=this.camera,s=n.isOrthographicCamera?n.getWorldDirection(new C):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new C(r/2,o/2,0))),n=new Je({color:Ii.fill,transparent:!0,opacity:.12,side:ke,depthWrite:!1}),s=new sn({color:Ii.frame});this.planeVisuals=Array.from({length:Yr},()=>{let r=new Re;return r.add(new ge(t,n),new zi(e,s)),this.group.add(r),r})}_buildPlaneGizmo(){let t=(n,s)=>n.rotateX(Math.PI/2).translate(0,0,s),e=Cl("move",Ii.z,[t(new ki(.025,.025,1),.5),t(new dr(.08,.25),1.125)],t(new ki(.12,.12,1.25),.625));e.name="arrow",this.arrow=e,this.planeGizmo=new Re,this.planeGizmo.add(e,Kh("ringX","x",n=>n.rotateY(Math.PI/2)),Kh("ringY","y",n=>n.rotateX(Math.PI/2))),this.group.add(this.planeGizmo)}_buildBox(){this.boxWire=new ln(new Hi(new gn(1,1,1)),new sn({color:Ii.frame})),this.group.add(this.boxWire);let t=new Wn(1,16,12),e=new Wn(1.6,8,6);this.boxHandles=[];for(let s of Zh)for(let r of[-1,1]){let o=Cl("face",Ii[s],[t],e);o.name=`face${r>0?"+":"-"}${s}`,Object.assign(o.userData,{axis:s,sign:r,normal:new C}),this.boxHandles.push(o)}let n=Cl("centre",Ii.centre,[new gn(1.4,1.4,1.4)],e);n.name="centre",this.boxHandles.push(n),this.boxRing=Kh("boxRing","z"),this.group.add(...this.boxHandles,this.boxRing)}_sync(){let t=this.sections,e=t.mode==="planes";this.planeVisuals.forEach((r,o)=>{let a=t.planes[o];if(r.visible=e&&!!a?.enabled,!r.visible)return;r.children[0].visible=!t.fill;let l=Tl(t.modelBox,a.quaternion,t.origin(o));r.position.copy(l.center),r.quaternion.copy(a.quaternion),r.scale.set(l.width,l.height,1)});let n=t.planes[t.active];this.planeGizmo.visible=e&&t.gizmoVisible&&!!n?.enabled,this.planeGizmo.visible&&(this.planeGizmo.position.copy(t.origin(t.active)),this.planeGizmo.quaternion.copy(n.quaternion));let s=t.mode==="box"?t.box:null;this.boxWire.visible=!!s,this.boxRing.visible=!!s&&t.gizmoVisible;for(let r of this.boxHandles)r.visible=r.userData.shown=!!s&&t.gizmoVisible;if(s){let r=s.getCenter(new C),o=s.getSize(new C);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new C(1e-6,1e-6,1e-6)),this.boxWire.rotation.z=t.boxYaw,this.boxRing.position.copy(r);for(let a of this.boxHandles){let{axis:l,sign:c,normal:h}=a.userData;h?(h.set(0,0,0).setComponent(Zh.indexOf(l),c).applyAxisAngle(Rl,t.boxYaw),a.position.copy(r).addScaledVector(h,o[l]/2)):a.position.copy(r)}}}_worldPerPixel(t){let e=this.camera,n=Math.max(this.dom.clientHeight,1);if(e.isOrthographicCamera)return(e.top-e.bottom)/e.zoom/n;let s=t.clone().sub(e.position).dot(e.getWorldDirection(new C));return 2*Math.max(s,e.near)*Math.tan(ae.degToRad(e.fov/2))/n}_ray(t){let e=this.dom.getBoundingClientRect(),n=new qt((t.clientX-e.left)/e.width*2-1,1-(t.clientY-e.top)/e.height*2);return this.camera.updateMatrixWorld(),this._raycaster.setFromCamera(n,this.camera),this._raycaster.ray.clone()}_hit(t){if(!this.camera)return null;this.update(this.camera),this.group.updateMatrixWorld(!0);let e=r=>{for(;r&&r!==this.group;r=r.parent)if(!r.visible)return!1;return!0},n=[];this.group.traverse(r=>r.userData.handle&&e(r)&&n.push(r)),this._ray(t);let s=this._raycaster.intersectObjects(n,!1);return(this.sections.mode==="box"?s.find(r=>r.object.userData.handle!==this.boxRing):null)??s[0]??null}_down(t){if(t.target!==this.dom||t.button!==0)return;let e=this._hit(t);if(!e)return;let n=e.object.userData.handle,s=this._start(n,this._raycaster.ray,e.point,t);s&&(t.stopPropagation(),t.preventDefault(),this.dom.setPointerCapture(t.pointerId),this._drag={id:t.pointerId,handle:n,...s},this._highlight(n))}_start(t,e,n,s){let r=this.sections,{kind:o}=t.userData;if(o==="move"){let u=r.active,f=r.origin(u),m=r.normal(u),_=qr(e,f,m);return _===null?null:{index:u,origin:f,normal:m,offset:r.planes[u].offset,s0:_}}if(o==="rotate"){let u=r.active,f=t===this.boxRing,m=f?t.position.clone():r.origin(u),_=f?null:r.planes[u].quaternion.clone(),g=f?Rl:new C().setComponent(Zh.indexOf(t.userData.axis),1).applyQuaternion(_),p={index:u,origin:m,quaternion:_,axis:g,yaw:f?r.boxYaw:null};if(Math.abs(g.dot(e.direction))0&&r===0}function gM(i,t){let{instances:e,geometries:n}=t.meta,s=t.readView(e.geometry),{width:r,height:o}=i.slotUniforms.slotState.value.image,a=new Uint8Array(r*o),l=new Map;for(let h=0;hq(i).replace(/\{(\w+)\}/g,(e,n)=>t[n]);function Fp(i){let t=K("dl","ioviewer-csv-totals");t.setAttribute("aria-label",i);let e=["elements",...Ji.map(n=>`csv.quantity.${n}`)].map(n=>{let s=K("dd"),r=K("div");return r.append(K("dt","",q(n)),s),t.append(r),s});return{element:t,update(n,s){e[0].textContent=Ci(n),s.forEach((r,o)=>{e[o+1].textContent=r===null?"\u2014":`${rM(r)} ${q(`csv.unit.${Ji[o]}`)}`})}}}function Bp(i,t,e,n){let s=new Map;t.forEach((O,$)=>{O.sourceId!=null&&s.set(O.sourceId,$)});let r=K("input");r.type="file",r.accept=".csv,text/csv",r.hidden=!0,r.setAttribute("aria-label",q("csv.open"));let o=K("div","ioviewer-csv-actions"),a=K("button","ioviewer-text-button",q("csv.open")),l=K("button","ioviewer-text-button",q("csv.download"));a.type=l.type="button",l.disabled=!0,a.addEventListener("click",()=>r.click()),o.append(a,l);let c=K("p","ioviewer-csv-status",q("csv.choose"));c.setAttribute("role","status");let h=K("div","ioviewer-csv-filters"),d=K("input");d.type="search",d.placeholder=q("csv.searchPlaceholder"),d.setAttribute("aria-label",q("csv.search"));let u=K("select");u.setAttribute("aria-label",q("category"));let f=K("label","ioviewer-csv-group-toggle"),m=K("input");m.type="checkbox",f.append(m,K("span","",q("csv.groupByCategory"))),h.append(d,u,f);let _=Fp(q("csv.totals"));_.element.setAttribute("aria-live","polite"),_.element.setAttribute("aria-atomic","true");let g=K("p","ioviewer-csv-feedback",q("csv.outsideFilters"));g.setAttribute("aria-live","polite");let p=K("p","ioviewer-csv-feedback",q("csv.noResults")),y=K("div","ioviewer-csv-scroll"),w=K("table");w.setAttribute("aria-label",q("panel.elements"));let M=w.createTHead(),x=w.createTBody();y.append(w);let S=K("div","ioviewer-csv-pagination"),A=K("button","ioviewer-text-button",q("csv.previous")),v=K("button","ioviewer-text-button",q("csv.next"));A.type=v.type="button";let E=K("span");S.append(A,E,v),h.hidden=_.element.hidden=g.hidden=p.hidden=y.hidden=S.hidden=!0,i.append(o,r,c,h,_.element,g,y,p,S);let R,L,N,B,D,F=-1,H=!0,V=0,z=0,U=new Map,k=[],Y;function G(){let O=Y?[...U.values(),Y]:U.values();for(let{index:$,row:rt,button:mt}of O){let ht=String(e.has($));rt.dataset.selected=ht,mt.setAttribute("aria-pressed",ht)}}function J(O,$){let rt=$[R.idColumn],mt=s.get(rt),ht=O.insertRow(),Et;for(let Zt of D){let Ct=ht.insertCell();Zt===R.idColumn&&mt!==void 0?(Et=K("button","ioviewer-csv-element",rt),Et.type="button",Ct.append(Et)):(Ct.textContent=$[Zt],Ct.title=$[Zt])}return mt===void 0?ht.title=q("csv.noGeometry"):(ht.dataset.linked="true",ht.addEventListener("click",()=>e.set([mt]))),{id:rt,index:mt,row:ht,button:Et}}function it(){for(let mt of k)mt.remove();k=[],U=new Map;let O=V*Sl,$=Math.min(O+Sl,N.rows.length);function rt(mt,ht,Et){for(let Zt=ht;Zt=Et)continue;let Zt=w.createTBody();k.push(Zt);let Ct=K("th","ioviewer-csv-group-heading");Ct.scope="rowgroup",Ct.colSpan=D.length;let Yt=K("div","ioviewer-csv-group-summary"),Ht=Fp(q("csv.categoryTotals"));Ht.update(mt.rows.length,mt.totals),Yt.append(K("strong","",mt.category||q("noCategory")),Ht.element),Ct.append(Yt),Zt.insertRow().append(Ct),rt(Zt,ht,Et)}else{let mt=w.createTBody();k.push(mt),rt(mt,O,$)}G(),p.hidden=N.rows.length!==0,S.hidden=N.rows.length<=Sl,E.textContent=qh("csv.range",{first:O+1,last:$,total:N.rows.length}),A.disabled=V===0,v.disabled=$===N.rows.length}function nt(){if(!R)return;let O,$;for(let rt of e.values()){let mt=t[rt]?.sourceId;if(!R.rowById.has(mt))continue;let ht=N.rowById.get(mt);if(ht===void 0){$=mt;break}let Et=Math.floor(ht/Sl);Et!==V&&(V=Et,it()),O=U.get(rt)?.row;break}$!==Y?.id&&(x.replaceChildren(),Y=$===void 0?void 0:J(x,R.rows[R.rowById.get($)])),g.hidden=!Y,y.hidden=!Y&&N.rows.length===0,G(),(Y?.row??O)?.scrollIntoView({block:"nearest",inline:"nearest"})}function at(){N=Cp(R,d.value,u.selectedIndex>0?u.value:null),B=Xh(R,N.rows),_.update(N.rows.length,B),_.element.hidden=!1,m.checked?N=Lp(R,N,F,H):F!==-1&&(N=Ip(R,N,F,H)),V=0,it(),y.scrollTop=0,nt()}l.addEventListener("click",()=>{let O=new Blob([Np(R.columns,N.rows,B,N.groups)],{type:"text/csv;charset=utf-8"}),$=URL.createObjectURL(O),rt=K("a");rt.href=$,rt.download=L,rt.hidden=!0,document.body.append(rt);try{rt.click()}finally{rt.remove(),setTimeout(()=>URL.revokeObjectURL($),1e3)}}),A.addEventListener("click",()=>{V--,it(),y.scrollTop=0}),v.addEventListener("click",()=>{V++,it(),y.scrollTop=0}),d.addEventListener("input",at),u.addEventListener("change",at),m.addEventListener("change",at),e.addEventListener("change",nt),r.addEventListener("change",async()=>{let O=r.files[0];if(!O)return;let $=++z;r.value="",l.disabled=!0,c.textContent=q("csv.loading");try{let rt=await O.text();if($!==z)return;let mt=Ap(rt),{csv:ht,conflicts:Et}=Rp(mt,n);R=ht,L=O.name.replace(/\.csv$/i,"")+"-filtered.csv",F=-1,H=!0,D=[...Up.filter(Ht=>R.columns.includes(Ht)),...R.columns.filter(Ht=>!Up.includes(Ht))].map(Ht=>R.columns.indexOf(Ht)),M.replaceChildren();let Zt=M.insertRow();for(let Ht of D){let dt=K("th");dt.scope="col";let Nt=R.columns[Ht],Gt=K("button","ioviewer-csv-sort");Gt.type="button",Gt.title=Nt;let ne=K("span","ioviewer-csv-sort-indicator");ne.setAttribute("aria-hidden","true"),Gt.append(K("span","ioviewer-csv-sort-label",Nt),ne),Gt.addEventListener("click",()=>{H=F!==Ht||!H,F=Ht,Zt.querySelector("[aria-sort]")?.removeAttribute("aria-sort"),dt.setAttribute("aria-sort",H?"ascending":"descending"),at()}),dt.append(Gt),Zt.append(dt)}let Ct=0;for(let Ht of s.keys())R.rowById.has(Ht)&&Ct++;c.textContent=qh(Ct||Et?"csv.loaded":"csv.noMatch",{file:O.name,matched:Ct,total:mt.rows.length}),Et&&c.append(" \xB7 ",qh("csv.conflicts",{count:Ci(Et)}));let Yt=R.columns.indexOf("category");if(u.hidden=Yt<0,f.hidden=u.hidden,m.checked=!1,u.replaceChildren(new Option(q("csv.allCategories"),"")),Yt>=0){let Ht=[...new Set(R.rows.map(dt=>dt[Yt]))];Ht.sort((dt,Nt)=>dt.localeCompare(Nt));for(let dt of Ht)u.add(new Option(dt||q("noCategory"),dt))}h.hidden=R.rows.length===0,d.value="",x.replaceChildren(),Y=void 0,at(),l.disabled=!1}catch{$===z&&(c.textContent=q("csv.invalid"),l.disabled=!R)}})}async function oM(i){if(await navigator.clipboard?.writeText(i).then(()=>!0,()=>!1))return!0;let t=document.createElement("textarea");t.value=i,t.setAttribute("readonly",""),t.className="ioviewer-offscreen",document.body.append(t),t.select();try{return document.execCommand("copy")}finally{t.remove()}}function Op({root:i,data:t,scene:e,controls:n,picker:s,selection:r,measure:o}){let{meta:a}=t,l=()=>n.fitBox(e.visibleBox()),c={hide:e.setVisible&&(()=>r.size&&e.setVisible([...r.values()],!1)),isolate:e.isolate&&(()=>r.size&&e.isolate([...r.values()])),showAll:e.showAll&&(()=>e.showAll()),zoomTo:()=>{if(!r.size)return l();let[w,...M]=r.values(),x=e.elementBox(w);for(let S of M)x.union(e.elementBox(S));n.zoomToBox(x)},fitAll:l},h=up(i);h.registerPanel("model",{icon:oe.model,title:q("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:w=>gp(w,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:g,zoomToElement:M=>n.zoomToBox(e.elementBox(M))})}),a.elementCsv&&h.registerPanel("elements",{icon:oe.elements,title:q("panel.elements"),render:w=>Bp(w,a.elements,r,a.glbUniqueIds)});let d=document.createElement("aside");d.id="ioviewer-properties",d.className="ioviewer-floating",i.append(d),bp(d,r,t);let u=fp(i,dp),f=w=>{n.is2D&&w==="orbit"||(n.setLeftButtonMode(w),u.setActive("orbit",w==="orbit"),u.setActive("pan",w==="pan"))};u.setHandler("orbit",()=>f("orbit")),u.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),u.setHandler("fit",l),u.setHandler("projection",()=>{if(n.is2D)return;let w=!n.camera.isOrthographicCamera;n.setProjection(w?"orthographic":"perspective"),u.setActive("projection",w)}),u.setActive("projection",!1);let m=()=>{let w=!!n.is2D;u.setActive("mode2d",w),u.setEnabled("orbit",!w),u.setEnabled("projection",!w),u.setActive("projection",w||n.camera.isOrthographicCamera),u.setActive("orbit",!w&&n.leftButtonMode==="orbit"),u.setActive("pan",w||n.leftButtonMode==="pan")};u.setHandler("mode2d",()=>{n.set2DMode(!n.is2D,e.visibleBox(),!1),m()}),m(),document.fullscreenEnabled&&(u.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{u.setActive("fullscreen",!!document.fullscreenElement),Xs(i,q("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>u.setActive("fullscreen",!!document.fullscreenElement)));let _=xp(i);function g(w,M,x,S){_.open(x===null?"empty":"element",w,M,x,S)}function p(w){if(_.isOpen)return;let M=w===document.body,x=(M?n.dom:w).getBoundingClientRect(),S=M?x.left+x.width/2:x.left,A=M?x.top+x.height/2:x.bottom;g(S,A,r.values().next().value??null,()=>w.focus({preventScroll:!0}))}_.setItem("properties",{handler:w=>r.set([w])});for(let w of["hide","isolate","showAll","zoomTo","fitAll"])_.setItem(w,{handler:c[w]});_.setItem("copyId",{handler:w=>oM(String(a.elements[w].id)).then(M=>Xs(i,q(M?"idCopied":"copyFailed")),()=>Xs(i,q("copyFailed")))}),n.addEventListener("contextmenu",async w=>{let{x:M,y:x}=w.detail;if(o?.active)return g(M,x,r.values().next().value??null);let S=s.pick(M,x),A=S?.then?await S:S;if(A!==void 0){if(!A||A.element<0)return g(M,x,null);r.has(A.element)||r.set([A.element]),g(M,x,A.element)}});let y=[];return window.addEventListener("keydown",w=>{if(w.defaultPrevented)return;let M=pp(w);if(M){if(w.preventDefault(),M==="contextMenu")return p(document.activeElement??document.body);if(M==="escape"&&!_.isOpen){y.some(x=>x())||r.clear();return}_.close(),M!=="escape"&&c[M]?.()}}),vp(document.getElementById("ioviewer-status"),r,e.elementCount),yp(i,a.truncated),{shell:h,toolbar:u,contextMenu:_,sync2DState:m,onEscape:w=>y.push(w)}}var Yh={x:new C(1,0,0),y:new C(0,1,0),z:new C(0,0,1)};function $h(i){let t=Yh[i];if(!t)throw new RangeError(`Unknown axis: ${i}`);return t.clone()}function wl(i,t,e){if(t.length===0)return!1;let n=s=>s.distanceToPoint(i)<0;return e?t.every(n):t.some(n)}function zp(i,t,e,n){let s=i.clone().normalize(),r=s.dot(t)+e;return n?new Ae(s,-r):new Ae(s.negate(),r)}function kp(i,t,e=0){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);let{min:n,max:s}=i,r=[new Ae(new C(1,0,0),-n.x),new Ae(new C(-1,0,0),s.x),new Ae(new C(0,1,0),-n.y),new Ae(new C(0,-1,0),s.y),new Ae(new C(0,0,1),-n.z),new Ae(new C(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new C);for(let a of r){let l=a.distanceToPoint(o);a.normal.applyAxisAngle(Yh.z,e),a.constant=l-a.normal.dot(o)}}return t==="keepInside"?{planes:r,intersection:!1}:{planes:r.map(o=>o.negate()),intersection:!0}}function Hp(i,t,e,n,s,r){let o=i.clone();if(n>0?o.max[e]=Math.max(i.max[e]+s,i.min[e]+r):o.min[e]=Math.min(i.min[e]-s,i.max[e]-r),t!==0){let a=o.getCenter(new C).sub(i.getCenter(new C));o.translate(a.clone().applyAxisAngle(Yh.z,t).sub(a))}return o}function Vp(i){let{min:t,max:e}=i;return Array.from({length:8},(n,s)=>new C(s&1?e.x:t.x,s&2?e.y:t.y,s&4?e.z:t.z))}function Gp(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=Vp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function El(i,t){let e=i.getSize(new C).multiplyScalar(.5);return Math.abs(t.x)*e.x+Math.abs(t.y)*e.y+Math.abs(t.z)*e.z}function qr(i,t,e){let n=t.clone().sub(i.origin),s=e.dot(i.direction),r=1-s*s;return r<.03?null:(s*i.direction.dot(n)-e.dot(n))/r}function Tl(i,t,e){let n=new C(1,0,0).applyQuaternion(t),s=new C(0,1,0).applyQuaternion(t),[r,o,a,l]=[1/0,-1/0,1/0,-1/0];for(let h of Vp(i)){h.sub(e);let d=h.dot(n),u=h.dot(s);[r,o,a,l]=[Math.min(r,d),Math.max(o,d),Math.min(a,u),Math.max(l,u)]}return{center:e.clone().addScaledVector(n,(r+o)/2).addScaledVector(s,(a+l)/2),width:(o-r)*1.1,height:(l-a)*1.1}}var Yr=6,aM=["off","planes","box"],lM=.05,Zh=new C(0,0,1),Al=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new C),this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this.boxMode="keepInside",this.fill=!1,this.gizmoVisible=!0,this._mode="off",n&&this.restore(n)}restore({planes:t,box:e,cutInside:n}){this.modelBox.isEmpty()||(this.planes=t.map(({axis:s,normal:r,offset:o,flipped:a})=>{let l=new C().fromArray(r),c=new Fe().setFromUnitVectors(Zh,l);return{axis:s,quaternion:c,offset:o-l.dot(this.center),flipped:a,enabled:!0,rotated:!1}}),this.active=this.planes.length?0:-1,this.box=e?new ae(new C().fromArray(e.min),new C().fromArray(e.max)):null,this.boxYaw=0,this.boxMode=n?"cutInside":"keepInside",this.gizmoVisible=!1,this.setMode(this.box?"box":this.planes.length?"planes":"off"))}get mode(){return this._mode}setMode(t){if(!aM.includes(t))throw new RangeError(`Unknown section mode: ${t}`);t==="box"&&!this.box&&this.fitBoxToShown()||(this._mode=t,this._changed(!0))}addPlane(t){let e=$h(t);if(this.planes.length>=Yr||this.modelBox.isEmpty())return null;let n=new Fe().setFromUnitVectors(Zh,e);return this.planes.push({axis:t,quaternion:n,offset:0,flipped:!1,enabled:!0,rotated:!1}),this.active=this.planes.length-1,this._mode="planes",this._changed(!0),this.active}removePlane(t){this._plane(t),this.planes.splice(t,1),(this.active>=this.planes.length||this.active>t)&&this.active--,this._changed(!0)}updatePlane(t,{offset:e,flipped:n,enabled:s,quaternion:r}){let o=this._plane(t);if(e!==void 0){if(!Number.isFinite(e))throw new RangeError(`Offset must be a finite number, got ${e}.`);o.offset=e}n!==void 0&&(o.flipped=!!n),s!==void 0&&(o.enabled=!!s),r&&(o.quaternion.copy(r).normalize(),o.rotated=o.axis!=="custom"&&this.normal(t).angleTo($h(o.axis))>1e-6),this._changed(!0)}setActivePlane(t){this._plane(t),this.active=t,this._changed(!1)}normal(t){return Zh.clone().applyQuaternion(this._plane(t).quaternion)}extent(t){return El(this.modelBox,this.normal(t))}origin(t){return this.center.clone().addScaledVector(this.normal(t),this._plane(t).offset)}clipPlane(t){let e=this._plane(t);return zp(this.normal(t),this.center,e.offset,e.flipped)}setBox(t,e=0){if(t.isEmpty())throw new RangeError("The section box is empty.");e=Wp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=Wp(t),this._changed(this.mode==="box"))}setBoxMode(t){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);this.boxMode=t,this._changed(!0)}fitBoxToElements(t){let e=new ae;for(let s of t)e.union(this.scene.elementBox(s));if(e.isEmpty())return!1;let n=e.getSize(new C);return this.setBox(e.expandByScalar(lM*Math.max(n.x,n.y,n.z))),!0}fitBoxToShown(){let t=this.scene.visibleBox();if(t.isEmpty())return!1;let e=t.getSize(new C);return this.setBox(t.expandByScalar(.001*Math.max(e.x,e.y,e.z))),!0}setGizmoVisible(t){this.gizmoVisible=!!t,this._changed(!1)}setFill(t){this.fill=!!t,this._changed(!1)}reset(){this.planes=[],this.active=-1,this.box=null,this.boxYaw=0,this._mode="off",this._changed(!0)}clipping(){if(this._mode==="planes")return{planes:this.planes.flatMap((e,n)=>e.enabled?[this.clipPlane(n)]:[]),intersection:!1};if(this._mode==="box"&&this.box){let t=kp(this.box,this.boxMode,this.boxYaw);if(!t.intersection&&this.boxYaw!==0){let e=this.box.getCenter(new C),n=this.box.getSize(new C).multiplyScalar(.5),s=Math.abs(Math.cos(this.boxYaw)),r=Math.abs(Math.sin(this.boxYaw));n.set(s*n.x+r*n.y,r*n.x+s*n.y,n.z),t.bounds=new ae(e.clone().sub(n),e.add(n))}return t}return{planes:[],intersection:!1}}isCut(t,{planes:e,intersection:n,bounds:s}=this.clipping()){return s&&!t.isEmpty()&&!s.intersectsBox(t)||Gp(t,e,n)}_plane(t){let e=this.planes[t];if(!Number.isInteger(t)||!e)throw new RangeError(`Plane index ${t} is out of range 0..${this.planes.length-1}.`);return e}_changed(t){if(t){let{planes:e,intersection:n}=this.clipping();this.scene.setClipping(e,n)}this.dispatchEvent(new Event("change"))}};function Wp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:le.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Kh=80,cM=8,Qh=.8,hM=Math.sin(le.degToRad(12)),Pi={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Jh=["x","y","z"],uM=Math.cos(le.degToRad(12)),Rl=new C(0,0,1),dM=i=>new Je({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),fM=new Je({visible:!1});function Cl(i,t,e,n){let s=new Re,r=dM(t);for(let a of e)s.add(new ge(a,r));let o=new ge(n,fM);return o.userData.handle=s,s.add(o),s.userData={kind:i,color:t,material:r,proxy:o},s.traverse(a=>a.renderOrder=1e3),s}function jh(i,t,e=n=>n){let n=Cl("rotate",Pi[t],[e(new As(Qh,.018,8,64))],e(new As(Qh,.09,8,48)));return n.name=i,n.userData.axis=t,n}var Il=class extends EventTarget{constructor(t,e){super(),this.sections=t,this.dom=e,this.camera=null,this.group=new Re,this.group.name="sections",this._raycaster=new qn,this._drag=null,this._hovered=null,this._buildPlanes(),this._buildPlaneGizmo(),this._buildBox(),t.addEventListener("change",()=>this._sync()),(e.parentElement??e).addEventListener("pointerdown",n=>this._down(n),!0),e.addEventListener("pointermove",n=>this._move(n)),e.addEventListener("pointerup",n=>this._up(n)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",()=>this._end()),this._sync()}get dragging(){return this._drag!==null}update(t){this.camera=t;let e=this.planeGizmo;e.visible&&(e.scale.setScalar(this._worldPerPixel(e.position)*Kh),this.arrow.visible=this._across(Rl.clone().applyQuaternion(e.quaternion),e.position));for(let s of this.boxHandles){let{shown:r,normal:o}=s.userData;s.visible=r&&(!o||this._across(o,s.position)),s.visible&&s.scale.setScalar(this._worldPerPixel(s.position)*cM)}let n=this.boxRing;n.visible&&n.scale.setScalar(this._worldPerPixel(n.position)*Kh)}_across(t,e){let n=this.camera,s=n.isOrthographicCamera?n.getWorldDirection(new C):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new C(r/2,o/2,0))),n=new Je({color:Pi.fill,transparent:!0,opacity:.12,side:ke,depthWrite:!1}),s=new sn({color:Pi.frame});this.planeVisuals=Array.from({length:Yr},()=>{let r=new Re;return r.add(new ge(t,n),new ki(e,s)),this.group.add(r),r})}_buildPlaneGizmo(){let t=(n,s)=>n.rotateX(Math.PI/2).translate(0,0,s),e=Cl("move",Pi.z,[t(new Hi(.025,.025,1),.5),t(new dr(.08,.25),1.125)],t(new Hi(.12,.12,1.25),.625));e.name="arrow",this.arrow=e,this.planeGizmo=new Re,this.planeGizmo.add(e,jh("ringX","x",n=>n.rotateY(Math.PI/2)),jh("ringY","y",n=>n.rotateX(Math.PI/2))),this.group.add(this.planeGizmo)}_buildBox(){this.boxWire=new ln(new Vi(new gn(1,1,1)),new sn({color:Pi.frame})),this.group.add(this.boxWire);let t=new Wn(1,16,12),e=new Wn(1.6,8,6);this.boxHandles=[];for(let s of Jh)for(let r of[-1,1]){let o=Cl("face",Pi[s],[t],e);o.name=`face${r>0?"+":"-"}${s}`,Object.assign(o.userData,{axis:s,sign:r,normal:new C}),this.boxHandles.push(o)}let n=Cl("centre",Pi.centre,[new gn(1.4,1.4,1.4)],e);n.name="centre",this.boxHandles.push(n),this.boxRing=jh("boxRing","z"),this.group.add(...this.boxHandles,this.boxRing)}_sync(){let t=this.sections,e=t.mode==="planes";this.planeVisuals.forEach((r,o)=>{let a=t.planes[o];if(r.visible=e&&!!a?.enabled,!r.visible)return;r.children[0].visible=!t.fill;let l=Tl(t.modelBox,a.quaternion,t.origin(o));r.position.copy(l.center),r.quaternion.copy(a.quaternion),r.scale.set(l.width,l.height,1)});let n=t.planes[t.active];this.planeGizmo.visible=e&&t.gizmoVisible&&!!n?.enabled,this.planeGizmo.visible&&(this.planeGizmo.position.copy(t.origin(t.active)),this.planeGizmo.quaternion.copy(n.quaternion));let s=t.mode==="box"?t.box:null;this.boxWire.visible=!!s,this.boxRing.visible=!!s&&t.gizmoVisible;for(let r of this.boxHandles)r.visible=r.userData.shown=!!s&&t.gizmoVisible;if(s){let r=s.getCenter(new C),o=s.getSize(new C);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new C(1e-6,1e-6,1e-6)),this.boxWire.rotation.z=t.boxYaw,this.boxRing.position.copy(r);for(let a of this.boxHandles){let{axis:l,sign:c,normal:h}=a.userData;h?(h.set(0,0,0).setComponent(Jh.indexOf(l),c).applyAxisAngle(Rl,t.boxYaw),a.position.copy(r).addScaledVector(h,o[l]/2)):a.position.copy(r)}}}_worldPerPixel(t){let e=this.camera,n=Math.max(this.dom.clientHeight,1);if(e.isOrthographicCamera)return(e.top-e.bottom)/e.zoom/n;let s=t.clone().sub(e.position).dot(e.getWorldDirection(new C));return 2*Math.max(s,e.near)*Math.tan(le.degToRad(e.fov/2))/n}_ray(t){let e=this.dom.getBoundingClientRect(),n=new qt((t.clientX-e.left)/e.width*2-1,1-(t.clientY-e.top)/e.height*2);return this.camera.updateMatrixWorld(),this._raycaster.setFromCamera(n,this.camera),this._raycaster.ray.clone()}_hit(t){if(!this.camera)return null;this.update(this.camera),this.group.updateMatrixWorld(!0);let e=r=>{for(;r&&r!==this.group;r=r.parent)if(!r.visible)return!1;return!0},n=[];this.group.traverse(r=>r.userData.handle&&e(r)&&n.push(r)),this._ray(t);let s=this._raycaster.intersectObjects(n,!1);return(this.sections.mode==="box"?s.find(r=>r.object.userData.handle!==this.boxRing):null)??s[0]??null}_down(t){if(t.target!==this.dom||t.button!==0)return;let e=this._hit(t);if(!e)return;let n=e.object.userData.handle,s=this._start(n,this._raycaster.ray,e.point,t);s&&(t.stopPropagation(),t.preventDefault(),this.dom.setPointerCapture(t.pointerId),this._drag={id:t.pointerId,handle:n,...s},this._highlight(n))}_start(t,e,n,s){let r=this.sections,{kind:o}=t.userData;if(o==="move"){let u=r.active,f=r.origin(u),m=r.normal(u),_=qr(e,f,m);return _===null?null:{index:u,origin:f,normal:m,offset:r.planes[u].offset,s0:_}}if(o==="rotate"){let u=r.active,f=t===this.boxRing,m=f?t.position.clone():r.origin(u),_=f?null:r.planes[u].quaternion.clone(),g=f?Rl:new C().setComponent(Jh.indexOf(t.userData.axis),1).applyQuaternion(_),p={index:u,origin:m,quaternion:_,axis:g,yaw:f?r.boxYaw:null};if(Math.abs(g.dot(e.direction))0&&r===0}function _M(i,t){let{instances:e,geometries:n}=t.meta,s=t.readView(e.geometry),{width:r,height:o}=i.slotUniforms.slotState.value.image,a=new Uint8Array(r*o),l=new Map;for(let h=0;h ${zr} #include @@ -4414,12 +4414,12 @@ void main() { void main() { #include gl_FragColor = vec4( 0.0 ); -}`,side:e,stencilZPass:n,stencilWrite:!0,clipping:!0,clippingPlanes:[t],colorWrite:!1,depthTest:!1,depthWrite:!1});return s.index0AttributeName="q",s}var Pl=class{constructor(t,e,n,s){this.model=t,this.sections=e,this.data=n,this.drawStencils=s,this._farSide=new Ae,this._surface=new ge(new cn(1,1),new Je({color:pM,side:ke,forceSinglePass:!0,stencilWrite:!0,stencilFunc:Gc,stencilWriteMask:0}))}render(t,e,n){let{sections:s,model:r}=this,{planes:o,intersection:a}=s.clipping(),l=a?o.map(u=>u.clone().negate()):o,c=u=>Math.abs(u.distanceToPoint(s.center)){if(!c(f))return;let _=u?-f.normal.dot(u):f.distanceToPoint(n.position);if(_===0)return;if(this._farSide.copy(f),_>0&&this._farSide.negate(),t.clearStencil(),this.drawStencils)this.drawStencils(t,n,this._farSide);else for(let p of this._stencils)r.withMaterial(p,()=>t.render(r.root,n),{section:!0});this._surface.quaternion.setFromUnitVectors(fM,f.normal);let g=Tl(s.modelBox,this._surface.quaternion,f.coplanarPoint(new C));this._surface.position.copy(g.center),this._surface.scale.set(g.width,g.height,1),h.clippingPlanes=l.filter((p,y)=>y!==m),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=d}}};function $r(i,t,e){let n=K("div","ioviewer-segmented");n.setAttribute("role","group"),n.setAttribute("aria-label",i);let s=t.map(([o,a])=>{let l=K("button","",a);return l.type="button",l.dataset.value=o,l.addEventListener("click",()=>e(o)),n.append(l),l});return{element:n,update:o=>s.forEach(a=>a.setAttribute("aria-pressed",String(a.dataset.value===o)))}}function jh(i,t){let e=K("label","ioviewer-check"),n=K("input");return n.type="checkbox",n.addEventListener("change",()=>t(n.checked)),e.append(n,K("span","",i)),{element:e,input:n}}function _M(i,t){let e=K("li","ioviewer-section-plane");e.addEventListener("pointerdown",()=>i.active!==t&&i.setActivePlane(t));let n=K("span","ioviewer-section-name"),s=tn("ioviewer-icon-button",re.flip,q("sections.flip"));s.addEventListener("click",()=>i.updatePlane(t,{flipped:!i.planes[t].flipped}));let r=jh(q("sections.enabled"),h=>i.updatePlane(t,{enabled:h})),o=tn("ioviewer-icon-button",re.remove,q("sections.delete"));o.addEventListener("click",()=>i.removePlane(t));let a=K("input","ioviewer-section-slider");a.type="range",a.step="any",a.setAttribute("aria-label",q("sections.position")),a.addEventListener("input",()=>i.updatePlane(t,{offset:Number(a.value)}));let l=K("div","ioviewer-section-head");return l.append(n,s,r.element,o),e.append(l,a),{element:e,update:()=>{let h=i.planes[t],d=h.rotated?` (${q("sections.rotated")})`:"",u=h.axis==="custom"?q("sections.custom"):h.axis.toUpperCase();n.textContent=`${t+1}. ${u}${d}`,e.classList.toggle("active",i.active===t),s.setAttribute("aria-pressed",String(h.flipped)),r.input.checked=h.enabled;let f=i.extent(t);a.min=String(Math.min(-f,h.offset)),a.max=String(Math.max(f,h.offset)),a.value=String(h.offset)}}}function Xp({root:i,shell:t,toolbar:e,contextMenu:n,sections:s,selection:r,canFill:o,hasMeshes:a=!0}){let l="z",c=()=>{s.addPlane(l)===null&&(s.setMode("planes"),Xs(i,q("sections.maxPlanes")))},h=()=>[...r.values()],d=()=>s.fitBoxToElements(h()),u=$r(q("sections.mode"),[["planes",q("sections.planes")],["box",q("sections.box")],["off",q("sections.off")]],F=>s.setMode(F)),f=$r(q("sections.axis"),["x","y","z"].map(F=>[F,F.toUpperCase()]),F=>f.update(l=F));f.update(l);let m=K("button","ioviewer-text-button",q("sections.addPlane"));m.type="button",m.addEventListener("click",c);let _=K("ul","ioviewer-section-list"),g=K("div","ioviewer-section-empty",q("sections.noPlanes")),p=K("div","ioviewer-section-block"),y=K("div","ioviewer-section-row");y.append(K("span","",q("sections.axis")),f.element,m),p.append(y,_,g);let E=$r(q("sections.box"),[["keepInside",q("sections.keepInside")],["cutInside",q("sections.cutInside")]],F=>s.setBoxMode(F)),M=K("button","ioviewer-text-button",q("sections.fitSelection"));M.type="button",M.addEventListener("click",d);let x=K("input","ioviewer-section-slider");Object.assign(x,{type:"range",min:"-180",max:"180",step:"1"}),x.addEventListener("input",()=>s.setBoxYaw(Number(x.value)*Math.PI/180));let S=K("span");S.setAttribute("aria-hidden","true");let A=K("label","ioviewer-section-row");A.append(K("span","",q("sections.boxYaw")),x,S);let v=K("div","ioviewer-section-block");v.append(E.element,A,M);let w=jh(q("sections.showGizmo"),F=>s.setGizmoVisible(F)),R=jh(q("sections.fill"),F=>s.setFill(F));o||(R.element.title=q(a?"sections.fillUnavailable":"sections.fillNeedsMeshes"));let L=[],N=()=>{u.update(s.mode),p.hidden=s.mode!=="planes",v.hidden=s.mode!=="box",m.disabled=s.planes.length>=Yr,L.length!==s.planes.length&&(L=s.planes.map((H,V)=>_M(s,V)),_.replaceChildren(...L.map(H=>H.element))),L.forEach(H=>H.update()),g.hidden=L.length>0,E.update(s.boxMode),x.value=String(Math.round(s.boxYaw*180/Math.PI)),S.textContent=`${x.value}\xB0`,x.setAttribute("aria-valuetext",S.textContent),w.input.checked=s.gizmoVisible,R.input.checked=s.fill;let F=s.mode==="box"||s.mode==="planes"&&s.planes.some(H=>H.enabled);R.input.disabled=!o||!F,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},B=()=>M.disabled=r.size===0;if(t.registerPanel("sections",{icon:re.sections,title:q("panel.sections"),visible:!s.modelBox.isEmpty(),render:F=>F.append(u.element,p,v,R.element,w.element)}),s.addEventListener("change",N),r.addEventListener("change",B),N(),B(),s.modelBox.isEmpty())return;let D=()=>t.openPanel("sections");e.setHandler("plane",()=>{c(),D()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&d()||s.fitBoxToShown())&&D()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:F=>{s.fitBoxToElements(r.has(F)?h():[F]),D()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var xM="#facc15",vM=9;function Qh(i,t=Pn){return`${new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}).format(i)} ${q("unit.m",t)}`}var Ll=class extends EventTarget{constructor(t){super(),this.active=!1,this.points=[],this.preview=null,this.group=new Re,this.group.name="measure";let e=new he;e.setAttribute("position",new xe(new Float32Array(6),3));let n={color:xM,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Oi(e,new sn(n)),this._markers=new wn(e,new Vn({...n,size:vM,sizeAttenuation:!1}));for(let s of[this._line,this._markers])s.frustumCulled=!1,s.renderOrder=1001,this.group.add(s);this.label=K("div","ioviewer-measure-label"),this.label.hidden=!0,this._previewMarker=K("div","ioviewer-measure-preview"),this._previewMarker.hidden=!0,this._previewMarker.setAttribute("aria-hidden","true"),t.prepend(this.label,this._previewMarker),this._sync()}get distance(){return this.points.length===2?this.points[0].distanceTo(this.points[1]):null}get box(){return new oe().setFromPoints(this.points)}setActive(t){this.active=!!t,this.active||(this.points=[],this.setPreview(null)),this._sync()}add(t){this.active&&(this.points=this.points.length===1?[this.points[0],t.clone()]:[t.clone()],this._sync())}clear(){return this.points.length===0?!1:(this.points=[],this._sync(),!0)}setPreview(t){!this.preview&&!t||(this.preview=t,this._previewMarker.hidden=!t,t&&(this._previewMarker.dataset.kind=t.kind),this.dispatchEvent(new Event("previewchange")))}update(t,e){this.preview&&Wr(this._previewMarker,this.preview.point,t,e),this.distance!==null&&Wr(this.label,this.points[0].clone().lerp(this.points[1],.5),t,e)}_sync(){let t=this._line.geometry.attributes.position;this.points.forEach((e,n)=>t.setXYZ(n,e.x,e.y,e.z)),t.needsUpdate=!0,this._line.geometry.setDrawRange(0,this.points.length),this._line.visible=this.points.length===2,this._markers.visible=this.points.length>0,this.label.hidden=this.distance===null,this.distance!==null&&(this.label.textContent=Qh(this.distance)),this.dispatchEvent(new Event("change"))}};var Zr=8,yM=1-1e-6,MM=8,qp={vertex:0,midpoint:1,edge:2},bM=2e4;function SM(i,t){let e=new Map,n=new Uint32Array(i.length/3);for(let d=0;d0&&(_.normalize(),l(u,f,_),l(f,m,_),l(m,u,_))}let c=[],h=new Set;for(let{lo:d,hi:u,count:f,crease:m}of s.values())f!==1&&!m||(c.push(d,u),h.add(d),h.add(u));return{edges:c,vertices:h}}function Dl(i,t,e){return t<0&&e<0?!1:(t<0&&(i[0]=Math.max(i[0],t/(t-e))),e<0&&(i[1]=Math.min(i[1],t/(t-e))),i[0]<=i[1])}function Yp(i,t,e,n,s,r){let o=[0,1];if(!Dl(o,e.w+e.z,n.w+n.z)||!Dl(o,e.w-e.z,n.w-n.z))return[];if(!r||!s.length)return s.every(c=>Dl(o,c.distanceToPoint(i),c.distanceToPoint(t)))?[o]:[];let a=o.slice();if(!s.every(c=>{let h=c.distanceToPoint(i),d=c.distanceToPoint(t);return(h<0||d<0)&&Dl(a,-h,-d)}))return[o];let l=[];return o[0]0))return null;let g=ae.clamp(((r-c)*f+(o-h)*m)/_,0,1);return e+(n-e)*(g*a.w/((1-g)*l.w+g*a.w))}var Nl=class{constructor(t,e,n){this.picker=t,this.sections=e,this.data=n,this.cache=new Map}release(){this.data.releaseBinary(),this.cache.clear()}_geometry(t){let e=this.cache.get(t);if(e)this.cache.delete(t);else{let n=this.data.meta.geometries[t],s=Hs({view:this.data.readView},n),r=this.data.readView(n.indices);if(n.kind==="lines"){let o=[],a=new Set,l=r.length-r.length%2;for(let c=0;cMM&&this.cache.delete(this.cache.keys().next().value),e}target(t,e){let n=this.picker.measureTile(t,e,Zr+1);if(!n)return null;if(n.pointSample)return{kind:"vertex",point:n.point.clone()};let{rect:s}=n,r=t-s.left,o=e-s.top,{camera:a,scene:l}=this.picker,{planes:c,intersection:h}=this.sections.clipping(),d=new Zt().multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),u=a.matrixWorldInverse.elements,f=null;function m(x,S,A,v){if(f&&qp[x]>qp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[w,R]=qs(A,s);if(!(w>=0&&R>=0&&wZr**2||f?.kind===x&&L>=f.distance||x!=="edge"&&wl(S,c,h))return;let N=-(u[2]*S.x+u[6]*S.y+u[10]*S.z+u[14]);N-n.depthAt(w,R,v)>2*Cn+Math.abs(N)*2**-21||(f={kind:x,distance:L,point:S.clone()})}let _=bM*3,g=new Zt,p=new C,y=new ve,{geometry:E,matrix:M}=this.data.meta.instances;for(let x of n.slots){let S=l.slotInstance(x),[A]=this.data.readView({t:"u32",o:E.o+S*4,n:1}),v=this.data.meta.geometries[A],w=Math.max(v.indices.n,v.positions.n/3);if(w>_)continue;_-=w;let{positions:R,vertices:L,edges:N}=this._geometry(A),B=this.data.readView({t:"f32",o:M.o+S*48,n:12});g.set(B[0],B[3],B[6],B[9],B[1],B[4],B[7],B[10],B[2],B[5],B[8],B[11],0,0,0,1);let D=new Map;for(let F of L){let H=new C().fromArray(R,F*3).applyMatrix4(g),V=new ve(H.x,H.y,H.z,1).applyMatrix4(d);D.set(F,[H,V]),m("vertex",H,V,x)}if(f?.kind!=="vertex")for(let F=0;F_)continue;_-=R;let{positions:L,vertices:N,edges:B}=this._geometry(v),D=this.data.readView({t:"f32",o:S.o+A*48,n:12});g.set(D[0],D[3],D[6],D[9],D[1],D[4],D[7],D[10],D[2],D[5],D[8],D[11],0,0,0,1);let F=new Map;for(let H of N){let V=new C().fromArray(L,H*3).applyMatrix4(g),k=new ve(V.x,V.y,V.z,1).applyMatrix4(d);if(F.set(H,[V,k]),k.w>0&&k.z>=-k.w&&k.z<=k.w){let[U,O]=qs(k,s),Y=(U-r)**2+(O-o)**2;Y<=Zr**2&&(!f||f.kind!=="vertex"||Y0&&G.z>=-G.w&&G.z<=G.w){let[J,rt]=qs(G,s),nt=(J-r)**2+(rt-o)**2;nt<=Zr**2&&(!f||f.kind!=="midpoint"||ntr.element)),t.prepend(s),this._layer=s,this.setVisible(this.count>0)}get visible(){return this.group.visible}setVisible(t){this.group.visible=!!t,this._layer.hidden=!t,this.dispatchEvent(new Event("change"))}update(t,e){if(this.visible)for(let{element:n,point:s}of this._labels)Wr(n,s,t,e)}};var wM=8,Zp=4;function tu(i,t,e,n="dialog"){let s=K("div","ioviewer-popover ioviewer-floating");s.setAttribute("role",n),s.setAttribute("aria-label",e),s.hidden=!0,t.setAttribute("aria-haspopup",n),t.setAttribute("aria-expanded","false"),i.append(s);function r(l){s.contains(l.target)||(a(),fl(l))}s.addEventListener("keydown",l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),a(),t.focus())});function o(){s.hidden=!1,t.setAttribute("aria-expanded","true");let l=t.getBoundingClientRect(),{width:c}=s.getBoundingClientRect();s.style.left=`${Math.max(Zp,Math.min(l.left+l.width/2-c/2,innerWidth-c-Zp))}px`,s.style.bottom=`${innerHeight-l.top+wM}px`,window.addEventListener("pointerdown",r,!0),window.addEventListener("resize",a)}function a(){return s.hidden?!1:(s.hidden=!0,t.setAttribute("aria-expanded","false"),window.removeEventListener("pointerdown",r,!0),window.removeEventListener("resize",a),!0)}return{element:s,close:a,toggle:()=>s.hidden?o():a(),get isOpen(){return!s.hidden}}}function EM(i){return i?.initialWireframe?"wireframe":i?.initialWhiteMode?"white":"materials"}function Kp({root:i,toolbar:t,scene:e,meta:n,grids:s,initialBackground:r,setBackground:o,hasMeshes:a=!0}){let l=L=>t.element.querySelector(`[data-tool="${L}"]`),c=l("displayMode"),h=tu(i,c,q("group.display"));h.element.classList.add("ioviewer-display-modes");let d=K("div");d.setAttribute("role","menu"),d.setAttribute("aria-label",q("tool.displayMode")),h.element.append(d);let u=(n.textures??[]).length>0,f=Dh.map(L=>{let N=K("button","ioviewer-menu-item",q(`display.${L}`));return N.type="button",N.dataset.mode=L,N.setAttribute("role","menuitemradio"),N.disabled=L==="textures"&&!u||L==="wireframe"&&!a,N.addEventListener("click",()=>{m(L),h.close(),c.focus()}),d.append(N),N}),m=L=>{e.setDisplayMode(L);for(let N of f)N.setAttribute("aria-checked",String(N.dataset.mode===L))},_=EM(n.options);m(_==="wireframe"&&!a?"materials":_),t.setHandler("displayMode",()=>{h.toggle(),h.isOpen&&d.querySelector('[aria-checked="true"]')?.focus()});let g=K("div","ioviewer-background-setting"),p=K("label","",q("display.background")),y=K("input");Object.assign(y,{type:"color",value:r}),p.append(y);let E=K("button","ioviewer-text-button",q("display.backgroundReset"));E.type="button",E.disabled=!0;let M=()=>{o(y.value),E.disabled=y.value===r};y.addEventListener("input",M),E.addEventListener("click",()=>{y.value=r,y.focus(),M()});let x=K("div","ioviewer-bg-presets");for(let[L,N]of[["#14171c","display.bgCadDark"],["#ffffff","display.bgPaper"]]){let B=K("button","ioviewer-text-button",q(N));B.type="button",B.addEventListener("click",()=>{y.value=L,M()}),x.append(B)}g.append(p,x,E),h.element.append(g),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let S=tu(i,l("opacity"),q("tool.opacity"));S.element.classList.add("ioviewer-opacity");let A=K("input","ioviewer-opacity-slider");Object.assign(A,{type:"range",min:"10",max:"100",step:"1",value:"100"}),A.setAttribute("aria-label",q("opacity.label"));let v=K("output","ioviewer-opacity-value"),w=()=>v.textContent=q("opacity.value").replace("{value}",A.value);A.addEventListener("input",()=>{e.setOpacity(Number(A.value)/100),w()}),w();let R=K("div","ioviewer-opacity-head");return R.append(K("span","",q("opacity.label")),v),S.element.append(R,A),t.setHandler("opacity",S.toggle),[h,S]}var TM=3e3;function Fl(i,t){let e=K("button",i);return e.type="button",e.setAttribute("title",t),e.append(K("span","ioviewer-row-name",t)),e}function Jp({shell:i,toolbar:t,controls:e,scene:n,sections:s,selection:r,restoreLinkedModels:o,views:a,bcfTopics:l}){let c=null,h=K("button","ioviewer-text-button ioviewer-tour");h.type="button";function d(E){E.sections!=null&&s.restore(E.sections),E.hiddenElements!=null&&n.setHiddenElements(E.hiddenElements),E.visibleElements!=null&&n.isolate(E.visibleElements),E.hiddenModelKeys!=null&&o(E.hiddenModelKeys),E.selectedElements!=null&&r.set(E.selectedElements);let M=E.camera.projection==="orthographic";e.setProjection(M?"orthographic":"perspective"),t.setActive("projection",M),e.restoreViewCamera(E.camera)}function u(){d(a[c.next]),c.next=(c.next+1)%a.length;let E=()=>{e.animating?c.frame=requestAnimationFrame(E):c.timer=setTimeout(u,TM)};c.frame=requestAnimationFrame(E)}let f=E=>h.contains(E.target),m=E=>!f(E)&&g(),_=E=>{f(E)&&(E.key==="Enter"||E.key===" ")||(E.key==="Escape"&&(E.preventDefault(),E.stopPropagation()),g())};function g(){c&&(cancelAnimationFrame(c.frame),clearTimeout(c.timer),c=null,window.removeEventListener("pointerdown",m,!0),window.removeEventListener("wheel",g,!0),window.removeEventListener("keydown",_,!0),y())}function p(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",m,!0),window.addEventListener("wheel",g,!0),window.addEventListener("keydown",_,!0),y(),u()}function y(){let E=q(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?re.pause:re.play),h.append(K("span","",E)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?g():p()),y(),i.registerPanel("views",{icon:re.views,title:q("panel.views"),visible:a.length>0,render:E=>{let M=K("div","ioviewer-row-list");for(let x of a){let S=Fl("ioviewer-row ioviewer-view",String(x.name??""));S.addEventListener("click",()=>d(x)),M.append(S)}E.append(h,M)}}),i.registerPanel("bcf",{icon:re.bcf,title:q("panel.bcf"),visible:l.length>0,render:E=>{let M=K("div","ioviewer-row-list");for(let x of l){let S=K("details","ioviewer-bcf-topic");S.append(K("summary","",x.title)),x.status&&S.append(K("p","ioviewer-bcf-status",x.status)),x.description&&S.append(K("p","ioviewer-bcf-description",x.description)),x.viewpoints.length||S.append(K("p","ioviewer-bcf-status",q("bcf.noView"))),x.viewpoints.forEach((A,v)=>{let w=q("bcf.viewpoint").replace("{index}",String(v+1)),R=Fl("ioviewer-row ioviewer-view",w);if(R.addEventListener("click",()=>d(A)),S.append(R),A.missingComponents||A.ambiguousComponents){let L=q("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));S.append(K("p","ioviewer-bcf-status",L))}}),M.append(S)}E.append(M)}})}function jp(i,t){let e=[];for(let[n,s]of[[i.element1Id,i.element1Name],[i.element2Id,i.element2Name]]){let r=n!=null?t.findIndex(o=>o.id!=null&&String(o.id)===String(n)&&!o.mesh):AM(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function AM(i,t){if(t==null)return-1;let e=i.findIndex(n=>n.name===t);return e>=0&&i.findIndex((n,s)=>s>e&&n.name===t)<0?e:-1}var RM=["New","Active","Reviewed","Approved","Resolved"],eu=27,CM=8,IM=14,PM=2,LM=new C(1,-1,.8).normalize();function Qp({shell:i,tests:t,elements:e,scene:n,controls:s,selection:r}){let o=new Re;o.name="clash-marker";let a=new he;a.setAttribute("position",new xe(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new wn(a,new Vn({...l,size:IM,sizeAttenuation:!1}));c.frustumCulled=!1,c.renderOrder=1002,o.add(c),o.visible=!1;let h=null,d=null;function u(){o.visible=!1,h?.removeAttribute("aria-current"),h=null,d=null,s.setExtraBounds("clash",null)}function f(y,E){let M=jp(y,e);M.length?r.set(M):r.clear();let x=new C(...y.point),S=0;for(let w of M){let R=n.elementBox(w);R.isEmpty()||(S=Math.max(S,...R.getSize(new C).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(LM);let v=Math.max(3*S,PM);s.animateTo({position:A.normalize().multiplyScalar(v).add(x),target:x}),a.attributes.position.setXYZ(0,x.x,x.y,x.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=E,d=y,E.setAttribute("aria-current","true"),s.setExtraBounds("clash",new oe(x.clone(),x.clone()))}function m(y){let E=Fl("ioviewer-row ioviewer-clash",String(y.name??""));E.setAttribute("title",`${y.name??""}: ${y.element1Name??""} \u2014 ${y.element2Name??""}`);let M=RM.includes(y.status),x=K("span","ioviewer-clash-status",M?q(`clash.${y.status}`):String(y.status??""));M&&(x.dataset.status=y.status);let S=typeof y.distance=="number"?Qh(y.distance):"";return E.append(x,K("span","ioviewer-clash-distance",S)),y===d&&(h=E,E.setAttribute("aria-current","true")),E.addEventListener("click",()=>f(y,E)),E}function _(y,E){let M=K("div","ioviewer-clash-test"),x=K("button","ioviewer-row ioviewer-clash-header");x.type="button",x.setAttribute("aria-expanded","true");let S=`${y.name??""} (${y.clashes.length})`;x.setAttribute("title",S),x.insertAdjacentHTML("afterbegin",re.chevron),x.append(K("span","ioviewer-row-name",S));let A=K("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,y.clashes.length*eu-1)}px`,x.addEventListener("click",()=>{A.hidden=!A.hidden,x.setAttribute("aria-expanded",String(!A.hidden)),E()}),M.append(x,A),{box:M,list:A,clashes:y.clashes,rows:new Map}}function g({list:y,clashes:E,rows:M},{start:x,end:S}){for(let[v,w]of M)(v=S)&&(w.remove(),M.delete(v));let A=null;for(let v=S-1;v>=x;v--){let w=M.get(v);w||(w=m(E[v]),w.style.top=`${v*eu}px`,y.insertBefore(w,A),M.set(v,w)),A=w}}function p(y){if(!t.length)return;y.classList.add("ioviewer-clashes-body");let E=t.map(x=>_(x,M));for(let x of E)y.append(x.box);function M(){let x=y.scrollTop,S=y.clientHeight,A=E.map(({list:v,clashes:w})=>S&&!v.hidden?Vh(x-v.offsetTop,eu,S,w.length,CM):{start:0,end:0});E.forEach((v,w)=>g(v,A[w]))}y.addEventListener("scroll",M),y.addEventListener("focusin",M),new ResizeObserver(M).observe(y)}return i.registerPanel("clashes",{icon:re.clashes,title:q("panel.clashes"),visible:t.length>0,render:p,onClose:()=>o.visible&&u()}),{group:o}}var DM=["construct","demolish","temporary"],NM=Date.parse("0002-01-01T00:00:00Z");function tm(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=NM?t:NaN}function em(i,t){let e=new Map(t.flatMap((o,a)=>o.mesh||o.id==null?[]:[[String(o.id),a]])),n=[];for(let o of Array.isArray(i?.tasks)?i.tasks:[]){let a=tm(o?.start),l=tm(o?.end);if(!(a<=l))continue;let c=DM.includes(o.type)?o.type:"construct",h=Array.isArray(o.attachedElements)?o.attachedElements:[];n.push({name:o.name,type:c,start:a,end:l,elements:h.map(d=>e.get(String(d))).filter(d=>d!==void 0)})}let s=n.reduce((o,a)=>Math.min(o,a.start),1/0),r=n.reduce((o,a)=>Math.max(o,a.end),-1/0);return{start:s,end:r,tasks:n}}function nm(i,t){let e=new Set,n=new Map;for(let s of i){let r=ts.end,a=s.type==="construct"?r:s.type==="demolish"?o:r||o;for(let l of s.elements)a?e.add(l):!r&&!o&&n.set(l,s.type)}for(let s of e)n.delete(s);return{hidden:e,active:n}}var UM=864e5,FM=["1","5","15"],BM={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function im({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=em(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:re.timeliner,title:q("panel.timeliner"),visible:!1,render:()=>{}}),null;let o=new Intl.DateTimeFormat(void 0,{dateStyle:"short",timeZone:"UTC"}),a=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}),l=r.start,c=1,h=0,d=0,u=!1,f=new Set,m=new Map,_=K("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",q("player.title")),_.hidden=!0;let g=tn("ioviewer-icon-button ioviewer-player-play",re.play,q("player.play"));g.addEventListener("click",()=>h?N():L());let p=K("output","ioviewer-player-date"),y=K("input","ioviewer-player-slider");Object.assign(y,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),y.setAttribute("aria-label",q("player.date")),y.addEventListener("input",()=>A(Number(y.value)));let E=$r(q("player.speed"),FM.map(D=>[D,`${D}\xD7`]),D=>{c=Number(D),E.update(D)});E.update(String(c));let M=tn("ioviewer-panel-close",re.close,q("close"));M.addEventListener("click",w),_.append(g,p,y,E.element,M),i.append(_),new ResizeObserver(()=>{let D=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${D}px`)}).observe(_);function S(){let D=nm(r.tasks,l),F=[...f].filter(U=>!D.hidden.has(U)),H=[...D.hidden].filter(U=>!f.has(U));f=D.hidden;let V=[...m.keys()].filter(U=>D.active.get(U)!==m.get(U)),k=new Map;for(let[U,O]of D.active)m.get(U)!==O&&(k.has(O)||k.set(O,[]),k.get(O).push(U));m=D.active,F.length&&s.setLayerHidden("schedule",F,!1),H.length&&s.setLayerHidden("schedule",H,!0),V.length&&s.setTint(V,null);for(let[U,O]of k)s.setTint(O,BM[U])}function A(D){l=Math.min(Math.max(D,r.start),r.end),y.value=String(l),p.textContent=a.format(l),u&&S()}function v(){u||(u=!0,_.hidden=!1,A(r.start))}function w(){u&&(N(),u=!1,s.setTint([...m.keys()],null),m=new Map,f=new Set,s.clearLayer("schedule"),_.hidden=!0)}function R(D){A(l+Math.max(D-d,0)/1e3*c*UM),d=D,l>=r.end?N():h=requestAnimationFrame(R)}function L(){v(),!h&&(l>=r.end&&A(r.start),d=performance.now(),h=requestAnimationFrame(R),B())}function N(){cancelAnimationFrame(h),h=0,B()}function B(){let D=q(h?"player.pause":"player.play");g.innerHTML=h?re.pause:re.play,g.title=D,g.setAttribute("aria-label",D)}return t.registerPanel("timeliner",{icon:re.timeliner,title:q("panel.timeliner"),render:D=>{let F=K("button","ioviewer-text-button ioviewer-player-open");F.type="button",F.insertAdjacentHTML("afterbegin",re.play),F.append(K("span","",q("player.play"))),F.addEventListener("click",L);let H=K("div","ioviewer-row-list");for(let V of r.tasks){let k=String(V.name??""),U=K("div","ioviewer-row ioviewer-task");U.dataset.type=V.type,U.setAttribute("title",`${k} \xB7 ${q(`task.${V.type}`)}`);let O=`${o.format(V.start)} \u2013 ${o.format(V.end)}`;U.append(K("span","ioviewer-row-name",k),K("span","ioviewer-task-dates",O)),H.append(U)}D.append(F,H)}}),{open:v,close:w,play:L,pause:N,setDate:A,get date(){return l},get isOpen(){return u}}}function sm({shell:i,files:t,elements:e,scene:n}){let s=t.map(o=>({file:o,members:o.members??e.flatMap((a,l)=>a.link!=null&&(a.link===o.name||a.link===o.path)?[l]:[]),input:K("input")})),r=()=>n.replaceLayerHidden("links",s.flatMap(({input:o,members:a})=>o.checked?[]:a));return i.registerPanel("links",{icon:re.links,title:q("panel.links"),visible:s.length>0,render:o=>{let a=K("div","ioviewer-row-list");for(let l of s){let c=String(l.file.name??""),h=K("label","ioviewer-row ioviewer-check ioviewer-link");h.setAttribute("title",`${c} (${l.file.path??""})`);let{input:d}=l;d.type="checkbox",d.checked=l.members.length===0||l.file.visible!==!1,d.disabled=l.members.length===0,d.addEventListener("change",r),h.append(d,K("span","ioviewer-row-name",c),K("span","ioviewer-row-count",String(l.members.length))),a.append(h)}o.append(a),r()}}),o=>{let a=new Set(o);for(let{file:l,input:c}of s)c.checked=c.disabled||!a.has(l.key);r()}}function rm(i,t,e){let n=i.filter(Number.isFinite).sort((a,l)=>a-l),s=[];for(let a of n){let l=s.at(-1);!l||a-l.at(-1)>2/2?s.push([a]):l.push(a)}let r=[];for(let a of s){if(a.length<2)continue;let l=r.at(-1);l&&a[Math.floor(a.length/2)]-l[Math.floor(l.length/2)]<2?l.push(...a):r.push(a)}if(r.length<2)return[];let o=[Math.min(t,n[0])];for(let a=1;a({min:o[l],max:a}))}function om(i,t){return!i||t>=i.min&&t<=i.max}function am(i,t,e,n){let s=Math.min(16,Math.max(.5,i.zoom*t)),r=1/i.zoom-1/s;return{...i,zoom:s,x:i.x+e*i.side*r,y:i.y-n*i.side*r}}function lm(){let i=new pn,t=new Ue(72,1,.15,20);t.up.set(0,0,1);let e=new C,n=new Ie({uniforms:{size:{value:1}},vertexShader:["attribute float intensity;","varying float signal;","uniform float size;","void main() {"," signal = intensity;"," gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);"," gl_PointSize = size;","}"].join(` +}`,side:e,stencilZPass:n,stencilWrite:!0,clipping:!0,clippingPlanes:[t],colorWrite:!1,depthTest:!1,depthWrite:!1});return s.index0AttributeName="q",s}var Pl=class{constructor(t,e,n,s){this.model=t,this.sections=e,this.data=n,this.drawStencils=s,this._farSide=new Ae,this._surface=new ge(new cn(1,1),new Je({color:mM,side:ke,forceSinglePass:!0,stencilWrite:!0,stencilFunc:Gc,stencilWriteMask:0}))}render(t,e,n){let{sections:s,model:r}=this,{planes:o,intersection:a}=s.clipping(),l=a?o.map(u=>u.clone().negate()):o,c=u=>Math.abs(u.distanceToPoint(s.center)){if(!c(f))return;let _=u?-f.normal.dot(u):f.distanceToPoint(n.position);if(_===0)return;if(this._farSide.copy(f),_>0&&this._farSide.negate(),t.clearStencil(),this.drawStencils)this.drawStencils(t,n,this._farSide);else for(let p of this._stencils)r.withMaterial(p,()=>t.render(r.root,n),{section:!0});this._surface.quaternion.setFromUnitVectors(pM,f.normal);let g=Tl(s.modelBox,this._surface.quaternion,f.coplanarPoint(new C));this._surface.position.copy(g.center),this._surface.scale.set(g.width,g.height,1),h.clippingPlanes=l.filter((p,y)=>y!==m),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=d}}};function $r(i,t,e){let n=K("div","ioviewer-segmented");n.setAttribute("role","group"),n.setAttribute("aria-label",i);let s=t.map(([o,a])=>{let l=K("button","",a);return l.type="button",l.dataset.value=o,l.addEventListener("click",()=>e(o)),n.append(l),l});return{element:n,update:o=>s.forEach(a=>a.setAttribute("aria-pressed",String(a.dataset.value===o)))}}function tu(i,t){let e=K("label","ioviewer-check"),n=K("input");return n.type="checkbox",n.addEventListener("change",()=>t(n.checked)),e.append(n,K("span","",i)),{element:e,input:n}}function xM(i,t){let e=K("li","ioviewer-section-plane");e.addEventListener("pointerdown",()=>i.active!==t&&i.setActivePlane(t));let n=K("span","ioviewer-section-name"),s=tn("ioviewer-icon-button",oe.flip,q("sections.flip"));s.addEventListener("click",()=>i.updatePlane(t,{flipped:!i.planes[t].flipped}));let r=tu(q("sections.enabled"),h=>i.updatePlane(t,{enabled:h})),o=tn("ioviewer-icon-button",oe.remove,q("sections.delete"));o.addEventListener("click",()=>i.removePlane(t));let a=K("input","ioviewer-section-slider");a.type="range",a.step="any",a.setAttribute("aria-label",q("sections.position")),a.addEventListener("input",()=>i.updatePlane(t,{offset:Number(a.value)}));let l=K("div","ioviewer-section-head");return l.append(n,s,r.element,o),e.append(l,a),{element:e,update:()=>{let h=i.planes[t],d=h.rotated?` (${q("sections.rotated")})`:"",u=h.axis==="custom"?q("sections.custom"):h.axis.toUpperCase();n.textContent=`${t+1}. ${u}${d}`,e.classList.toggle("active",i.active===t),s.setAttribute("aria-pressed",String(h.flipped)),r.input.checked=h.enabled;let f=i.extent(t);a.min=String(Math.min(-f,h.offset)),a.max=String(Math.max(f,h.offset)),a.value=String(h.offset)}}}function qp({root:i,shell:t,toolbar:e,contextMenu:n,sections:s,selection:r,canFill:o,hasMeshes:a=!0}){let l="z",c=()=>{s.addPlane(l)===null&&(s.setMode("planes"),Xs(i,q("sections.maxPlanes")))},h=()=>[...r.values()],d=()=>s.fitBoxToElements(h()),u=$r(q("sections.mode"),[["planes",q("sections.planes")],["box",q("sections.box")],["off",q("sections.off")]],F=>s.setMode(F)),f=$r(q("sections.axis"),["x","y","z"].map(F=>[F,F.toUpperCase()]),F=>f.update(l=F));f.update(l);let m=K("button","ioviewer-text-button",q("sections.addPlane"));m.type="button",m.addEventListener("click",c);let _=K("ul","ioviewer-section-list"),g=K("div","ioviewer-section-empty",q("sections.noPlanes")),p=K("div","ioviewer-section-block"),y=K("div","ioviewer-section-row");y.append(K("span","",q("sections.axis")),f.element,m),p.append(y,_,g);let w=$r(q("sections.box"),[["keepInside",q("sections.keepInside")],["cutInside",q("sections.cutInside")]],F=>s.setBoxMode(F)),M=K("button","ioviewer-text-button",q("sections.fitSelection"));M.type="button",M.addEventListener("click",d);let x=K("input","ioviewer-section-slider");Object.assign(x,{type:"range",min:"-180",max:"180",step:"1"}),x.addEventListener("input",()=>s.setBoxYaw(Number(x.value)*Math.PI/180));let S=K("span");S.setAttribute("aria-hidden","true");let A=K("label","ioviewer-section-row");A.append(K("span","",q("sections.boxYaw")),x,S);let v=K("div","ioviewer-section-block");v.append(w.element,A,M);let E=tu(q("sections.showGizmo"),F=>s.setGizmoVisible(F)),R=tu(q("sections.fill"),F=>s.setFill(F));o||(R.element.title=q(a?"sections.fillUnavailable":"sections.fillNeedsMeshes"));let L=[],N=()=>{u.update(s.mode),p.hidden=s.mode!=="planes",v.hidden=s.mode!=="box",m.disabled=s.planes.length>=Yr,L.length!==s.planes.length&&(L=s.planes.map((H,V)=>xM(s,V)),_.replaceChildren(...L.map(H=>H.element))),L.forEach(H=>H.update()),g.hidden=L.length>0,w.update(s.boxMode),x.value=String(Math.round(s.boxYaw*180/Math.PI)),S.textContent=`${x.value}\xB0`,x.setAttribute("aria-valuetext",S.textContent),E.input.checked=s.gizmoVisible,R.input.checked=s.fill;let F=s.mode==="box"||s.mode==="planes"&&s.planes.some(H=>H.enabled);R.input.disabled=!o||!F,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},B=()=>M.disabled=r.size===0;if(t.registerPanel("sections",{icon:oe.sections,title:q("panel.sections"),visible:!s.modelBox.isEmpty(),render:F=>F.append(u.element,p,v,R.element,E.element)}),s.addEventListener("change",N),r.addEventListener("change",B),N(),B(),s.modelBox.isEmpty())return;let D=()=>t.openPanel("sections");e.setHandler("plane",()=>{c(),D()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&d()||s.fitBoxToShown())&&D()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:F=>{s.fitBoxToElements(r.has(F)?h():[F]),D()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var vM="#facc15",yM=9;function eu(i,t=Pn){return`${new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}).format(i)} ${q("unit.m",t)}`}var Ll=class extends EventTarget{constructor(t){super(),this.active=!1,this.points=[],this.preview=null,this.group=new Re,this.group.name="measure";let e=new he;e.setAttribute("position",new xe(new Float32Array(6),3));let n={color:vM,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new zi(e,new sn(n)),this._markers=new wn(e,new Vn({...n,size:yM,sizeAttenuation:!1}));for(let s of[this._line,this._markers])s.frustumCulled=!1,s.renderOrder=1001,this.group.add(s);this.label=K("div","ioviewer-measure-label"),this.label.hidden=!0,this._previewMarker=K("div","ioviewer-measure-preview"),this._previewMarker.hidden=!0,this._previewMarker.setAttribute("aria-hidden","true"),t.prepend(this.label,this._previewMarker),this._sync()}get distance(){return this.points.length===2?this.points[0].distanceTo(this.points[1]):null}get box(){return new ae().setFromPoints(this.points)}setActive(t){this.active=!!t,this.active||(this.points=[],this.setPreview(null)),this._sync()}add(t){this.active&&(this.points=this.points.length===1?[this.points[0],t.clone()]:[t.clone()],this._sync())}clear(){return this.points.length===0?!1:(this.points=[],this._sync(),!0)}setPreview(t){!this.preview&&!t||(this.preview=t,this._previewMarker.hidden=!t,t&&(this._previewMarker.dataset.kind=t.kind),this.dispatchEvent(new Event("previewchange")))}update(t,e){this.preview&&Wr(this._previewMarker,this.preview.point,t,e),this.distance!==null&&Wr(this.label,this.points[0].clone().lerp(this.points[1],.5),t,e)}_sync(){let t=this._line.geometry.attributes.position;this.points.forEach((e,n)=>t.setXYZ(n,e.x,e.y,e.z)),t.needsUpdate=!0,this._line.geometry.setDrawRange(0,this.points.length),this._line.visible=this.points.length===2,this._markers.visible=this.points.length>0,this.label.hidden=this.distance===null,this.distance!==null&&(this.label.textContent=eu(this.distance)),this.dispatchEvent(new Event("change"))}};var Zr=8,MM=1-1e-6,bM=8,Yp={vertex:0,midpoint:1,edge:2},SM=2e4;function wM(i,t){let e=new Map,n=new Uint32Array(i.length/3);for(let d=0;d0&&(_.normalize(),l(u,f,_),l(f,m,_),l(m,u,_))}let c=[],h=new Set;for(let{lo:d,hi:u,count:f,crease:m}of s.values())f!==1&&!m||(c.push(d,u),h.add(d),h.add(u));return{edges:c,vertices:h}}function Dl(i,t,e){return t<0&&e<0?!1:(t<0&&(i[0]=Math.max(i[0],t/(t-e))),e<0&&(i[1]=Math.min(i[1],t/(t-e))),i[0]<=i[1])}function $p(i,t,e,n,s,r){let o=[0,1];if(!Dl(o,e.w+e.z,n.w+n.z)||!Dl(o,e.w-e.z,n.w-n.z))return[];if(!r||!s.length)return s.every(c=>Dl(o,c.distanceToPoint(i),c.distanceToPoint(t)))?[o]:[];let a=o.slice();if(!s.every(c=>{let h=c.distanceToPoint(i),d=c.distanceToPoint(t);return(h<0||d<0)&&Dl(a,-h,-d)}))return[o];let l=[];return o[0]0))return null;let g=le.clamp(((r-c)*f+(o-h)*m)/_,0,1);return e+(n-e)*(g*a.w/((1-g)*l.w+g*a.w))}var Nl=class{constructor(t,e,n){this.picker=t,this.sections=e,this.data=n,this.cache=new Map}release(){this.data.releaseBinary(),this.cache.clear()}_geometry(t){let e=this.cache.get(t);if(e)this.cache.delete(t);else{let n=this.data.meta.geometries[t],s=Hs({view:this.data.readView},n),r=this.data.readView(n.indices);if(n.kind==="lines"){let o=[],a=new Set,l=r.length-r.length%2;for(let c=0;cbM&&this.cache.delete(this.cache.keys().next().value),e}target(t,e){let n=this.picker.measureTile(t,e,Zr+1);if(!n)return null;if(n.pointSample)return{kind:"vertex",point:n.point.clone()};let{rect:s}=n,r=t-s.left,o=e-s.top,{camera:a,scene:l}=this.picker,{planes:c,intersection:h}=this.sections.clipping(),d=new Kt().multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),u=a.matrixWorldInverse.elements,f=null;function m(x,S,A,v){if(f&&Yp[x]>Yp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[E,R]=qs(A,s);if(!(E>=0&&R>=0&&EZr**2||f?.kind===x&&L>=f.distance||x!=="edge"&&wl(S,c,h))return;let N=-(u[2]*S.x+u[6]*S.y+u[10]*S.z+u[14]);N-n.depthAt(E,R,v)>2*Cn+Math.abs(N)*2**-21||(f={kind:x,distance:L,point:S.clone()})}let _=SM*3,g=new Kt,p=new C,y=new ve,{geometry:w,matrix:M}=this.data.meta.instances;for(let x of n.slots){let S=l.slotInstance(x),[A]=this.data.readView({t:"u32",o:w.o+S*4,n:1}),v=this.data.meta.geometries[A],E=Math.max(v.indices.n,v.positions.n/3);if(E>_)continue;_-=E;let{positions:R,vertices:L,edges:N}=this._geometry(A),B=this.data.readView({t:"f32",o:M.o+S*48,n:12});g.set(B[0],B[3],B[6],B[9],B[1],B[4],B[7],B[10],B[2],B[5],B[8],B[11],0,0,0,1);let D=new Map;for(let F of L){let H=new C().fromArray(R,F*3).applyMatrix4(g),V=new ve(H.x,H.y,H.z,1).applyMatrix4(d);D.set(F,[H,V]),m("vertex",H,V,x)}if(f?.kind!=="vertex")for(let F=0;F_)continue;_-=R;let{positions:L,vertices:N,edges:B}=this._geometry(v),D=this.data.readView({t:"f32",o:S.o+A*48,n:12});g.set(D[0],D[3],D[6],D[9],D[1],D[4],D[7],D[10],D[2],D[5],D[8],D[11],0,0,0,1);let F=new Map;for(let H of N){let V=new C().fromArray(L,H*3).applyMatrix4(g),z=new ve(V.x,V.y,V.z,1).applyMatrix4(d);if(F.set(H,[V,z]),z.w>0&&z.z>=-z.w&&z.z<=z.w){let[U,k]=qs(z,s),Y=(U-r)**2+(k-o)**2;Y<=Zr**2&&(!f||f.kind!=="vertex"||Y0&&G.z>=-G.w&&G.z<=G.w){let[J,it]=qs(G,s),nt=(J-r)**2+(it-o)**2;nt<=Zr**2&&(!f||f.kind!=="midpoint"||ntr.element)),t.prepend(s),this._layer=s,this.setVisible(this.count>0)}get visible(){return this.group.visible}setVisible(t){this.group.visible=!!t,this._layer.hidden=!t,this.dispatchEvent(new Event("change"))}update(t,e){if(this.visible)for(let{element:n,point:s}of this._labels)Wr(n,s,t,e)}};var EM=8,Kp=4;function nu(i,t,e,n="dialog"){let s=K("div","ioviewer-popover ioviewer-floating");s.setAttribute("role",n),s.setAttribute("aria-label",e),s.hidden=!0,t.setAttribute("aria-haspopup",n),t.setAttribute("aria-expanded","false"),i.append(s);function r(l){s.contains(l.target)||(a(),fl(l))}s.addEventListener("keydown",l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),a(),t.focus())});function o(){s.hidden=!1,t.setAttribute("aria-expanded","true");let l=t.getBoundingClientRect(),{width:c}=s.getBoundingClientRect();s.style.left=`${Math.max(Kp,Math.min(l.left+l.width/2-c/2,innerWidth-c-Kp))}px`,s.style.bottom=`${innerHeight-l.top+EM}px`,window.addEventListener("pointerdown",r,!0),window.addEventListener("resize",a)}function a(){return s.hidden?!1:(s.hidden=!0,t.setAttribute("aria-expanded","false"),window.removeEventListener("pointerdown",r,!0),window.removeEventListener("resize",a),!0)}return{element:s,close:a,toggle:()=>s.hidden?o():a(),get isOpen(){return!s.hidden}}}function TM(i){return i?.initialWireframe?"wireframe":i?.initialWhiteMode?"white":"materials"}function Jp({root:i,toolbar:t,scene:e,meta:n,grids:s,initialBackground:r,setBackground:o,hasMeshes:a=!0}){let l=L=>t.element.querySelector(`[data-tool="${L}"]`),c=l("displayMode"),h=nu(i,c,q("group.display"));h.element.classList.add("ioviewer-display-modes");let d=K("div");d.setAttribute("role","menu"),d.setAttribute("aria-label",q("tool.displayMode")),h.element.append(d);let u=(n.textures??[]).length>0,f=Dh.map(L=>{let N=K("button","ioviewer-menu-item",q(`display.${L}`));return N.type="button",N.dataset.mode=L,N.setAttribute("role","menuitemradio"),N.disabled=L==="textures"&&!u||L==="wireframe"&&!a,N.addEventListener("click",()=>{m(L),h.close(),c.focus()}),d.append(N),N}),m=L=>{e.setDisplayMode(L);for(let N of f)N.setAttribute("aria-checked",String(N.dataset.mode===L))},_=TM(n.options);m(_==="wireframe"&&!a?"materials":_),t.setHandler("displayMode",()=>{h.toggle(),h.isOpen&&d.querySelector('[aria-checked="true"]')?.focus()});let g=K("div","ioviewer-background-setting"),p=K("label","",q("display.background")),y=K("input");Object.assign(y,{type:"color",value:r}),p.append(y);let w=K("button","ioviewer-text-button",q("display.backgroundReset"));w.type="button",w.disabled=!0;let M=()=>{o(y.value),w.disabled=y.value===r};y.addEventListener("input",M),w.addEventListener("click",()=>{y.value=r,y.focus(),M()});let x=K("div","ioviewer-bg-presets");for(let[L,N]of[["#14171c","display.bgCadDark"],["#ffffff","display.bgPaper"]]){let B=K("button","ioviewer-text-button",q(N));B.type="button",B.addEventListener("click",()=>{y.value=L,M()}),x.append(B)}g.append(p,x,w),h.element.append(g),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let S=nu(i,l("opacity"),q("tool.opacity"));S.element.classList.add("ioviewer-opacity");let A=K("input","ioviewer-opacity-slider");Object.assign(A,{type:"range",min:"10",max:"100",step:"1",value:"100"}),A.setAttribute("aria-label",q("opacity.label"));let v=K("output","ioviewer-opacity-value"),E=()=>v.textContent=q("opacity.value").replace("{value}",A.value);A.addEventListener("input",()=>{e.setOpacity(Number(A.value)/100),E()}),E();let R=K("div","ioviewer-opacity-head");return R.append(K("span","",q("opacity.label")),v),S.element.append(R,A),t.setHandler("opacity",S.toggle),[h,S]}var AM=3e3;function Fl(i,t){let e=K("button",i);return e.type="button",e.setAttribute("title",t),e.append(K("span","ioviewer-row-name",t)),e}function jp({shell:i,toolbar:t,controls:e,scene:n,sections:s,selection:r,restoreLinkedModels:o,views:a,bcfTopics:l}){let c=null,h=K("button","ioviewer-text-button ioviewer-tour");h.type="button";function d(w){w.sections!=null&&s.restore(w.sections),w.hiddenElements!=null&&n.setHiddenElements(w.hiddenElements),w.visibleElements!=null&&n.isolate(w.visibleElements),w.hiddenModelKeys!=null&&o(w.hiddenModelKeys),w.selectedElements!=null&&r.set(w.selectedElements);let M=w.camera.projection==="orthographic";e.setProjection(M?"orthographic":"perspective"),t.setActive("projection",M),e.restoreViewCamera(w.camera)}function u(){d(a[c.next]),c.next=(c.next+1)%a.length;let w=()=>{e.animating?c.frame=requestAnimationFrame(w):c.timer=setTimeout(u,AM)};c.frame=requestAnimationFrame(w)}let f=w=>h.contains(w.target),m=w=>!f(w)&&g(),_=w=>{f(w)&&(w.key==="Enter"||w.key===" ")||(w.key==="Escape"&&(w.preventDefault(),w.stopPropagation()),g())};function g(){c&&(cancelAnimationFrame(c.frame),clearTimeout(c.timer),c=null,window.removeEventListener("pointerdown",m,!0),window.removeEventListener("wheel",g,!0),window.removeEventListener("keydown",_,!0),y())}function p(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",m,!0),window.addEventListener("wheel",g,!0),window.addEventListener("keydown",_,!0),y(),u()}function y(){let w=q(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?oe.pause:oe.play),h.append(K("span","",w)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?g():p()),y(),i.registerPanel("views",{icon:oe.views,title:q("panel.views"),visible:a.length>0,render:w=>{let M=K("div","ioviewer-row-list");for(let x of a){let S=Fl("ioviewer-row ioviewer-view",String(x.name??""));S.addEventListener("click",()=>d(x)),M.append(S)}w.append(h,M)}}),i.registerPanel("bcf",{icon:oe.bcf,title:q("panel.bcf"),visible:l.length>0,render:w=>{let M=K("div","ioviewer-row-list");for(let x of l){let S=K("details","ioviewer-bcf-topic");S.append(K("summary","",x.title)),x.status&&S.append(K("p","ioviewer-bcf-status",x.status)),x.description&&S.append(K("p","ioviewer-bcf-description",x.description)),x.viewpoints.length||S.append(K("p","ioviewer-bcf-status",q("bcf.noView"))),x.viewpoints.forEach((A,v)=>{let E=q("bcf.viewpoint").replace("{index}",String(v+1)),R=Fl("ioviewer-row ioviewer-view",E);if(R.addEventListener("click",()=>d(A)),S.append(R),A.missingComponents||A.ambiguousComponents){let L=q("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));S.append(K("p","ioviewer-bcf-status",L))}}),M.append(S)}w.append(M)}})}function Qp(i,t){let e=[];for(let[n,s]of[[i.element1Id,i.element1Name],[i.element2Id,i.element2Name]]){let r=n!=null?t.findIndex(o=>o.id!=null&&String(o.id)===String(n)&&!o.mesh):RM(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function RM(i,t){if(t==null)return-1;let e=i.findIndex(n=>n.name===t);return e>=0&&i.findIndex((n,s)=>s>e&&n.name===t)<0?e:-1}var CM=["New","Active","Reviewed","Approved","Resolved"],iu=27,IM=8,PM=14,LM=2,DM=new C(1,-1,.8).normalize();function tm({shell:i,tests:t,elements:e,scene:n,controls:s,selection:r}){let o=new Re;o.name="clash-marker";let a=new he;a.setAttribute("position",new xe(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new wn(a,new Vn({...l,size:PM,sizeAttenuation:!1}));c.frustumCulled=!1,c.renderOrder=1002,o.add(c),o.visible=!1;let h=null,d=null;function u(){o.visible=!1,h?.removeAttribute("aria-current"),h=null,d=null,s.setExtraBounds("clash",null)}function f(y,w){let M=Qp(y,e);M.length?r.set(M):r.clear();let x=new C(...y.point),S=0;for(let E of M){let R=n.elementBox(E);R.isEmpty()||(S=Math.max(S,...R.getSize(new C).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(DM);let v=Math.max(3*S,LM);s.animateTo({position:A.normalize().multiplyScalar(v).add(x),target:x}),a.attributes.position.setXYZ(0,x.x,x.y,x.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=w,d=y,w.setAttribute("aria-current","true"),s.setExtraBounds("clash",new ae(x.clone(),x.clone()))}function m(y){let w=Fl("ioviewer-row ioviewer-clash",String(y.name??""));w.setAttribute("title",`${y.name??""}: ${y.element1Name??""} \u2014 ${y.element2Name??""}`);let M=CM.includes(y.status),x=K("span","ioviewer-clash-status",M?q(`clash.${y.status}`):String(y.status??""));M&&(x.dataset.status=y.status);let S=typeof y.distance=="number"?eu(y.distance):"";return w.append(x,K("span","ioviewer-clash-distance",S)),y===d&&(h=w,w.setAttribute("aria-current","true")),w.addEventListener("click",()=>f(y,w)),w}function _(y,w){let M=K("div","ioviewer-clash-test"),x=K("button","ioviewer-row ioviewer-clash-header");x.type="button",x.setAttribute("aria-expanded","true");let S=`${y.name??""} (${y.clashes.length})`;x.setAttribute("title",S),x.insertAdjacentHTML("afterbegin",oe.chevron),x.append(K("span","ioviewer-row-name",S));let A=K("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,y.clashes.length*iu-1)}px`,x.addEventListener("click",()=>{A.hidden=!A.hidden,x.setAttribute("aria-expanded",String(!A.hidden)),w()}),M.append(x,A),{box:M,list:A,clashes:y.clashes,rows:new Map}}function g({list:y,clashes:w,rows:M},{start:x,end:S}){for(let[v,E]of M)(v=S)&&(E.remove(),M.delete(v));let A=null;for(let v=S-1;v>=x;v--){let E=M.get(v);E||(E=m(w[v]),E.style.top=`${v*iu}px`,y.insertBefore(E,A),M.set(v,E)),A=E}}function p(y){if(!t.length)return;y.classList.add("ioviewer-clashes-body");let w=t.map(x=>_(x,M));for(let x of w)y.append(x.box);function M(){let x=y.scrollTop,S=y.clientHeight,A=w.map(({list:v,clashes:E})=>S&&!v.hidden?Vh(x-v.offsetTop,iu,S,E.length,IM):{start:0,end:0});w.forEach((v,E)=>g(v,A[E]))}y.addEventListener("scroll",M),y.addEventListener("focusin",M),new ResizeObserver(M).observe(y)}return i.registerPanel("clashes",{icon:oe.clashes,title:q("panel.clashes"),visible:t.length>0,render:p,onClose:()=>o.visible&&u()}),{group:o}}var NM=["construct","demolish","temporary"],UM=Date.parse("0002-01-01T00:00:00Z");function em(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=UM?t:NaN}function nm(i,t){let e=new Map(t.flatMap((o,a)=>o.mesh||o.id==null?[]:[[String(o.id),a]])),n=[];for(let o of Array.isArray(i?.tasks)?i.tasks:[]){let a=em(o?.start),l=em(o?.end);if(!(a<=l))continue;let c=NM.includes(o.type)?o.type:"construct",h=Array.isArray(o.attachedElements)?o.attachedElements:[];n.push({name:o.name,type:c,start:a,end:l,elements:h.map(d=>e.get(String(d))).filter(d=>d!==void 0)})}let s=n.reduce((o,a)=>Math.min(o,a.start),1/0),r=n.reduce((o,a)=>Math.max(o,a.end),-1/0);return{start:s,end:r,tasks:n}}function im(i,t){let e=new Set,n=new Map;for(let s of i){let r=ts.end,a=s.type==="construct"?r:s.type==="demolish"?o:r||o;for(let l of s.elements)a?e.add(l):!r&&!o&&n.set(l,s.type)}for(let s of e)n.delete(s);return{hidden:e,active:n}}var FM=864e5,BM=["1","5","15"],OM={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function sm({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=nm(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:oe.timeliner,title:q("panel.timeliner"),visible:!1,render:()=>{}}),null;let o=new Intl.DateTimeFormat(void 0,{dateStyle:"short",timeZone:"UTC"}),a=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}),l=r.start,c=1,h=0,d=0,u=!1,f=new Set,m=new Map,_=K("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",q("player.title")),_.hidden=!0;let g=tn("ioviewer-icon-button ioviewer-player-play",oe.play,q("player.play"));g.addEventListener("click",()=>h?N():L());let p=K("output","ioviewer-player-date"),y=K("input","ioviewer-player-slider");Object.assign(y,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),y.setAttribute("aria-label",q("player.date")),y.addEventListener("input",()=>A(Number(y.value)));let w=$r(q("player.speed"),BM.map(D=>[D,`${D}\xD7`]),D=>{c=Number(D),w.update(D)});w.update(String(c));let M=tn("ioviewer-panel-close",oe.close,q("close"));M.addEventListener("click",E),_.append(g,p,y,w.element,M),i.append(_),new ResizeObserver(()=>{let D=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${D}px`)}).observe(_);function S(){let D=im(r.tasks,l),F=[...f].filter(U=>!D.hidden.has(U)),H=[...D.hidden].filter(U=>!f.has(U));f=D.hidden;let V=[...m.keys()].filter(U=>D.active.get(U)!==m.get(U)),z=new Map;for(let[U,k]of D.active)m.get(U)!==k&&(z.has(k)||z.set(k,[]),z.get(k).push(U));m=D.active,F.length&&s.setLayerHidden("schedule",F,!1),H.length&&s.setLayerHidden("schedule",H,!0),V.length&&s.setTint(V,null);for(let[U,k]of z)s.setTint(k,OM[U])}function A(D){l=Math.min(Math.max(D,r.start),r.end),y.value=String(l),p.textContent=a.format(l),u&&S()}function v(){u||(u=!0,_.hidden=!1,A(r.start))}function E(){u&&(N(),u=!1,s.setTint([...m.keys()],null),m=new Map,f=new Set,s.clearLayer("schedule"),_.hidden=!0)}function R(D){A(l+Math.max(D-d,0)/1e3*c*FM),d=D,l>=r.end?N():h=requestAnimationFrame(R)}function L(){v(),!h&&(l>=r.end&&A(r.start),d=performance.now(),h=requestAnimationFrame(R),B())}function N(){cancelAnimationFrame(h),h=0,B()}function B(){let D=q(h?"player.pause":"player.play");g.innerHTML=h?oe.pause:oe.play,g.title=D,g.setAttribute("aria-label",D)}return t.registerPanel("timeliner",{icon:oe.timeliner,title:q("panel.timeliner"),render:D=>{let F=K("button","ioviewer-text-button ioviewer-player-open");F.type="button",F.insertAdjacentHTML("afterbegin",oe.play),F.append(K("span","",q("player.play"))),F.addEventListener("click",L);let H=K("div","ioviewer-row-list");for(let V of r.tasks){let z=String(V.name??""),U=K("div","ioviewer-row ioviewer-task");U.dataset.type=V.type,U.setAttribute("title",`${z} \xB7 ${q(`task.${V.type}`)}`);let k=`${o.format(V.start)} \u2013 ${o.format(V.end)}`;U.append(K("span","ioviewer-row-name",z),K("span","ioviewer-task-dates",k)),H.append(U)}D.append(F,H)}}),{open:v,close:E,play:L,pause:N,setDate:A,get date(){return l},get isOpen(){return u}}}function rm({shell:i,files:t,elements:e,scene:n}){let s=t.map(o=>({file:o,members:o.members??e.flatMap((a,l)=>a.link!=null&&(a.link===o.name||a.link===o.path)?[l]:[]),input:K("input")})),r=()=>n.replaceLayerHidden("links",s.flatMap(({input:o,members:a})=>o.checked?[]:a));return i.registerPanel("links",{icon:oe.links,title:q("panel.links"),visible:s.length>0,render:o=>{let a=K("div","ioviewer-row-list");for(let l of s){let c=String(l.file.name??""),h=K("label","ioviewer-row ioviewer-check ioviewer-link");h.setAttribute("title",`${c} (${l.file.path??""})`);let{input:d}=l;d.type="checkbox",d.checked=l.members.length===0||l.file.visible!==!1,d.disabled=l.members.length===0,d.addEventListener("change",r),h.append(d,K("span","ioviewer-row-name",c),K("span","ioviewer-row-count",String(l.members.length))),a.append(h)}o.append(a),r()}}),o=>{let a=new Set(o);for(let{file:l,input:c}of s)c.checked=c.disabled||!a.has(l.key);r()}}function om(i,t,e){let n=i.filter(Number.isFinite).sort((a,l)=>a-l),s=[];for(let a of n){let l=s.at(-1);!l||a-l.at(-1)>2/2?s.push([a]):l.push(a)}let r=[];for(let a of s){if(a.length<2)continue;let l=r.at(-1);l&&a[Math.floor(a.length/2)]-l[Math.floor(l.length/2)]<2?l.push(...a):r.push(a)}if(r.length<2)return[];let o=[Math.min(t,n[0])];for(let a=1;a({min:o[l],max:a}))}function am(i,t){return!i||t>=i.min&&t<=i.max}function lm(i,t,e,n){let s=Math.min(16,Math.max(.5,i.zoom*t)),r=1/i.zoom-1/s;return{...i,zoom:s,x:i.x+e*i.side*r,y:i.y-n*i.side*r}}function cm(){let i=new pn,t=new Ue(72,1,.15,20);t.up.set(0,0,1);let e=new C,n=new Ie({uniforms:{size:{value:1}},vertexShader:["attribute float intensity;","varying float signal;","uniform float size;","void main() {"," signal = intensity;"," gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);"," gl_PointSize = size;","}"].join(` `),fragmentShader:["varying float signal;","void main() {"," vec2 offset = gl_PointCoord - 0.5;"," if (signal == 0.0 || dot(offset, offset) > 0.25) discard;"," gl_FragColor = vec4(vec3(0.12 + 0.88 * signal), 1.0);","}"].join(` -`)}),s=new Be(1,1,{depthTexture:new Gn(1,1)}),r=new qt,o=new pn,a=new Vi,l=new Ie({depthTest:!1,depthWrite:!1,uniforms:{levels:{value:s.texture},depth:{value:s.depthTexture},sampleStep:{value:new qt},range:{value:new qt}},vertexShader:["varying vec2 uvScreen;","void main() { uvScreen = uv; gl_Position = vec4(position, 1.0); }"].join(` +`)}),s=new Be(1,1,{depthTexture:new Gn(1,1)}),r=new qt,o=new pn,a=new Gi,l=new Ie({depthTest:!1,depthWrite:!1,uniforms:{levels:{value:s.texture},depth:{value:s.depthTexture},sampleStep:{value:new qt},range:{value:new qt}},vertexShader:["varying vec2 uvScreen;","void main() { uvScreen = uv; gl_Position = vec4(position, 1.0); }"].join(` `),fragmentShader:["uniform sampler2D levels, depth;","uniform vec2 sampleStep, range;","varying vec2 uvScreen;","float distanceAt(float z) { return range.x * range.y / mix(range.y, range.x, z); }","void main() {"," float center = texture2D(depth, uvScreen).r;"," float anchor = center;"," if (center >= 1.0) {"," for (int y = -1; y <= 1; y++) for (int x = -1; x <= 1; x++)"," anchor = min(anchor, texture2D(depth, uvScreen + vec2(float(x), float(y)) * sampleStep).r);"," }"," float total = 0.0, weight = 0.0;"," if (anchor < 1.0) {"," float d = distanceAt(anchor);"," for (int y = -1; y <= 1; y++) for (int x = -1; x <= 1; x++) {"," vec2 p = uvScreen + vec2(float(x), float(y)) * sampleStep;"," float z = texture2D(depth, p).r;"," if (z >= 1.0 || abs(distanceAt(z) - d) > max(0.08, d * 0.015)) continue;"," float w = 1.0 / (1.0 + float(x * x + y * y));"," total += texture2D(levels, p).r * w;"," weight += w;"," }"," }"," gl_FragColor = vec4(weight > 0.0 ? vec3(total / weight) : vec3(0.063, 0.075, 0.094), 1.0);","}"].join(` -`)}),c=new ge(new cn(2,2),l);return c.frustumCulled=!1,o.add(c),{setScan(h,d){i.clear();for(let m of h){if(!m.geometry.getAttribute("intensity"))continue;let _=new wn(m.geometry,n);_.matrixAutoUpdate=!1,_.matrix.copy(m.matrixWorld),i.add(_)}t.position.copy(d);let u=new oe().setFromObject(i),f=u.getSize(e).length();t.far=Math.max(20,f+d.distanceTo(u.getCenter(e)))},draw(h,d,u){t.aspect=d.aspect,t.fov=d.fov,t.updateProjectionMatrix(),t.lookAt(e.copy(t.position).add(u));let f=h.getPixelRatio();n.uniforms.size.value=5.5*f,h.getDrawingBufferSize(r),s.setSize(r.x,r.y),l.uniforms.sampleStep.value.set(2*f/r.x,2*f/r.y),l.uniforms.range.value.set(t.near,t.far),h.setRenderTarget(s),h.render(i,t),h.setRenderTarget(null),h.render(o,a)}}}var OM=new Intl.NumberFormat(Pn,{maximumFractionDigits:2,minimumFractionDigits:2}),Bl=i=>`${OM.format(i)} ${q("scanMap.metres")}`;function Jn(i,t,e){let n=document.createElement("button");return n.type="button",n.textContent=t,n.title=i,n.setAttribute("aria-label",i),n.addEventListener("click",e),n}function zM(i,t){return[i*.005,t*.005]}function kM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function HM(i,t,e,n,s,r,o){let a=new qn;a.setFromCamera(new qt(n,s),i),a.ray.origin.copy(t),a.near=.05,a.params.Points.threshold=.12;let l=new C,c=new C;for(let h of a.intersectObjects(e,!1))if(l.fromBufferAttribute(h.object.geometry.attributes.position,h.index).applyMatrix4(h.object.matrixWorld),c.copy(l).sub(t).project(i),Math.hypot((c.x-n)*r/2,(c.y-s)*o/2)<=14)return l.z}function cm(i,t,e,n,s,r){if(!e.count)return;let o=new oe().setFromObject(e.root);if(o.isEmpty())return;let a=o.getSize(new C),l=o.getCenter(new C),c={x:l.x,y:l.y,side:Math.max(a.x,a.y,.01)*1.12,zoom:1},h={...c},d=P=>50+100*(P-h.x)*h.zoom/h.side,u=P=>50-100*(P-h.y)*h.zoom/h.side,f=P=>Math.min(96,Math.max(4,P)),m=(P,dt,Tt=!1)=>{let I=d(dt.x),b=u(dt.y);return P.style.left=`${Tt?f(I):I}%`,P.style.top=`${Tt?f(b):b}%`,I>=0&&I<=100&&b>=0&&b<=100},_=t.meta.rtcOffset?.[2]??0,g=t.meta.panoramas??[],p=g.map(P=>new C(...P.position)),y=`ioviewer.scan-levels.v1:${location.pathname}`,E=()=>rm(p.map(P=>P.z+_),o.min.z+_,o.max.z+_),M=null;try{let P=JSON.parse(localStorage.getItem(y));Array.isArray(P)&&(M=P.filter(dt=>Number.isFinite(dt?.min)&&Number.isFinite(dt.max)&&dt.max>dt.min))}catch{M=null}let x=M??E(),S=-1,A=!0,v=P=>om(x[S],P+_),w=document.createElement("details");w.className="ioviewer-floating ioviewer-scan-map",w.open=!matchMedia("(max-width: 600px)").matches;let R=document.createElement("summary");R.textContent=q("scanMap.title");let L=document.createElement("div");L.className="scan-map-plot";let N=document.createElement("canvas");N.width=N.height=300,N.setAttribute("role","img"),N.setAttribute("aria-label",q("scanMap.plan")),N.tabIndex=0;let B=document.createElement("span");B.className="scan-map-camera",B.setAttribute("aria-hidden","true");let D=document.createElement("span");D.className="scan-map-axes",D.textContent="Y \u2191";let F=document.createElement("span");F.className="scan-map-scale",L.append(N,B,D,F),w.append(R,L),i.append(w);let H=e.root.children.reduce((P,dt)=>P+dt.geometry.attributes.position.count,0),V=Math.max(1,Math.ceil(H/6e4)),k=e.root.children.map(P=>{let dt=P.geometry.attributes.position,Tt=new Float32Array(Math.ceil(dt.count/V)*3),I=new C;for(let b=0,Z=0;b{if(U=0,!w.open)return;let P=N.getContext("2d");if(!P)return;P.clearRect(0,0,300,300),P.fillStyle="rgba(160, 185, 201, .33)";for(let[I,b]of k.entries())if(e.root.children[I].visible)for(let Z=0;Z{U||(U=requestAnimationFrame(O))},G=new C,J=null,rt=()=>{if(J){B.hidden=!v(J.position.z),m(B,J.position,!0),B.style.rotate=`${Math.PI/2-J.yaw}rad`;return}B.hidden=!1,m(B,s.camera.position,!0),s.camera.getWorldDirection(G),B.style.rotate=`${Math.atan2(G.x,G.y)}rad`};w.addEventListener("toggle",Y),n.root.addEventListener("change",P=>{P.detail.kind==="visibility"&&Y()}),s.addEventListener("change",rt);let nt=document.createElement("div");nt.className="scan-map-controls";let it=document.createElement("select");it.setAttribute("aria-label",q("scanMap.size"));for(let P of["small","medium","large"])it.add(new Option(q(`scanMap.${P}`),P));it.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=it.value,it.addEventListener("change",()=>{i.dataset.scanMapSize=it.value});let z=(P,dt=0,Tt=0)=>{h=am(h,P,dt,Tt),Y()},$=()=>{h={...c},Y()};nt.append(it,Jn(q("scanMap.zoomOut"),"\u2212",()=>z(.8)),Jn(q("scanMap.zoomIn"),"+",()=>z(1.25)),Jn(q("scanMap.reset"),"\u21BA",$)),w.insertBefore(nt,L),N.addEventListener("wheel",P=>{P.preventDefault();let dt=N.getBoundingClientRect();z(P.deltaY<0?1.15:1/1.15,(P.clientX-dt.left)/dt.width-.5,(P.clientY-dt.top)/dt.height-.5)},{passive:!1});let st;N.addEventListener("pointerdown",P=>{P.button!==0||st||(N.setPointerCapture(P.pointerId),st={id:P.pointerId,x:P.clientX,y:P.clientY})}),N.addEventListener("pointermove",P=>{if(st?.id!==P.pointerId)return;let dt=h.side/(h.zoom*Math.max(1,N.clientWidth));h.x-=(P.clientX-st.x)*dt,h.y+=(P.clientY-st.y)*dt,st.x=P.clientX,st.y=P.clientY,Y()}),N.addEventListener("lostpointercapture",P=>{P.pointerId===st?.id&&(st=void 0)}),N.addEventListener("keydown",P=>{let dt={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[P.key];if(dt){let Tt=h.side/h.zoom/10;h.x+=dt[0]*Tt,h.y+=dt[1]*Tt,Y()}else if(P.key==="+"||P.key==="="||P.key==="-")z(P.key==="-"?.8:1.25);else if(P.key==="0")$();else return;P.preventDefault(),P.stopPropagation()});let gt=document.createElement("div");gt.className="scan-map-controls";let ht=document.createElement("select");ht.setAttribute("aria-label",q("scanMap.levels"));let _t=document.createElement("p");_t.className="scan-map-feedback",_t.setAttribute("role","status");function Bt(){try{localStorage.setItem(y,JSON.stringify(x))}catch{_t.textContent=q("scanMap.levelTemporary")}}function Ft(){ht.replaceChildren(new Option(q("scanMap.allLevels"),"-1")),x.forEach((P,dt)=>ht.add(new Option(`${q("scanMap.level").replace("{n}",dt+1)} \xB7 ${Bl(P.min)} \u2013 ${Bl(P.max)}`,String(dt)))),ht.value=String(S),pt.disabled=S<0;for(let[P,dt]of p.entries())$t.options[P+1].hidden=!v(dt.z);Y(),r()}ht.addEventListener("change",()=>{S=Number(ht.value),_t.textContent="",Ft()});let Wt=Jn(q("scanMap.addLevel"),"+",()=>{if(kt.isClosed()){let P=p.findIndex(dt=>v(dt.z));Dt(Math.max(0,P))}kt.pickLevel()});Wt.disabled=!g.length;let te=Jn(q("scanMap.autoLevels"),q("scanMap.autoButton"),()=>{let P=E(),dt=P.filter(Tt=>!x.some(I=>I.min{S<0||(x.splice(S,1),S=-1,_t.textContent="",Bt(),Ft())});if(gt.append(ht,Wt,te,pt),g.length){let P=Jn(q("scanMap.spheres"),"\u25C9",()=>{A=!A,P.setAttribute("aria-pressed",String(A)),r()});P.setAttribute("aria-pressed","true"),gt.append(P)}w.append(gt,_t);let kt=g.length?VM(i,t,e,Dt,P=>{J=P,P||ft.forEach(dt=>dt.classList.remove("current")),rt()},P=>{S=x.push(P)-1,_t.textContent=q("scanMap.levelAdded"),Bt(),Ft()}):null,$t=document.createElement("select");$t.setAttribute("aria-label",q("scanMap.choosePhoto"));let le=new Option(q("scanMap.choosePhoto"),"");le.disabled=!0,$t.add(le);let ft=[];for(let[P,dt]of g.entries()){let Tt=dt.name||t.meta.elements[dt.element].name||String(P+1);$t.add(new Option(Tt,String(P)));let I=document.createElement("button");I.type="button",I.className="scan-map-station",I.title=Tt,I.setAttribute("aria-label",`${q("scanMap.photo")} \xB7 ${Tt}`),I.addEventListener("click",()=>Dt(P)),ft.push(I),L.append(I)}$t.value="",$t.addEventListener("change",()=>Dt(Number($t.value))),$t.hidden=!g.length,w.append($t),Ft(),!M&&x.length&&Bt();function Dt(P,dt=!1){w.open=!0,$t.value=String(P),ft.forEach((Tt,I)=>Tt.classList.toggle("current",P===I)),kt.open(P,dt),$t.value=""}return{open:Dt,showSphere:(P,dt)=>A&&v(dt)&&n.isVisible(P)}}function VM(i,t,e,n,s,r){let o=document.createElement("section");o.className="ioviewer-floating scan-photo",o.setAttribute("aria-label",q("scanMap.photo")),o.hidden=!0;let a=document.createElement("header"),l=document.createElement("span"),c=document.createElement("div");c.className="scan-photo-actions";let h=Jn(q("scanMap.enlargePhoto"),q("scanMap.enlargePhoto"),()=>{let ft=o.classList.toggle("is-expanded"),Dt=q(ft?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Dt,h.setAttribute("aria-label",Dt),h.setAttribute("aria-pressed",String(ft))});h.setAttribute("aria-pressed","false");let d=document.createElement("button");d.type="button",d.textContent=q("close"),d.addEventListener("click",Ft);let u=!1,f=Jn(q("scanMap.intensity"),q("scanMap.intensity"),()=>{u=!u,le(!1)});f.className="scan-photo-intensity",f.hidden=!0,c.append(f,h,d),a.append(l,c);let m=document.createElement("canvas");m.tabIndex=0,m.setAttribute("aria-label",q("scanMap.photoControls"));let _=document.createElement("p");_.setAttribute("role","status");let g=document.createElement("div");g.className="scan-photo-view";let p=document.createElement("span");p.className="scan-photo-crosshair",p.setAttribute("aria-hidden","true");let y=document.createElement("div");y.className="scan-photo-level",y.hidden=!0;let E=document.createElement("span");E.setAttribute("role","status"),y.append(E,Jn(q("scanMap.cancel"),q("scanMap.cancel"),te)),g.append(m,p,_),o.append(a,y,g),i.append(o);let M=t.meta.panoramas.map((ft,Dt)=>{let P=ft.name||t.meta.elements[ft.element].name||String(Dt+1),dt=document.createElement("button");return dt.className="scan-photo-link",dt.type="button",dt.title=P,dt.setAttribute("aria-label",q("scanMap.goToStation").replace("{name}",P)),dt.hidden=!0,dt.addEventListener("click",()=>n(Dt,!0)),g.append(dt),{photo:ft,name:P,button:dt,position:new C(...ft.position)}}),x=t.readView(t.meta.points.element),S=new qn;S.params.Points.threshold=.12,S.near=.25;let A=new C,v=new C,w=new C,R=[],L=[],N=!1,B,D=t.meta.rtcOffset?.[2]??0,F,H,V,k=0,U=!1,O=!1,Y=0,G=0,J=null,rt,nt,it=new pn,z=new Ue(72,1,.1,20);z.up.set(0,0,1);let $=new Wn(10,56,28);$.rotateX(Math.PI/2);let st=new Je({side:ze}),gt=new ge($,st);it.add(gt);let ht=()=>{if(!(o.hidden||!H&&!O)){F.setSize(m.clientWidth,m.clientHeight,!1),z.aspect=m.clientWidth/Math.max(1,m.clientHeight),z.updateProjectionMatrix(),z.lookAt(kM(A,Y,G)),O?V.draw(F,z,A):F.render(it,z),z.getWorldDirection(A);for(let ft of R){if(N){ft.button.hidden=!0;continue}w.copy(ft.position).sub(rt.position).normalize(),v.copy(w).project(z);let Dt=w.dot(A)>0&&Math.abs(v.x)<.92&&Math.abs(v.y)<.88;ft.button.hidden=!Dt,Dt&&(ft.button.style.left=`${(1+v.x)*50}%`,ft.button.style.top=`${(1-v.y)*50}%`)}s({position:rt.position,yaw:Y})}},_t=(ft,Dt)=>{Y+=ft,G=ae.clamp(G+Dt,-1.55,1.55),ht()};new ResizeObserver(ht).observe(m),m.addEventListener("pointerdown",ft=>{ft.button!==0||J||(m.setPointerCapture(ft.pointerId),J={id:ft.pointerId,x:ft.clientX,y:ft.clientY,moved:!1})}),m.addEventListener("pointermove",ft=>{J?.id===ft.pointerId&&(N&&!J.moved&&Math.hypot(ft.clientX-J.x,ft.clientY-J.y)<5||(J.moved=!0,_t(...zM(ft.clientX-J.x,ft.clientY-J.y)),J.x=ft.clientX,J.y=ft.clientY))}),m.addEventListener("pointerup",ft=>{if(J?.id!==ft.pointerId||J.moved||!N)return;let Dt=m.getBoundingClientRect();kt((ft.clientX-Dt.left)*2/Dt.width-1,1-(ft.clientY-Dt.top)*2/Dt.height)}),m.addEventListener("lostpointercapture",ft=>{J?.id===ft.pointerId&&(J=null)}),m.addEventListener("keydown",ft=>{if(N&&ft.key==="Enter"){ft.preventDefault(),kt(0,0);return}let Dt={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[ft.key];Dt&&(ft.preventDefault(),ft.stopPropagation(),_t(...Dt))}),m.addEventListener("wheel",ft=>{ft.preventDefault(),z.fov=ae.clamp(z.fov+Math.sign(ft.deltaY)*5,32,95),ht()},{passive:!1}),o.addEventListener("keydown",ft=>{ft.key==="Escape"&&(N?te():Ft()),ft.stopPropagation()});function Ft(){o.hidden=!0,te(),k++,J=null,Wt(),s(null),nt?.focus()}function Wt(){O=!1,H?.dispose(),H=void 0,st.map=null;for(let ft of R)ft.button.hidden=!0;R=[]}function te(){N=!1,B=void 0,o.classList.remove("is-picking"),y.hidden=!0,ht()}function pt(){N=!0,B=void 0,o.classList.add("is-picking"),E.textContent=q("scanMap.pickLower"),y.hidden=!1,ht(),(H||O)&&m.focus()}function kt(ft,Dt){if(!H&&!O)return;let P=HM(z,rt.position,L,ft,Dt,m.clientWidth,m.clientHeight);if(P===void 0){E.textContent=q(B===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let dt=P+D;B===void 0?(B=dt,E.textContent=q("scanMap.pickUpper").replace("{z}",Bl(dt))):dt<=B?E.textContent=q("scanMap.upperAboveLower").replace("{z}",Bl(B)):(r({min:B,max:dt}),te())}function $t(ft,Dt){let P=o.hidden;if(P&&(nt=document.activeElement),Wt(),rt=M[ft],o.hidden=!1,l.textContent=rt.name,gt.rotation.z=ae.degToRad(rt.photo.yaw),L=e.root.children.filter((dt,Tt)=>x[Tt]===rt.photo.element),U=L.some(dt=>dt.geometry.getAttribute("intensity")),f.hidden=!U&&!rt.photo.intensity,R=M.filter(dt=>{if(dt===rt)return!1;let Tt=w.copy(dt.position).sub(rt.position).length();return Tt<=.25?!1:(S.set(rt.position,w.multiplyScalar(1/Tt)),S.far=Tt-.25,!S.intersectObjects(L,!1).length)}),P||!Dt){let dt=R.reduce((Tt,I)=>!Tt||I.position.distanceToSquared(rt.position){Dt===k&&(_.textContent=q("scanMap.photoError"))},Tt;try{if(F??(F=new Ti({canvas:m,antialias:!0})),F.setPixelRatio(Math.min(devicePixelRatio,2)),P&&U){V??(V=lm()),V.setScan(L,rt.position),O=!0,_.textContent="",m.style.visibility="visible",ht(),ft&&m.focus();return}let I=P?rt.photo.intensity:rt.photo.image;Tt=URL.createObjectURL(new Blob([t.readView(I)],{type:"image/jpeg"}))}catch{dt();return}new mr().load(Tt,I=>{if(URL.revokeObjectURL(Tt),Dt!==k||I.image.width!==2*I.image.height){I.dispose(),dt();return}H?.dispose(),H=I,H.colorSpace=me,st.map=H,st.needsUpdate=!0,_.textContent="",m.style.visibility="visible",ht(),ft&&m.focus()},void 0,()=>{URL.revokeObjectURL(Tt),dt()})}return{open:$t,pickLevel:pt,isClosed:()=>o.hidden}}var Ys=7;function hm(i){if(!i?.length)return null;let t=i.map(({position:l})=>new C(...l)),e=new fr({color:"#72bfff",depthTest:!1,depthWrite:!1}),n=new xi(new Wn(1,12,8),e,i.length);n.count=0,n.frustumCulled=!1,n.renderOrder=10,n.instanceMatrix.setUsage(Pr);let s=[],r=new Zt,o=new C,a=new qt;return{mesh:n,update(l,c,h){if(n.count=0,s.length=0,!(c.width<=0||c.height<=0)){for(let[d,u]of t.entries()){if(!h(i[d].element,u.z))continue;let f=-o.copy(u).applyMatrix4(l.matrixWorldInverse).z;if(f<=l.near||f>=l.far||(o.copy(u).project(l),!Number.isFinite(o.x)||!Number.isFinite(o.y)))continue;let m=(o.x+1)*c.width/2,_=(1-o.y)*c.height/2;if(m<-Ys||m>c.width+Ys||_<-Ys||_>c.height+Ys)continue;let g=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,p=Ys*g/c.height;n.setMatrixAt(n.count++,r.makeScale(p,p,p).setPosition(u)),s.push({index:d,depth:f,x:m+c.left,y:_+c.top})}n.instanceMatrix.needsUpdate=n.count>0}},pick(l,c){let h;for(let d of s)(!h||d.depth0))return n;let s=[];for(let r of n){let o="";for(let a of r.match(/\s*\S+|\s+$/gu)??[]){let l=o+a;if(e.measureText(l).width<=t){o=l;continue}if(o&&(s.push(o),a=a.trimStart()),o=a,!(e.measureText(a).width<=t)){o="";for(let c of a)o&&e.measureText(o+c).width>t&&(s.push(o),o=""),o+=c}}s.push(o)}return s}function qM(i,t){let e=i.width/i.height*nu,n=XM(i.text,e,t),s=ae.clamp(Math.trunc(i.attachment||1),1,9)-1,r=s%3,o=Math.floor(s/3),a=0;for(let _ of n)a=Math.max(a,t.measureText(_).width/nu*i.height);let l=n.length*dm*i.height,c=-a*r/2,h=l*o/2,d=new oe,u=new C,f=Math.cos(i.rotation),m=Math.sin(i.rotation);for(let _ of[c,c+a])for(let g of[h-l,h])u.set(i.position[0]+_*f-g*m,i.position[1]+_*m+g*f,i.position[2]),d.expandByPoint(u);return{lines:n,box:d,hAlign:r,vAlign:o}}var Ol=class{constructor(t,e){this.annotations=e.meta.annotations??[],this.lightBackground=!1,this.canvas=document.createElement("canvas"),this.canvas.className="ioviewer-annotations",this.canvas.setAttribute("aria-hidden","true"),this.annotations.length===0&&(this.canvas.hidden=!0),t.append(this.canvas),this._ctx=this.canvas.getContext("2d"),this._ctx&&(this._ctx.font=`${nu}px ${um}`),this.layouts=this._ctx?this.annotations.map(n=>qM(n,this._ctx)):[],this._p=new C,this._x=new C}setLightBackground(t){this.lightBackground=!!t}update(t,e,n){if(!this.annotations.length||!this._ctx||e.width<1||e.height<1)return;let s=window.devicePixelRatio||1,r=Math.round(e.width*s),o=Math.round(e.height*s);(this.canvas.width!==r||this.canvas.height!==o)&&(this.canvas.width=r,this.canvas.height=o);let a=this._ctx;a.setTransform(s,0,0,s,0,0),a.clearRect(0,0,e.width,e.height);let l=new Zt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),c=t.matrixWorldInverse,h=t.isOrthographicCamera?e.height*t.zoom/Math.max(t.top-t.bottom,1e-9):0,d=t.isPerspectiveCamera?Math.tan(ae.degToRad(t.fov/2)):0;for(let u=0;u=-t.near)continue;let y=h||e.height/(2*Math.max(-p.z,1e-6)*d),E=f.height*y;if(!Number.isFinite(E)||E<1.5)continue;let M=this._p.clone().applyMatrix4(l);if(M.z<-1||M.z>1)continue;let x=(M.x*.5+.5)*e.width,S=(-M.y*.5+.5)*e.height;if(x<-400||x>e.width+400||S<-400||S>e.height+400)continue;this._x.set(f.position[0]+Math.cos(f.rotation),f.position[1]+Math.sin(f.rotation),f.position[2]).applyMatrix4(l);let A=(this._x.x*.5+.5)*e.width,v=(-this._x.y*.5+.5)*e.height,w=Math.atan2(v-S,A-x),[R,L,N]=f.color?[Math.round(f.color[0]*255),Math.round(f.color[1]*255),Math.round(f.color[2]*255)]:this.lightBackground?[17,24,39]:[229,231,235];this.lightBackground&&R>230&&L>230&&N>230?[R,L,N]=[17,24,39]:!this.lightBackground&&R<20&&L<20&&N<20&&([R,L,N]=[241,245,249]),a.save(),a.translate(x,S),Math.abs(w)>1e-4&&a.rotate(w),a.font=`${E.toFixed(2)}px ${um}`,a.fillStyle=`rgb(${R},${L},${N})`,a.textAlign=GM[_],a.textBaseline=WM[g];let B=E*dm,D=-(m.length-1)*B*g/2;for(let F=0;F{}};let l=new Set(a.flatMap(_=>_.elements)),c=K("div","ioviewer-sheets ioviewer-floating");c.setAttribute("role","tablist"),c.setAttribute("aria-label",q("sheets.label"));let h=new zi(new he,new sn({color:"#94a3b8",transparent:!0,opacity:.55}));h.visible=!1,t.add(h);let d=null,u=new Map;function f(_,g=!1){let p=a.find(x=>x.key===_)??a[0];if(!p)return;d=p;for(let[x,S]of u){let A=x===p.key;S.classList.toggle("active",A),S.setAttribute("aria-selected",String(A))}let y=new Set(p.elements),E=[];for(let x of l)y.has(x)||E.push(x);if(n.setAnnotationSheet(p.key),n.replaceLayerHidden("sheet",E),!p.isModel&&p.paperBounds){let{min:x,max:S}=p.paperBounds,A=x[2];h.geometry.setFromPoints([new C(x[0],x[1],A),new C(S[0],x[1],A),new C(S[0],S[1],A),new C(x[0],S[1],A)]),h.visible=!0}else h.visible=!1;p.background&&r(p.background,!g);let M=n.visibleBox();!p.isModel&&p.paperBounds&&(M.expandByPoint(new C(...p.paperBounds.min)),M.expandByPoint(new C(...p.paperBounds.max))),s(!!p.is2D,M,!1),o()}for(let _ of a){let g=K("button","ioviewer-sheet-tab",_.name);g.type="button",g.setAttribute("role","tab"),g.dataset.sheet=_.key,g.addEventListener("click",()=>f(_.key,!1)),u.set(_.key,g),c.append(g)}a.length>1&&i.append(c);let m=e.options?.initialSheet??a[0].key;return f(m,!0),{get active(){return d},setSheet:_=>f(_,!1)}}document.documentElement.lang=Pn;var Dn=document.getElementById("ioviewer-canvas"),iu=window.IOVIEWER_TEST??{},Kr=iu.startup;function Jr(i){let t=document.getElementById("ioviewer-message");t.textContent=i,t.hidden=!1}try{let i=xh(document,Kr);i.title&&(document.title=i.title);let t=Dn.getContext("webgl2",{antialias:!0,stencil:!0});t?YM(_f(document,Kr,i),t):Jr(q("noWebGL"))}catch(i){if(!(i instanceof ee))throw i;Jr(q("badData"))}function YM(i,t){let e=new Ti({canvas:Dn,context:t,antialias:!0,stencil:!0,logarithmicDepthBuffer:jf(i.meta)});e.setPixelRatio(window.devicePixelRatio),e.autoClearStencil=!1,e.localClippingEnabled=!0;let n=new pn,s=i.meta.options?.initialBackground||"#1f2228",r=new Vt(s);e.setClearColor(r,1);let o=new _r("#ffffff","#8a8f99",1.6);o.position.set(0,0,1),n.add(o);let a=new Ue(45,1,.1,1e3);a.up.set(0,0,1),a.position.set(1,-1,.8);let l=new xr("#ffffff",1.4);l.position.set(.3,.6,0),a.add(l,l.target),l.target.position.set(0,0,-1),n.add(a);let c=!1,h=document.getElementById("ioviewer-ui"),d=new Ol(h,i),u=d.layouts;Kr?.("sceneStart");let f=L(),m=new ll(i),_=new cl(i);Kr?.("sceneEnd"),i.releaseBinary(),!c&&f.totalCost===0&&m.count===0&&_.count===0&&!u.length&&Jr(q("noGeometry"));let g=new xl(f,V,Math.min(f.totalCost,2e7));n.add(f.root),n.add(m.root),n.add(_.root);let p=m.count?hm(i.meta.panoramas):null;p&&n.add(p.mesh);let y=()=>f.visibleBox(),E=new Al(f,y(),i.meta.sections);m.syncVisibility(f),m.syncAppearance(f),_.syncVisibility(f),_.syncAppearance(f);let M=()=>{let{planes:pt,intersection:kt}=E.clipping();m.setClipping(pt,kt),_.setClipping(pt,kt)};M();let x=f.slotCount>0,S=x&&t.getContextAttributes()?.stencil===!0,A,v=new Il(E,Dn);n.add(v.group);let w=new Ll(h),R=new Ul(h,i.meta.grids??[]);n.add(w.group,R.group);function L(){try{return new Gr(i,{...iu,maxTextureSize:e.capabilities.maxTextureSize,annotationLayouts:u})}catch(pt){if(!(pt instanceof Vr))throw pt;c=!0,Jr(q("tooLarge").replace("{count}",pt.count).replace("{limit}",pt.limit));let kt=le=>({o:0,n:0,t:le}),$t={count:0,geometry:kt("u32"),material:kt("u32"),element:kt("i32"),matrix:kt("f32")};return new Gr({...i,meta:{...i.meta,instances:$t}},{annotationLayouts:u})}}let N=!1;Dn.addEventListener("webglcontextlost",()=>{N=!0,Jr(q("contextLost"))});let B,D=new Promise(pt=>B=pt),F=Kr,H=!1;function V(){H||N||(H=!0,g.requested(performance.now()),requestAnimationFrame(()=>{if(H=!1,N)return;let pt=Dn.getBoundingClientRect();nt.camera.updateMatrixWorld(),Wt&&p?.update(nt.camera,pt,Wt.showSphere),v.update(nt.camera),w.update(nt.camera,pt),R.update(nt.camera,pt),d.update(nt.camera,pt,f),g.begin(nt.camera,pt.height,performance.now()),F?.("renderStart"),E.fill&&S?(A??(A=new Pl(f,E,i)),A.render(e,n,nt.camera)):e.render(n,nt.camera),F&&(F("renderEnd"),F=void 0),g.end(performance.now()),it.update(),B()}))}f.root.addEventListener("change",V),E.addEventListener("change",()=>{M(),V()}),v.addEventListener("change",V),w.addEventListener("change",V),w.addEventListener("previewchange",V),R.addEventListener("change",V);let k=new gl(e,f,a,{points:m,lines:_,pickFloat:iu.pickFloat}),U=new Nl(k,E,i),O=0,Y=null;function G(){cancelAnimationFrame(O),O=0,Y=null,w.setPreview(null)}function J(){O=0,Y&&w.setPreview(U.target(...Y))}function rt(){Y&&(w.setPreview(null),cancelAnimationFrame(O),O=requestAnimationFrame(()=>{O=requestAnimationFrame(J)}))}Dn.addEventListener("pointermove",pt=>{if(!w.active||pt.buttons)return G();Y=[pt.clientX,pt.clientY],O||(O=requestAnimationFrame(J))});for(let pt of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Dn.addEventListener(pt,G);f.root.addEventListener("change",pt=>{pt.detail.kind!=="appearance"&&rt()});let nt=new dl(a,Dn,{pick:(pt,kt)=>k.pick(pt,kt)?.point??null,visibleBox:y});nt.addEventListener("change",()=>{k.camera=nt.camera,rt(),V()}),f.root.addEventListener("change",pt=>{pt.detail.kind==="appearance"&&(m.syncAppearance(f),_.syncAppearance(f)),(pt.detail.kind==="appearance"||pt.detail.kind==="visibility")&&d.update(nt.camera,Dn.getBoundingClientRect(),f),pt.detail.kind==="visibility"&&(m.syncVisibility(f),_.syncVisibility(f),nt.invalidateBounds(),nt.resize())});let it,z=new yl;z.addEventListener("change",()=>f.setHighlighted([...z.values()]));let $=Bp({root:h,data:i,scene:f,controls:nt,picker:k,selection:z,measure:w});nt.addEventListener("mode2d",()=>{$.sync2DState(),it?.set2D(nt.is2D)}),Xp({root:h,...$,sections:E,selection:z,canFill:S,hasMeshes:x});let{meta:st}=i,gt=sm({...$,files:st.linkedFiles??[],elements:st.elements,scene:f});Jp({...$,controls:nt,scene:f,sections:E,selection:z,restoreLinkedModels:gt,views:st.viewpoints??[],bcfTopics:st.bcfTopics??[]});let ht=Qp({...$,tests:st.clashTests??[],elements:st.elements,scene:f,controls:nt,selection:z});n.add(ht.group);let _t=im({root:h,...$,timeliner:st.timeliner,elements:st.elements,scene:f}),Bt=pt=>{e.setClearColor(r.set(pt),1);let{r:kt,g:$t,b:le}=r,Dt=.2126*kt+.7152*$t+.0722*le>Math.sqrt(.0525)-.05,P=Dt?"#000":"#fff";h.style.setProperty("--viewport-text",pt===s?"":P),_.setLightBackground(Dt),d.setLightBackground(Dt),V()};{let{r:pt,g:kt,b:$t}=r,le=.2126*pt+.7152*kt+.0722*$t>Math.sqrt(.0525)-.05;_.setLightBackground(le),d.setLightBackground(le),le&&h.style.setProperty("--viewport-text","#000")}for(let pt of Kp({root:h,toolbar:$.toolbar,scene:f,meta:st,grids:R,initialBackground:s,setBackground:Bt,hasMeshes:x}))$.onEscape(pt.close);$.toolbar.setHandler("distance",()=>{G(),w.setActive(!w.active),w.active||U.release(),$.toolbar.setActive("distance",w.active)}),$.toolbar.setActive("distance",!1),$.onEscape(()=>(G(),w.clear()));let Ft=()=>{nt.setExtraBounds("grids",R.visible?R.box:null),nt.setExtraBounds("measure",w.box)};R.addEventListener("change",Ft),w.addEventListener("change",Ft),Ft(),nt.addEventListener("click",pt=>{let{x:kt,y:$t,ctrl:le,shift:ft}=pt.detail;if(w.active){let Tt=U.target(kt,$t);Tt&&w.add(Tt.point);return}let Dt=!le&&!ft?p?.pick(kt,$t):void 0;if(Dt!==void 0){Wt.open(Dt);return}let dt=k.pick(kt,$t)?.element??-1;le?dt>=0&&z.toggle(dt):dt>=0?z.set([dt]):ft||z.clear()}),nt.addEventListener("boxselect",pt=>{if(w.active)return;let{rect:kt,mode:$t,ctrl:le,shift:ft}=pt.detail;if(kt.width<4||kt.height<4){!le&&!ft&&z.clear();return}let Dt=new oe,P=op(kt,$t,ap(f,nt.camera,Dn.getBoundingClientRect())),dt=E.clipping(),Tt=P.filter(I=>!E.isCut(f.elementBox(I,Dt),dt));z.set(le?[...z.values(),...Tt]:Tt)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),nt.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),nt.resize(),nt.fitBox(y(),!1);let Wt=cm(h,i,m,f,nt,V);it=new ml(document.getElementById("ioviewer-ui"),a,nt);let te=fm({root:h,world:n,meta:st,scene:f,apply2DMode:(pt,kt,$t)=>{nt.set2DMode(pt,kt,$t),pt||nt.fitBox(kt,$t),$.sync2DState(),it.set2D(nt.is2D)},setBackground:Bt,requestRender:V});!st.sheets?.length&&st.options?.initial2DMode&&(nt.set2DMode(!0,y(),!1),$.sync2DState(),it.set2D(!0)),window.addEventListener("pointerdown",pt=>{(pt.target===Dn||it.element.contains(pt.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:f,points:m,lines:_,annotationsOverlay:d,sheetsBar:te,motionDetail:g,controls:nt,picker:k,selection:z,ui:$,viewCube:it,sections:E,sectionGizmo:v,measure:w,measureSnap:U,grids:R,clashes:ht,timeliner:_t,ready:D,get camera(){return nt.camera}}}})(); +`)}),c=new ge(new cn(2,2),l);return c.frustumCulled=!1,o.add(c),{setScan(h,d){i.clear();for(let m of h){if(!m.geometry.getAttribute("intensity"))continue;let _=new wn(m.geometry,n);_.matrixAutoUpdate=!1,_.matrix.copy(m.matrixWorld),i.add(_)}t.position.copy(d);let u=new ae().setFromObject(i),f=u.getSize(e).length();t.far=Math.max(20,f+d.distanceTo(u.getCenter(e)))},draw(h,d,u){t.aspect=d.aspect,t.fov=d.fov,t.updateProjectionMatrix(),t.lookAt(e.copy(t.position).add(u));let f=h.getPixelRatio();n.uniforms.size.value=5.5*f,h.getDrawingBufferSize(r),s.setSize(r.x,r.y),l.uniforms.sampleStep.value.set(2*f/r.x,2*f/r.y),l.uniforms.range.value.set(t.near,t.far),h.setRenderTarget(s),h.render(i,t),h.setRenderTarget(null),h.render(o,a)}}}var zM=new Intl.NumberFormat(Pn,{maximumFractionDigits:2,minimumFractionDigits:2}),Bl=i=>`${zM.format(i)} ${q("scanMap.metres")}`;function Jn(i,t,e){let n=document.createElement("button");return n.type="button",n.textContent=t,n.title=i,n.setAttribute("aria-label",i),n.addEventListener("click",e),n}function kM(i,t){return[i*.005,t*.005]}function HM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function VM(i,t,e,n,s,r,o){let a=new qn;a.setFromCamera(new qt(n,s),i),a.ray.origin.copy(t),a.near=.05,a.params.Points.threshold=.12;let l=new C,c=new C;for(let h of a.intersectObjects(e,!1))if(l.fromBufferAttribute(h.object.geometry.attributes.position,h.index).applyMatrix4(h.object.matrixWorld),c.copy(l).sub(t).project(i),Math.hypot((c.x-n)*r/2,(c.y-s)*o/2)<=14)return l.z}function hm(i,t,e,n,s,r){if(!e.count)return;let o=new ae().setFromObject(e.root);if(o.isEmpty())return;let a=o.getSize(new C),l=o.getCenter(new C),c={x:l.x,y:l.y,side:Math.max(a.x,a.y,.01)*1.12,zoom:1},h={...c},d=P=>50+100*(P-h.x)*h.zoom/h.side,u=P=>50-100*(P-h.y)*h.zoom/h.side,f=P=>Math.min(96,Math.max(4,P)),m=(P,ft,Tt=!1)=>{let I=d(ft.x),b=u(ft.y);return P.style.left=`${Tt?f(I):I}%`,P.style.top=`${Tt?f(b):b}%`,I>=0&&I<=100&&b>=0&&b<=100},_=t.meta.rtcOffset?.[2]??0,g=t.meta.panoramas??[],p=g.map(P=>new C(...P.position)),y=`ioviewer.scan-levels.v1:${location.pathname}`,w=()=>om(p.map(P=>P.z+_),o.min.z+_,o.max.z+_),M=null;try{let P=JSON.parse(localStorage.getItem(y));Array.isArray(P)&&(M=P.filter(ft=>Number.isFinite(ft?.min)&&Number.isFinite(ft.max)&&ft.max>ft.min))}catch{M=null}let x=M??w(),S=-1,A=!0,v=P=>am(x[S],P+_),E=document.createElement("details");E.className="ioviewer-floating ioviewer-scan-map",E.open=!matchMedia("(max-width: 600px)").matches;let R=document.createElement("summary");R.textContent=q("scanMap.title");let L=document.createElement("div");L.className="scan-map-plot";let N=document.createElement("canvas");N.width=N.height=300,N.setAttribute("role","img"),N.setAttribute("aria-label",q("scanMap.plan")),N.tabIndex=0;let B=document.createElement("span");B.className="scan-map-camera",B.setAttribute("aria-hidden","true");let D=document.createElement("span");D.className="scan-map-axes",D.textContent="Y \u2191";let F=document.createElement("span");F.className="scan-map-scale",L.append(N,B,D,F),E.append(R,L),i.append(E);let H=e.root.children.reduce((P,ft)=>P+ft.geometry.attributes.position.count,0),V=Math.max(1,Math.ceil(H/6e4)),z=e.root.children.map(P=>{let ft=P.geometry.attributes.position,Tt=new Float32Array(Math.ceil(ft.count/V)*3),I=new C;for(let b=0,Z=0;b{if(U=0,!E.open)return;let P=N.getContext("2d");if(!P)return;P.clearRect(0,0,300,300),P.fillStyle="rgba(160, 185, 201, .33)";for(let[I,b]of z.entries())if(e.root.children[I].visible)for(let Z=0;Z{U||(U=requestAnimationFrame(k))},G=new C,J=null,it=()=>{if(J){B.hidden=!v(J.position.z),m(B,J.position,!0),B.style.rotate=`${Math.PI/2-J.yaw}rad`;return}B.hidden=!1,m(B,s.camera.position,!0),s.camera.getWorldDirection(G),B.style.rotate=`${Math.atan2(G.x,G.y)}rad`};E.addEventListener("toggle",Y),n.root.addEventListener("change",P=>{P.detail.kind==="visibility"&&Y()}),s.addEventListener("change",it);let nt=document.createElement("div");nt.className="scan-map-controls";let at=document.createElement("select");at.setAttribute("aria-label",q("scanMap.size"));for(let P of["small","medium","large"])at.add(new Option(q(`scanMap.${P}`),P));at.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=at.value,at.addEventListener("change",()=>{i.dataset.scanMapSize=at.value});let O=(P,ft=0,Tt=0)=>{h=lm(h,P,ft,Tt),Y()},$=()=>{h={...c},Y()};nt.append(at,Jn(q("scanMap.zoomOut"),"\u2212",()=>O(.8)),Jn(q("scanMap.zoomIn"),"+",()=>O(1.25)),Jn(q("scanMap.reset"),"\u21BA",$)),E.insertBefore(nt,L),N.addEventListener("wheel",P=>{P.preventDefault();let ft=N.getBoundingClientRect();O(P.deltaY<0?1.15:1/1.15,(P.clientX-ft.left)/ft.width-.5,(P.clientY-ft.top)/ft.height-.5)},{passive:!1});let rt;N.addEventListener("pointerdown",P=>{P.button!==0||rt||(N.setPointerCapture(P.pointerId),rt={id:P.pointerId,x:P.clientX,y:P.clientY})}),N.addEventListener("pointermove",P=>{if(rt?.id!==P.pointerId)return;let ft=h.side/(h.zoom*Math.max(1,N.clientWidth));h.x-=(P.clientX-rt.x)*ft,h.y+=(P.clientY-rt.y)*ft,rt.x=P.clientX,rt.y=P.clientY,Y()}),N.addEventListener("lostpointercapture",P=>{P.pointerId===rt?.id&&(rt=void 0)}),N.addEventListener("keydown",P=>{let ft={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[P.key];if(ft){let Tt=h.side/h.zoom/10;h.x+=ft[0]*Tt,h.y+=ft[1]*Tt,Y()}else if(P.key==="+"||P.key==="="||P.key==="-")O(P.key==="-"?.8:1.25);else if(P.key==="0")$();else return;P.preventDefault(),P.stopPropagation()});let mt=document.createElement("div");mt.className="scan-map-controls";let ht=document.createElement("select");ht.setAttribute("aria-label",q("scanMap.levels"));let Et=document.createElement("p");Et.className="scan-map-feedback",Et.setAttribute("role","status");function Zt(){try{localStorage.setItem(y,JSON.stringify(x))}catch{Et.textContent=q("scanMap.levelTemporary")}}function Ct(){ht.replaceChildren(new Option(q("scanMap.allLevels"),"-1")),x.forEach((P,ft)=>ht.add(new Option(`${q("scanMap.level").replace("{n}",ft+1)} \xB7 ${Bl(P.min)} \u2013 ${Bl(P.max)}`,String(ft)))),ht.value=String(S),dt.disabled=S<0;for(let[P,ft]of p.entries())Gt.options[P+1].hidden=!v(ft.z);Y(),r()}ht.addEventListener("change",()=>{S=Number(ht.value),Et.textContent="",Ct()});let Yt=Jn(q("scanMap.addLevel"),"+",()=>{if(Nt.isClosed()){let P=p.findIndex(ft=>v(ft.z));Ut(Math.max(0,P))}Nt.pickLevel()});Yt.disabled=!g.length;let Ht=Jn(q("scanMap.autoLevels"),q("scanMap.autoButton"),()=>{let P=w(),ft=P.filter(Tt=>!x.some(I=>I.min{S<0||(x.splice(S,1),S=-1,Et.textContent="",Zt(),Ct())});if(mt.append(ht,Yt,Ht,dt),g.length){let P=Jn(q("scanMap.spheres"),"\u25C9",()=>{A=!A,P.setAttribute("aria-pressed",String(A)),r()});P.setAttribute("aria-pressed","true"),mt.append(P)}E.append(mt,Et);let Nt=g.length?GM(i,t,e,Ut,P=>{J=P,P||pt.forEach(ft=>ft.classList.remove("current")),it()},P=>{S=x.push(P)-1,Et.textContent=q("scanMap.levelAdded"),Zt(),Ct()}):null,Gt=document.createElement("select");Gt.setAttribute("aria-label",q("scanMap.choosePhoto"));let ne=new Option(q("scanMap.choosePhoto"),"");ne.disabled=!0,Gt.add(ne);let pt=[];for(let[P,ft]of g.entries()){let Tt=ft.name||t.meta.elements[ft.element].name||String(P+1);Gt.add(new Option(Tt,String(P)));let I=document.createElement("button");I.type="button",I.className="scan-map-station",I.title=Tt,I.setAttribute("aria-label",`${q("scanMap.photo")} \xB7 ${Tt}`),I.addEventListener("click",()=>Ut(P)),pt.push(I),L.append(I)}Gt.value="",Gt.addEventListener("change",()=>Ut(Number(Gt.value))),Gt.hidden=!g.length,E.append(Gt),Ct(),!M&&x.length&&Zt();function Ut(P,ft=!1){E.open=!0,Gt.value=String(P),pt.forEach((Tt,I)=>Tt.classList.toggle("current",P===I)),Nt.open(P,ft),Gt.value=""}return{open:Ut,showSphere:(P,ft)=>A&&v(ft)&&n.isVisible(P)}}function GM(i,t,e,n,s,r){let o=document.createElement("section");o.className="ioviewer-floating scan-photo",o.setAttribute("aria-label",q("scanMap.photo")),o.hidden=!0;let a=document.createElement("header"),l=document.createElement("span"),c=document.createElement("div");c.className="scan-photo-actions";let h=Jn(q("scanMap.enlargePhoto"),q("scanMap.enlargePhoto"),()=>{let pt=o.classList.toggle("is-expanded"),Ut=q(pt?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Ut,h.setAttribute("aria-label",Ut),h.setAttribute("aria-pressed",String(pt))});h.setAttribute("aria-pressed","false");let d=document.createElement("button");d.type="button",d.textContent=q("close"),d.addEventListener("click",Ct);let u=!1,f=Jn(q("scanMap.intensity"),q("scanMap.intensity"),()=>{u=!u,ne(!1)});f.className="scan-photo-intensity",f.hidden=!0,c.append(f,h,d),a.append(l,c);let m=document.createElement("canvas");m.tabIndex=0,m.setAttribute("aria-label",q("scanMap.photoControls"));let _=document.createElement("p");_.setAttribute("role","status");let g=document.createElement("div");g.className="scan-photo-view";let p=document.createElement("span");p.className="scan-photo-crosshair",p.setAttribute("aria-hidden","true");let y=document.createElement("div");y.className="scan-photo-level",y.hidden=!0;let w=document.createElement("span");w.setAttribute("role","status"),y.append(w,Jn(q("scanMap.cancel"),q("scanMap.cancel"),Ht)),g.append(m,p,_),o.append(a,y,g),i.append(o);let M=t.meta.panoramas.map((pt,Ut)=>{let P=pt.name||t.meta.elements[pt.element].name||String(Ut+1),ft=document.createElement("button");return ft.className="scan-photo-link",ft.type="button",ft.title=P,ft.setAttribute("aria-label",q("scanMap.goToStation").replace("{name}",P)),ft.hidden=!0,ft.addEventListener("click",()=>n(Ut,!0)),g.append(ft),{photo:pt,name:P,button:ft,position:new C(...pt.position)}}),x=t.readView(t.meta.points.element),S=new qn;S.params.Points.threshold=.12,S.near=.25;let A=new C,v=new C,E=new C,R=[],L=[],N=!1,B,D=t.meta.rtcOffset?.[2]??0,F,H,V,z=0,U=!1,k=!1,Y=0,G=0,J=null,it,nt,at=new pn,O=new Ue(72,1,.1,20);O.up.set(0,0,1);let $=new Wn(10,56,28);$.rotateX(Math.PI/2);let rt=new Je({side:ze}),mt=new ge($,rt);at.add(mt);let ht=()=>{if(!(o.hidden||!H&&!k)){F.setSize(m.clientWidth,m.clientHeight,!1),O.aspect=m.clientWidth/Math.max(1,m.clientHeight),O.updateProjectionMatrix(),O.lookAt(HM(A,Y,G)),k?V.draw(F,O,A):F.render(at,O),O.getWorldDirection(A);for(let pt of R){if(N){pt.button.hidden=!0;continue}E.copy(pt.position).sub(it.position).normalize(),v.copy(E).project(O);let Ut=E.dot(A)>0&&Math.abs(v.x)<.92&&Math.abs(v.y)<.88;pt.button.hidden=!Ut,Ut&&(pt.button.style.left=`${(1+v.x)*50}%`,pt.button.style.top=`${(1-v.y)*50}%`)}s({position:it.position,yaw:Y})}},Et=(pt,Ut)=>{Y+=pt,G=le.clamp(G+Ut,-1.55,1.55),ht()};new ResizeObserver(ht).observe(m),m.addEventListener("pointerdown",pt=>{pt.button!==0||J||(m.setPointerCapture(pt.pointerId),J={id:pt.pointerId,x:pt.clientX,y:pt.clientY,moved:!1})}),m.addEventListener("pointermove",pt=>{J?.id===pt.pointerId&&(N&&!J.moved&&Math.hypot(pt.clientX-J.x,pt.clientY-J.y)<5||(J.moved=!0,Et(...kM(pt.clientX-J.x,pt.clientY-J.y)),J.x=pt.clientX,J.y=pt.clientY))}),m.addEventListener("pointerup",pt=>{if(J?.id!==pt.pointerId||J.moved||!N)return;let Ut=m.getBoundingClientRect();Nt((pt.clientX-Ut.left)*2/Ut.width-1,1-(pt.clientY-Ut.top)*2/Ut.height)}),m.addEventListener("lostpointercapture",pt=>{J?.id===pt.pointerId&&(J=null)}),m.addEventListener("keydown",pt=>{if(N&&pt.key==="Enter"){pt.preventDefault(),Nt(0,0);return}let Ut={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[pt.key];Ut&&(pt.preventDefault(),pt.stopPropagation(),Et(...Ut))}),m.addEventListener("wheel",pt=>{pt.preventDefault(),O.fov=le.clamp(O.fov+Math.sign(pt.deltaY)*5,32,95),ht()},{passive:!1}),o.addEventListener("keydown",pt=>{pt.key==="Escape"&&(N?Ht():Ct()),pt.stopPropagation()});function Ct(){o.hidden=!0,Ht(),z++,J=null,Yt(),s(null),nt?.focus()}function Yt(){k=!1,H?.dispose(),H=void 0,rt.map=null;for(let pt of R)pt.button.hidden=!0;R=[]}function Ht(){N=!1,B=void 0,o.classList.remove("is-picking"),y.hidden=!0,ht()}function dt(){N=!0,B=void 0,o.classList.add("is-picking"),w.textContent=q("scanMap.pickLower"),y.hidden=!1,ht(),(H||k)&&m.focus()}function Nt(pt,Ut){if(!H&&!k)return;let P=VM(O,it.position,L,pt,Ut,m.clientWidth,m.clientHeight);if(P===void 0){w.textContent=q(B===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let ft=P+D;B===void 0?(B=ft,w.textContent=q("scanMap.pickUpper").replace("{z}",Bl(ft))):ft<=B?w.textContent=q("scanMap.upperAboveLower").replace("{z}",Bl(B)):(r({min:B,max:ft}),Ht())}function Gt(pt,Ut){let P=o.hidden;if(P&&(nt=document.activeElement),Yt(),it=M[pt],o.hidden=!1,l.textContent=it.name,mt.rotation.z=le.degToRad(it.photo.yaw),L=e.root.children.filter((ft,Tt)=>x[Tt]===it.photo.element),U=L.some(ft=>ft.geometry.getAttribute("intensity")),f.hidden=!U&&!it.photo.intensity,R=M.filter(ft=>{if(ft===it)return!1;let Tt=E.copy(ft.position).sub(it.position).length();return Tt<=.25?!1:(S.set(it.position,E.multiplyScalar(1/Tt)),S.far=Tt-.25,!S.intersectObjects(L,!1).length)}),P||!Ut){let ft=R.reduce((Tt,I)=>!Tt||I.position.distanceToSquared(it.position){Ut===z&&(_.textContent=q("scanMap.photoError"))},Tt;try{if(F??(F=new Ti({canvas:m,antialias:!0})),F.setPixelRatio(Math.min(devicePixelRatio,2)),P&&U){V??(V=cm()),V.setScan(L,it.position),k=!0,_.textContent="",m.style.visibility="visible",ht(),pt&&m.focus();return}let I=P?it.photo.intensity:it.photo.image;Tt=URL.createObjectURL(new Blob([t.readView(I)],{type:"image/jpeg"}))}catch{ft();return}new mr().load(Tt,I=>{if(URL.revokeObjectURL(Tt),Ut!==z||I.image.width!==2*I.image.height){I.dispose(),ft();return}H?.dispose(),H=I,H.colorSpace=me,rt.map=H,rt.needsUpdate=!0,_.textContent="",m.style.visibility="visible",ht(),pt&&m.focus()},void 0,()=>{URL.revokeObjectURL(Tt),ft()})}return{open:Gt,pickLevel:dt,isClosed:()=>o.hidden}}var Ys=7;function um(i){if(!i?.length)return null;let t=i.map(({position:l})=>new C(...l)),e=new fr({color:"#72bfff",depthTest:!1,depthWrite:!1}),n=new xi(new Wn(1,12,8),e,i.length);n.count=0,n.frustumCulled=!1,n.renderOrder=10,n.instanceMatrix.setUsage(Pr);let s=[],r=new Kt,o=new C,a=new qt;return{mesh:n,update(l,c,h){if(n.count=0,s.length=0,!(c.width<=0||c.height<=0)){for(let[d,u]of t.entries()){if(!h(i[d].element,u.z))continue;let f=-o.copy(u).applyMatrix4(l.matrixWorldInverse).z;if(f<=l.near||f>=l.far||(o.copy(u).project(l),!Number.isFinite(o.x)||!Number.isFinite(o.y)))continue;let m=(o.x+1)*c.width/2,_=(1-o.y)*c.height/2;if(m<-Ys||m>c.width+Ys||_<-Ys||_>c.height+Ys)continue;let g=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,p=Ys*g/c.height;n.setMatrixAt(n.count++,r.makeScale(p,p,p).setPosition(u)),s.push({index:d,depth:f,x:m+c.left,y:_+c.top})}n.instanceMatrix.needsUpdate=n.count>0}},pick(l,c){let h;for(let d of s)(!h||d.depth0))return n;let s=[];for(let r of n){let o="";for(let a of r.match(/\s*\S+|\s+$/gu)??[]){let l=o+a;if(e.measureText(l).width<=t){o=l;continue}if(o&&(s.push(o),a=a.trimStart()),o=a,!(e.measureText(a).width<=t)){o="";for(let c of a)o&&e.measureText(o+c).width>t&&(s.push(o),o=""),o+=c}}s.push(o)}return s}function YM(i,t){let e=i.width/i.height*su,n=qM(i.text,e,t),s=le.clamp(Math.trunc(i.attachment||1),1,9)-1,r=s%3,o=Math.floor(s/3),a=0;for(let _ of n)a=Math.max(a,t.measureText(_).width/su*i.height);let l=n.length*fm*i.height,c=-a*r/2,h=l*o/2,d=new ae,u=new C,f=Math.cos(i.rotation),m=Math.sin(i.rotation);for(let _ of[c,c+a])for(let g of[h-l,h])u.set(i.position[0]+_*f-g*m,i.position[1]+_*m+g*f,i.position[2]),d.expandByPoint(u);return{lines:n,box:d,hAlign:r,vAlign:o}}var Ol=class{constructor(t,e){this.annotations=e.meta.annotations??[],this.lightBackground=!1,this.canvas=document.createElement("canvas"),this.canvas.className="ioviewer-annotations",this.canvas.setAttribute("aria-hidden","true"),this.annotations.length===0&&(this.canvas.hidden=!0),t.append(this.canvas),this._ctx=this.canvas.getContext("2d"),this._ctx&&(this._ctx.font=`${su}px ${dm}`),this.layouts=this._ctx?this.annotations.map(n=>YM(n,this._ctx)):[],this._p=new C,this._x=new C}setLightBackground(t){this.lightBackground=!!t}update(t,e,n){if(!this.annotations.length||!this._ctx||e.width<1||e.height<1)return;let s=window.devicePixelRatio||1,r=Math.round(e.width*s),o=Math.round(e.height*s);(this.canvas.width!==r||this.canvas.height!==o)&&(this.canvas.width=r,this.canvas.height=o);let a=this._ctx;a.setTransform(s,0,0,s,0,0),a.clearRect(0,0,e.width,e.height);let l=new Kt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),c=t.matrixWorldInverse,h=t.isOrthographicCamera?e.height*t.zoom/Math.max(t.top-t.bottom,1e-9):0,d=t.isPerspectiveCamera?Math.tan(le.degToRad(t.fov/2)):0;for(let u=0;u=-t.near)continue;let y=h||e.height/(2*Math.max(-p.z,1e-6)*d),w=f.height*y;if(!Number.isFinite(w)||w<1.5)continue;let M=this._p.clone().applyMatrix4(l);if(M.z<-1||M.z>1)continue;let x=(M.x*.5+.5)*e.width,S=(-M.y*.5+.5)*e.height;if(x<-400||x>e.width+400||S<-400||S>e.height+400)continue;this._x.set(f.position[0]+Math.cos(f.rotation),f.position[1]+Math.sin(f.rotation),f.position[2]).applyMatrix4(l);let A=(this._x.x*.5+.5)*e.width,v=(-this._x.y*.5+.5)*e.height,E=Math.atan2(v-S,A-x),[R,L,N]=f.color?[Math.round(f.color[0]*255),Math.round(f.color[1]*255),Math.round(f.color[2]*255)]:this.lightBackground?[17,24,39]:[229,231,235];this.lightBackground&&R>230&&L>230&&N>230?[R,L,N]=[17,24,39]:!this.lightBackground&&R<20&&L<20&&N<20&&([R,L,N]=[241,245,249]),a.save(),a.translate(x,S),Math.abs(E)>1e-4&&a.rotate(E),a.font=`${w.toFixed(2)}px ${dm}`,a.fillStyle=`rgb(${R},${L},${N})`,a.textAlign=WM[_],a.textBaseline=XM[g];let B=w*fm,D=-(m.length-1)*B*g/2;for(let F=0;F{}};let l=new Set(a.flatMap(_=>_.elements)),c=K("div","ioviewer-sheets ioviewer-floating");c.setAttribute("role","tablist"),c.setAttribute("aria-label",q("sheets.label"));let h=new ki(new he,new sn({color:"#94a3b8",transparent:!0,opacity:.55}));h.visible=!1,t.add(h);let d=null,u=new Map;function f(_,g=!1){let p=a.find(x=>x.key===_)??a[0];if(!p)return;d=p;for(let[x,S]of u){let A=x===p.key;S.classList.toggle("active",A),S.setAttribute("aria-selected",String(A))}let y=new Set(p.elements),w=[];for(let x of l)y.has(x)||w.push(x);if(n.setAnnotationSheet(p.key),n.replaceLayerHidden("sheet",w),!p.isModel&&p.paperBounds){let{min:x,max:S}=p.paperBounds,A=x[2];h.geometry.setFromPoints([new C(x[0],x[1],A),new C(S[0],x[1],A),new C(S[0],S[1],A),new C(x[0],S[1],A)]),h.visible=!0}else h.visible=!1;p.background&&r(p.background,!g);let M=n.visibleBox();!p.isModel&&p.paperBounds&&(M.expandByPoint(new C(...p.paperBounds.min)),M.expandByPoint(new C(...p.paperBounds.max))),s(!!p.is2D,M,!1),o()}for(let _ of a){let g=K("button","ioviewer-sheet-tab",_.name);g.type="button",g.setAttribute("role","tab"),g.dataset.sheet=_.key,g.addEventListener("click",()=>f(_.key,!1)),u.set(_.key,g),c.append(g)}a.length>1&&i.append(c);let m=e.options?.initialSheet??a[0].key;return f(m,!0),{get active(){return d},setSheet:_=>f(_,!1)}}document.documentElement.lang=Pn;var Dn=document.getElementById("ioviewer-canvas"),ru=window.IOVIEWER_TEST??{},Kr=ru.startup;function Jr(i){let t=document.getElementById("ioviewer-message");t.textContent=i,t.hidden=!1}try{let i=xh(document,Kr);i.title&&(document.title=i.title);let t=Dn.getContext("webgl2",{antialias:!0,stencil:!0});t?$M(vf(document,Kr,i),t):Jr(q("noWebGL"))}catch(i){if(!(i instanceof ee))throw i;Jr(q("badData"))}function $M(i,t){let e=new Ti({canvas:Dn,context:t,antialias:!0,stencil:!0,logarithmicDepthBuffer:tp(i.meta)});e.setPixelRatio(window.devicePixelRatio),e.autoClearStencil=!1,e.localClippingEnabled=!0;let n=new pn,s=i.meta.options?.initialBackground||"#1f2228",r=new Vt(s);e.setClearColor(r,1);let o=new _r("#ffffff","#8a8f99",1.6);o.position.set(0,0,1),n.add(o);let a=new Ue(45,1,.1,1e3);a.up.set(0,0,1),a.position.set(1,-1,.8);let l=new xr("#ffffff",1.4);l.position.set(.3,.6,0),a.add(l,l.target),l.target.position.set(0,0,-1),n.add(a);let c=!1,h=document.getElementById("ioviewer-ui"),d=new Ol(h,i),u=d.layouts;Kr?.("sceneStart");let f=L(),m=new ll(i),_=new cl(i);Kr?.("sceneEnd"),i.releaseBinary(),!c&&f.totalCost===0&&m.count===0&&_.count===0&&!u.length&&Jr(q("noGeometry"));let g=new xl(f,V,Math.min(f.totalCost,2e7));n.add(f.root),n.add(m.root),n.add(_.root);let p=m.count?um(i.meta.panoramas):null;p&&n.add(p.mesh);let y=()=>f.visibleBox(),w=new Al(f,y(),i.meta.sections);m.syncVisibility(f),m.syncAppearance(f),_.syncVisibility(f),_.syncAppearance(f);let M=()=>{let{planes:dt,intersection:Nt}=w.clipping();m.setClipping(dt,Nt),_.setClipping(dt,Nt)};M();let x=f.slotCount>0,S=x&&t.getContextAttributes()?.stencil===!0,A,v=new Il(w,Dn);n.add(v.group);let E=new Ll(h),R=new Ul(h,i.meta.grids??[]);n.add(E.group,R.group);function L(){try{return new Gr(i,{...ru,maxTextureSize:e.capabilities.maxTextureSize,annotationLayouts:u})}catch(dt){if(!(dt instanceof Vr))throw dt;c=!0,Jr(q("tooLarge").replace("{count}",dt.count).replace("{limit}",dt.limit));let Nt=ne=>({o:0,n:0,t:ne}),Gt={count:0,geometry:Nt("u32"),material:Nt("u32"),element:Nt("i32"),matrix:Nt("f32")};return new Gr({...i,meta:{...i.meta,instances:Gt}},{annotationLayouts:u})}}let N=!1;Dn.addEventListener("webglcontextlost",()=>{N=!0,Jr(q("contextLost"))});let B,D=new Promise(dt=>B=dt),F=Kr,H=!1;function V(){H||N||(H=!0,g.requested(performance.now()),requestAnimationFrame(()=>{if(H=!1,N)return;let dt=Dn.getBoundingClientRect();nt.camera.updateMatrixWorld(),Yt&&p?.update(nt.camera,dt,Yt.showSphere),v.update(nt.camera),E.update(nt.camera,dt),R.update(nt.camera,dt),d.update(nt.camera,dt,f),g.begin(nt.camera,dt.height,performance.now()),F?.("renderStart"),w.fill&&S?(A??(A=new Pl(f,w,i)),A.render(e,n,nt.camera)):e.render(n,nt.camera),F&&(F("renderEnd"),F=void 0),g.end(performance.now()),at.update(),B()}))}f.root.addEventListener("change",V),w.addEventListener("change",()=>{M(),V()}),v.addEventListener("change",V),E.addEventListener("change",V),E.addEventListener("previewchange",V),R.addEventListener("change",V);let z=new gl(e,f,a,{points:m,lines:_,pickFloat:ru.pickFloat}),U=new Nl(z,w,i),k=0,Y=null;function G(){cancelAnimationFrame(k),k=0,Y=null,E.setPreview(null)}function J(){k=0,Y&&E.setPreview(U.target(...Y))}function it(){Y&&(E.setPreview(null),cancelAnimationFrame(k),k=requestAnimationFrame(()=>{k=requestAnimationFrame(J)}))}Dn.addEventListener("pointermove",dt=>{if(!E.active||dt.buttons)return G();Y=[dt.clientX,dt.clientY],k||(k=requestAnimationFrame(J))});for(let dt of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Dn.addEventListener(dt,G);f.root.addEventListener("change",dt=>{dt.detail.kind!=="appearance"&&it()});let nt=new dl(a,Dn,{pick:(dt,Nt)=>z.pick(dt,Nt)?.point??null,visibleBox:y});nt.addEventListener("change",()=>{z.camera=nt.camera,it(),V()}),f.root.addEventListener("change",dt=>{dt.detail.kind==="appearance"&&(m.syncAppearance(f),_.syncAppearance(f)),(dt.detail.kind==="appearance"||dt.detail.kind==="visibility")&&d.update(nt.camera,Dn.getBoundingClientRect(),f),dt.detail.kind==="visibility"&&(m.syncVisibility(f),_.syncVisibility(f),nt.invalidateBounds(),nt.resize())});let at,O=new yl;O.addEventListener("change",()=>f.setHighlighted([...O.values()]));let $=Op({root:h,data:i,scene:f,controls:nt,picker:z,selection:O,measure:E});nt.addEventListener("mode2d",()=>{$.sync2DState(),at?.set2D(nt.is2D)}),qp({root:h,...$,sections:w,selection:O,canFill:S,hasMeshes:x});let{meta:rt}=i,mt=rm({...$,files:rt.linkedFiles??[],elements:rt.elements,scene:f});jp({...$,controls:nt,scene:f,sections:w,selection:O,restoreLinkedModels:mt,views:rt.viewpoints??[],bcfTopics:rt.bcfTopics??[]});let ht=tm({...$,tests:rt.clashTests??[],elements:rt.elements,scene:f,controls:nt,selection:O});n.add(ht.group);let Et=sm({root:h,...$,timeliner:rt.timeliner,elements:rt.elements,scene:f}),Zt=dt=>{e.setClearColor(r.set(dt),1);let{r:Nt,g:Gt,b:ne}=r,Ut=.2126*Nt+.7152*Gt+.0722*ne>Math.sqrt(.0525)-.05,P=Ut?"#000":"#fff";h.style.setProperty("--viewport-text",dt===s?"":P),_.setLightBackground(Ut),d.setLightBackground(Ut),V()};{let{r:dt,g:Nt,b:Gt}=r,ne=.2126*dt+.7152*Nt+.0722*Gt>Math.sqrt(.0525)-.05;_.setLightBackground(ne),d.setLightBackground(ne),ne&&h.style.setProperty("--viewport-text","#000")}for(let dt of Jp({root:h,toolbar:$.toolbar,scene:f,meta:rt,grids:R,initialBackground:s,setBackground:Zt,hasMeshes:x}))$.onEscape(dt.close);$.toolbar.setHandler("distance",()=>{G(),E.setActive(!E.active),E.active||U.release(),$.toolbar.setActive("distance",E.active)}),$.toolbar.setActive("distance",!1),$.onEscape(()=>(G(),E.clear()));let Ct=()=>{nt.setExtraBounds("grids",R.visible?R.box:null),nt.setExtraBounds("measure",E.box)};R.addEventListener("change",Ct),E.addEventListener("change",Ct),Ct(),nt.addEventListener("click",dt=>{let{x:Nt,y:Gt,ctrl:ne,shift:pt}=dt.detail;if(E.active){let Tt=U.target(Nt,Gt);Tt&&E.add(Tt.point);return}let Ut=!ne&&!pt?p?.pick(Nt,Gt):void 0;if(Ut!==void 0){Yt.open(Ut);return}let ft=z.pick(Nt,Gt)?.element??-1;ne?ft>=0&&O.toggle(ft):ft>=0?O.set([ft]):pt||O.clear()}),nt.addEventListener("boxselect",dt=>{if(E.active)return;let{rect:Nt,mode:Gt,ctrl:ne,shift:pt}=dt.detail;if(Nt.width<4||Nt.height<4){!ne&&!pt&&O.clear();return}let Ut=new ae,P=lp(Nt,Gt,cp(f,nt.camera,Dn.getBoundingClientRect())),ft=w.clipping(),Tt=P.filter(I=>!w.isCut(f.elementBox(I,Ut),ft));O.set(ne?[...O.values(),...Tt]:Tt)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),nt.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),nt.resize(),nt.fitBox(y(),!1);let Yt=hm(h,i,m,f,nt,V);at=new ml(document.getElementById("ioviewer-ui"),a,nt);let Ht=pm({root:h,world:n,meta:rt,scene:f,apply2DMode:(dt,Nt,Gt)=>{nt.set2DMode(dt,Nt,Gt),dt||nt.fitBox(Nt,Gt),$.sync2DState(),at.set2D(nt.is2D)},setBackground:Zt,requestRender:V});!rt.sheets?.length&&rt.options?.initial2DMode&&(nt.set2DMode(!0,y(),!1),$.sync2DState(),at.set2D(!0)),window.addEventListener("pointerdown",dt=>{(dt.target===Dn||at.element.contains(dt.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:f,points:m,lines:_,annotationsOverlay:d,sheetsBar:Ht,motionDetail:g,controls:nt,picker:z,selection:O,ui:$,viewCube:at,sections:w,sectionGizmo:v,measure:E,measureSnap:U,grids:R,clashes:ht,timeliner:Et,ready:D,get camera(){return nt.camera}}}})(); /*! Bundled license information: three/build/three.core.js: diff --git a/src/IOViewer/Viewer/src/i18n.js b/src/IOViewer/Viewer/src/i18n.js index 0410af1..4dbead5 100644 --- a/src/IOViewer/Viewer/src/i18n.js +++ b/src/IOViewer/Viewer/src/i18n.js @@ -62,6 +62,7 @@ const dictionaries = { 'csv.loading': 'Чтение CSV…', 'csv.loaded': '{file} · Связано с 3D: {matched} из {total}', 'csv.noMatch': '{file} · Нет совпадений. Проверьте, что CSV относится к этой модели.', + 'csv.conflicts': 'Исключено строк из-за конфликта uniqueId: {count}. Проверьте, что файлы относятся к одной модели.', 'csv.invalid': 'Не удалось прочитать CSV. Выберите таблицу элементов RvtIO с уникальным elementId.', 'csv.noGeometry': 'У этого элемента нет геометрии в модели.', 'csv.search': 'Поиск по ID и имени', @@ -257,6 +258,7 @@ const dictionaries = { 'csv.loading': 'Reading CSV…', 'csv.loaded': '{file} · Linked to 3D: {matched} of {total}', 'csv.noMatch': '{file} · No matches. Check that the CSV belongs to this model.', + 'csv.conflicts': 'Rows excluded due to conflicting uniqueId values: {count}. Check that the files belong to the same model.', 'csv.invalid': 'Could not read the CSV. Choose an RvtIO element table with unique elementId values.', 'csv.noGeometry': 'This element has no geometry in the model.', 'csv.search': 'Search by ID and name', diff --git a/src/IOViewer/Viewer/src/model/elementCsv.js b/src/IOViewer/Viewer/src/model/elementCsv.js index 7d64486..be80538 100644 --- a/src/IOViewer/Viewer/src/model/elementCsv.js +++ b/src/IOViewer/Viewer/src/model/elementCsv.js @@ -67,6 +67,19 @@ export function parseElementCsv(text) { return { columns, rows, idColumn, rowById }; } +export function reconcileElementRows(csv, glbUniqueIds) { + if (!glbUniqueIds) return { csv, conflicts: 0 }; + const uniqueIdColumn = csv.columns.indexOf('uniqueId'); + const rows = csv.rows.filter((row) => { + const glbId = glbUniqueIds[row[csv.idColumn]]; + const csvId = row[uniqueIdColumn]; + // Null marks an elementId assigned to different UniqueIds by nodes in the GLB itself. + return glbId !== null && (glbId === undefined || !csvId?.trim() || glbId === csvId); + }); + const conflicts = csv.rows.length - rows.length; + return { csv: conflicts ? { ...csv, ...indexRows(csv, rows) } : csv, conflicts }; +} + export function filterElementRows(csv, search, category) { const query = search.trim().toLowerCase(); if (!query && category === null) return csv; diff --git a/src/IOViewer/Viewer/src/ui/app.js b/src/IOViewer/Viewer/src/ui/app.js index b72d861..549d7c1 100644 --- a/src/IOViewer/Viewer/src/ui/app.js +++ b/src/IOViewer/Viewer/src/ui/app.js @@ -68,7 +68,7 @@ export function mountUI({ root, data, scene, controls, picker, selection, measur shell.registerPanel('elements', { icon: icons.elements, title: t('panel.elements'), - render: (body) => mountElementTable(body, meta.elements, selection), + render: (body) => mountElementTable(body, meta.elements, selection, meta.glbUniqueIds), }); } const properties = document.createElement('aside'); diff --git a/src/IOViewer/Viewer/src/ui/elementTable.js b/src/IOViewer/Viewer/src/ui/elementTable.js index 30fae5a..d1f2572 100644 --- a/src/IOViewer/Viewer/src/ui/elementTable.js +++ b/src/IOViewer/Viewer/src/ui/elementTable.js @@ -1,5 +1,5 @@ import { formatCount, lang, t } from '../i18n.js'; -import { filterElementRows, formatElementCsv, groupElementRows, parseElementCsv, QUANTITY_COLUMNS, sortElementRows, sumElementQuantities } from '../model/elementCsv.js'; +import { filterElementRows, formatElementCsv, groupElementRows, parseElementCsv, QUANTITY_COLUMNS, reconcileElementRows, sortElementRows, sumElementQuantities } from '../model/elementCsv.js'; import { el } from './dom.js'; const PAGE_SIZE = 100; @@ -28,7 +28,7 @@ function createTotals(label) { }; } -export function mountElementTable(body, elements, selection) { +export function mountElementTable(body, elements, selection, glbUniqueIds) { const elementById = new Map(); elements.forEach((element, index) => { if (element.sourceId != null) elementById.set(element.sourceId, index); @@ -244,7 +244,9 @@ export function mountElementTable(body, elements, selection) { try { const text = await file.text(); if (request !== loadRequest) return; - csv = parseElementCsv(text); + const parsed = parseElementCsv(text); + const { csv: compatible, conflicts } = reconcileElementRows(parsed, glbUniqueIds); + csv = compatible; downloadName = file.name.replace(/\.csv$/i, '') + '-filtered.csv'; sortColumn = -1; ascending = true; @@ -276,7 +278,8 @@ export function mountElementTable(body, elements, selection) { } let matched = 0; for (const id of elementById.keys()) if (csv.rowById.has(id)) matched++; - status.textContent = message(matched ? 'csv.loaded' : 'csv.noMatch', { file: file.name, matched, total: csv.rows.length }); + status.textContent = message(matched || conflicts ? 'csv.loaded' : 'csv.noMatch', { file: file.name, matched, total: parsed.rows.length }); + if (conflicts) status.append(' · ', message('csv.conflicts', { count: formatCount(conflicts) })); const categoryColumn = csv.columns.indexOf('category'); category.hidden = categoryColumn < 0; groupToggle.hidden = category.hidden; diff --git a/src/IOViewer/Viewer/test/e2e/element-table.spec.js b/src/IOViewer/Viewer/test/e2e/element-table.spec.js index 0a9145a..4c6205f 100644 --- a/src/IOViewer/Viewer/test/e2e/element-table.spec.js +++ b/src/IOViewer/Viewer/test/e2e/element-table.spec.js @@ -4,13 +4,15 @@ import path from 'node:path'; import { pathToFileURL } from 'node:url'; import { viewerDir } from './global-setup.js'; -const screenAt = (page, index) => page.evaluate((i) => { +const screenAt = (page, index, xFraction = 0.5) => page.evaluate(({ index, xFraction }) => { const { scene, camera } = window.__ioviewer; - const box = scene.elementBox(i); - const center = box.getCenter(box.min.clone()).project(camera); + const box = scene.elementBox(index); + const center = box.getCenter(box.min.clone()); + center.x = box.min.x + (box.max.x - box.min.x) * xFraction; + center.project(camera); const rect = document.getElementById('ioviewer-canvas').getBoundingClientRect(); return [rect.left + ((center.x + 1) / 2) * rect.width, rect.top + ((1 - center.y) / 2) * rect.height]; -}, index); +}, { index, xFraction }); test('CSV selects all GLB placements and picking in 3D finds the row on another page', async ({ page }) => { const errors = []; @@ -47,6 +49,52 @@ test('CSV selects all GLB placements and picking in 3D finds the row on another expect(errors).toEqual([]); }); +test('conflicting UniqueIds prevent linking and exclude foreign quantities from totals and downloads', async ({ page }) => { + await page.goto(pathToFileURL(path.join(viewerDir, 'test-results', 'element-table.html')).href); + await page.evaluate(() => window.__ioviewer.ready); + await page.getByRole('button', { name: 'Таблица элементов' }).click(); + const panel = page.getByRole('region', { name: 'Таблица элементов' }); + const heading = 'elementId,uniqueId,name,category,volume_m3'; + const load = async (name, rows) => { + await panel.locator('input[type=file]').setInputFiles({ + name, mimeType: 'text/csv', buffer: Buffer.from([heading, ...rows].join('\n')), + }); + await expect(panel.getByRole('status')).toContainText(name); + }; + + const foreign = '101,other-wall-101,Чужая стена,Стены,100'; + await load('foreign.csv', [foreign]); + await expect(panel.getByRole('status')).toContainText('Связано с 3D: 0 из 1'); + await expect(panel.getByRole('status')).toContainText('конфликта uniqueId: 1'); + await expect(panel.getByRole('button', { name: '101', exact: true })).toHaveCount(0); + await expect(panel.locator('.ioviewer-csv-totals dd')).toHaveText(['0', '—', '—', '—']); + + const fallback = '202,csv-only-202,Колонна,Опоры,3'; + await load('mixed.csv', [foreign, fallback]); + await expect(panel.getByRole('status')).toContainText('Связано с 3D: 1 из 2'); + await panel.getByRole('checkbox', { name: 'Группировать по категориям' }).check(); + await expect(panel.locator('.ioviewer-csv-group-heading strong')).toHaveText(['Опоры']); + await expect(panel.locator('.ioviewer-csv-group-heading dd')).toHaveText(['1', '—', '—', '3 м³']); + const download = page.waitForEvent('download'); + await panel.getByRole('button', { name: 'Скачать CSV' }).click(); + const file = await readFile(await (await download).path(), 'utf8'); + expect(file).toBe('\uFEFF' + [heading + ',element_count', fallback + ',', 'SUBTOTAL,,,Опоры,3,1', 'TOTAL,,,,3,1', ''].join('\r\n')); + + const toggle = page.getByRole('button', { name: 'Таблица элементов' }); + await toggle.click(); + // Element 101 has two placements. Aim inside the first, away from the gap between them. + await page.mouse.click(...(await screenAt(page, 0, 0.25))); + expect(await page.evaluate(() => [...window.__ioviewer.selection.values()])).toEqual([0]); + await toggle.click(); + await expect(panel.getByRole('button', { name: '101', exact: true })).toHaveCount(0); + await expect(panel.getByText('Чужая стена')).toHaveCount(0); + + await load('matching.csv', ['101,wall-101,Стена,Стены,5']); + await expect(panel.getByRole('status')).toContainText('Связано с 3D: 1 из 1'); + await expect(panel.getByRole('status')).not.toContainText('конфликта uniqueId'); + await expect(panel.getByRole('button', { name: '101', exact: true })).toHaveAttribute('aria-pressed', 'true'); +}); + test('search and category preserve two-way selection, including a picked row outside the filters', async ({ page }) => { await page.goto(pathToFileURL(path.join(viewerDir, 'test-results', 'element-table.html')).href); await page.evaluate(() => window.__ioviewer.ready); diff --git a/src/IOViewer/Viewer/test/e2e/global-setup.js b/src/IOViewer/Viewer/test/e2e/global-setup.js index b86c6df..3374b52 100644 --- a/src/IOViewer/Viewer/test/e2e/global-setup.js +++ b/src/IOViewer/Viewer/test/e2e/global-setup.js @@ -34,8 +34,8 @@ function elementTableGlb() { accessors: [{ bufferView: 0, componentType: 5126, count: positions.length / 3, type: 'VEC3' }, { bufferView: 1, componentType: 5125, count: box.Indices.length, type: 'SCALAR' }], meshes: [{ primitives: [{ attributes: { POSITION: 0 }, indices: 1 }] }], - nodes: [[101, -2], [101, -0.8], [202, 2]].map(([elementId, x]) => - ({ mesh: 0, translation: [x, 0, 0], extras: { elementId } })), + nodes: [[101, -2, 'wall-101'], [101, -0.8, 'wall-101'], [202, 2]].map(([elementId, x, uniqueId]) => + ({ mesh: 0, translation: [x, 0, 0], extras: { elementId, uniqueId } })), scenes: [{ nodes: [0, 1, 2] }], }); const metadata = Buffer.from(json.padEnd(Math.ceil(json.length / 4) * 4)); diff --git a/src/IOViewer/Viewer/test/unit/elementCsv.test.js b/src/IOViewer/Viewer/test/unit/elementCsv.test.js index 0f5324e..518468e 100644 --- a/src/IOViewer/Viewer/test/unit/elementCsv.test.js +++ b/src/IOViewer/Viewer/test/unit/elementCsv.test.js @@ -1,6 +1,23 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { filterElementRows, formatElementCsv, groupElementRows, parseElementCsv, sortElementRows, sumElementQuantities } from '../../src/model/elementCsv.js'; +import { filterElementRows, formatElementCsv, groupElementRows, parseElementCsv, reconcileElementRows, sortElementRows, sumElementQuantities } from '../../src/model/elementCsv.js'; + +test('reconciles supplied UniqueIds and keeps rows lacking either identity', () => { + const parsed = parseElementCsv([ + 'elementId,uniqueId,volume_m3', '101,foreign,100', '102,wall,2', '103,,3', '104,csv-only,4', + '105,ambiguous,100', '106, ,6', '107,unmodeled,7', + ].join('\n')); + const glbUniqueIds = { 101: 'wall', 102: 'wall', 103: 'known', 105: null, 106: 'known' }; + const { csv, conflicts } = reconcileElementRows(parsed, glbUniqueIds); + assert.equal(conflicts, 2); + assert.deepEqual([...csv.rowById], [['102', 0], ['103', 1], ['104', 2], ['106', 3], ['107', 4]]); + assert.deepEqual(sumElementQuantities(csv, csv.rows), [null, null, 22]); + assert.equal(parsed.rows.length, 7); + + const legacy = parseElementCsv('elementId,volume_m3\n101,1'); + assert.deepEqual(reconcileElementRows(legacy, glbUniqueIds), { csv: legacy, conflicts: 0 }); + assert.deepEqual(reconcileElementRows(parsed, undefined), { csv: parsed, conflicts: 0 }); +}); test('reads RvtIO CSV with BOM, LF/CRLF, Unicode, quotes, empty cells and zero', () => { const value = parseElementCsv('\uFEFFelementId,name,volume_m3\r\n-2,"Стена, ""А""\r\nсекция",\r\n0,,0'); diff --git a/tests/IOViewer.Tests/GlbSharedGeometryTests.cs b/tests/IOViewer.Tests/GlbSharedGeometryTests.cs index 9c3a849..383b212 100644 --- a/tests/IOViewer.Tests/GlbSharedGeometryTests.cs +++ b/tests/IOViewer.Tests/GlbSharedGeometryTests.cs @@ -1,6 +1,8 @@ using System.Buffers.Binary; using System.Text; +using System.Text.Json; using IOScene; +using IOViewer.Exporters; using IOViewer.Importers; using IOViewer.Model; using Xunit; @@ -104,6 +106,29 @@ public void ExplicitSourceIdGroupsPlacementsWithoutUsingLocalSceneIds() Assert.Empty(doc.Scene.Validate()); } + [Fact] + public void CsvUniqueIdsSurviveViewerJsonAndMarkConflictingPlacements() + { + var doc = Import(""" + { "children": [1, 2], "extras": { "elementId": 101, "uniqueId": "wall" } }, + { "mesh": 0, "extras": { "elementId": 101 } }, + { "mesh": 0, "extras": { "elementId": 101, "uniqueId": "wall" } }, + { "mesh": 0, "extras": { "elementId": 202, "uniqueId": "first" } }, + { "mesh": 0, "extras": { "elementId": 202, "uniqueId": "other" } }, + { "extras": { "elementId": 303, "uniqueId": "without-mesh" } }, + { "mesh": 0, "extras": { "elementId": 404, "uniqueId": 42 } } + """, "0, 3, 4, 5, 6"); + + using var buffer = new MemoryStream(Encoding.UTF8.GetBytes(JsonViewerExporter.ExportToString(doc))); + var restored = JsonViewerImporter.Load(buffer); + var identities = ViewerHtml.Export(restored, new HtmlViewerOptions { IncludeProperties = false }) + .Meta.GetProperty("glbUniqueIds"); + Assert.Equal("wall", identities.GetProperty("101").GetString()); + Assert.Equal(JsonValueKind.Null, identities.GetProperty("202").ValueKind); + Assert.Equal("without-mesh", identities.GetProperty("303").GetString()); + Assert.False(identities.TryGetProperty("404", out _)); + } + [Fact] public void YUp_IsConvertedToZUp() {