From e8ad04e2255a5b593a1a12490896f20ab4509fcb Mon Sep 17 00:00:00 2001 From: mahach666 <79989386+mahach666@users.noreply.github.com> Date: Thu, 3 Dec 2026 11:05:17 +0300 Subject: [PATCH] Link GLB elements to a filterable CSV table --- README.md | 24 ++ src/IOViewer/Exporters/ViewerPayloadWriter.cs | 2 + src/IOViewer/Importers/GlbViewerImporter.cs | 30 +- src/IOViewer/Viewer/dist/viewer.js | 398 +++++++++--------- src/IOViewer/Viewer/src/i18n.js | 52 +++ src/IOViewer/Viewer/src/model/elementCsv.js | 195 +++++++++ src/IOViewer/Viewer/src/ui/app.js | 8 + src/IOViewer/Viewer/src/ui/elementTable.js | 303 +++++++++++++ src/IOViewer/Viewer/src/ui/icons.js | 1 + src/IOViewer/Viewer/src/ui/shell.js | 2 +- src/IOViewer/Viewer/styles/viewer.css | 258 ++++++++++++ .../Viewer/test/e2e/element-table.spec.js | 229 ++++++++++ src/IOViewer/Viewer/test/e2e/global-setup.js | 41 +- .../Viewer/test/unit/elementCsv.test.js | 131 ++++++ .../IOViewer.Tests/GlbSharedGeometryTests.cs | 18 + 15 files changed, 1484 insertions(+), 208 deletions(-) create mode 100644 src/IOViewer/Viewer/src/model/elementCsv.js create mode 100644 src/IOViewer/Viewer/src/ui/elementTable.js create mode 100644 src/IOViewer/Viewer/test/e2e/element-table.spec.js create mode 100644 src/IOViewer/Viewer/test/unit/elementCsv.test.js diff --git a/README.md b/README.md index b781cd9..a1726b9 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,30 @@ ioviewer model.nwc -o viewer.html ioviewer model.glb --serve ``` +To link a Revit element table with the model, export both files from the same RvtIO run and generate a viewer from the GLB. + +```sh +rvtio project.rvt --glb project.glb --csv elements.csv +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 +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, +with empty values last. The summary shows the count and total length, area, and volume for all matching rows across +pages. Missing measurements are skipped. A quantity with no valid measurements is shown as a dash. +Enable **Group by category** to see counts and sums for each category alongside its element rows. The totals cover +the full matching group on each page where it appears. Categories appear alphabetically, and selecting the category +heading as the sort column controls the category order. Sorting on another column orders elements within each group. +**Download CSV** saves every matching row across all pages in the selected row order. When grouping is enabled, +each category is followed by a row with `SUBTOTAL` in `elementId` and the category name in `category`. The last row +has `TOTAL` in `elementId`. Both summaries put the element count in `element_count` and sums in the source quantity +columns. Existing columns keep their order. Missing sums are blank, and an empty result exports a count of zero. +The viewer skips summary rows when reopening a downloaded CSV and recalculates the totals from the element rows. +This panel is available for single-model GLB viewers with source element IDs. + Pass `--add` and `--placement` to combine several source models into one offline HTML viewer. ```sh diff --git a/src/IOViewer/Exporters/ViewerPayloadWriter.cs b/src/IOViewer/Exporters/ViewerPayloadWriter.cs index 0c85418..e66b223 100644 --- a/src/IOViewer/Exporters/ViewerPayloadWriter.cs +++ b/src/IOViewer/Exporters/ViewerPayloadWriter.cs @@ -894,6 +894,8 @@ public void WriteMeta(Stream output) var host = _scene.Models.Count > 0 ? _scene.Models[0] : null; 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); WriteVector(w, "rtcOffset", _rtcOffset); WriteBox(w, "bbox", _bounds, _rtcOffset); diff --git a/src/IOViewer/Importers/GlbViewerImporter.cs b/src/IOViewer/Importers/GlbViewerImporter.cs index 7a09861..cec20b8 100644 --- a/src/IOViewer/Importers/GlbViewerImporter.cs +++ b/src/IOViewer/Importers/GlbViewerImporter.cs @@ -1,4 +1,5 @@ using System.Buffers.Binary; +using System.Globalization; using System.Text; using System.Text.Json; using IOScene; @@ -8,7 +9,7 @@ namespace IOViewer.Importers; /// /// Imports standard glTF 2.0 Binary (.glb) files into a ViewerDocument whose scene has one model: one geometry per -/// mesh primitive, one element per node that draws a mesh, and one instance per primitive of that node, with the +/// mesh primitive, one element per source element (or node without a source id), and one instance per primitive, with the /// node's world transform converted from glTF's Y-up to the scene's Z-up. /// public static class GlbViewerImporter @@ -129,10 +130,11 @@ private static ViewerDocument Load(Stream stream, string documentTitle, string m // Parse meshes lazily: one geometry per (mesh, primitive), one instance per primitive of a node occurrence. var meshElements = root.TryGetProperty("meshes", out var meshesEl) ? meshesEl.EnumerateArray().ToArray() : []; var geometryIds = new Dictionary<(int Mesh, int Primitive), int?>(); + var sourceElements = new Dictionary(); int meshCounter = 0; - // One element per node occurrence: all primitives of its mesh select, hide and list as one object. - void Instantiate(int meshIndex, Transform3d world, string? nodeName) + // Mesh placements sharing an explicit source element id select and hide together. + void Instantiate(int meshIndex, Transform3d world, string? nodeName, int? sourceId) { if (meshIndex < 0 || meshIndex >= meshElements.Length) { @@ -143,7 +145,7 @@ void Instantiate(int meshIndex, Transform3d world, string? nodeName) string meshName = meshEl.TryGetProperty("name", out var mn) ? mn.GetString() ?? $"Mesh {meshCounter + 1}" : $"Mesh {meshCounter + 1}"; if (!meshEl.TryGetProperty("primitives", out var primsEl)) return; - SceneElement? element = null; + SceneElement? element = sourceId is int id ? sourceElements.GetValueOrDefault(id) : null; int primIndex = -1; foreach (var prim in primsEl.EnumerateArray()) { @@ -204,8 +206,16 @@ void Instantiate(int meshIndex, Transform3d world, string? nodeName) if (element is null) { - element = new SceneElement { Id = doc.Elements.Count + 1, ModelId = 1, Name = string.IsNullOrEmpty(nodeName) ? meshName : nodeName, Category = "GLB" }; + element = new SceneElement + { + Id = doc.Elements.Count + 1, + ModelId = 1, + Name = string.IsNullOrEmpty(nodeName) ? meshName : nodeName, + Category = "GLB", + SourceId = sourceId?.ToString(CultureInfo.InvariantCulture), + }; doc.Elements.Add(element); + if (sourceId is int newId) sourceElements.Add(newId, element); } ++meshCounter; @@ -248,7 +258,8 @@ void Instantiate(int meshIndex, Transform3d world, string? nodeName) var world = ReadNodeTransform(node).Then(parentWorld); if (node.TryGetProperty("mesh", out var meshProp)) { - Instantiate(meshProp.GetInt32(), world, node.TryGetProperty("name", out var nodeName) ? nodeName.GetString() : null); + Instantiate(meshProp.GetInt32(), world, + node.TryGetProperty("name", out var nodeName) ? nodeName.GetString() : null, ReadElementId(node)); } if (node.TryGetProperty("children", out var children)) @@ -261,12 +272,17 @@ void Instantiate(int meshIndex, Transform3d world, string? nodeName) else { // No scene graph: import every mesh once without a node transform. - for (int i = 0; i < meshElements.Length; i++) Instantiate(i, Transform3d.Identity, null); + for (int i = 0; i < meshElements.Length; i++) Instantiate(i, Transform3d.Identity, null, null); } return new ViewerDocument(doc); } + 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; + // 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/Viewer/dist/viewer.js b/src/IOViewer/Viewer/dist/viewer.js index e4fb3db..a234b51 100644 --- a/src/IOViewer/Viewer/dist/viewer.js +++ b/src/IOViewer/Viewer/dist/viewer.js @@ -1,10 +1,10 @@ -(()=>{var cu=i=>{throw TypeError(i)};var Ol=(i,t,e)=>t.has(i)||cu("Cannot "+e);var di=(i,t,e)=>(Ol(i,t,"read from private field"),e?e.call(i):t.get(i)),zl=(i,t,e)=>t.has(i)?cu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),hu=(i,t,e,n)=>(Ol(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),Qr=(i,t,e)=>(Ol(i,t,"access private method"),e);var Wu=0,xc=1,Xu=2;var xr=1,qu=2,Cs=3,qn=0,ze=1,ke=2,Yn=0,Is=1,vc=2,yc=3,Mc=4,Yu=5;var Gi=100,$u=101,Zu=102,Ku=103,Ju=104,ju=200,Qu=201,td=202,ed=203,bc=204,Sc=205,nd=206,id=207,sd=208,rd=209,od=210,ad=211,ld=212,cd=213,hd=214,Po=0,Lo=1,Do=2,ms=3,No=4,Uo=5,Fo=6,Bo=7,vr=0,ud=1,dd=2,En=0,wc=1,Ec=2,Tc=3,Ac=4,Rc=5,Cc=6,Ic=7;var Pc=300,bi=301,Wi=302,ha=303,ua=304,yr=306,gs=1e3,Fn=1001,Oo=1002,Le=1003,fd=1004;var Mr=1005;var qe=1006,da=1007;var Si=1008;var rn=1009,Lc=1010,Dc=1011,Ps=1012,fa=1013,Tn=1014,Ye=1015,An=1016,pa=1017,ma=1018,Ls=1020,Nc=35902,Uc=35899,Fc=1021,Bc=1022,je=1023,Bn=1026,wi=1027,Ds=1028,ga=1029,Ei=1030,_a=1031;var xa=1033,br=33776,Sr=33777,wr=33778,Er=33779,va=35840,ya=35841,Ma=35842,ba=35843,Sa=36196,wa=37492,Ea=37496,Ta=37488,Aa=37489,Tr=37490,Ra=37491,Ca=37808,Ia=37809,Pa=37810,La=37811,Da=37812,Na=37813,Ua=37814,Fa=37815,Ba=37816,Oa=37817,za=37818,ka=37819,Ha=37820,Va=37821,Ga=36492,Wa=36494,Xa=36495,qa=36283,Ya=36284,Ar=36285,$a=36286;var tr=2300,zo=2301,Ro=2302,cc=2303,hc=2400,uc=2401,dc=2402;var pd=3200;var Rr=0,md=1,oi="",me="srgb",er="srgb-linear",nr="linear",fe="srgb";var Co=7680;var Oc=34055,zc=34056;var kc=517;var gd=519,_d=512,xd=513,vd=514,Za=515,yd=516,Md=517,Ka=518,bd=519,Hc=35044,Cr=35048;var Vc="300 es",bn=2e3,_s=2001;function tm(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function em(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function xs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Sd(){let i=xs("canvas");return i.style.display="block",i}var uu={},vs=null;function ir(...i){let t="THREE."+i.shift();vs?vs("log",t,...i):console.log(t,...i)}function wd(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 Ht(...i){i=wd(i);let t="THREE."+i.shift();if(vs)vs("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Xt(...i){i=wd(i);let t="THREE."+i.shift();if(vs)vs("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 uu||(uu[t]=!0,Ht(...i))}function Ed(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 Td={[Po]:Lo,[Do]:Fo,[No]:Bo,[ms]:Uo,[Lo]:Po,[Fo]:Do,[Bo]:No,[Uo]:ms},On=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 ie(i,t,e){return Math.max(t,Math.min(e,i))}function Gc(i,t){return(i%t+t)%t}function nm(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function im(i,t,e){return i!==t?(e-i)/(t-i):0}function Qs(i,t,e){return(1-e)*i+e*t}function sm(i,t,e,n){return Qs(i,t,1-Math.exp(-e*n))}function rm(i,t=1){return t-Math.abs(Gc(i,t*2)-t)}function om(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function am(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function lm(i,t){return i+Math.floor(Math.random()*(t-i+1))}function cm(i,t){return i+Math.random()*(t-i)}function hm(i){return i*(.5-Math.random())}function um(i){i!==void 0&&(du=i);let t=du+=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*fs}function fm(i){return i*ys}function pm(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function mm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function gm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function _m(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),g=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*g,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*g,a*c);break;case"ZYZ":i.set(l*g,l*f,a*h,a*c);break;default:Ht("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 re={DEG2RAD:fs,RAD2DEG:ys,generateUUID:ii,clamp:ie,euclideanModulo:Gc,mapLinear:nm,inverseLerp:im,lerp:Qs,damp:sm,pingpong:rm,smoothstep:om,smootherstep:am,randInt:lm,randFloat:cm,randFloatSpread:hm,seededRandom:um,degToRad:dm,radToDeg:fm,isPowerOfTwo:pm,ceilPowerOfTwo:mm,floorPowerOfTwo:gm,setQuaternionFromProperEuler:_m,normalize:pe,denormalize:Mn},$c=class $c{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=ie(this.x,t.x,e.x),this.y=ie(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ie(this.x,t,e),this.y=ie(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ie(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(ie(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}};$c.prototype.isVector2=!0;var Wt=$c,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],g=r[o+2],_=r[o+3];if(d!==_||l!==u||c!==f||h!==g){let m=l*u+c*f+h*g+d*_;m<0&&(u=-u,f=-f,g=-g,_=-_,m=-m);let p=1-a;if(m<.9995){let y=Math.acos(m),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+g*a,d=d*p+_*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+g*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],g=r[o+3];return t[e]=a*g+h*d+l*f-c*u,t[e+1]=l*g+h*u+c*d-a*f,t[e+2]=c*g+h*f+a*u-l*d,t[e+3]=h*g-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),g=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:Ht("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(ie(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}},Zc=class Zc{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(fu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(fu.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=ie(this.x,t.x,e.x),this.y=ie(this.y,t.y,e.y),this.z=ie(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ie(this.x,t,e),this.y=ie(this.y,t,e),this.z=ie(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ie(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 kl.copy(this).projectOnVector(t),this.sub(kl)}reflect(t){return this.sub(kl.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(ie(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}};Zc.prototype.isVector3=!0;var C=Zc,kl=new C,fu=new Fe,Kc=class Kc{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],g=n[8],_=s[0],m=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*m+a*w+l*S,r[6]=o*p+a*M+l*A,r[1]=c*_+h*y+d*x,r[4]=c*m+h*w+d*S,r[7]=c*p+h*M+d*A,r[2]=u*_+f*y+g*x,r[5]=u*m+f*w+g*S,r[8]=u*p+f*M+g*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,g=e*d+n*u+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;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(Hl.makeScale(t,e)),this}rotate(t){return Fi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Hl.makeRotation(-t)),this}translate(t,e){return Fi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Hl.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)}};Kc.prototype.isMatrix3=!0;var $t=Kc,Hl=new $t,pu=new $t().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mu=new $t().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xm(){let i={enabled:!0,workingColorSpace:er,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===fe&&(s.r=si(s.r),s.g=si(s.g),s.b=si(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=ps(s.r),s.g=ps(s.g),s.b=ps(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===oi?nr: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({[er]:{primaries:t,whitePoint:n,transfer:nr,toXYZ:pu,fromXYZ:mu,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:me},outputColorSpaceConfig:{drawingBufferColorSpace:me}},[me]:{primaries:t,whitePoint:n,transfer:fe,toXYZ:pu,fromXYZ:mu,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:me}}}),i}var ne=xm();function si(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ps(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ji,ko=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{ji===void 0&&(ji=xs("canvas")),ji.width=t.width,ji.height=t.height;let s=ji.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=ji}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=xs("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(Gl).x}get height(){return this.source.getSize(Gl).y}get depth(){return this.source.getSize(Gl).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){Ht(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Ht(`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!==Pc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case gs:t.x=t.x-Math.floor(t.x);break;case Fn:t.x=t.x<0?0:1;break;case Oo: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 gs:t.y=t.y-Math.floor(t.y);break;case Fn:t.y=t.y<0?0:1;break;case Oo: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=Pc;We.DEFAULT_ANISOTROPY=1;var Jc=class Jc{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],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(g+m)<.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=(g+m)/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((m-g)*(m-g)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(y)<.001&&(y=1),this.x=(m-g)/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=ie(this.x,t.x,e.x),this.y=ie(this.y,t.y,e.y),this.z=ie(this.z,t.z,e.z),this.w=ie(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=ie(this.x,t,e),this.y=ie(this.y,t,e),this.z=ie(this.z,t,e),this.w=ie(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ie(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}};Jc.prototype.isVector4=!0;var ve=Jc,Ho=class extends On{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),g.length>0&&(n.nodes=g)}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+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(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(Am)))}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]}},Ad={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},no={h:0,s:0,l:0};function Xl(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 kt=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,ne.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=ne.workingColorSpace){return this.r=t,this.g=e,this.b=n,ne.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=ne.workingColorSpace){if(t=Gc(t,1),e=ie(e,0,1),n=ie(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=Xl(o,r,t+1/3),this.g=Xl(o,r,t),this.b=Xl(o,r,t-1/3)}return ne.colorSpaceToWorking(this,s),this}setStyle(t,e=me){function n(r){r!==void 0&&parseFloat(r)<1&&Ht("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:Ht("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);Ht("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=me){let n=Ad[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Ht("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=si(t.r),this.g=si(t.g),this.b=si(t.b),this}copyLinearToSRGB(t){return this.r=ps(t.r),this.g=ps(t.g),this.b=ps(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=me){return ne.workingToColorSpace(Ke.copy(this),t),Math.round(ie(Ke.r*255,0,255))*65536+Math.round(ie(Ke.g*255,0,255))*256+Math.round(ie(Ke.b*255,0,255))}getHexString(t=me){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ne.workingColorSpace){ne.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),jn.subVectors(n,e),ql.subVectors(t,e);let o=vn.dot(vn),a=vn.dot(jn),l=vn.dot(ql),c=jn.dot(jn),h=jn.dot(ql),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,g=(o*h-a*l)*u;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,Qn)===null?!1:Qn.x>=0&&Qn.y>=0&&Qn.x+Qn.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,Qn)===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,Qn.x),l.addScaledVector(o,Qn.y),l.addScaledVector(a,Qn.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return Kl.setScalar(0),Jl.setScalar(0),jl.setScalar(0),Kl.fromBufferAttribute(t,e),Jl.fromBufferAttribute(t,n),jl.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(Kl,r.x),o.addScaledVector(Jl,r.y),o.addScaledVector(jl,r.z),o}static isFrontFacing(t,e,n,s){return vn.subVectors(n,e),jn.subVectors(t,e),vn.cross(jn).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),jn.subVectors(this.a,this.b),vn.cross(jn).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;ns.subVectors(s,n),is.subVectors(r,n),Yl.subVectors(t,n);let l=ns.dot(Yl),c=is.dot(Yl);if(l<=0&&c<=0)return e.copy(n);$l.subVectors(t,s);let h=ns.dot($l),d=is.dot($l);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(ns,o);Zl.subVectors(t,r);let f=ns.dot(Zl),g=is.dot(Zl);if(g>=0&&f<=g)return e.copy(r);let _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return a=c/(c-g),e.copy(n).addScaledVector(is,a);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return Su.subVectors(r,s),a=(d-h)/(d-h+(f-g)),e.copy(s).addScaledVector(Su,a);let p=1/(m+_+u);return o=_*p,a=u*p,e.copy(n).addScaledVector(ns,o).addScaledVector(is,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},se=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(Ys),so.subVectors(this.max,Ys),ss.subVectors(t.a,Ys),rs.subVectors(t.b,Ys),os.subVectors(t.c,Ys),mi.subVectors(rs,ss),gi.subVectors(os,rs),Li.subVectors(ss,os);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!Ql(e,ss,rs,os,so)||(e=[1,0,0,0,1,0,0,0,1],!Ql(e,ss,rs,os,so))?!1:(ro.crossVectors(mi,gi),e=[ro.x,ro.y,ro.z],Ql(e,ss,rs,os,so))}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:(ti[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ti[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ti[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ti[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ti[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ti[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ti[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ti[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ti),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}},ti=[new C,new C,new C,new C,new C,new C,new C,new C],yn=new C,io=new se,ss=new C,rs=new C,os=new C,mi=new C,gi=new C,Li=new C,Ys=new C,so=new C,ro=new C,Di=new C;function Ql(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,oo=new Wt,Rm=0,xe=class extends On{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:Rm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Hc,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;$s.subVectors(t,this.center);let e=$s.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector($s,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):(tc.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint($s.copy(t.center).add(tc)),this.expandByPoint($s.copy(t.center).sub(tc))),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}},Im=0,fn=new Yt,ec=new Xe,as=new C,an=new se,Zs=new se,Ge=new C,ce=class i extends On{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Im++}),this.uuid=ii(),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(tm(t)?or:rr)(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 $t().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 ec.lookAt(t),ec.updateMatrix(),this.applyMatrix4(ec.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(as).negate(),this.translate(as.x,as.y,as.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;se.count&&Ht("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 se);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Xt("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||Lm.getNormalMatrix(t),s=this.coplanarPoint(nc).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}},Dm=0,Sn=class extends On{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Dm++}),this.uuid=ii(),this.name="",this.type="Material",this.blending=Is,this.side=qn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bc,this.blendDst=Sc,this.blendEquation=Gi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new kt(0,0,0),this.blendAlpha=0,this.depthFunc=ms,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=gd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Co,this.stencilZFail=Co,this.stencilZPass=Co,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){Ht(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){Ht(`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 kt().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 Wt().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 Wt().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 ei=new C,ic=new C,ao=new C,lo=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,ei)),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=ei.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ei.copy(this.origin).addScaledVector(this.direction,e),ei.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){ic.copy(t).add(e).multiplyScalar(.5),ao.copy(e).sub(t).normalize(),lo.copy(this.origin).sub(ic);let r=t.distanceTo(e)*.5,o=-this.direction.dot(ao),a=lo.dot(this.direction),l=-lo.dot(ao),c=lo.lengthSq(),h=Math.abs(1-o*o),d,u,f,g;if(h>0)if(d=o*l-a,u=o*a-l,g=r*h,d>=0)if(u>=-g)if(u<=g){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<=-g?(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<=g?(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(ic).addScaledVector(ao,u),f}intersectSphere(t,e){if(t.radius<0)return null;ei.subVectors(t.center,this.origin);let n=ei.dot(this.direction),s=ei.dot(ei)-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,ei)!==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,g=e.x-o.x,_=e.y-o.y,m=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,k,V,O;if(M>=x&&M>=S?(E=l,N=d,F=g,O=p,l>=0?(A=c,v=h,R=u,L=f,B=_,D=m,k=y,V=w):(A=h,v=c,R=f,L=u,B=m,D=_,k=w,V=y)):x>=S?(E=c,N=u,F=_,O=y,c>=0?(A=h,v=l,R=f,L=d,B=m,D=g,k=w,V=p):(A=l,v=h,R=d,L=f,B=g,D=m,k=p,V=w)):(E=h,N=f,F=m,O=w,h>=0?(A=l,v=c,R=d,L=u,B=g,D=_,k=p,V=y):(A=c,v=l,R=u,L=d,B=_,D=g,k=y,V=p)),E===0)return null;let U=A/E,z=v/E,q=1/E,G=R-U*N,Z=L-z*N,st=B-U*F,nt=D-z*F,lt=k-U*O,H=V-z*O,K=lt*nt-H*st,ct=G*H-Z*lt,Ct=st*Z-nt*G;if(s){if(K<0||ct<0||Ct<0)return null}else if((K<0||ct<0||Ct<0)&&(K>0||ct>0||Ct>0))return null;let ft=K+ct+Ct;if(ft===0)return null;let Bt=q*(K*N+ct*F+Ct*O);return(ft>0?Bt<0:Bt>0)?null:this.at(Bt/ft,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 kt(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 zn,this.combine=vr,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}},wu=new Yt,Ni=new Bi,co=new Oe,Eu=new C,ho=new C,uo=new C,fo=new C,sc=new C,po=new C,Tu=new C,mo=new C,ge=class extends Xe{constructor(t=new ce,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))&&(wu.copy(r).invert(),Ni.copy(t.ray).applyMatrix4(wu),!(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 g=0,_=u.length;g<_;g++){let m=u[g],p=o[m.materialIndex],y=Math.max(m.start,f.start),w=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let M=y,x=w;Me.far?null:{distance:c,point:mo.clone(),object:i}}function go(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,ho),i.getVertexPosition(l,uo),i.getVertexPosition(c,fo);let h=Nm(i,t,e,n,ho,uo,fo,Tu);if(h){let d=new C;ni.getBarycoord(Tu,ho,uo,fo,d),s&&(h.uv=ni.getInterpolatedAttribute(s,a,l,c,d,new Wt)),r&&(h.uv1=ni.getInterpolatedAttribute(r,a,l,c,d,new Wt)),o&&(h.normal=ni.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};ni.getNormal(ho,uo,fo,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 ri=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}},ls=new Yt,Au=new Yt,_o=[],Ru=new se,Um=new Yt,Ks=new ge,Js=new Oe,xi=class extends ge{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ri(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,xo.y=s.normal.y>0?t.max.y:t.min.y,xo.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(xo)<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 kt(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}},Wo=new C,Xo=new C,Cu=new Yt,js=new Bi,vo=new Oe,rc=new C,Iu=new C,Oi=class extends Xe{constructor(t=new ce,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;rc.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(rc);if(!(ct.far))return{distance:c,point:Iu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Pu=new C,Lu=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 ar=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}},lr=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 Vn=class extends We{constructor(t,e,n=Tn,s,r,o,a=Le,l=Le,c,h=Bn,d=1){if(h!==Bn&&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 Ms(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},qo=class extends Vn{constructor(t,e=Tn,n=bi,s,r,o=Le,a=Le,l,c=Bn){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}},cr=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 ce{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;g("z","y","x",-1,-1,n,e,t,o,r,0),g("z","y","x",1,-1,n,e,-t,o,r,1),g("x","z","y",1,1,t,n,e,s,o,2),g("x","z","y",1,-1,t,n,-e,s,o,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("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 g(_,m,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,k=v+1,V=0,O=0,U=new C;for(let z=0;z0?1:-1,h.push(U.x,U.y,U.z),d.push(G/A),d.push(1-z/v),V+=1}}for(let z=0;z0&&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),k=Math.cos(D);x.x=L*F,x.y=-R*n+m,x.z=L*k,d.push(x.x,x.y,x.z),M.set(F,A,k).normalize(),u.push(M.x,M.y,M.z),f.push(B,1-R),E.push(g++)}_.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=g,S=new Wt,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,m*R,0),u.push(0,R,0),f.push(.5,.5),g++;let L=g;for(let N=0;N<=s;N++){let D=N/s*l+a,F=Math.cos(D),k=Math.sin(D);A.x=E*k,A.y=m*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=k*.5*R+.5,f.push(S.x,S.y),g++}for(let N=0;N0)&&f.push(w,M,S),(p!==n-1||l{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||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 kt().setHex(s.value);break;case"v2":this.uniforms[n].value=new Wt().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 $t().fromArray(s.value);break;case"m4":this.uniforms[n].value=new Yt().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}},Yo=class extends Ie{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var ur=class extends Sn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new kt(16777215),this.specular=new kt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Rr,this.normalScale=new Wt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new zn,this.combine=vr,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 Ts=class extends Sn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new kt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Rr,this.normalScale=new Wt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new zn,this.combine=vr,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}},$o=class extends Sn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=pd,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}},Zo=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 cs(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function ac(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&&(Xt("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Xt("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)){Xt("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Xt("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(s!==void 0&&em(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Xt("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()===Ro,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,ac(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Fu(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=zo;var yi=class extends hn{constructor(t,e,n){super(t,e,n)}};yi.prototype.ValueTypeName="bool";yi.prototype.ValueBufferType=Array;yi.prototype.DefaultInterpolation=tr;yi.prototype.InterpolantFactoryMethodLinear=void 0;yi.prototype.InterpolantFactoryMethodSmooth=void 0;var ta=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};ta.prototype.ValueTypeName="color";var ea=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};ea.prototype.ValueTypeName="number";var na=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}},dr=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new na(this.times,this.values,this.getValueSize(),t)}};dr.prototype.ValueTypeName="quaternion";dr.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=tr;Mi.prototype.InterpolantFactoryMethodLinear=void 0;Mi.prototype.InterpolantFactoryMethodSmooth=void 0;var ia=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};ia.prototype.ValueTypeName="vector";var Io={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(Bu(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Bu(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Bu(i){try{let t=i.slice(i.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}var sa=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-g.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 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;f 0 +#endif`,Ug=`#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`,mg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Fg=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Bg=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Og=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,zg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; -#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,kg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; -#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,Hg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; -#endif`,Mg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,Vg=`#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`,bg=`#define PI 3.141592653589793 +#endif`,Gg=`#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`,Sg=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,Wg=`#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`,wg=`vec3 transformedNormal = objectNormal; +#endif`,Xg=`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`,Eg=`#ifdef USE_DISPLACEMENTMAP +#endif`,qg=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP +#endif`,Yg=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,Ag=`#ifdef USE_EMISSIVEMAP +#endif`,$g=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,Rg=`#ifdef USE_EMISSIVEMAP +#endif`,Zg=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,Cg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ig=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,Kg="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 ); -}`,Pg=`#ifdef USE_ENVMAP +}`,jg=`#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`,Lg=`#ifdef USE_ENVMAP +#endif`,Qg=`#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`,Dg=`#ifdef USE_ENVMAP +#endif`,t0=`#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`,Ng=`#ifdef USE_ENVMAP +#endif`,e0=`#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`,Ug=`#ifdef USE_ENVMAP +#endif`,n0=`#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`,Fg=`#ifdef USE_FOG +#endif`,i0=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,Bg=`#ifdef USE_FOG +#endif`,s0=`#ifdef USE_FOG varying float vFogDepth; -#endif`,Og=`#ifdef USE_FOG +#endif`,r0=`#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`,zg=`#ifdef USE_FOG +#endif`,o0=`#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`,kg=`#ifdef USE_GRADIENTMAP +#endif`,a0=`#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 -}`,Hg=`#ifdef USE_LIGHTMAP +}`,l0=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,Vg=`LambertMaterial material; +#endif`,c0=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,h0=`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`,Wg=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,u0=`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 `,Xg=`#ifdef USE_ENVMAP +#include `,d0=`#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`,qg=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Yg=`varying vec3 vViewPosition; +#endif`,f0=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,p0=`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`,$g=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,m0=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,g0=`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`,Kg=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,_0=`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`,Jg=`uniform sampler2D dfgLUT; +#endif`,x0=`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 ); -}`,jg=` +}`,v0=` 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`,Qg=`#if defined( RE_IndirectDiffuse ) +#endif`,y0=`#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`,t_=`#if defined( RE_IndirectDiffuse ) +#endif`,M0=`#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`,e_=`#ifdef USE_LIGHT_PROBES_GRID +#endif`,b0=`#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`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,S0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,w0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,E0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,T0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,o_=`#ifdef USE_MAP +#endif`,A0=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,a_=`#ifdef USE_MAP +#endif`,R0=`#ifdef USE_MAP uniform sampler2D map; -#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,C0=`#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`,c_=`#if defined( USE_POINTS_UV ) +#endif`,I0=`#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`,h_=`float metalnessFactor = metalness; +#endif`,P0=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,u_=`#ifdef USE_METALNESSMAP +#endif`,L0=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,d_=`#ifdef USE_INSTANCING_MORPH +#endif`,D0=`#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`,f_=`#if defined( USE_MORPHCOLORS ) +#endif`,N0=`#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`,p_=`#ifdef USE_MORPHNORMALS +#endif`,U0=`#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`,m_=`#ifdef USE_MORPHTARGETS +#endif`,F0=`#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`,g_=`#ifdef USE_MORPHTARGETS +#endif`,B0=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,O0=`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;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,z0=`#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;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,v_=`#ifndef FLAT_SHADED +#endif`,k0=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,y_=`#ifndef FLAT_SHADED +#endif`,H0=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,M_=`#ifndef FLAT_SHADED +#endif`,V0=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,b_=`#ifdef USE_NORMALMAP +#endif`,G0=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,S_=`#ifdef USE_CLEARCOAT +#endif`,W0=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,w_=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,X0=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,E_=`#ifdef USE_CLEARCOATMAP +#endif`,q0=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,T_=`#ifdef USE_IRIDESCENCEMAP +#endif`,Y0=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,A_=`#ifdef OPAQUE +#endif`,$0=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,R_=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Z0=`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 -}`,C_=`#ifdef PREMULTIPLIED_ALPHA +}`,K0=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,I_=`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;`,P_=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,j0=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,L_=`#ifdef DITHERING +#endif`,Q0=`#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`,D_=`float roughnessFactor = roughness; +#endif`,t_=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,N_=`#ifdef USE_ROUGHNESSMAP +#endif`,e_=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,U_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,n_=`#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;`,P_=`#ifdef DITHERING } #endif #endif -#endif`,F_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,i_=`#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;`,P_=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,B_=`#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`,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 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else @@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,P_=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,O_=`float getShadowMask() { +#endif`,r_=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,P_=`#ifdef DITHERING #endif #endif return shadow; -}`,z_=`#ifdef USE_SKINNING +}`,o_=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,k_=`#ifdef USE_SKINNING +#endif`,a_=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,P_=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,H_=`#ifdef USE_SKINNING +#endif`,l_=`#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;`,P_=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,V_=`#ifdef USE_SKINNING +#endif`,c_=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,P_=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,G_=`float specularStrength; +#endif`,h_=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,W_=`#ifdef USE_SPECULARMAP +#endif`,u_=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,X_=`#if defined( TONE_MAPPING ) +#endif`,d_=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,q_=`#ifndef saturate +#endif`,f_=`#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; }`,Y_=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,p_=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Y_=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,$_=`#ifdef USE_TRANSMISSION +#endif`,m_=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Y_=`#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`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,g_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Y_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,K_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,__=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Y_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,x_=`#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; }`,Y_=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,j_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,v_=`#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; }`,Y_=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,Q_=`varying vec2 vUv; +#endif`,y_=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,t0=`uniform sampler2D t2D; +}`,M_=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2780,14 +2780,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,e0=`varying vec3 vWorldDirection; +}`,b_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,n0=`#ifdef ENVMAP_TYPE_CUBE +}`,S_=`#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 -}`,i0=`varying vec3 vWorldDirection; +}`,w_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,s0=`uniform samplerCube tCube; +}`,E_=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2826,7 +2826,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,r0=`#include +}`,T_=`#include #include #include #include @@ -2853,7 +2853,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,o0=`#if DEPTH_PACKING == 3200 +}`,A_=`#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 -}`,a0=`#define DISTANCE +}`,R_=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2918,7 +2918,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,l0=`#define DISTANCE +}`,C_=`#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 ); -}`,c0=`varying vec3 vWorldDirection; +}`,I_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,h0=`uniform sampler2D tEquirect; +}`,P_=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2956,7 +2956,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,u0=`uniform float scale; +}`,L_=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2978,7 +2978,7 @@ void main() { #include #include #include -}`,d0=`uniform vec3 diffuse; +}`,D_=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3006,7 +3006,7 @@ void main() { #include #include #include -}`,f0=`#include +}`,N_=`#include #include #include #include @@ -3038,7 +3038,7 @@ void main() { #include #include #include -}`,p0=`uniform vec3 diffuse; +}`,U_=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -3086,7 +3086,7 @@ void main() { #include #include #include -}`,m0=`#define LAMBERT +}`,F_=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3125,7 +3125,7 @@ void main() { #include #include #include -}`,g0=`#define LAMBERT +}`,B_=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3183,7 +3183,7 @@ void main() { #include #include #include -}`,_0=`#define MATCAP +}`,O_=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3217,7 +3217,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,x0=`#define MATCAP +}`,z_=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3263,7 +3263,7 @@ void main() { #include #include #include -}`,v0=`#define NORMAL +}`,k_=`#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 -}`,y0=`#define NORMAL +}`,H_=`#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 -}`,M0=`#define PHONG +}`,V_=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3356,7 +3356,7 @@ void main() { #include #include #include -}`,b0=`#define PHONG +}`,G_=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3416,7 +3416,7 @@ void main() { #include #include #include -}`,S0=`#define STANDARD +}`,W_=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3459,7 +3459,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,w0=`#define STANDARD +}`,X_=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3587,7 +3587,7 @@ void main() { #include #include #include -}`,E0=`#define TOON +}`,q_=`#define TOON varying vec3 vViewPosition; #include #include @@ -3624,7 +3624,7 @@ void main() { #include #include #include -}`,T0=`#define TOON +}`,Y_=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3676,7 +3676,7 @@ void main() { #include #include #include -}`,A0=`uniform float size; +}`,$_=`uniform float size; uniform float scale; #include #include @@ -3707,7 +3707,7 @@ void main() { #include #include #include -}`,R0=`uniform vec3 diffuse; +}`,Z_=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3732,7 +3732,7 @@ void main() { #include #include #include -}`,C0=`#include +}`,K_=`#include #include #include #include @@ -3755,7 +3755,7 @@ void main() { #include #include #include -}`,I0=`uniform vec3 color; +}`,J_=`uniform vec3 color; uniform float opacity; #include #include @@ -3771,7 +3771,7 @@ void main() { #include #include #include -}`,P0=`uniform float rotation; +}`,j_=`uniform float rotation; uniform vec2 center; #include #include @@ -3795,7 +3795,7 @@ void main() { #include #include #include -}`,L0=`uniform vec3 diffuse; +}`,Q_=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3820,7 +3820,7 @@ void main() { #include #include #include -}`,jt={alphahash_fragment:Qm,alphahash_pars_fragment:tg,alphamap_fragment:eg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:og,batching_pars_vertex:ag,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:hg,bsdfs:ug,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:vg,color_pars_vertex:yg,color_vertex:Mg,common:bg,cube_uv_reflection_fragment:Sg,defaultnormal_vertex:wg,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Ag,emissivemap_pars_fragment:Rg,colorspace_fragment:Cg,colorspace_pars_fragment:Ig,envmap_fragment:Pg,envmap_common_pars_fragment:Lg,envmap_pars_fragment:Dg,envmap_pars_vertex:Ng,envmap_physical_pars_fragment:Xg,envmap_vertex:Ug,fog_vertex:Fg,fog_pars_vertex:Bg,fog_fragment:Og,fog_pars_fragment:zg,gradientmap_pars_fragment:kg,lightmap_pars_fragment:Hg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:qg,lights_toon_pars_fragment:Yg,lights_phong_fragment:$g,lights_phong_pars_fragment:Zg,lights_physical_fragment:Kg,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:t_,lightprobes_pars_fragment:e_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:o_,map_pars_fragment:a_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:h_,metalnessmap_pars_fragment:u_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:v_,normal_pars_vertex:y_,normal_vertex:M_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:S_,clearcoat_normal_fragment_maps:w_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:A_,packing:R_,premultiplied_alpha_fragment:C_,project_vertex:I_,dithering_fragment:P_,dithering_pars_fragment:L_,roughnessmap_fragment:D_,roughnessmap_pars_fragment:N_,shadowmap_pars_fragment:U_,shadowmap_pars_vertex:F_,shadowmap_vertex:B_,shadowmask_pars_fragment:O_,skinbase_vertex:z_,skinning_pars_vertex:k_,skinning_vertex:H_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:q_,transmission_fragment:Y_,transmission_pars_fragment:$_,uv_pars_fragment:Z_,uv_pars_vertex:K_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:t0,backgroundCube_vert:e0,backgroundCube_frag:n0,cube_vert:i0,cube_frag:s0,depth_vert:r0,depth_frag:o0,distance_vert:a0,distance_frag:l0,equirect_vert:c0,equirect_frag:h0,linedashed_vert:u0,linedashed_frag:d0,meshbasic_vert:f0,meshbasic_frag:p0,meshlambert_vert:m0,meshlambert_frag:g0,meshmatcap_vert:_0,meshmatcap_frag:x0,meshnormal_vert:v0,meshnormal_frag:y0,meshphong_vert:M0,meshphong_frag:b0,meshphysical_vert:S0,meshphysical_frag:w0,meshtoon_vert:E0,meshtoon_frag:T0,points_vert:A0,points_frag:R0,shadow_vert:C0,shadow_frag:I0,sprite_vert:P0,sprite_frag:L0},bt={common:{diffuse:{value:new kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new $t},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $t}},envmap:{envMap:{value:null},envMapRotation:{value:new $t},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new $t}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $t}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $t},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $t},normalScale:{value:new Wt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $t},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $t}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $t}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $t}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new kt(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 kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0},uvTransform:{value:new $t}},sprite:{diffuse:{value:new kt(16777215)},opacity:{value:1},center:{value:new Wt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $t},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0}}},Zn={basic:{uniforms:Qe([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:Qe([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new kt(0)},envMapIntensity:{value:1}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:Qe([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new kt(0)},specular:{value:new kt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:Qe([bt.common,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.roughnessmap,bt.metalnessmap,bt.fog,bt.lights,{emissive:{value:new kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:Qe([bt.common,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.gradientmap,bt.fog,bt.lights,{emissive:{value:new kt(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:Qe([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:Qe([bt.points,bt.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:Qe([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:Qe([bt.common,bt.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:Qe([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:Qe([bt.sprite,bt.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new $t},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jt.background_vert,fragmentShader:jt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $t}},vertexShader:jt.backgroundCube_vert,fragmentShader:jt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jt.cube_vert,fragmentShader:jt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jt.equirect_vert,fragmentShader:jt.equirect_frag},distance:{uniforms:Qe([bt.common,bt.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jt.distance_vert,fragmentShader:jt.distance_frag},shadow:{uniforms:Qe([bt.lights,bt.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};Zn.physical={uniforms:Qe([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $t},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $t},clearcoatNormalScale:{value:new Wt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $t},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $t},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $t},sheen:{value:0},sheenColor:{value:new kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $t},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $t},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $t},transmissionSamplerSize:{value:new Wt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $t},attenuationDistance:{value:0},attenuationColor:{value:new kt(0)},specularColor:{value:new kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $t},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $t},anisotropyVector:{value:new Wt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $t}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};var Ja={r:0,b:0,g:0},D0=new Yt,Qd=new $t;Qd.set(-1,0,0,0,1,0,0,0,1);function N0(i,t,e,n,s,r){let o=new kt(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 g(y){let w=!1,M=f(y);M===null?m(o,a):M&&M.isColor&&(m(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===yr)?(c===void 0&&(c=new ge(new gn(1,1,1),new Ie({name:"BackgroundCubeMaterial",uniforms:Xi(Zn.backgroundCube.uniforms),vertexShader:Zn.backgroundCube.vertexShader,fragmentShader:Zn.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(D0.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Qd),c.material.toneMapped=ne.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(Zn.background.uniforms),vertexShader:Zn.background.vertexShader,fragmentShader:Zn.background.fragmentShader,side:qn,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=ne.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 m(y,w){y.getRGB(Ja,Wc(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,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,m(o,a)},render:g,addToRenderList:_,dispose:p}}function U0(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 k=!1,V=d(L,D,B,N);r!==V&&(r=V,c(r.object)),k=f(L,D,B,F),k&&g(L,D,B,F),F!==null&&t.update(F,i.ELEMENT_ARRAY_BUFFER),(k||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,k=n[N.id];k===void 0&&(k={},n[N.id]=k);let V=L.isInstancedMesh===!0?L.id:0,O=k[V];O===void 0&&(O={},k[V]=O);let U=O[B.id];U===void 0&&(U={},O[B.id]=U);let z=U[F];return z===void 0&&(z=u(l()),U[F]=z),z}function u(L){let N=[],B=[],D=[];for(let F=0;F=0){let q=F[U],G=k[U];if(G===void 0&&(U==="instanceMatrix"&&L.instanceMatrix&&(G=L.instanceMatrix),U==="instanceColor"&&L.instanceColor&&(G=L.instanceColor)),q===void 0||q.attribute!==G||G&&q.data!==G.data)return!0;V++}return r.attributesNum!==V||r.index!==D}function g(L,N,B,D){let F={},k=N.attributes,V=0,O=B.getAttributes();for(let U in O)if(O[U].location>=0){let q=k[U];q===void 0&&(U==="instanceMatrix"&&L.instanceMatrix&&(q=L.instanceMatrix),U==="instanceColor"&&L.instanceColor&&(q=L.instanceColor));let G={};G.attribute=q,q&&q.data&&(G.data=q.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 z=F[O];if(z===void 0&&(O==="instanceMatrix"&&L.instanceMatrix&&(z=L.instanceMatrix),O==="instanceColor"&&L.instanceColor&&(z=L.instanceColor)),z!==void 0){let q=z.normalized,G=z.itemSize,Z=t.get(z);if(Z===void 0)continue;let st=Z.buffer,nt=Z.type,lt=Z.bytesPerElement,H=nt===i.INT||nt===i.UNSIGNED_INT||z.gpuType===fa;if(z.isInterleavedBufferAttribute){let K=z.data,ct=K.stride,Ct=z.offset;if(K.isInstancedInterleavedBuffer){for(let ft=0;ft0&&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&&(Ht("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&&Ht("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),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),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:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:y,maxVaryings:w,maxFragmentUniforms:M,maxSamples:x,samples:S}}function O0(i){let t=this,e=null,n=0,s=!1,r=!1,o=new Ae,a=new $t,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 g=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{let y=r?0:n,w=y*4,M=p.clippingState||null;l.value=M,M=h(g,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,g){let _=d!==null?d.length:0,m=null;if(_!==0){if(m=l.value,g!==!0||m===null){let p=f+_*4,y=u.matrixWorldInverse;a.getNormalMatrix(y),(m===null||m.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=Nd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Dd(),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=Nd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Dd());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;Ns(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Ir)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rg-Us?n-g+Us:0),p=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=g-e,Ns(r,m,p,3*_,2*_),s.setRenderTarget(r),s.render(a,Ir),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Ns(t,m,p,3*_,2*_),s.setRenderTarget(t),s.render(a,Ir)}_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-Us?s-this._lodMax+Us:0),u=4*(this._cubeSize-h);Ns(e,d,u,3*h,2*h),o.setRenderTarget(e),o.render(l,Ir)}};function G0(i){let t=[],e=[],n=i,s=i-Us+1+z0;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];g.set(M,f*u*p);for(let x=0;xUs&&n--}return{lodMeshes:e,sizeLods:t}}function Ld(i,t,e){let n=new Be(i,t,e);return n.texture.mapping=yr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ns(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function W0(i,t,e){return new Ie({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:H0,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:el(),fragmentShader:` +}`,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:` precision highp float; precision highp int; @@ -3924,7 +3924,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:Yn,depthTest:!1,depthWrite:!1})}function X0(i,t,e){return new Ie({name:"SphericalGaussianBlur",defines:{SAMPLES:k0,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:el(),fragmentShader:` + `,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:` precision highp float; precision highp int; @@ -3984,7 +3984,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `,blending:Yn,depthTest:!1,depthWrite:!1})}function Dd(){return new Ie({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:el(),fragmentShader:` + `,blending:$n,depthTest:!1,depthWrite:!1})}function Od(){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:Yn,depthTest:!1,depthWrite:!1})}function Nd(){return new Ie({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:el(),fragmentShader:` + `,blending:$n,depthTest:!1,depthWrite:!1})}function zd(){return new Ie({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:nl(),fragmentShader:` precision mediump float; precision mediump int; @@ -4019,7 +4019,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:Yn,depthTest:!1,depthWrite:!1})}function el(){return` + `,blending:$n,depthTest:!1,depthWrite:!1})}function nl(){return` precision mediump float; precision mediump int; @@ -4034,7 +4034,7 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}var tl=class extends Be{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new ar(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + `}var el=class extends Be{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new cr(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -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:Yn});r.uniforms.tEquirect.value=e;let o=new ge(s,r),a=e.minFilter;return e.minFilter===Si&&(e.minFilter=qe),new aa(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 q0(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===ha||f===ua)if(t.has(u)){let g=t.get(u).texture;return a(g,u.mapping)}else{let g=u.image;if(g&&g.height>0){let _=new tl(g.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,g=f===ha||f===ua,_=f===bi||f===Wi;if(g||_){let m=e.get(u),p=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new Qa(i)),m=g?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),m.texture;if(m!==void 0)return m.texture;{let y=u.image;return g&&y&&y.height>0||_&&y&&l(y)?(n===null&&(n=new Qa(i)),m=g?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function a(u,f){return f===ha?u.mapping=bi:f===ua&&(u.mapping=Wi),u}function l(u){let f=0,g=6;for(let _=0;_=65535?or:rr)(u,1);m.version=_;let p=r.get(d);p&&t.remove(p),r.set(d,m)}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 sr(S,M,x,d);A.type=Ye,A.needsUpdate=!0;let v=w*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===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&&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=Ud[s];if(r===void 0&&(r=new Float32Array(s),Ud[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 Hd(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var Vx=37297,Gx=0;function Wx(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=[],E=!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=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(` `),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 Vd=new $t;function Xx(i){ne._getMatrix(Vd,ne.workingColorSpace,i);let t=`mat3( ${Vd.elements.map(e=>e.toFixed(4))} )`;switch(ne.getTransfer(i)){case nr:return[t,"LinearTransferOETF"];case fe:return[t,"sRGBTransferOETF"];default:return Ht("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Gd(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 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()+` `+r+` -`+Wx(i.getShaderSource(t),a)}else return r}function qx(i,t){let e=Xx(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` -`)}var Yx={[wc]:"Linear",[Ec]:"Reinhard",[Tc]:"Cineon",[Ac]:"ACESFilmic",[Cc]:"AgX",[Ic]:"Neutral",[Rc]:"Custom"};function $x(i,t){let e=Yx[t];return e===void 0?(Ht("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var ja=new C;function Zx(){ne.getLuminanceCoefficients(ja);let i=ja.x.toFixed(4),t=ja.y.toFixed(4),e=ja.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(` -`)}function Kx(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Lr).join(` -`)}function Jx(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` -`)}function jx(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function ch(i){return i.replace(Qx,ev)}var tv=new Map;function ev(i,t){let e=jt[t];if(e===void 0){let n=tv.get(t);if(n!==void 0)e=jt[n],Ht('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return ch(e)}var nv=/#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(nv,iv)}function iv(i,t,e,n){let s="";for(let r=parseInt(t);r/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);r0&&(m+=` -`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Lr).join(` +#define LOW_PRECISION`),t}var Ev={[yr]:"SHADOWMAP_TYPE_PCF",[Ps]:"SHADOWMAP_TYPE_VSM"};function Tv(i){return Ev[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var Av={[bi]:"ENVMAP_TYPE_CUBE",[Wi]:"ENVMAP_TYPE_CUBE",[br]:"ENVMAP_TYPE_CUBE_UV"};function Rv(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":Av[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var Cv={[Wi]:"ENVMAP_MODE_REFRACTION"};function Iv(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":Cv[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var Pv={[Mr]:"ENVMAP_BLENDING_MULTIPLY",[gd]:"ENVMAP_BLENDING_MIX",[_d]:"ENVMAP_BLENDING_ADD"};function Lv(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":Pv[i.combine]||"ENVMAP_BLENDING_NONE"}function Dv(i){let t=i.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function Nv(i,t,e,n){let s=i.getContext(),r=e.defines,o=e.vertexShader,a=e.fragmentShader,l=Tv(e),c=Rv(e),h=Iv(e),d=Lv(e),u=Dv(e),f=_v(e),m=xv(r),_=s.createProgram(),g,p,y=e.glslVersion?"#version "+e.glslVersion+` +`:"";e.isRawShaderMaterial?(g=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Nr).join(` +`),g.length>0&&(g+=` +`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Nr).join(` `),p.length>0&&(p+=` -`)):(m=[Yd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,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(Lr).join(` -`),p=[Yd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,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?jt.tonemapping_pars_fragment:"",e.toneMapping!==En?$x("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",jt.colorspace_pars_fragment,qx("linearToOutputTexel",e.outputColorSpace),Zx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` -`].filter(Lr).join(` -`)),o=ch(o),o=Wd(o,e),o=Xd(o,e),a=ch(a),a=Wd(a,e),a=Xd(a,e),o=qd(o),a=qd(a),e.isRawShaderMaterial!==!0&&(y=`#version 300 es -`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)):(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",` +`].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:"",` +`].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 +`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+m,p=["#define varying in",e.glslVersion===Vc?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Vc?"":"#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(` +`+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 w=y+m+o,M=y+p+a,x=Hd(s,s.VERTEX_SHADER,w),S=Hd(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(),k=B.trim(),V=D.trim(),O=!0,U=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(O=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,x,S);else{let z=Gd(s,x,"vertex"),q=Gd(s,S,"fragment");Xt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` +`+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)+` Material Name: `+L.name+` Material Type: `+L.type+` Program Info Log: `+F+` -`+z+` -`+q)}else F!==""?Ht("WebGLProgram: Program Info Log:",F):(k===""||V==="")&&(U=!1);U&&(L.diagnostics={runnable:O,programLog:F,vertexShader:{log:k,prefix:m},fragmentShader:{log:V,prefix:p}})}s.deleteShader(x),s.deleteShader(S),v=new Fs(s,_),E=jx(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(_,Vx)),R},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Gx++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=x,this.fragmentShader=S,this}var pv=0,hh=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 uh(t),e.set(t,n)),n}},uh=class{constructor(t){this.id=pv++,this.code=t,this.usedTimes=0}};function mv(i){return i===Ei||i===Tr||i===Ar}function gv(i,t,e,n,s,r){let o=new bs,a=new hh,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 g(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,E,R,L,N,B){let D=L.fog,F=N.geometry,k=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,V=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,O=t.get(v.envMap||k,V),U=O&&O.mapping===yr?O.image.height:null,z=f[v.type];v.precision!==null&&(u=n.getMaxPrecision(v.precision),u!==v.precision&&Ht("WebGLProgram.getParameters:",v.precision,"not supported, using",u,"instead."));let q=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,G=q!==void 0?q.length:0,Z=0;F.morphAttributes.position!==void 0&&(Z=1),F.morphAttributes.normal!==void 0&&(Z=2),F.morphAttributes.color!==void 0&&(Z=3);let st,nt,lt,H;if(z){let be=Zn[z];st=be.vertexShader,nt=be.fragmentShader}else{st=v.vertexShader,nt=v.fragmentShader;let be=a.getVertexShaderStage(v),ue=a.getFragmentShaderStage(v);a.update(v,be,ue),lt=be.id,H=ue.id}let K=i.getRenderTarget(),ct=i.state.buffers.depth.getReversed(),Ct=N.isInstancedMesh===!0,ft=N.isBatchedMesh===!0,Bt=!!v.map,he=!!v.matcap,Gt=!!O,Zt=!!v.aoMap,ee=!!v.lightMap,pt=!!v.bumpMap&&v.wireframe===!1,Ot=!!v.normalMap,qt=!!v.displacementMap,ae=!!v.emissiveMap,dt=!!v.metalnessMap,Lt=!!v.roughnessMap,P=v.anisotropy>0,ut=v.clearcoat>0,wt=v.dispersion>0,I=v.retroreflectivity>0,b=v.iridescence>0,Y=v.sheen>0,Q=v.transmission>0,it=P&&!!v.anisotropyMap,mt=ut&&!!v.clearcoatMap,gt=ut&&!!v.clearcoatNormalMap,rt=ut&&!!v.clearcoatRoughnessMap,at=b&&!!v.iridescenceMap,_t=b&&!!v.iridescenceThicknessMap,Ut=Y&&!!v.sheenColorMap,Mt=Y&&!!v.sheenRoughnessMap,xt=!!v.specularMap,Ft=!!v.specularColorMap,Vt=!!v.specularIntensityMap,Kt=Q&&!!v.transmissionMap,X=Q&&!!v.thicknessMap,vt=!!v.gradientMap,ot=!!v.alphaMap,yt=v.alphaTest>0,Tt=!!v.alphaHash,ht=!!v.extensions,zt=En;v.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(zt=i.toneMapping);let Dt={shaderID:z,shaderType:v.type,shaderName:v.name,vertexShader:st,fragmentShader:nt,defines:v.defines,customVertexShaderID:lt,customFragmentShaderID:H,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:ft,batchingColor:ft&&N._colorsTexture!==null,instancing:Ct,instancingColor:Ct&&N.instanceColor!==null,instancingMorph:Ct&&N.morphTexture!==null,outputColorSpace:K===null?i.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:ne.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Bt,matcap:he,envMap:Gt,envMapMode:Gt&&O.mapping,envMapCubeUVHeight:U,aoMap:Zt,lightMap:ee,bumpMap:pt,normalMap:Ot,displacementMap:qt,emissiveMap:ae,normalMapObjectSpace:Ot&&v.normalMapType===md,normalMapTangentSpace:Ot&&v.normalMapType===Rr,packedNormalMap:Ot&&v.normalMapType===Rr&&mv(v.normalMap.format),metalnessMap:dt,roughnessMap:Lt,anisotropy:P,anisotropyMap:it,clearcoat:ut,clearcoatMap:mt,clearcoatNormalMap:gt,clearcoatRoughnessMap:rt,dispersion:wt,retroreflection:I,iridescence:b,iridescenceMap:at,iridescenceThicknessMap:_t,sheen:Y,sheenColorMap:Ut,sheenRoughnessMap:Mt,specularMap:xt,specularColorMap:Ft,specularIntensityMap:Vt,transmission:Q,transmissionMap:Kt,thicknessMap:X,gradientMap:vt,opaque:v.transparent===!1&&v.blending===Is&&v.alphaToCoverage===!1,alphaMap:ot,alphaTest:yt,alphaHash:Tt,combine:v.combine,mapUv:Bt&&g(v.map.channel),aoMapUv:Zt&&g(v.aoMap.channel),lightMapUv:ee&&g(v.lightMap.channel),bumpMapUv:pt&&g(v.bumpMap.channel),normalMapUv:Ot&&g(v.normalMap.channel),displacementMapUv:qt&&g(v.displacementMap.channel),emissiveMapUv:ae&&g(v.emissiveMap.channel),metalnessMapUv:dt&&g(v.metalnessMap.channel),roughnessMapUv:Lt&&g(v.roughnessMap.channel),anisotropyMapUv:it&&g(v.anisotropyMap.channel),clearcoatMapUv:mt&&g(v.clearcoatMap.channel),clearcoatNormalMapUv:gt&&g(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&g(v.clearcoatRoughnessMap.channel),iridescenceMapUv:at&&g(v.iridescenceMap.channel),iridescenceThicknessMapUv:_t&&g(v.iridescenceThicknessMap.channel),sheenColorMapUv:Ut&&g(v.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&g(v.sheenRoughnessMap.channel),specularMapUv:xt&&g(v.specularMap.channel),specularColorMapUv:Ft&&g(v.specularColorMap.channel),specularIntensityMapUv:Vt&&g(v.specularIntensityMap.channel),transmissionMapUv:Kt&&g(v.transmissionMap.channel),thicknessMapUv:X&&g(v.thicknessMap.channel),alphaMapUv:ot&&g(v.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(Ot||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&&(Bt||ot),fog:!!D,useFog:v.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||F.attributes.normal===void 0&&Ot===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ct,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:Z,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:zt,decodeVideoTexture:Bt&&v.map.isVideoTexture===!0&&ne.getTransfer(v.map.colorSpace)===fe,decodeVideoTextureEmissive:ae&&v.emissiveMap.isVideoTexture===!0&&ne.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:ht&&v.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ht&&v.extensions.multiDraw===!0||ft)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Dt.vertexUv1s=l.has(1),Dt.vertexUv2s=l.has(2),Dt.vertexUv3s=l.has(3),l.clear(),Dt}function m(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=Zn[E];R=Rd.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 fv(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:m,getUniforms:w,acquireProgram:M,releaseProgram:x,releaseShaderCache:S,programs:c,dispose:A}}function _v(){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 xv(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 $d(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 Zd(){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,g,_,m,p){let y=i[t];return y===void 0?(y={id:u.id,object:u,geometry:f,material:g,materialVariant:o(u),groupOrder:_,renderOrder:u.renderOrder,z:m,group:p},i[t]=y):(y.id=u.id,y.object=u,y.geometry=f,y.material=g,y.materialVariant=o(u),y.groupOrder=_,y.renderOrder=u.renderOrder,y.z=m,y.group=p),t++,y}function l(u,f,g,_,m,p,y){y.reversedDepth===!0&&(m=-m);let w=a(u,f,g,_,m,p);g.transmission>0?n.push(w):g.transparent===!0?s.push(w):e.push(w)}function c(u,f,g,_,m,p){let y=a(u,f,g,_,m,p);g.transmission>0?n.unshift(y):g.transparent===!0?s.unshift(y):e.unshift(y)}function h(u,f){e.length>1&&e.sort(u||xv),n.length>1&&n.sort(f||$d),s.length>1&&s.sort(f||$d)}function d(){for(let u=t,f=i.length;u=r.length?(o=new Zd,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function yv(){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 kt};break;case"SpotLight":e={position:new C,direction:new C,color:new kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new kt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new kt,groundColor:new kt};break;case"RectAreaLight":e={color:new kt,position:new C,halfWidth:new C,halfHeight:new C};break}return i[t.id]=e,e}}}function Mv(){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 Wt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Wt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Wt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var bv=0;function Sv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function wv(i){let t=new yv,e=Mv(),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 Yt,o=new Yt;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,g=0,_=0,m=0,p=0,y=0,w=0,M=0,x=0,S=0,A=0,v=0,E=0,R=0;c.sort(Sv);for(let N=0,B=c.length;N0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=bt.LTC_FLOAT_1,n.rectAreaLTC2=bt.LTC_FLOAT_2):(n.rectAreaLTC1=bt.LTC_HALF_1,n.rectAreaLTC2=bt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let L=n.hash;(L.sunLength!==f||L.directionalLength!==m||L.pointLength!==p||L.spotLength!==y||L.rectAreaLength!==w||L.hemiLength!==M||L.numSunShadows!==g||L.numDirectionalShadows!==x||L.numPointShadows!==S||L.numSpotShadows!==A||L.numSpotMaps!==v||L.numLightProbes!==R)&&(n.sun.length=f,n.directional.length=m,n.spot.length=y,n.rectArea.length=w,n.point.length=p,n.hemi.length=M,n.sunShadow.length=g,n.sunShadowMap.length=g,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=m,L.pointLength=p,L.spotLength=y,L.rectAreaLength=w,L.hemiLength=M,L.numSunShadows=g,L.numDirectionalShadows=x,L.numPointShadows=S,L.numSpotShadows=A,L.numSpotMaps=v,L.numLightProbes=R,n.version=bv++)}function l(c,h){let d=0,u=0,f=0,g=0,_=0,m=0,p=h.matrixWorldInverse;for(let y=0,w=c.length;y=o.length?(a=new Kd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var Tv=`void main() { +`+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() { gl_Position = vec4( position, 1.0 ); -}`,Av=`uniform sampler2D shadow_pass; +}`,$v=`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 ); -}`,Rv=[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)],Cv=[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)],Jd=new Yt,Pr=new C,sh=new C;function Iv(i,t,e){let n=new kn,s=new Wt,r=new Wt,o=new ve,a=new $o,l=new Zo,c={},h=e.maxTextureSize,d={[qn]:ze,[ze]:qn,[ke]:ke},u=new Ie({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Wt},radius:{value:4}},vertexShader:Tv,fragmentShader:Av}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new ce;g.setAttribute("position",new xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new ge(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xr;let p=this.type;this.render=function(S,A,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===qu&&(Ht("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=xr);let E=i.getRenderTarget(),R=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),N=i.state;N.setBlending(Yn),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/O.x),s.x=r.x*O.x,V.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/O.y),s.y=r.y*O.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===Cs){if(k.isPointLight){Ht("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=k.name+".shadowMap",V.map.depthTexture=new Vn(s.x,s.y,Ye),V.map.depthTexture.name=k.name+".shadowMapDepth",V.map.depthTexture.format=Bn,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Le,V.map.depthTexture.magFilter=Le}else k.isPointLight?(V.map=new tl(s.x),V.map.depthTexture=new qo(s.x,Tn)):(V.map=new Be(s.x,s.y),V.map.depthTexture=new Vn(s.x,s.y,Tn)),V.map.depthTexture.name=k.name+".shadowMap",V.map.depthTexture.format=Bn,this.type===xr?(V.map.depthTexture.compareFunction=U?Ka:Za,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 z=V.map.isWebGLCubeRenderTarget?6:V.getViewportCount();k.isPointLight!==!0&&V.updateMatrices(k,v);for(let q=0;q0||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===Cs?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===Cs)&&(!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 k=0,V=F.length;k=1):U.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),V=O>=2);let z=null,q={},G=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),st=new ve().fromArray(G),nt=new ve().fromArray(Z);function lt(X,vt,ot,yt){let Tt=new Uint8Array(4),ht=i.createTexture();i.bindTexture(X,ht),i.texParameteri(X,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(X,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let zt=0;zt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Wt,h=new WeakMap,d=new Set,u,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(I,b){return g?new OffscreenCanvas(I,b):xs("canvas")}function m(I,b,Y){let Q=1,it=wt(I);if((it.width>Y||it.height>Y)&&(Q=Y/Math.max(it.width,it.height)),Q<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(Q*it.width),gt=Math.floor(Q*it.height);u===void 0&&(u=_(mt,gt));let rt=b?_(mt,gt):u;return rt.width=mt,rt.height=gt,rt.getContext("2d").drawImage(I,0,0,mt,gt),Ht("WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+mt+"x"+gt+")."),rt}else return"data"in I&&Ht("WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.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,Y,Q,it,mt=!1){if(I!==null){if(i[I]!==void 0)return i[I];Ht("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let gt;Q&&(gt=t.get("EXT_texture_norm16"),gt||Ht("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let rt=b;if(b===i.RED&&(Y===i.FLOAT&&(rt=i.R32F),Y===i.HALF_FLOAT&&(rt=i.R16F),Y===i.UNSIGNED_BYTE&&(rt=i.R8),Y===i.UNSIGNED_SHORT&>&&(rt=gt.R16_EXT),Y===i.SHORT&>&&(rt=gt.R16_SNORM_EXT)),b===i.RED_INTEGER&&(Y===i.UNSIGNED_BYTE&&(rt=i.R8UI),Y===i.UNSIGNED_SHORT&&(rt=i.R16UI),Y===i.UNSIGNED_INT&&(rt=i.R32UI),Y===i.BYTE&&(rt=i.R8I),Y===i.SHORT&&(rt=i.R16I),Y===i.INT&&(rt=i.R32I)),b===i.RG&&(Y===i.FLOAT&&(rt=i.RG32F),Y===i.HALF_FLOAT&&(rt=i.RG16F),Y===i.UNSIGNED_BYTE&&(rt=i.RG8),Y===i.UNSIGNED_SHORT&>&&(rt=gt.RG16_EXT),Y===i.SHORT&>&&(rt=gt.RG16_SNORM_EXT)),b===i.RG_INTEGER&&(Y===i.UNSIGNED_BYTE&&(rt=i.RG8UI),Y===i.UNSIGNED_SHORT&&(rt=i.RG16UI),Y===i.UNSIGNED_INT&&(rt=i.RG32UI),Y===i.BYTE&&(rt=i.RG8I),Y===i.SHORT&&(rt=i.RG16I),Y===i.INT&&(rt=i.RG32I)),b===i.RGB_INTEGER&&(Y===i.UNSIGNED_BYTE&&(rt=i.RGB8UI),Y===i.UNSIGNED_SHORT&&(rt=i.RGB16UI),Y===i.UNSIGNED_INT&&(rt=i.RGB32UI),Y===i.BYTE&&(rt=i.RGB8I),Y===i.SHORT&&(rt=i.RGB16I),Y===i.INT&&(rt=i.RGB32I)),b===i.RGBA_INTEGER&&(Y===i.UNSIGNED_BYTE&&(rt=i.RGBA8UI),Y===i.UNSIGNED_SHORT&&(rt=i.RGBA16UI),Y===i.UNSIGNED_INT&&(rt=i.RGBA32UI),Y===i.BYTE&&(rt=i.RGBA8I),Y===i.SHORT&&(rt=i.RGBA16I),Y===i.INT&&(rt=i.RGBA32I)),b===i.RGB&&(Y===i.UNSIGNED_SHORT&>&&(rt=gt.RGB16_EXT),Y===i.SHORT&>&&(rt=gt.RGB16_SNORM_EXT),Y===i.UNSIGNED_INT_5_9_9_9_REV&&(rt=i.RGB9_E5),Y===i.UNSIGNED_INT_10F_11F_11F_REV&&(rt=i.R11F_G11F_B10F)),b===i.RGBA){let at=mt?nr:ne.getTransfer(it);Y===i.FLOAT&&(rt=i.RGBA32F),Y===i.HALF_FLOAT&&(rt=i.RGBA16F),Y===i.UNSIGNED_BYTE&&(rt=at===fe?i.SRGB8_ALPHA8:i.RGBA8),Y===i.UNSIGNED_SHORT&>&&(rt=gt.RGBA16_EXT),Y===i.SHORT&>&&(rt=gt.RGBA16_SNORM_EXT),Y===i.UNSIGNED_SHORT_4_4_4_4&&(rt=i.RGBA4),Y===i.UNSIGNED_SHORT_5_5_5_1&&(rt=i.RGB5_A1)}return(rt===i.R16F||rt===i.R32F||rt===i.RG16F||rt===i.RG32F||rt===i.RGBA16F||rt===i.RGBA32F)&&t.get("EXT_color_buffer_float"),rt}function x(I,b){let Y;return I?b===null||b===Tn||b===Ls?Y=i.DEPTH24_STENCIL8:b===Ye?Y=i.DEPTH32F_STENCIL8:b===Ps&&(Y=i.DEPTH24_STENCIL8,Ht("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):b===null||b===Tn||b===Ls?Y=i.DEPTH_COMPONENT24:b===Ye?Y=i.DEPTH_COMPONENT32F:b===Ps&&(Y=i.DEPTH_COMPONENT16),Y}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 Y=I.source,Q=f.get(Y);if(Q){let it=Q[b.__cacheKey];it.usedTimes--,it.usedTimes===0&&R(I),Object.keys(Q).length===0&&f.delete(Y)}n.remove(I)}function R(I){let b=n.get(I);i.deleteTexture(b.__webglTexture);let Y=I.source,Q=f.get(Y);delete Q[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 Q=0;Q<6;Q++){if(Array.isArray(b.__webglFramebuffer[Q]))for(let it=0;it=s.maxTextures&&Ht("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 O(I,b){let Y=n.get(I);if(I.isVideoTexture&&P(I),I.isRenderTargetTexture===!1&&I.isExternalTexture!==!0&&I.version>0&&Y.__version!==I.version){let Q=I.image;if(Q===null)Ht("WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)Ht("WebGLRenderer: Texture marked for update but image is incomplete");else{ct(Y,I,b);return}}else I.isExternalTexture&&(Y.__webglTexture=I.sourceTexture?I.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,Y.__webglTexture,i.TEXTURE0+b)}function U(I,b){let Y=n.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&Y.__version!==I.version){ct(Y,I,b);return}else I.isExternalTexture&&(Y.__webglTexture=I.sourceTexture?I.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,Y.__webglTexture,i.TEXTURE0+b)}function z(I,b){let Y=n.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&Y.__version!==I.version){ct(Y,I,b);return}e.bindTexture(i.TEXTURE_3D,Y.__webglTexture,i.TEXTURE0+b)}function q(I,b){let Y=n.get(I);if(I.isCubeDepthTexture!==!0&&I.version>0&&Y.__version!==I.version){Ct(Y,I,b);return}e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture,i.TEXTURE0+b)}let G={[gs]:i.REPEAT,[Fn]:i.CLAMP_TO_EDGE,[Oo]:i.MIRRORED_REPEAT},Z={[Le]:i.NEAREST,[fd]:i.NEAREST_MIPMAP_NEAREST,[Mr]:i.NEAREST_MIPMAP_LINEAR,[qe]:i.LINEAR,[da]:i.LINEAR_MIPMAP_NEAREST,[Si]:i.LINEAR_MIPMAP_LINEAR},st={[_d]:i.NEVER,[bd]:i.ALWAYS,[xd]:i.LESS,[Za]:i.LEQUAL,[vd]:i.EQUAL,[Ka]:i.GEQUAL,[yd]:i.GREATER,[Md]:i.NOTEQUAL};function nt(I,b){if(b.type===Ye&&t.has("OES_texture_float_linear")===!1&&(b.magFilter===qe||b.magFilter===da||b.magFilter===Mr||b.magFilter===Si||b.minFilter===qe||b.minFilter===da||b.minFilter===Mr||b.minFilter===Si)&&Ht("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,Z[b.magFilter]),i.texParameteri(I,i.TEXTURE_MIN_FILTER,Z[b.minFilter]),b.compareFunction&&(i.texParameteri(I,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(I,i.TEXTURE_COMPARE_FUNC,st[b.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(b.magFilter===Le||b.minFilter!==Mr&&b.minFilter!==Si||b.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(b.anisotropy>1||n.get(b).__currentAnisotropy){let Y=t.get("EXT_texture_filter_anisotropic");i.texParameterf(I,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,s.getMaxAnisotropy())),n.get(b).__currentAnisotropy=b.anisotropy}}}function lt(I,b){let Y=!1;I.__webglInit===void 0&&(I.__webglInit=!0,b.addEventListener("dispose",A));let Q=b.source,it=f.get(Q);it===void 0&&(it={},f.set(Q,it));let mt=V(b);if(mt!==I.__cacheKey){it[mt]===void 0&&(it[mt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),it[mt].usedTimes++;let gt=it[I.__cacheKey];gt!==void 0&&(it[I.__cacheKey].usedTimes--,gt.usedTimes===0&&R(b)),I.__cacheKey=mt,I.__webglTexture=it[mt].texture}return Y}function H(I,b,Y){return Math.floor(Math.floor(I/Y)/b)}function K(I,b,Y,Q){let mt=I.updateRanges;if(mt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,b.width,b.height,Y,Q,b.data);else{mt.sort((Ut,Mt)=>Ut.start-Mt.start);let gt=0;for(let Ut=1;Ut0){Vt&&Kt&&e.texStorage2D(i.TEXTURE_2D,vt,Mt,Ft[0].width,Ft[0].height);for(let ot=0,yt=Ft.length;ot0){let Tt=Yc(xt.width,xt.height,b.format,b.type);for(let ht of b.layerUpdates){let zt=xt.data.subarray(ht*Tt/xt.data.BYTES_PER_ELEMENT,(ht+1)*Tt/xt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,ht,xt.width,xt.height,1,_t,zt)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,xt.width,xt.height,at.depth,_t,xt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,ot,Mt,xt.width,xt.height,at.depth,0,xt.data,0,0);else Ht("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Vt?X&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,xt.width,xt.height,at.depth,_t,Ut,xt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,ot,Mt,xt.width,xt.height,at.depth,0,_t,Ut,xt.data);b.layerUpdates.size>0&&b.clearLayerUpdates()}else{Vt&&Kt&&e.texStorage2D(i.TEXTURE_2D,vt,Mt,Ft[0].width,Ft[0].height);for(let ot=0,yt=Ft.length;ot0){let ot=Yc(at.width,at.height,b.format,b.type);for(let yt of b.layerUpdates){let Tt=at.data.subarray(yt*ot/at.data.BYTES_PER_ELEMENT,(yt+1)*ot/at.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,yt,at.width,at.height,1,_t,Ut,Tt)}b.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,at.width,at.height,at.depth,_t,Ut,at.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Mt,at.width,at.height,at.depth,0,_t,Ut,at.data);else if(b.isData3DTexture)Vt?(Kt&&e.texStorage3D(i.TEXTURE_3D,vt,Mt,at.width,at.height,at.depth),X&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,at.width,at.height,at.depth,_t,Ut,at.data)):e.texImage3D(i.TEXTURE_3D,0,Mt,at.width,at.height,at.depth,0,_t,Ut,at.data);else if(b.isFramebufferTexture){if(Kt)if(Vt)e.texStorage2D(i.TEXTURE_2D,vt,Mt,at.width,at.height);else{let ot=at.width,yt=at.height;for(let Tt=0;Tt>=1,yt>>=1}}else if(b.isHTMLTexture){if("texElementImage2D"in i){let ot=i.canvas;if(ot.hasAttribute("layoutsubtree")||ot.setAttribute("layoutsubtree","true"),at.parentNode!==ot){ot.appendChild(at),d.add(b),ot.onpaint=yt=>{let Tt=yt.changedElements;for(let ht of d)Tt.includes(ht.image)&&(ht.needsUpdate=!0)},ot.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,at);else{let Tt=i.RGBA,ht=i.RGBA,zt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Tt,ht,zt,at)}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(Ft.length>0){if(Vt&&Kt){let ot=wt(Ft[0]);e.texStorage2D(i.TEXTURE_2D,vt,Mt,ot.width,ot.height)}for(let ot=0,yt=Ft.length;ot0&&yt++;let ht=wt(Mt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,yt,Kt,ht.width,ht.height)}for(let ht=0;ht<6;ht++)if(Ut){X?ot&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0,0,0,Mt[ht].width,Mt[ht].height,Ft,Vt,Mt[ht].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0,Kt,Mt[ht].width,Mt[ht].height,0,Ft,Vt,Mt[ht].data);for(let zt=0;zt>mt),xt=Math.max(1,b.height>>mt);it===i.TEXTURE_3D||it===i.TEXTURE_2D_ARRAY?e.texImage3D(it,mt,at,Mt,xt,b.depth,0,gt,rt,null):e.texImage2D(it,mt,at,Mt,xt,0,gt,rt,null)}e.bindFramebuffer(i.FRAMEBUFFER,I),Lt(b)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,it,Ut.__webglTexture,0,dt(b)):(it===i.TEXTURE_2D||it>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Q,it,Ut.__webglTexture,mt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Bt(I,b,Y){if(i.bindRenderbuffer(i.RENDERBUFFER,I),b.depthBuffer){let Q=b.depthTexture,it=Q&&Q.isDepthTexture?Q.type:null,mt=x(b.stencilBuffer,it),gt=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Lt(b)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,dt(b),mt,b.width,b.height):Y?i.renderbufferStorageMultisample(i.RENDERBUFFER,dt(b),mt,b.width,b.height):i.renderbufferStorage(i.RENDERBUFFER,mt,b.width,b.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,gt,i.RENDERBUFFER,I)}else{let Q=b.textures;for(let it=0;it{delete b.__boundDepthTexture,delete b.__depthDisposeCallback,Q.removeEventListener("dispose",it)};Q.addEventListener("dispose",it),b.__depthDisposeCallback=it}b.__boundDepthTexture=Q}if(I.depthTexture&&!b.__autoAllocateDepthBuffer)if(Y)for(let Q=0;Q<6;Q++)he(b.__webglFramebuffer[Q],I,Q);else{let Q=I.texture.mipmaps;Q&&Q.length>0?he(b.__webglFramebuffer[0],I,0):he(b.__webglFramebuffer,I,0)}else if(Y){b.__webglDepthbuffer=[];for(let Q=0;Q<6;Q++)if(e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[Q]),b.__webglDepthbuffer[Q]===void 0)b.__webglDepthbuffer[Q]=i.createRenderbuffer(),Bt(b.__webglDepthbuffer[Q],I,!1);else{let it=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=b.__webglDepthbuffer[Q];i.bindRenderbuffer(i.RENDERBUFFER,mt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,mt)}}else{let Q=I.texture.mipmaps;if(Q&&Q.length>0?e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer===void 0)b.__webglDepthbuffer=i.createRenderbuffer(),Bt(b.__webglDepthbuffer,I,!1);else{let it=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=b.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,mt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,mt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Zt(I,b,Y){let Q=n.get(I);b!==void 0&&ft(Q.__webglFramebuffer,I,I.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Y!==void 0&&Gt(I)}function ee(I){let b=I.texture,Y=n.get(I),Q=n.get(b);I.addEventListener("dispose",v);let it=I.textures,mt=I.isWebGLCubeRenderTarget===!0,gt=it.length>1;if(gt||(Q.__webglTexture===void 0&&(Q.__webglTexture=i.createTexture()),Q.__version=b.version,o.memory.textures++),mt){Y.__webglFramebuffer=[];for(let rt=0;rt<6;rt++)if(b.mipmaps&&b.mipmaps.length>0){Y.__webglFramebuffer[rt]=[];for(let at=0;at0){Y.__webglFramebuffer=[];for(let rt=0;rt0&&Lt(I)===!1){Y.__webglMultisampledFramebuffer=i.createFramebuffer(),Y.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let rt=0;rt0)for(let at=0;at0)for(let at=0;at0){if(Lt(I)===!1){let b=I.textures,Y=I.width,Q=I.height,it=i.COLOR_BUFFER_BIT,mt=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,gt=n.get(I),rt=b.length>1;if(rt)for(let _t=0;_t0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,gt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,gt.__webglFramebuffer);for(let _t=0;_t0&&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 ut(I,b){let Y=I.colorSpace,Q=I.format,it=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||Y!==er&&Y!==oi&&(ne.getTransfer(Y)===fe?(Q!==je||it!==rn)&&Ht("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xt("WebGLTextures: Unsupported texture color space:",Y)),b}function wt(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=k,this.resetTextureUnits=B,this.getTextureUnits=D,this.setTextureUnits=F,this.setTexture2D=O,this.setTexture2DArray=U,this.setTexture3D=z,this.setTextureCube=q,this.rebindTextures=Zt,this.setupRenderTarget=ee,this.updateRenderTargetMipmap=pt,this.updateMultisampleRenderTarget=ae,this.setupDepthRenderbuffer=Gt,this.setupFrameBufferTexture=ft,this.useMultisampledRTT=Lt,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function Dv(i,t){function e(n,s=oi){let r,o=ne.getTransfer(s);if(n===rn)return i.UNSIGNED_BYTE;if(n===pa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ma)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Nc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Uc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Lc)return i.BYTE;if(n===Dc)return i.SHORT;if(n===Ps)return i.UNSIGNED_SHORT;if(n===fa)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===Fc)return i.ALPHA;if(n===Bc)return i.RGB;if(n===je)return i.RGBA;if(n===Bn)return i.DEPTH_COMPONENT;if(n===wi)return i.DEPTH_STENCIL;if(n===Ds)return i.RED;if(n===ga)return i.RED_INTEGER;if(n===Ei)return i.RG;if(n===_a)return i.RG_INTEGER;if(n===xa)return i.RGBA_INTEGER;if(n===br||n===Sr||n===wr||n===Er)if(o===fe)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===br)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Sr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===wr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===br)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Sr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===wr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Er)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===va||n===ya||n===Ma||n===ba)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===va)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ya)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ma)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ba)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Sa||n===wa||n===Ea||n===Ta||n===Aa||n===Tr||n===Ra)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Sa||n===wa)return o===fe?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ea)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ta)return r.COMPRESSED_R11_EAC;if(n===Aa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Tr)return r.COMPRESSED_RG11_EAC;if(n===Ra)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ca||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)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ca)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ia)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Pa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===La)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Da)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Na)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ua)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Fa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ba)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Oa)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===za)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ka)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ha)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Va)return o===fe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ga||n===Wa||n===Xa)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Ga)return o===fe?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Wa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Xa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===qa||n===Ya||n===Ar||n===$a)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===qa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ya)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ar)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===$a)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ls?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var Nv=` +}`,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=` void main() { gl_Position = vec4( position, 1.0 ); -}`,Uv=` +}`,ny=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4217,7 +4217,7 @@ void main() { } -}`,dh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new cr(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:Nv,fragmentShader:Uv,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}},fh=class extends On{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,g=null,_=typeof XRWebGLBinding<"u",m=new dh,p={},y=e.getContextAttributes(),w=null,M=null,x=[],S=[],A=new Wt,v=null,E=null,R=new Ue;R.viewport=new ve;let L=new Ue;L.viewport=new ve;let N=[R,L],B=new la,D=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(H){let K=x[H];return K===void 0&&(K=new Ss,x[H]=K),K.getTargetRaySpace()},this.getControllerGrip=function(H){let K=x[H];return K===void 0&&(K=new Ss,x[H]=K),K.getGripSpace()},this.getHand=function(H){let K=x[H];return K===void 0&&(K=new Ss,x[H]=K),K.getHandSpace()};function k(H){let K=S.indexOf(H.inputSource);if(K===-1)return;let ct=x[K];ct!==void 0&&(ct.update(H.inputSource,H.frame,c||o),ct.dispatchEvent({type:H.type,data:H.inputSource}))}function V(){s.removeEventListener("select",k),s.removeEventListener("selectstart",k),s.removeEventListener("selectend",k),s.removeEventListener("squeeze",k),s.removeEventListener("squeezestart",k),s.removeEventListener("squeezeend",k),s.removeEventListener("end",V),s.removeEventListener("inputsourceschange",O);for(let H=0;H=0&&(S[Ct]=null,x[Ct].disconnect(ct))}for(let K=0;K=S.length){S.push(ct),Ct=Bt;break}else if(S[Bt]===null){S[Bt]=ct,Ct=Bt;break}if(Ct===-1)break}let ft=x[Ct];ft&&ft.connect(ct)}}let U=new C,z=new C;function q(H,K,ct){U.setFromMatrixPosition(K.matrixWorld),z.setFromMatrixPosition(ct.matrixWorld);let Ct=U.distanceTo(z),ft=K.projectionMatrix.elements,Bt=ct.projectionMatrix.elements,he=ft[14]/(ft[10]-1),Gt=ft[14]/(ft[10]+1),Zt=(ft[9]+1)/ft[5],ee=(ft[9]-1)/ft[5],pt=(ft[8]-1)/ft[0],Ot=(Bt[8]+1)/Bt[0],qt=he*pt,ae=he*Ot,dt=Ct/(-pt+Ot),Lt=dt*-pt;if(K.matrixWorld.decompose(H.position,H.quaternion,H.scale),H.translateX(Lt),H.translateZ(dt),H.matrixWorld.compose(H.position,H.quaternion,H.scale),H.matrixWorldInverse.copy(H.matrixWorld).invert(),ft[10]===-1)H.projectionMatrix.copy(K.projectionMatrix),H.projectionMatrixInverse.copy(K.projectionMatrixInverse);else{let P=he+dt,ut=Gt+dt,wt=qt-Lt,I=ae+(Ct-Lt),b=Zt*Gt/ut*P,Y=ee*Gt/ut*P;H.projectionMatrix.makePerspective(wt,I,b,Y,P,ut),H.projectionMatrixInverse.copy(H.projectionMatrix).invert()}}function G(H,K){K===null?H.matrixWorld.copy(H.matrix):H.matrixWorld.multiplyMatrices(K.matrixWorld,H.matrix),H.matrixWorldInverse.copy(H.matrixWorld).invert()}this.updateCamera=function(H){if(s===null)return;let K=H.near,ct=H.far;m.texture!==null&&(m.depthNear>0&&(K=m.depthNear),m.depthFar>0&&(ct=m.depthFar)),B.near=L.near=R.near=K,B.far=L.far=R.far=ct,(D!==B.near||F!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),D=B.near,F=B.far),B.layers.mask=H.layers.mask|6,R.layers.mask=B.layers.mask&-5,L.layers.mask=B.layers.mask&-3;let Ct=H.parent,ft=B.cameras;G(B,Ct);for(let Bt=0;Bt0&&(m.alphaTest.value=p.alphaTest);let y=t.get(p),w=y.envMap,M=y.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(Fv.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(rf),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,y,w){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*y,m.scale.value=w*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function u(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,y){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===ze&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.retroreflectivity>0&&(m.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){let y=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Ov(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&&(m(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?Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(x.boundary=16,x.storage=M.byteLength):Ht("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 zv=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]),$n=null;function kv(){return $n===null&&($n=new mn(zv,16,16,Ei,An),$n.name="DFG_LUT",$n.minFilter=qe,$n.magFilter=qe,$n.wrapS=Fn,$n.wrapT=Fn,$n.generateMipmaps=!1,$n.needsUpdate=!0),$n}var Ti=class{constructor(t={}){let{canvas:e=Sd(),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 g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let _=f,m=new Set([xa,_a,ga]),p=new Set([rn,Tn,Ps,Ls,pa,ma]),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 k=0,V=0,O=null,U=-1,z=null,q=new ve,G=new ve,Z=null,st=new kt(0),nt=0,lt=e.width,H=e.height,K=1,ct=null,Ct=null,ft=new ve(0,0,lt,H),Bt=new ve(0,0,lt,H),he=!1,Gt=new kn,Zt=!1,ee=!1,pt=new Yt,Ot=new C,qt=new ve,ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},dt=!1;function Lt(){return O===null?K:1}let P=n;function ut(T,W){return e.getContext(T,W)}let wt,I,b,Y,Q,it,mt,gt,rt,at,_t,Ut,Mt,xt,Ft,Vt,Kt,X,vt,ot,yt,Tt,ht;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=ut(W,T),P===null)throw ut(W)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}zt()}catch(T){throw e.removeEventListener("webglcontextlost",be,!1),e.removeEventListener("webglcontextrestored",ue,!1),e.removeEventListener("webglcontextcreationerror",_n,!1),Xt("WebGLRenderer: "+T.message),T}function zt(){wt=new Y0(P),wt.init(),yt=new Dv(P,wt),I=new B0(P,wt,t,yt),b=new Pv(P,wt),I.reversedDepthBuffer&&u&&b.buffers.depth.setReversed(!0),B=P.createFramebuffer(),D=P.createFramebuffer(),F=P.createFramebuffer(),Y=new K0(P),Q=new _v,it=new Lv(P,wt,b,Q,I,yt,Y),mt=new q0(R),gt=new jm(P),Tt=new U0(P,gt),rt=new $0(P,gt,Y,Tt),at=new j0(P,rt,gt,Tt,Y),X=new J0(P,I,it),Ft=new O0(Q),_t=new gv(R,mt,wt,I,Tt,Ft),Ut=new Bv(R,Q),Mt=new vv,xt=new Ev(wt),Kt=new N0(R,mt,b,at,g,l),Vt=new Iv(R,at,I),ht=new Ov(P,Y,I,b),vt=new F0(P,wt,Y),ot=new Z0(P,wt,Y),Y.programs=_t.programs,R.capabilities=I,R.extensions=wt,R.properties=Q,R.renderLists=Mt,R.shadowMap=Vt,R.state=b,R.info=Y}_!==rn&&(E=new tx(_,e.width,e.height,a,s,r));let Dt=new fh(R,P);this.xr=Dt,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){let T=wt.get("WEBGL_lose_context");T&&T.loseContext()},this.forceContextRestore=function(){let T=wt.get("WEBGL_lose_context");T&&T.restoreContext()},this.getPixelRatio=function(){return K},this.setPixelRatio=function(T){T!==void 0&&(K=T,this.setSize(lt,H,!1))},this.getSize=function(T){return T.set(lt,H)},this.setSize=function(T,W,tt=!0){if(Dt.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}lt=T,H=W,e.width=Math.floor(T*K),e.height=Math.floor(W*K),tt===!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(lt*K,H*K).floor()},this.setDrawingBufferSize=function(T,W,tt){lt=T,H=W,K=tt,e.width=Math.floor(T*tt),e.height=Math.floor(W*tt),this.setViewport(0,0,T,W)},this.setEffects=function(T){if(_===rn){Xt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(T){for(let W=0;W{function Et(){if(J.forEach(function(Rt){let It=Q.get(Rt).currentProgram;(It===void 0||It.isReady())&&J.delete(Rt)}),J.size===0){j(T);return}setTimeout(Et,10)}wt.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let Fl=null;function Zp(T){Fl&&Fl(T)}function tu(){Pi.stop()}function eu(){Pi.start()}let Pi=new jd;Pi.setAnimationLoop(Zp),typeof self<"u"&&Pi.setContext(self),this.setAnimationLoop=function(T){Fl=T,Dt.setAnimationLoop(T),T===null?Pi.stop():Pi.start()},Dt.addEventListener("sessionstart",tu),Dt.addEventListener("sessionend",eu),this.render=function(T,W){if(W!==void 0&&W.isCamera!==!0){Xt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;N!==null&&N.renderStart(T,W);let tt=Dt.enabled===!0&&Dt.isPresenting===!0,J=E!==null&&(O===null||tt)&&E.begin(R,O);if(T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),W.parent===null&&W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),Dt.enabled===!0&&Dt.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Dt.cameraAutoUpdate===!0&&Dt.updateCamera(W),W=Dt.getCamera()),T.isScene===!0&&T.onBeforeRender(R,T,W,O),S=xt.get(T,v.length),S.init(W),S.state.textureUnits=it.getTextureUnits(),v.push(S),pt.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),Gt.setFromProjectionMatrix(pt,bn,W.reversedDepth),ee=this.localClippingEnabled,Zt=Ft.init(this.clippingPlanes,ee),x=Mt.get(T,A.length),x.init(),A.push(x),Dt.enabled===!0&&Dt.isPresenting===!0){let Rt=R.xr.getDepthSensingMesh();Rt!==null&&Bl(Rt,W,-1/0,R.sortObjects)}Bl(T,W,0,R.sortObjects),x.finish(),N!==null&&N.updateLights(S.state.lightsArray),R.sortObjects===!0&&x.sort(ct,Ct),dt=Dt.enabled===!1||Dt.isPresenting===!1||Dt.hasDepthSensing()===!1,dt&&Kt.addToRenderList(x,T),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Zt===!0&&Ft.beginShadows();let j=S.state.shadowsArray;if(Vt.render(j,T,W),Zt===!0&&Ft.endShadows(),(J&&E.hasRenderPass())===!1){let Rt=x.opaque,St=x.transmissive;if(S.setupLights(),W.isArrayCamera){let It=W.cameras;if(St.length>0)for(let Nt=0,Jt=It.length;Nt0&&iu(Rt,St,T,W),dt&&Kt.render(T),nu(x,T,W)}O!==null&&V===0&&(it.updateMultisampleRenderTarget(O),it.updateRenderTargetMipmap(O)),J&&E.end(R),T.isScene===!0&&T.onAfterRender(R,T,W),Tt.resetDefaultState(),U=-1,z=null,v.pop(),v.length>0?(S=v[v.length-1],it.setTextureUnits(S.state.textureUnits),Zt===!0&&Ft.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 Bl(T,W,tt,J){if(T.visible===!1)return;if(T.layers.test(W.layers)){if(T.isGroup)tt=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(Gt)){J&&qt.setFromMatrixPosition(T.matrixWorld).applyMatrix4(pt);let Rt=at.update(T),St=T.material;St.visible&&x.push(T,Rt,St,tt,qt.z,null,W)}}else if((T.isMesh||T.isLine||T.isPoints)&&(!T.frustumCulled||T.intersectsFrustum(Gt))){let Rt=at.update(T),St=T.material;if(J&&(T.boundingSphere!==void 0?(T.boundingSphere===null&&T.computeBoundingSphere(),qt.copy(T.boundingSphere.center)):(Rt.boundingSphere===null&&Rt.computeBoundingSphere(),qt.copy(Rt.boundingSphere.center)),qt.applyMatrix4(T.matrixWorld).applyMatrix4(pt)),Array.isArray(St)){let It=Rt.groups;for(let Nt=0,Jt=It.length;Nt0&&Jr(j,W,tt),Et.length>0&&Jr(Et,W,tt),Rt.length>0&&Jr(Rt,W,tt),b.buffers.depth.setTest(!0),b.buffers.depth.setMask(!0),b.buffers.color.setMask(!0),b.setPolygonOffset(!1)}function iu(T,W,tt,J){if((tt.isScene===!0?tt.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[J.id]===void 0){let Pt=wt.has("EXT_color_buffer_half_float")||wt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[J.id]=new Be(1,1,{generateMipmaps:!0,type:Pt?An:rn,minFilter:Si,samples:Math.max(4,I.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ne.workingColorSpace})}let Et=S.state.transmissionRenderTarget[J.id],Rt=J.viewport||q;Et.setSize(Rt.z*R.transmissionResolutionScale,Rt.w*R.transmissionResolutionScale);let St=R.getRenderTarget(),It=R.getActiveCubeFace(),Nt=R.getActiveMipmapLevel();R.setRenderTarget(Et),R.getClearColor(st),nt=R.getClearAlpha(),nt<1&&R.setClearColor(16777215,.5),R.clear(),dt&&Kt.render(tt);let Jt=R.toneMapping;R.toneMapping=En;let te=J.viewport;if(J.viewport!==void 0&&(J.viewport=void 0),S.setupLightsView(J),Zt===!0&&Ft.setGlobalState(R.clippingPlanes,J),Jr(T,tt,J),it.updateMultisampleRenderTarget(Et),it.updateRenderTargetMipmap(Et),wt.has("WEBGL_multisampled_render_to_texture")===!1){let Pt=!1;for(let de=0,De=W.length;de0,J.currentProgram=te,J.uniformsList=null,te}function ru(T){if(T.uniformsList===null){let W=T.currentProgram.getUniforms();T.uniformsList=Fs.seqWithValue(W.seq,T.uniforms)}return T.uniformsList}function ou(T,W){let tt=Q.get(T);tt.outputColorSpace=W.outputColorSpace,tt.batching=W.batching,tt.batchingColor=W.batchingColor,tt.instancing=W.instancing,tt.instancingColor=W.instancingColor,tt.instancingMorph=W.instancingMorph,tt.skinning=W.skinning,tt.morphTargets=W.morphTargets,tt.morphNormals=W.morphNormals,tt.morphColors=W.morphColors,tt.morphTargetsCount=W.morphTargetsCount,tt.numClippingPlanes=W.numClippingPlanes,tt.numIntersection=W.numClipIntersection,tt.vertexAlphas=W.vertexAlphas,tt.vertexTangents=W.vertexTangents,tt.toneMapping=W.toneMapping}function Kp(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 tt=0,J=T.length;tt0),Pt=!!tt.morphAttributes.position,de=!!tt.morphAttributes.normal,De=!!tt.morphAttributes.color,Ee=En;J.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(Ee=R.toneMapping);let ye=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,$e=ye!==void 0?ye.length:0,At=Q.get(J),en=S.state.lights;if(Zt===!0&&(ee===!0||T!==z)){let Se=T===z&&J.id===U;Ft.setState(J,T,Se)}let le=!1;J.version===At.__version?(At.needsLights&&At.lightsStateVersion!==en.state.version||At.outputColorSpace!==St||j.isBatchedMesh&&At.batching===!1||!j.isBatchedMesh&&At.batching===!0||j.isBatchedMesh&&At.batchingColor===!0&&j._colorsTexture===null||j.isBatchedMesh&&At.batchingColor===!1&&j._colorsTexture!==null||j.isInstancedMesh&&At.instancing===!1||!j.isInstancedMesh&&At.instancing===!0||j.isSkinnedMesh&&At.skinning===!1||!j.isSkinnedMesh&&At.skinning===!0||j.isInstancedMesh&&At.instancingColor===!0&&j.instanceColor===null||j.isInstancedMesh&&At.instancingColor===!1&&j.instanceColor!==null||j.isInstancedMesh&&At.instancingMorph===!0&&j.morphTexture===null||j.isInstancedMesh&&At.instancingMorph===!1&&j.morphTexture!==null||At.envMap!==Nt||J.fog===!0&&At.fog!==Et||At.numClippingPlanes!==void 0&&(At.numClippingPlanes!==Ft.numPlanes||At.numIntersection!==Ft.numIntersection)||At.vertexAlphas!==Jt||At.vertexTangents!==te||At.morphTargets!==Pt||At.morphNormals!==de||At.morphColors!==De||At.toneMapping!==Ee||At.morphTargetsCount!==$e||!!At.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(le=!0):(le=!0,At.__version=J.version);let dn=At.currentProgram;le===!0&&(dn=jr(J,W,j),N&&J.isNodeMaterial&&N.onUpdateProgram(J,dn,At));let Nn=!1,ci=!1,Ki=!1,_e=dn.getUniforms(),Pe=At.uniforms;if(b.useProgram(dn.program)&&(Nn=!0,ci=!0,Ki=!0),J.id!==U&&(U=J.id,ci=!0),At.needsLights){let Se=Kp(S.state.lightProbeGridArray,j);At.lightProbeGrid!==Se&&(At.lightProbeGrid=Se,ci=!0)}if(Nn||z!==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,Ot.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),z!==T&&(z=T,ci=!0,Ki=!0)}if(At.needsLights&&(en.state.sunShadowMap.length>0&&_e.setValue(P,"sunShadowMap",en.state.sunShadowMap,it),en.state.directionalShadowMap.length>0&&_e.setValue(P,"directionalShadowMap",en.state.directionalShadowMap,it),en.state.spotShadowMap.length>0&&_e.setValue(P,"spotShadowMap",en.state.spotShadowMap,it),en.state.pointShadowMap.length>0&&_e.setValue(P,"pointShadowMap",en.state.pointShadowMap,it)),j.isSkinnedMesh){_e.setOptional(P,j,"bindMatrix"),_e.setOptional(P,j,"bindMatrixInverse");let Se=j.skeleton;Se&&(Se.boneTexture===null&&Se.computeBoneTexture(),_e.setValue(P,"boneTexture",Se.boneTexture,it))}j.isBatchedMesh&&(_e.setOptional(P,j,"batchingTexture"),_e.setValue(P,"batchingTexture",j._matricesTexture,it),_e.setOptional(P,j,"batchingIdTexture"),_e.setValue(P,"batchingIdTexture",j._indirectTexture,it),_e.setOptional(P,j,"batchingColorTexture"),j._colorsTexture!==null&&_e.setValue(P,"batchingColorTexture",j._colorsTexture,it));let hi=tt.morphAttributes;if((hi.position!==void 0||hi.normal!==void 0||hi.color!==void 0)&&X.update(j,tt,dn),(ci||At.receiveShadow!==j.receiveShadow)&&(At.receiveShadow=j.receiveShadow,_e.setValue(P,"receiveShadow",j.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=kv()),ci){if(_e.setValue(P,"toneMappingExposure",R.toneMappingExposure),At.needsLights&&jp(Pe,Ki),Et&&J.fog===!0&&Ut.refreshFogUniforms(Pe,Et),Ut.refreshMaterialUniforms(Pe,J,K,H,S.state.transmissionRenderTarget[T.id]),At.needsLights&&At.lightProbeGrid){let Se=At.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)}Fs.upload(P,ru(At),Pe,it)}if(J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Fs.upload(P,ru(At),Pe,it),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&_e.setValue(P,"center",j.center),_e.setValue(P,"modelViewMatrix",j.modelViewMatrix),_e.setValue(P,"normalMatrix",j.normalMatrix),_e.setValue(P,"modelMatrix",j.matrixWorld),J.uniformsGroups!==void 0){let Se=J.uniformsGroups;for(let ui=0,Ji=Se.length;ui0&&it.useMultisampledRTT(T)===!1?J=Q.get(T).__webglMultisampledFramebuffer:Array.isArray(Nt)?J=Nt[tt]:J=Nt,q.copy(T.viewport),G.copy(T.scissor),Z=T.scissorTest}else q.copy(ft).multiplyScalar(K).floor(),G.copy(Bt).multiplyScalar(K).floor(),Z=he;if(tt!==0&&(J=B),b.bindFramebuffer(P.FRAMEBUFFER,J)&&b.drawBuffers(T,J),b.viewport(q),b.scissor(G),b.setScissorTest(Z),j){let St=Q.get(T.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+W,St.__webglTexture,tt)}else if(Et){let St=W;for(let It=0;It1&&P.readBuffer(P.COLOR_ATTACHMENT0+St);let Pt=au(Nt);if(Pt.__formatReadable===!1){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Pt.__typeReadable===!1){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}W>=0&&W<=T.width-J&&tt>=0&&tt<=T.height-j&&P.readPixels(W,tt,J,j,yt.convert(Jt),yt.convert(te),Et)}finally{let Nt=O!==null?Q.get(O).__webglFramebuffer:null;b.bindFramebuffer(P.FRAMEBUFFER,Nt)}}},this.readRenderTargetPixelsAsync=async function(T,W,tt,J,j,Et,Rt,St=0){if(!(T&&T.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let It=Q.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&Rt!==void 0&&(It=It[Rt]),It)if(W>=0&&W<=T.width-J&&tt>=0&&tt<=T.height-j){b.bindFramebuffer(P.FRAMEBUFFER,It);let Nt=T.textures[St],Jt=Nt.format,te=Nt.type;T.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+St);let Pt=au(Nt);if(Pt.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Pt.__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,Et.byteLength,P.STREAM_READ),P.readPixels(W,tt,J,j,yt.convert(Jt),yt.convert(te),0),P.bindBuffer(P.PIXEL_PACK_BUFFER,null);let De=O!==null?Q.get(O).__webglFramebuffer:null;b.bindFramebuffer(P.FRAMEBUFFER,De);let Ee=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await Ed(P,Ee,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,de),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,Et),P.bindBuffer(P.PIXEL_PACK_BUFFER,null),P.deleteBuffer(de),P.deleteSync(Ee),Et}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,W=null,tt=0){let J=Math.pow(2,-tt),j=Math.floor(T.image.width*J),Et=Math.floor(T.image.height*J),Rt=W!==null?W.x:0,St=W!==null?W.y:0;it.setTexture2D(T,0),P.copyTexSubImage2D(P.TEXTURE_2D,tt,0,0,Rt,St,j,Et),b.unbindTexture()},this.copyTextureToTexture=function(T,W,tt=null,J=null,j=0,Et=0){let Rt,St,It,Nt,Jt,te,Pt,de,De,Ee=T.isCompressedTexture?T.mipmaps[Et]:T.image;if(tt!==null)Rt=tt.max.x-tt.min.x,St=tt.max.y-tt.min.y,It=tt.isBox3?tt.max.z-tt.min.z:1,Nt=tt.min.x,Jt=tt.min.y,te=tt.isBox3?tt.min.z:0;else{let Pe=Math.pow(2,-j);Rt=Math.floor(Ee.width*Pe),St=Math.floor(Ee.height*Pe),T.isDataArrayTexture?It=Ee.depth:T.isData3DTexture?It=Math.floor(Ee.depth*Pe):It=1,Nt=0,Jt=0,te=0}J!==null?(Pt=J.x,de=J.y,De=J.z):(Pt=0,de=0,De=0);let ye=yt.convert(W.format),$e=yt.convert(W.type),At;W.isData3DTexture?(it.setTexture3D(W,0),At=P.TEXTURE_3D):W.isDataArrayTexture||W.isCompressedArrayTexture?(it.setTexture2DArray(W,0),At=P.TEXTURE_2D_ARRAY):(it.setTexture2D(W,0),At=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),le=b.getParameter(P.UNPACK_IMAGE_HEIGHT),dn=b.getParameter(P.UNPACK_SKIP_PIXELS),Nn=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,Nt),b.pixelStorei(P.UNPACK_SKIP_ROWS,Jt),b.pixelStorei(P.UNPACK_SKIP_IMAGES,te);let Ki=T.isDataArrayTexture||T.isData3DTexture,_e=W.isDataArrayTexture||W.isData3DTexture;if(T.isDepthTexture){let Pe=Q.get(T),hi=Q.get(W),Se=Q.get(Pe.__renderTarget),ui=Q.get(hi.__renderTarget);b.bindFramebuffer(P.READ_FRAMEBUFFER,Se.__webglFramebuffer),b.bindFramebuffer(P.DRAW_FRAMEBUFFER,ui.__webglFramebuffer);for(let Ji=0;Ji=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(ph(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"),uf=i=>Yi(i)&&Ai(i.min)&&Ai(i.max),lf=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||uf(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function Gv(i){if(!Yi(i)||!Rn(i.elements)||!Rn(i.geometries)||!Rn(i.materials)||!Yi(i.instances))throw new Qt("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new Qt("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new Qt("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 Qt(`Invalid META instance ${n} view.`);for(let n of i.geometries){let s=n.q;if(!uf(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 Qt("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 Qt(`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 Qt(`Invalid META ${n} ${r} view.`)}if(i.annotations!=null&&!Rn(i.annotations))throw new Qt("Invalid META annotations.");if(i.sheets!=null&&!Rn(i.sheets))throw new Qt("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 Qt("Invalid META panorama.");function e(n){return n?.t==="u8"&&Number.isSafeInteger(n.n)&&n.n>=4&&n.n<=16*1024*1024}Wv(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 Qt("Invalid META material.")}}function Wv(i){if(!Yi(i)||!Rn(i.elements)||i.title!=null&&typeof i.title!="string")throw new Qt("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!Rn(i[l]))throw new Qt(`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 Qt("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)&&lf(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=Dr(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 Qt("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 Qt("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new Qt("Invalid META linked file members.");if(!lf(i.sections))throw new Qt("Invalid META sections.")}function Xv(i){let t;try{t=JSON.parse(i)}catch(e){throw new Qt(e.message,{cause:e})}return Gv(t),t}function mh(i=document,t){t?.("metadataStart");let e;try{e=hf(i,"ioviewer-meta")}catch(s){throw s instanceof Qt?s:new Qt(s.message,{cause:s})}let n=Xv(e);return t?.("metadataEnd"),n}function cf(i,t){let e=Hv[i?.t];if(!e)throw new Qt(`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 Qt(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function df(i=document,t,e=mh(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}=af(s)),t?.("binaryEnd")}catch(c){throw new Qt(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=cf(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=cf(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=af(s).bytes));let d=n??o;return d?new h(d.buffer,c.o,c.n):new h(Vv(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(hf(i,"ioviewer-props"))),l[c]??null}}}var ff=new Yt,pf=new kn,gh=32;function _h(i,t=new Float64Array(24)){return ff.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),pf.setFromProjectionMatrix(ff,i.coordinateSystem,i.reversedDepth),pf.planes.forEach(({normal:e,constant:n},s)=>t.set([e.x,e.y,e.z,n],s*4)),t}function xh(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 mf(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,yh=32767,Nr=i=>i<0?-1:1;function _f(i){let t=Math.min(Math.max(i,-1),1)*yh;return Nr(t)*Math.round(Math.abs(t))}function Ur(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))*Nr(o),(1-Math.abs(o))*Nr(a)]),i[t]=_f(o),i[t+1]=_f(a)}function xf(i,t,e,n){let s=Math.max(e/yh,-1),r=Math.max(n/yh,-1),o=1-Math.abs(s)-Math.abs(r);o<0&&([s,r]=[(1-Math.abs(r))*Nr(s),(1-Math.abs(s))*Nr(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 Fr(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 zs(i,t){let e=Fr(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=Yv(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 Ef(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&&$v(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+=wf(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function $v(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 Tf(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 bh=384*2**20;function Af(i,{cap:t=bh,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 il(i,t){return i>65535?new Uint32Array(t):new Uint16Array(t)}function Sh(i,t){return i.sort((e,n)=>t[n]-t[e]||e-n)}function Rf(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function Cf(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function If(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 Mf}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)<=bf||(o=!1)}return o||n.fill(0),o?qv:ks}function Pf(i,t){let e=i.length,n=0,s=0;for(let m of i){let p=t.source(t.geometryOf[m]);n+=p.vertices,s+=p.indices.length}let r=t.kind[i[0]]===ks,o=r?new Float32Array(n*4):new Uint16Array(n*4),a=new Int16Array(n*2),l=t.textured?new Float32Array(n*2):null,c=il(n,s),h=new Uint32Array(e+1),d=new Float32Array(e*3),u=new Float32Array(e),f=new Float64Array(3),g=0,_=0;for(let m=0;mMath.min(Math.max(Math.round(i/Cn),0),bf);function Lf(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 sl(i){if(!i.normals&&i.oct){i.normals=new Float32Array(i.vertices*3);for(let t=0;t=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.0 ? - t : t, n.y >= 0.0 ? - t : t ); return n; -}`,Or=` +}`,kr=` int slot = int( slotBase ) + int( q.w ); ivec2 st = ivec2( slot & 2047, slot >> 11 ); vec4 info = texelFetch( slotInfo, st, 0 ); vec4 state = texelFetch( slotState, st, 0 ); -vec3 slotPosition = info.xyz + q.xyz * info.w;`,wh=` +vec3 slotPosition = info.xyz + q.xyz * info.w;`,Ah=` #ifndef IO_NO_HIDE_BRANCH if ( state.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); -#endif`,jv=` +#endif`,vy=` vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); @@ -4248,11 +4248,11 @@ transformedNormal = mat3( cross( im[ 1 ], im[ 2 ] ), cross( im[ 2 ], im[ 0 ] ), transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; -#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 Qv(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ri(i.vertexShader,"#include ",`#include -${Br}`);t=Ri(t,"#include ",`${Or} -vTint = state.rgb;`),t=Ri(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ri(t,"#include ",jv),t=Ri(t,"#include ","vec3 transformed = slotPosition;"),t=Ri(t,"#include ",`#include -${wh}`),i.vertexShader=t;let e=Ri(i.fragmentShader,"#include ",`#include -varying vec3 vTint;`);e=Ri(e,"#include ","diffuseColor.rgb *= vTint;"),i.fragmentShader=e}function Eh(i,t,e=!1){return i.userData.slotUniforms=t,i.onBeforeCompile=Qv,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var Ih=["materials","textures","white","wireframe"],ty=[245,158,11],ey=[235,235,237],zr=4294967295,$i=2048,Th=256,ny=16,Ah=1024,iy=.1,sy=8192,ry=1.4,ol=2**-20,rl=17;function oy(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 ay(){this.array=null}function In(i,t,e=!1,n=xe){return new n(i,t,e).onUpload(ay)}var kr=class extends RangeError{constructor(t,e){super(`${t} drawable instances exceed the limit of ${e}.`),this.name="ModelTooLargeError",this.count=t,this.limit=e}},Df=(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+ol*Math.abs(l)))return!0}return!1}function Rh(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],g=c*e[1],_=c*n[1],m=h*e[2],p=h*n[2];s[o+a]=Math.min(u,f)+Math.min(g,_)+Math.min(m,p)+d,s[o+a+3]=Math.max(u,f)+Math.max(g,_)+Math.max(m,p)+d}}var cy=i=>{let t=i.getHex(me);return[t>>16&255,t>>8&255,t&255]},Hr=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??[],g=e.annotationLayouts??[],_=r+h+u+g.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=g,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 m=!!e.noHideBranch;if(this.slotUniforms={slotInfo:{value:null},slotState:{value:null}},this._buckets=this._createBuckets(n,a,m),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=_h(n,this._planes);let{x:r,y:o,z:a}=n.position;this._pickViewPadding=ol*(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 se){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+=Ch(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]/m:1/0:o[6];d[f]=p;let y=g.cell&&this._detailUsesInstances,w=y&&!mf(r,_[0],_[1],_[2],_[3]+g.pickPadding),M=g.slotBase+g.n,x=-1;if(y){let R=this._slotRadius[g.slotBase],L=this._slotRadius[M-1],N=m+_[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,k=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);Os(V)===Os(k)&&(x=k)}if(x>=0&&!w){g.detailLow=g.detailHigh=x,g.detailEnd=g.n;let R=this._slotCost[g.slotBase]*g.shown;l[Os(x)]+=R,u+=R;continue}let S=0,A=1/0,v=-1,E=0;for(let R=g.slotBase;R=0){S++;continue}let U=(k-o[0])*o[3]+(V-o[1])*o[4]+(O-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[Os(B)]+=D,u+=D}if(y){if(S){A=v=x;let R=S*this._slotCost[g.slotBase];l[Os(x)]+=R,u+=R}g.detailLow=A,g.detailHigh=v,g.detailEnd=E}}return this.visibleCost=u,gf(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+=Ch(r,r.first,Math.max(r.last+1,r.first)),e+=Ch(r,r.first,Math.max(r.end,r.first)),s++);return{drawn:e,inView:n,draws:s}}drawnInstances(t){t.updateMatrixWorld();let e=new kn().setFromProjectionMatrix(new Yt().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=O=>{let U=l.get(O);if(!U){let z=a.geometries[O],q=t.view(z.indices),G=z.uvs?t.view(z.uvs):null;U=Lf(Fr(t,z),z.q??null,vf(t,z),q,G),U.drawable=U.indices.length>=3&&U.min.every(Number.isFinite)&&U.max.every(Number.isFinite),l.set(O,U)}return U},h=new Uint8Array(o),d=new Float64Array(o*3),u=new Float32Array(o*3),f=new Uint32Array(o),g=new Float32Array(o),_=new Uint8Array(o),m=new Map,p=this._boxes;for(let O=0;OO-U).map(O=>{let U=m.get(O),z=c(e[U[0]]),q=this._buckets[this._bucketOf[U[0]]].texture!==null,G=[0,1,2].every(st=>(z.max[st]-z.min[st])/Cn<=65535),Z=z.vertices*((G?12:20)+(q?8:0))+z.indices.length*(z.vertices>65535?4:2);return{k:U.length,bytes:Z,members:U,textured:q}}),M=s.mergedCap??bh,x=s.minRepeats??ny;if(w.reduce((O,U)=>O+U.k*U.bytes,0)>M){let O=s.cellExtent==null?Tf(p,f)*iy:this.visibleBox().getSize(new C).length()*s.cellExtent;for(let U of w)U.k{if(S[U]){for(let z of O.leaves)E.push({shape:O,members:Sh(z,g)});return}for(let z of O.members){v[e[z]]++;let q=this._bucketOf[z]*2+(h[z]===ks?1:0),G=A.get(q);G||A.set(q,G=[]),G.push(z)}});let R=[];for(let O of[...A.keys()].sort((U,z)=>U-z))for(let U of Sf(u,f,A.get(O),s.chunkVertices??yf))R.push(Sh(U,g));let L=[...R,...E.map(O=>O.members)].reduce((O,U)=>O+U.length,0);if(L>r)throw new kr(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(Th),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(zr),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(Ah),this._detailBins=new Float64Array(gh),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 k=0;for(let O of R){let U=this._buckets[this._bucketOf[O[0]]];F.textured=U.texture!==null;let z=Pf(O,F);for(let q=0;qO+U,0);let V=new Map;for(let{shape:O,members:U}of E){let z=U[0],q=c(e[z]),G=V.get(O);if(!G){let Z=a.geometries[e[z]].bbox;G=this._shape(q,_[z]===1,O.textured);let st=lt=>Math.max(...lt.map(Math.abs)),nt=Math.max(st(q.min),st(q.max));G.pickExtent=nt,G.pickPadding=Math.max(0,...q.min.map((lt,H)=>Z.min[H]-lt),...q.max.map((lt,H)=>lt-Z.max[H]))+(q.q?ol*(st(q.q.o)+65535*Math.abs(q.q.s)):0),V.set(O,G)}for(let Z=0;ZO+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,ri);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Uf(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),g=0;for(let m=0;mthis._range(_,m,y,d),d.visible=!1,this.root.add(d),_}_chunk(t,e,n,s,r,o){let a=new Rs;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,ri)),a.setIndex(In(s.index,1));let l=Uf(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=il(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]&&!ly(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&&(vh(n,this._viewHeight,this._frameView),this._frameViewAt=o);let a=this._frameView,l=Nf(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,Rf(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]=Cf(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:Eh(new Ts({side:ke}),this.slotUniforms,n),wire:Eh(new Ts({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=gs,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]?ty:this._tint.get(t)??(this._mode==="white"?ey: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!==zr&&(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===zr)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._dirtyCountTh)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(!Df(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 Ch(i,t,e){return e<=t?0:i.cell?(e-t)*i.triangles:(i.starts[e]-i.starts[t])/3}function Nf(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function Uf(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 al=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(hy(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 hy(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 Ph=2048,uy=524288,Lh=[245,158,11],Dh=[235,235,237],dy=` +#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 yy(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 +${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=` #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); -}`,fy=` +}`,Ny=` #include #include #include @@ -4286,7 +4286,7 @@ void main() { c = vec3(0.95, 0.96, 0.98); } gl_FragColor = vec4(c, opacity); -}`,ll=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/Ph);this._stateData=new Uint8Array(Ph*o*4),this._state=new mn(this._stateData,Ph,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 g=t.meta.geometries[f];if(!g||g.kind!=="lines")throw new Qt(`Line instance references a geometry (${f}) that is not lines.`);a.set(f,zs(t,g)),l.set(f,t.view(g.indices))}return{positions:a.get(f),indices:l.get(f)}},h=[],d=[],u=()=>{if(h.length===0)return;let f=new ce;f.setAttribute("position",new xe(new Float32Array(h),3)),f.setAttribute("lineSlot",new xe(new Float32Array(d),1)),f.computeBoundingSphere();let g=new ln(f,this._material);g.frustumCulled=!1,this.root.add(g),h=[],d=[]};for(let f=0;fuy&&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]=Dh[0],this._stateData[l+1]=Dh[1],this._stateData[l+2]=Dh[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 py={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.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.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"}},ai=(globalThis.navigator?.language??"").toLowerCase().startsWith("ru")?"ru":"en",Vr=new Intl.NumberFormat(ai).format;function $(i,t=ai){let e=py[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Ff=new C(0,0,1),cl=Math.PI/2-.01;function Of(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function zf(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(Ff,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Ff);if(h.lengthSq()>1e-12){let d=Math.asin(re.clamp(c.z,-1,1)),u=re.clamp(s*r,d-cl,d+cl);l(new Fe().setFromAxisAngle(h.normalize(),-u))}return{position:o.add(e),target:a.add(e)}}function kf(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var my=.85,gy=100/3;function Hf(i,t,e){let n=i*(t===1?gy:t===2?e:1);return re.clamp(my**(-n/100),.5,2)}var Nh=(i,t)=>t>=i?"window":"crossing";function Vf(i,t,e){let n=Bf(i.position,i.target),s=Bf(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=re.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,m)=>_+(m-_)*e,c=r+a*e,h=re.clamp(l(n.elevation,s.elevation),-cl,cl),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 Gf(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 Yt().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 g=>{f.identity().slerp(l,g);let _=s.clone().applyQuaternion(f),m=i.target.clone().lerp(t.target,g),p=_.clone().multiplyScalar(re.lerp(o,a,g)).add(m),y=e.clone().applyQuaternion(f).applyAxisAngle(_,u*g);return{position:p,target:m,up:y}}}function Bf(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(re.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var _y=.005,Wf=new C(1,-1,.8).normalize(),Uh=.01,Xf=1e-6,xy=64,qf=1.05,vy=5e3,hl=(i,t)=>new CustomEvent(i,{detail:t});function Yf({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 se(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 Dr(r)){if(!e(o))return!0;n.expandByPoint(s.fromArray(o))}return n.getSize(s).length()*qf>Uh*vy}var ul=class extends EventTarget{constructor(t,e,{pick:n=()=>null,visibleBox:s=()=>new se}={}){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 Wn(-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(re.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(Uh,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 se;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 g=Math.max(this.dom.clientWidth/Math.max(this.dom.clientHeight,1),.001),_=Math.max(this.camera.top,1e-6),m=Math.max(h.y/2,h.x/(2*g),1e-4)*1.06;this.camera.zoom=_/m,this.resize();return}let s=Math.max(n.radius,.001),r=re.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(Wf);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(Wf,l*2.5),a),this.fitBox(o,!1)}}}this.dispatchEvent(hl("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(re.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?Gf(o,a,new C(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):u=>Vf(o,a,u),h=performance.now(),d=u=>{let f=Math.min((u-h)/r,1),g=f*f*(3-2*f),_=c(g);this.camera.isOrthographicCamera&&(this.camera.zoom=re.lerp(l,n,g)),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(Xf,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&&Of(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=zf(this.camera.position,this.target,e.pivot,s,r,_y);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(re.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=Nh(e.down.x,n.x);this.dispatchEvent(hl("boxselect",{rect:s,mode:r,ctrl:t.ctrlKey,shift:t.shiftKey}))}else!e.moved&&e.button===0?this.dispatchEvent(hl("click",{x:n.x,y:n.y,button:0,ctrl:t.ctrlKey,shift:t.shiftKey})):!e.moved&&e.button===2&&this.dispatchEvent(hl("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:Nh(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=Hf(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=xy*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:m,width:p,height:y}=this.dom.getBoundingClientRect();if(!p||!y)return;let w=re.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-m)/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(Uh,Math.max(Xf,r)),h=re.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,g=kf(n.position,d,f,h);this._set(g.position,g.target)}};function et(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=et("button",i);return n.type="button",n.innerHTML=t,n.title=e,n.setAttribute("aria-label",e),n}function Hs(i){i.preventDefault(),i.stopPropagation()}function dl(i){Hs(i);let t=i.button===2,e=()=>{window.removeEventListener("pointerup",n,!0),setTimeout(()=>{window.removeEventListener("click",Hs,!0),t&&window.removeEventListener("contextmenu",Hs,!0)})},n=s=>{Hs(s),e()};window.addEventListener("pointerup",n,!0),window.addEventListener("click",Hs,!0),t&&window.addEventListener("contextmenu",Hs,!0)}function Gr(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 Me=i=>``,$f='',oe={model:Me(''),views:Me(''),sections:Me(''),clashes:Me(''),bcf:Me(''),timeliner:Me(''),links:Me(''),orbit:Me(''),pan:Me(''),fit:Me(''),projection:Me($f),mode2d:Me(''),plane:Me(''),box:Me(`${$f}`),resetSections:Me(''),distance:Me(''),displayMode:Me(''),grids:Me(''),opacity:Me(''),fullscreen:Me(''),close:Me(''),chevron:Me(''),flip:Me(''),remove:Me(''),play:Me(''),pause:Me(''),home:Me('')};var Wr=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)},yy={right:Wr,left:Wr,back:Wr,front:Wr,top:un.back,bottom:un.front},Zi=.7,My=re.degToRad(1),Zf=.01,Kf=96,fl=1.75;function Jf(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 by(i){let t=[];return Math.abs(i.z)>=Zi&&t.push(i.z>0?"top":"bottom"),Math.abs(i.y)>=Zi&&t.push(i.y>0?"back":"front"),Math.abs(i.x)>=Zi&&t.push(i.x>0?"right":"left"),t.join("-")}function Fh(i,t=My){let e=i.clone().normalize(),n=Math.cos(t);return Object.keys(un).find(s=>e.dot(un[s])>=n)??null}function jf(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 Bh(i,t){return un[jf(t)].clone().multiplyScalar(Math.sin(Zf)).addScaledVector(un[i],Math.cos(Zf))}function Sy(i,t){let e=Fh(i);if(!e)return null;let n=e==="top"||e==="bottom";if(t==="left"||t==="right")return(n?Bh(e,i):Jf(e)).applyAxisAngle(Wr,t==="right"?Math.PI/2:-Math.PI/2);if(t!=="up"&&t!=="down")throw new RangeError(`Unknown arrow: ${t}`);if(!n)return Bh(t==="up"?"top":"bottom",i);let s=un[jf(i)];return t==="up"==(e==="top")?s.clone().negate():s.clone()}function wy(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 lr(e);return r.colorSpace=me,r}var pl=class{constructor(t,e,n){this.controls=n,this.home={position:e.position.clone(),target:n.target.clone()},this.element=et("div","ioviewer-viewcube"),this.canvas=et("canvas","ioviewer-viewcube-canvas"),this.canvas.title=$("cube.title"),this.canvas.setAttribute("aria-label",$("cube.title")),this.element.append(this.canvas),this.error=null,this.renderer=this._createRenderer(),this.scene=new pn,this.camera=new Wn(-fl,fl,fl,-fl,.1,10),this.faces=new Re;let s=getComputedStyle(t).fontFamily;for(let[l,c]of Object.entries(un)){let h=$(`face.${l}`),d=new ge(new cn(2,2),new Je({map:wy(h,s)})),u=yy[l];d.quaternion.setFromRotationMatrix(new Yt().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 Xn,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?Bh(c,n.camera.position.clone().sub(n.target)):Jf(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=tn("ioviewer-viewcube-arrow",oe.chevron,$(`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,$("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(Kf,Kf),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=Fh(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 Wt((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?by(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?[-Zi,Zi]:a>0?[Zi,1.02]:[-1.02,-Zi],[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=Sy(n,t);if(!s)return;let r=Fh(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 Ey=` +}`,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=` #include #ifdef IO_PICK_POINTS uniform uint pointIndex; @@ -4298,7 +4298,7 @@ attribute float lineSlot; uniform sampler2D lineState; varying float vLine; #else -${Br} +${zr} varying vec2 vSlot; #endif #include @@ -4319,7 +4319,7 @@ void main() { vec3 transformed = position; vLine = float( lSlot ); #else - ${Or} + ${kr} vec3 transformed = slotPosition; #endif #include @@ -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 -}`,Ty=` +}`,Yy=` #include #include #include @@ -4390,32 +4390,36 @@ void main() { uvec4 bytes = ( uvec4( bits ) >> uvec4( 0u, 8u, 16u, 24u ) ) & 255u; gl_FragColor = vec4( bytes ) / 255.0; #endif -}`,Qf=i=>i&&{element:i.element,point:i.point.clone()};function li(i,t,e=null){let n=new Ie({vertexShader:Ey,fragmentShader:Ty,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 ml=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 Qf(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},Qf(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,g=r-n,_=o-n;this._render(this._material,g,_,s,d,u);let m=(v,E)=>{let R=Math.floor(v)-g,L=Math.floor(E)-_;return R>=0&&R=0&&Lthis._slotAt(p,v),w=m(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,g,_,s,d,f);let v=f&&new DataView(f.buffer),E=l.matrixWorldInverse.elements.slice(),R=new C,L=U=>{let z=this._vertexAt(y(U),u,v,U,R);return z?-(E[2]*z.x+E[6]*z.y+E[10]*z.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,k=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(z)&&(this._isLine(z)?F.add(z-this.scene.slotCount-(this.points?.count??0)):k>=0&&!V.has(z)&&this.scene.slotElement(z)===k&&V.add(z))}let O=l.isPerspectiveCamera;S={rect:s,point:N,element:k,slots:V,lineInstances:F,pointSample:B,depthAt(U,z,q){let G=m(U,z),Z=G<0?-1:y(G);if(Z<0)return 1/0;if(Z!==q)return L(G);let st=K=>O?1/L(K):L(K),nt=st(G);function lt(K,ct,Ct){let ft=Math.sign(Ct),Bt=m(U+ft*K,z+ft*ct);if(Bt>=0&&y(Bt)===Z)return(st(Bt)-nt)*Math.abs(Ct);let he=m(U-ft*K,z-ft*ct);return he>=0&&y(he)===Z?(nt-st(he))*Math.abs(Ct):0}let H=nt+lt(1,0,U-Math.floor(U)-.5)+lt(0,1,z-Math.floor(z)-.5);return H>0?O?1/H:H: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 kt),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 gl=33.333333333333336,Ay=200,tp=1e6,Ry=20,_l=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,Ay)))}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>gl*1.1?(this._refine=!1,this._fastFrames=0):this._refine||(this._fastFrames=this.minPixels>0&&t=Ry),this._cost>gl*1.1?this.budget=Math.max(this.budget*.9,tp):this._cost0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),tp))}_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 Pn,Vs,xl,vl=class extends EventTarget{constructor(){super(...arguments);zl(this,Vs);zl(this,Pn,new Set)}get size(){return di(this,Pn).size}has(e){return di(this,Pn).has(e)}values(){return di(this,Pn).values()}set(e){hu(this,Pn,new Set(e)),Qr(this,Vs,xl).call(this)}toggle(e){di(this,Pn).delete(e)||di(this,Pn).add(e),Qr(this,Vs,xl).call(this)}clear(){di(this,Pn).size!==0&&(di(this,Pn).clear(),Qr(this,Vs,xl).call(this))}};Pn=new WeakMap,Vs=new WeakSet,xl=function(){this.dispatchEvent(new Event("change"))};function ep(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 np(i,t,e){let n=new Yt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse).elements,{left:s,top:r,width:o,height:a}=e,l=new se,c=[];for(let h=0;hn===l?r(l):o(l));let m=[...t.children].find(x=>ip.indexOf(x.dataset.panel)>g);t.insertBefore(_,m??null);let p=et("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,$("close"));y.addEventListener("click",()=>r(l));let w=et("header","ioviewer-panel-header");w.append(et("h2","",h),y);let M=et("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 rp=[{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 op(i,t){let e=et("div","ioviewer-toolbar ioviewer-floating");e.setAttribute("role","toolbar");let n=new Map;for(let a of t){let l=et("div","ioviewer-toolbar-group");l.setAttribute("role","group"),l.setAttribute("aria-label",$(`group.${a.id}`));let c=et("div","ioviewer-toolbar-row");for(let h of a.items){let d=tn("ioviewer-tool",oe[h],$(`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,et("div","ioviewer-toolbar-label",$(`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 Cy="input, textarea, select, [contenteditable]";function Oh(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function ap(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(Cy))return null;if(Oh(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 lp(i,t,e,n,s){let r=et("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=et("summary","",$("filters.title")),a=et("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:$("filters.model"),key:c,labels:new Map},{name:$("level"),key:h,labels:new Map},{name:$("category"),key:d,labels:new Map}],[f,g,_]=u,m=et("div","ioviewer-filter-actions"),p=et("button","ioviewer-text-button",$("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=et("button","ioviewer-text-button",$("filters.isolate"));y.type="button",y.addEventListener("click",s),m.append(p,y),r.append(o,a,m);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(!g.labels.has(v)){let R=x.level||(v==null?$("filters.noLevel"):`#${v}`);g.labels.set(v,v!=null&&t.length>1&&A?`${R} \xB7 ${A}`:R)}let E=d(x);_.labels.set(E,E||$("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=et("select");v.append(new Option($("filters.all"),""));for(let[R,[,L]]of A.entries())v.append(new Option(L,String(R+1)));v.addEventListener("change",n);let E=et("label","ioviewer-filter-field");E.append(et("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?`${$("filters.title")} (${A})`:$("filters.title"),p.disabled=!A&&!x,y.disabled=!S}}}var Ci=24,Iy=8;function zh(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 Py(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} +}`,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??""} ${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 cp(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=Ly(t),l=new Int32Array(t.length);a.forEach((G,Z)=>G.indices.forEach(st=>l[st]=Z));let c=new Uint8Array(a.length),h=new Int32Array(a.length),d=new Uint32Array(a.length),u=Py(t),f="",g=!1,_=new Int32Array(0),m=0,p=-1,y=null,w=!1,M=et("input","ioviewer-tree-search");M.type="search",M.placeholder=$("searchPlaceholder"),M.setAttribute("aria-label",$("searchPlaceholder"));let x=et("div","ioviewer-tree");x.setAttribute("role","tree"),x.setAttribute("aria-label",$("panel.model")),x.setAttribute("aria-multiselectable","true"),x.tabIndex=-1;let S=et("div","ioviewer-tree-spacer");S.setAttribute("role","presentation"),x.append(S);let A=et("div","ioviewer-tree-empty",$("noMatches")),v=lp(t,e,M,U,()=>s.isolate(_));i.append(v.element,M,x,A);function E(){let G=_[m],Z=v.predicate();if(g=!!(f||Z),g){let nt=f?u(f):t.keys();if(Z){let lt=[];for(let H of nt)Z(t[H])&<.push(H);_=Int32Array.from(lt)}else _=Int32Array.from(nt)}else{let nt=a.length;a.forEach((H,K)=>c[K]&&(nt+=H.indices.length)),_=new Int32Array(nt);let lt=0;a.forEach((H,K)=>{if(h[K]=lt,_[lt++]=-(K+1),c[K])for(let ct of H.indices)_[lt++]=ct})}let st=_.indexOf(G);m=st>=0?st:0,S.style.height=`${_.length*Ci}px`,A.hidden=_.length>0||!g,v.update(f,!!s.isolate&&g&&_.some(nt=>s.instancesOf(nt).length>0)),R()}function R(G=x.contains(document.activeElement)){let Z=x.clientHeight;if(Z===0||_.length===0){S.replaceChildren();return}let st=x.scrollTop,{start:nt,end:lt}=zh(st,Ci,Z,_.length,Iy);!G&&(m=lt)&&(m=Math.min(_.length-1,Math.floor(st/Ci)));let H=[];m=lt&&H.push(L(m)),S.replaceChildren(...H),G&&S.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function L(G){let Z=_[G],st=Z<0?-Z-1:l[Z],nt=Z<0?d[st]===a[st].indices.length:n.has(Z),lt=et("div","tree-row");if(lt.style.top=`${G*Ci}px`,lt.style.height=`${Ci}px`,lt.dataset.row=G,lt.tabIndex=G===m?0:-1,lt.setAttribute("role","treeitem"),lt.classList.toggle("selected",nt),lt.setAttribute("aria-selected",String(nt)),Z<0){lt.classList.add("tree-category"),lt.setAttribute("aria-level","1"),lt.setAttribute("aria-posinset",String(st+1)),lt.setAttribute("aria-setsize",String(a.length)),lt.setAttribute("aria-expanded",String(!!c[st]));let H=et("span","tree-chevron");H.innerHTML=oe.chevron;let{name:K,indices:ct}=a[st];lt.append(H,et("span","tree-name",K||$("noCategory")),et("span","tree-count",Vr(ct.length)))}else{let H=t[Z];lt.classList.add("tree-element"),lt.setAttribute("aria-level",g?"1":"2"),lt.setAttribute("aria-posinset",String(g?G+1:G-h[st])),lt.setAttribute("aria-setsize",String(g?_.length:a[st].indices.length)),lt.classList.toggle("tree-child",!g),lt.classList.toggle("tree-hidden",s.isVisible?.(Z)===!1),lt.append(et("span","tree-name",H.name||`#${H.id}`),et("span","tree-type",H.type??""))}return lt}function N(G){let Z=x.clientHeight;if(Z===0){p=G;return}let st=G*Ci;stx.scrollTop+Z&&(x.scrollTop=st+Ci-Z)}function B(G){m=G,N(G),R(!0)}function D(G){let Z=l[G];!g&&!c[Z]&&(c[Z]=1,E());let st=_.indexOf(G);st>=0&&(x.contains(document.activeElement)||(m=st),N(st)),R()}function F(G){w=!0;try{n.set(G)}finally{w=!1}}function k(G,Z){let st=_.indexOf(y);st<0&&(st=G,y=_[G]);let nt=_.subarray(Math.min(st,G),Math.max(st,G)+1).filter(lt=>lt>=0);nt.length>0&&F(Z?[...n.values(),...nt]:nt)}function V(G){y=G;let Z=-G-1,st=G<0?a[Z].indices:[G],nt=G<0?d[Z]===st.length:n.has(G),lt=new Set(n.values());for(let H of st)nt?lt.delete(H):lt.add(H);F(lt)}function O(G,Z,st){G>=0&&!n.has(G)&&(y=G,F([G]));let nt=G>=0?G:n.values().next().value??null;o(Z,st,nt,()=>{let lt=_.indexOf(G);lt>=0?B(lt):M.focus()})}M.addEventListener("focus",()=>{S.firstElementChild||q()});function U(){f=M.value.trim(),x.scrollTop=0,p=-1,m=-1,E()}M.addEventListener("input",U),x.addEventListener("scroll",()=>R()),x.addEventListener("focusin",G=>{let Z=G.target.closest(".tree-row");!Z||Z.tabIndex===0||(S.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),m=Number(Z.dataset.row),Z.tabIndex=0)}),x.addEventListener("keydown",G=>{let Z=G.target.closest(".tree-row");if(!Z||G.ctrlKey||G.altKey||G.metaKey)return;let st=Number(Z.dataset.row),nt=_[st];if(Oh(G)){if(G.preventDefault(),!G.repeat){let{left:H,bottom:K}=Z.getBoundingClientRect();O(nt,H,K)}return}if(G.key===" "){G.preventDefault(),G.repeat||(G.shiftKey?k(st,!1):V(nt));return}if(G.shiftKey)return;let lt=st;switch(G.key){case"ArrowUp":lt=Math.max(0,st-1);break;case"ArrowDown":lt=Math.min(_.length-1,st+1);break;case"Home":lt=0;break;case"End":lt=_.length-1;break;case"ArrowRight":nt<0&&(c[-nt-1]?lt=st+1:(c[-nt-1]=1,E()));break;case"ArrowLeft":nt>=0&&!g?lt=h[l[nt]]:nt<0&&c[-nt-1]&&(c[-nt-1]=0,E());break;case"Enter":G.repeat||z(nt);break;default:return}G.preventDefault(),lt!==st&&B(lt)});function z(G){if(G>=0){y=G,F([G]),r(G);return}c[-G-1]^=1,E()}x.addEventListener("click",G=>{let Z=G.target.closest(".tree-row");if(!Z)return;let st=Number(Z.dataset.row),nt=G.ctrlKey||G.metaKey;G.shiftKey?k(st,nt):nt?V(_[st]):z(_[st])}),x.addEventListener("contextmenu",G=>{let Z=G.target.closest(".tree-row");Z&&(G.preventDefault(),O(_[Number(Z.dataset.row)],G.clientX,G.clientY))});function q(){p>=0&&x.clientHeight>0&&(N(p),p=-1),R()}new ResizeObserver(q).observe(x),n.addEventListener("change",()=>{let G=-1;d.fill(0);for(let Z of n.values())d[l[Z]]++,G=Z;if(w){R();return}y=null,G>=0?D(G):R()}),s.root?.addEventListener("change",G=>G.detail.kind==="visibility"&&R()),E()}var hp={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},Dy={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},yl=4;function up(i){let t=et("div","ioviewer-context-menu");t.setAttribute("role","menu"),t.setAttribute("aria-label",$("contextMenu")),t.hidden=!0,i.append(t);let e=new Map(Object.values(hp).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(),dl(c))}function a(c,h,d,u,f=null){let g=hp[c];if(!g)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let p of g){if(p==="-"){let M=et("div","ioviewer-menu-separator");M.setAttribute("role","separator"),t.append(M);continue}let y=e.get(p),w=et("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=$("menu.unavailable")),w.append(et("span","",$(`menu.${p}`)),et("kbd","",Dy[p]??"")),w.addEventListener("click",()=>{y.enabled&&(s(),y.handler(u))}),t.append(w)}t.hidden=!1;let{width:_,height:m}=t.getBoundingClientRect();t.style.left=`${Math.max(yl,Math.min(h,innerWidth-_-yl))}px`,t.style.top=`${Math.max(yl,Math.min(d,innerHeight-m-yl))}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 Ny=1600;function dp(i,t,e){let n=()=>i.textContent=`${$("selected")}: ${Vr(t.size)} \xB7 ${$("elements")}: ${Vr(e)}`;t.addEventListener("change",n),n()}function fp(i,t){if(!t)return;let e=et("div","ioviewer-banner ioviewer-floating");e.setAttribute("role","status");let n=$("truncated").replace("{meshes}",t.meshes).replace("{total}",t.totalMeshes),s=tn("ioviewer-panel-close",oe.close,$("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(et("span","",n),s),i.append(e),r.observe(e)}function Gs(i,t){let e=et("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),Ny)}function pp(i,t){let e=et("table");for(let[s,r]of t)e.insertRow().append(et("th","",s),et("td","",String(r??"")));let n=et("section");return n.append(et("h3","",i),e),n}function mp(i,t,e){let n=et("h2","ioviewer-properties-title"),s=et("button","ioviewer-properties-close","\xD7");s.type="button",s.title=$("close"),s.setAttribute("aria-label",$("close")),s.addEventListener("click",()=>t.clear());let r=et("header");r.append(n,s);let o=et("div","ioviewer-properties-body");i.replaceChildren(r,o),i.hidden=!0;let a=h=>{let d=[[$("id"),h.id],[$("category"),h.category],[$("type"),h.type],[$("level"),h.level]];return h.sourceId&&d.push([$("sourceId"),h.sourceId]),h.link&&d.push([$("link"),h.link]),pp($("elementGroup"),d)},l=h=>{for(let[d,u]of Object.entries(h??{}))o.append(pp(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=`${$("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(et("p","",$("badData")))}).finally(()=>{c===u&&o.removeAttribute("aria-busy")})})}async function Uy(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 gp({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=sp(i);h.registerPanel("model",{icon:oe.model,title:$("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:w=>cp(w,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:m,zoomToElement:M=>n.zoomToBox(e.elementBox(M))})});let d=document.createElement("aside");d.id="ioviewer-properties",d.className="ioviewer-floating",i.append(d),mp(d,r,t);let u=op(i,rp),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 g=()=>{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),g()}),g(),document.fullscreenEnabled&&(u.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{u.setActive("fullscreen",!!document.fullscreenElement),Gs(i,$("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>u.setActive("fullscreen",!!document.fullscreenElement)));let _=up(i);function m(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;m(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=>Uy(String(a.elements[w].id)).then(M=>Gs(i,$(M?"idCopied":"copyFailed")),()=>Gs(i,$("copyFailed")))}),n.addEventListener("contextmenu",async w=>{let{x:M,y:x}=w.detail;if(o?.active)return m(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 m(M,x,null);r.has(A.element)||r.set([A.element]),m(M,x,A.element)}});let y=[];return window.addEventListener("keydown",w=>{if(w.defaultPrevented)return;let M=ap(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]?.()}}),dp(document.getElementById("ioviewer-status"),r,e.elementCount),fp(i,a.truncated),{shell:h,toolbar:u,contextMenu:_,sync2DState:g,onEscape:w=>y.push(w)}}var kh={x:new C(1,0,0),y:new C(0,1,0),z:new C(0,0,1)};function Hh(i){let t=kh[i];if(!t)throw new RangeError(`Unknown axis: ${i}`);return t.clone()}function Ml(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 _p(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 xp(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(kh.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 vp(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(kh.z,t).sub(a))}return o}function yp(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 Mp(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=yp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function bl(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 Xr(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 Sl(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 yp(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 qr=6,Fy=["off","planes","box"],By=.05,Vh=new C(0,0,1),wl=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(Vh,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 se(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(!Fy.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=Hh(t);if(this.planes.length>=qr||this.modelBox.isEmpty())return null;let n=new Fe().setFromUnitVectors(Vh,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(Hh(o.axis))>1e-6),this._changed(!0)}setActivePlane(t){this._plane(t),this.active=t,this._changed(!1)}normal(t){return Vh.clone().applyQuaternion(this._plane(t).quaternion)}extent(t){return bl(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 _p(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=bp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=bp(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 se;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(By*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=xp(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 se(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)||Mp(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 bp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:re.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Gh=80,Oy=8,qh=.8,zy=Math.sin(re.degToRad(12)),Ii={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Wh=["x","y","z"],ky=Math.cos(re.degToRad(12)),El=new C(0,0,1),Hy=i=>new Je({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),Vy=new Je({visible:!1});function Tl(i,t,e,n){let s=new Re,r=Hy(t);for(let a of e)s.add(new ge(a,r));let o=new ge(n,Vy);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 Xh(i,t,e=n=>n){let n=Tl("rotate",Ii[t],[e(new Es(qh,.018,8,64))],e(new Es(qh,.09,8,48)));return n.name=i,n.userData.axis=t,n}var Al=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 Xn,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)*Gh),this.arrow.visible=this._across(El.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)*Oy)}let n=this.boxRing;n.visible&&n.scale.setScalar(this._worldPerPixel(n.position)*Gh)}_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:qr},()=>{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=Tl("move",Ii.z,[t(new ki(.025,.025,1),.5),t(new hr(.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,Xh("ringX","x",n=>n.rotateY(Math.PI/2)),Xh("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 Gn(1,16,12),e=new Gn(1.6,8,6);this.boxHandles=[];for(let s of Wh)for(let r of[-1,1]){let o=Tl("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=Tl("centre",Ii.centre,[new gn(1.4,1.4,1.4)],e);n.name="centre",this.boxHandles.push(n),this.boxRing=Xh("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=Sl(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(Wh.indexOf(l),c).applyAxisAngle(El,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(re.degToRad(e.fov/2))/n}_ray(t){let e=this.dom.getBoundingClientRect(),n=new Wt((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),g=r.normal(u),_=Xr(e,f,g);return _===null?null:{index:u,origin:f,normal:g,offset:r.planes[u].offset,s0:_}}if(o==="rotate"){let u=r.active,f=t===this.boxRing,g=f?t.position.clone():r.origin(u),_=f?null:r.planes[u].quaternion.clone(),m=f?El:new C().setComponent(Wh.indexOf(t.userData.axis),1).applyQuaternion(_),p={index:u,origin:g,quaternion:_,axis:m,yaw:f?r.boxYaw:null};if(Math.abs(m.dot(e.direction))0&&r===0}function qy(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{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;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 +`)+`\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;h -${Br} +${zr} #include uniform highp sampler2D closedSlots; void main() { - ${Or} + ${kr} vec3 transformed = slotPosition; #include #include - ${wh} + ${Ah} if ( texelFetch( closedSlots, st, 0 ).r < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); }`,fragmentShader:` #include 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 Rl=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:Wy,side:ke,forceSinglePass:!0,stencilWrite:!0,stencilFunc:kc,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(Gy,f.normal);let m=Sl(s.modelBox,this._surface.quaternion,f.coplanarPoint(new C));this._surface.position.copy(m.center),this._surface.scale.set(m.width,m.height,1),h.clippingPlanes=l.filter((p,y)=>y!==g),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=d}}};function Yr(i,t,e){let n=et("div","ioviewer-segmented");n.setAttribute("role","group"),n.setAttribute("aria-label",i);let s=t.map(([o,a])=>{let l=et("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 Yh(i,t){let e=et("label","ioviewer-check"),n=et("input");return n.type="checkbox",n.addEventListener("change",()=>t(n.checked)),e.append(n,et("span","",i)),{element:e,input:n}}function Yy(i,t){let e=et("li","ioviewer-section-plane");e.addEventListener("pointerdown",()=>i.active!==t&&i.setActivePlane(t));let n=et("span","ioviewer-section-name"),s=tn("ioviewer-icon-button",oe.flip,$("sections.flip"));s.addEventListener("click",()=>i.updatePlane(t,{flipped:!i.planes[t].flipped}));let r=Yh($("sections.enabled"),h=>i.updatePlane(t,{enabled:h})),o=tn("ioviewer-icon-button",oe.remove,$("sections.delete"));o.addEventListener("click",()=>i.removePlane(t));let a=et("input","ioviewer-section-slider");a.type="range",a.step="any",a.setAttribute("aria-label",$("sections.position")),a.addEventListener("input",()=>i.updatePlane(t,{offset:Number(a.value)}));let l=et("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?` (${$("sections.rotated")})`:"",u=h.axis==="custom"?$("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 wp({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"),Gs(i,$("sections.maxPlanes")))},h=()=>[...r.values()],d=()=>s.fitBoxToElements(h()),u=Yr($("sections.mode"),[["planes",$("sections.planes")],["box",$("sections.box")],["off",$("sections.off")]],F=>s.setMode(F)),f=Yr($("sections.axis"),["x","y","z"].map(F=>[F,F.toUpperCase()]),F=>f.update(l=F));f.update(l);let g=et("button","ioviewer-text-button",$("sections.addPlane"));g.type="button",g.addEventListener("click",c);let _=et("ul","ioviewer-section-list"),m=et("div","ioviewer-section-empty",$("sections.noPlanes")),p=et("div","ioviewer-section-block"),y=et("div","ioviewer-section-row");y.append(et("span","",$("sections.axis")),f.element,g),p.append(y,_,m);let w=Yr($("sections.box"),[["keepInside",$("sections.keepInside")],["cutInside",$("sections.cutInside")]],F=>s.setBoxMode(F)),M=et("button","ioviewer-text-button",$("sections.fitSelection"));M.type="button",M.addEventListener("click",d);let x=et("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=et("span");S.setAttribute("aria-hidden","true");let A=et("label","ioviewer-section-row");A.append(et("span","",$("sections.boxYaw")),x,S);let v=et("div","ioviewer-section-block");v.append(w.element,A,M);let E=Yh($("sections.showGizmo"),F=>s.setGizmoVisible(F)),R=Yh($("sections.fill"),F=>s.setFill(F));o||(R.element.title=$(a?"sections.fillUnavailable":"sections.fillNeedsMeshes"));let L=[],N=()=>{u.update(s.mode),p.hidden=s.mode!=="planes",v.hidden=s.mode!=="box",g.disabled=s.planes.length>=qr,L.length!==s.planes.length&&(L=s.planes.map((k,V)=>Yy(s,V)),_.replaceChildren(...L.map(k=>k.element))),L.forEach(k=>k.update()),m.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(k=>k.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:$("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 $y="#facc15",Zy=9;function $h(i,t=ai){return`${new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}).format(i)} ${$("unit.m",t)}`}var Cl=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 ce;e.setAttribute("position",new xe(new Float32Array(6),3));let n={color:$y,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Oi(e,new sn(n)),this._markers=new wn(e,new Hn({...n,size:Zy,sizeAttenuation:!1}));for(let s of[this._line,this._markers])s.frustumCulled=!1,s.renderOrder=1001,this.group.add(s);this.label=et("div","ioviewer-measure-label"),this.label.hidden=!0,this._previewMarker=et("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 se().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&&Gr(this._previewMarker,this.preview.point,t,e),this.distance!==null&&Gr(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=$h(this.distance)),this.dispatchEvent(new Event("change"))}};var $r=8,Ky=1-1e-6,Jy=8,Ep={vertex:0,midpoint:1,edge:2},jy=2e4;function Qy(i,t){let e=new Map,n=new Uint32Array(i.length/3);for(let d=0;d0&&(_.normalize(),l(u,f,_),l(f,g,_),l(g,u,_))}let c=[],h=new Set;for(let{lo:d,hi:u,count:f,crease:g}of s.values())f!==1&&!g||(c.push(d,u),h.add(d),h.add(u));return{edges:c,vertices:h}}function Il(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 Tp(i,t,e,n,s,r){let o=[0,1];if(!Il(o,e.w+e.z,n.w+n.z)||!Il(o,e.w-e.z,n.w-n.z))return[];if(!r||!s.length)return s.every(c=>Il(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)&&Il(a,-h,-d)}))return[o];let l=[];return o[0]0))return null;let m=re.clamp(((r-c)*f+(o-h)*g)/_,0,1);return e+(n-e)*(m*a.w/((1-m)*l.w+m*a.w))}var Pl=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=zs({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;cJy&&this.cache.delete(this.cache.keys().next().value),e}target(t,e){let n=this.picker.measureTile(t,e,$r+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 Yt().multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),u=a.matrixWorldInverse.elements,f=null;function g(x,S,A,v){if(f&&Ep[x]>Ep[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[E,R]=Ws(A,s);if(!(E>=0&&R>=0&&E$r**2||f?.kind===x&&L>=f.distance||x!=="edge"&&Ml(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 _=jy*3,m=new Yt,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});m.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 k=new C().fromArray(R,F*3).applyMatrix4(m),V=new ve(k.x,k.y,k.z,1).applyMatrix4(d);D.set(F,[k,V]),g("vertex",k,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});m.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 k of N){let V=new C().fromArray(L,k*3).applyMatrix4(m),O=new ve(V.x,V.y,V.z,1).applyMatrix4(d);if(F.set(k,[V,O]),O.w>0&&O.z>=-O.w&&O.z<=O.w){let[U,z]=Ws(O,s),q=(U-r)**2+(z-o)**2;q<=$r**2&&(!f||f.kind!=="vertex"||q0&&G.z>=-G.w&&G.z<=G.w){let[Z,st]=Ws(G,s),nt=(Z-r)**2+(st-o)**2;nt<=$r**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)Gr(n,s,t,e)}};var tM=8,Rp=4;function Zh(i,t,e,n="dialog"){let s=et("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(),dl(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(Rp,Math.min(l.left+l.width/2-c/2,innerWidth-c-Rp))}px`,s.style.bottom=`${innerHeight-l.top+tM}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 Cp({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=Zh(i,c,$("group.display"));h.element.classList.add("ioviewer-display-modes");let d=et("div");d.setAttribute("role","menu"),d.setAttribute("aria-label",$("tool.displayMode")),h.element.append(d);let u=(n.textures??[]).length>0,f=Ih.map(L=>{let N=et("button","ioviewer-menu-item",$(`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",()=>{g(L),h.close(),c.focus()}),d.append(N),N}),g=L=>{e.setDisplayMode(L);for(let N of f)N.setAttribute("aria-checked",String(N.dataset.mode===L))},_=eM(n.options);g(_==="wireframe"&&!a?"materials":_),t.setHandler("displayMode",()=>{h.toggle(),h.isOpen&&d.querySelector('[aria-checked="true"]')?.focus()});let m=et("div","ioviewer-background-setting"),p=et("label","",$("display.background")),y=et("input");Object.assign(y,{type:"color",value:r}),p.append(y);let w=et("button","ioviewer-text-button",$("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=et("div","ioviewer-bg-presets");for(let[L,N]of[["#14171c","display.bgCadDark"],["#ffffff","display.bgPaper"]]){let B=et("button","ioviewer-text-button",$(N));B.type="button",B.addEventListener("click",()=>{y.value=L,M()}),x.append(B)}m.append(p,x,w),h.element.append(m),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let S=Zh(i,l("opacity"),$("tool.opacity"));S.element.classList.add("ioviewer-opacity");let A=et("input","ioviewer-opacity-slider");Object.assign(A,{type:"range",min:"10",max:"100",step:"1",value:"100"}),A.setAttribute("aria-label",$("opacity.label"));let v=et("output","ioviewer-opacity-value"),E=()=>v.textContent=$("opacity.value").replace("{value}",A.value);A.addEventListener("input",()=>{e.setOpacity(Number(A.value)/100),E()}),E();let R=et("div","ioviewer-opacity-head");return R.append(et("span","",$("opacity.label")),v),S.element.append(R,A),t.setHandler("opacity",S.toggle),[h,S]}var nM=3e3;function Dl(i,t){let e=et("button",i);return e.type="button",e.setAttribute("title",t),e.append(et("span","ioviewer-row-name",t)),e}function Ip({shell:i,toolbar:t,controls:e,scene:n,sections:s,selection:r,restoreLinkedModels:o,views:a,bcfTopics:l}){let c=null,h=et("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,nM)};c.frame=requestAnimationFrame(w)}let f=w=>h.contains(w.target),g=w=>!f(w)&&m(),_=w=>{f(w)&&(w.key==="Enter"||w.key===" ")||(w.key==="Escape"&&(w.preventDefault(),w.stopPropagation()),m())};function m(){c&&(cancelAnimationFrame(c.frame),clearTimeout(c.timer),c=null,window.removeEventListener("pointerdown",g,!0),window.removeEventListener("wheel",m,!0),window.removeEventListener("keydown",_,!0),y())}function p(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",g,!0),window.addEventListener("wheel",m,!0),window.addEventListener("keydown",_,!0),y(),u()}function y(){let w=$(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?oe.pause:oe.play),h.append(et("span","",w)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?m():p()),y(),i.registerPanel("views",{icon:oe.views,title:$("panel.views"),visible:a.length>0,render:w=>{let M=et("div","ioviewer-row-list");for(let x of a){let S=Dl("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:$("panel.bcf"),visible:l.length>0,render:w=>{let M=et("div","ioviewer-row-list");for(let x of l){let S=et("details","ioviewer-bcf-topic");S.append(et("summary","",x.title)),x.status&&S.append(et("p","ioviewer-bcf-status",x.status)),x.description&&S.append(et("p","ioviewer-bcf-description",x.description)),x.viewpoints.length||S.append(et("p","ioviewer-bcf-status",$("bcf.noView"))),x.viewpoints.forEach((A,v)=>{let E=$("bcf.viewpoint").replace("{index}",String(v+1)),R=Dl("ioviewer-row ioviewer-view",E);if(R.addEventListener("click",()=>d(A)),S.append(R),A.missingComponents||A.ambiguousComponents){let L=$("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));S.append(et("p","ioviewer-bcf-status",L))}}),M.append(S)}w.append(M)}})}function Pp(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):iM(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function iM(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 sM=["New","Active","Reviewed","Approved","Resolved"],Kh=27,rM=8,oM=14,aM=2,lM=new C(1,-1,.8).normalize();function Lp({shell:i,tests:t,elements:e,scene:n,controls:s,selection:r}){let o=new Re;o.name="clash-marker";let a=new ce;a.setAttribute("position",new xe(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new wn(a,new Hn({...l,size:oM,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=Pp(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(lM);let v=Math.max(3*S,aM);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 se(x.clone(),x.clone()))}function g(y){let w=Dl("ioviewer-row ioviewer-clash",String(y.name??""));w.setAttribute("title",`${y.name??""}: ${y.element1Name??""} \u2014 ${y.element2Name??""}`);let M=sM.includes(y.status),x=et("span","ioviewer-clash-status",M?$(`clash.${y.status}`):String(y.status??""));M&&(x.dataset.status=y.status);let S=typeof y.distance=="number"?$h(y.distance):"";return w.append(x,et("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=et("div","ioviewer-clash-test"),x=et("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(et("span","ioviewer-row-name",S));let A=et("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,y.clashes.length*Kh-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 m({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=g(w[v]),E.style.top=`${v*Kh}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?zh(x-v.offsetTop,Kh,S,E.length,rM):{start:0,end:0});w.forEach((v,E)=>m(v,A[E]))}y.addEventListener("scroll",M),y.addEventListener("focusin",M),new ResizeObserver(M).observe(y)}return i.registerPanel("clashes",{icon:oe.clashes,title:$("panel.clashes"),visible:t.length>0,render:p,onClose:()=>o.visible&&u()}),{group:o}}var cM=["construct","demolish","temporary"],hM=Date.parse("0002-01-01T00:00:00Z");function Dp(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=hM?t:NaN}function Np(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=Dp(o?.start),l=Dp(o?.end);if(!(a<=l))continue;let c=cM.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 Up(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,dM=["1","5","15"],fM={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function Fp({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=Np(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:oe.timeliner,title:$("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,g=new Map,_=et("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",$("player.title")),_.hidden=!0;let m=tn("ioviewer-icon-button ioviewer-player-play",oe.play,$("player.play"));m.addEventListener("click",()=>h?N():L());let p=et("output","ioviewer-player-date"),y=et("input","ioviewer-player-slider");Object.assign(y,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),y.setAttribute("aria-label",$("player.date")),y.addEventListener("input",()=>A(Number(y.value)));let w=Yr($("player.speed"),dM.map(D=>[D,`${D}\xD7`]),D=>{c=Number(D),w.update(D)});w.update(String(c));let M=tn("ioviewer-panel-close",oe.close,$("close"));M.addEventListener("click",E),_.append(m,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=Up(r.tasks,l),F=[...f].filter(U=>!D.hidden.has(U)),k=[...D.hidden].filter(U=>!f.has(U));f=D.hidden;let V=[...g.keys()].filter(U=>D.active.get(U)!==g.get(U)),O=new Map;for(let[U,z]of D.active)g.get(U)!==z&&(O.has(z)||O.set(z,[]),O.get(z).push(U));g=D.active,F.length&&s.setLayerHidden("schedule",F,!1),k.length&&s.setLayerHidden("schedule",k,!0),V.length&&s.setTint(V,null);for(let[U,z]of O)s.setTint(z,fM[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([...g.keys()],null),g=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=$(h?"player.pause":"player.play");m.innerHTML=h?oe.pause:oe.play,m.title=D,m.setAttribute("aria-label",D)}return t.registerPanel("timeliner",{icon:oe.timeliner,title:$("panel.timeliner"),render:D=>{let F=et("button","ioviewer-text-button ioviewer-player-open");F.type="button",F.insertAdjacentHTML("afterbegin",oe.play),F.append(et("span","",$("player.play"))),F.addEventListener("click",L);let k=et("div","ioviewer-row-list");for(let V of r.tasks){let O=String(V.name??""),U=et("div","ioviewer-row ioviewer-task");U.dataset.type=V.type,U.setAttribute("title",`${O} \xB7 ${$(`task.${V.type}`)}`);let z=`${o.format(V.start)} \u2013 ${o.format(V.end)}`;U.append(et("span","ioviewer-row-name",O),et("span","ioviewer-task-dates",z)),k.append(U)}D.append(F,k)}}),{open:v,close:E,play:L,pause:N,setDate:A,get date(){return l},get isOpen(){return u}}}function Bp({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:et("input")})),r=()=>n.replaceLayerHidden("links",s.flatMap(({input:o,members:a})=>o.checked?[]:a));return i.registerPanel("links",{icon:oe.links,title:$("panel.links"),visible:s.length>0,render:o=>{let a=et("div","ioviewer-row-list");for(let l of s){let c=String(l.file.name??""),h=et("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,et("span","ioviewer-row-name",c),et("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 Op(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 zp(i,t){return!i||t>=i.min&&t<=i.max}function kp(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 Hp(){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: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(` `),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 Vn(1,1)}),r=new Wt,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 Wt},range:{value:new Wt}},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 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(` `),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 g of h){if(!g.geometry.getAttribute("intensity"))continue;let _=new wn(g.geometry,n);_.matrixAutoUpdate=!1,_.matrix.copy(g.matrixWorld),i.add(_)}t.position.copy(d);let u=new se().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 pM=new Intl.NumberFormat(ai,{maximumFractionDigits:2,minimumFractionDigits:2}),Nl=i=>`${pM.format(i)} ${$("scanMap.metres")}`;function Kn(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 mM(i,t){return[i*.005,t*.005]}function gM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function _M(i,t,e,n,s,r,o){let a=new Xn;a.setFromCamera(new Wt(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 Vp(i,t,e,n,s,r){if(!e.count)return;let o=new se().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)),g=(P,ut,wt=!1)=>{let I=d(ut.x),b=u(ut.y);return P.style.left=`${wt?f(I):I}%`,P.style.top=`${wt?f(b):b}%`,I>=0&&I<=100&&b>=0&&b<=100},_=t.meta.rtcOffset?.[2]??0,m=t.meta.panoramas??[],p=m.map(P=>new C(...P.position)),y=`ioviewer.scan-levels.v1:${location.pathname}`,w=()=>Op(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(ut=>Number.isFinite(ut?.min)&&Number.isFinite(ut.max)&&ut.max>ut.min))}catch{M=null}let x=M??w(),S=-1,A=!0,v=P=>zp(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=$("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",$("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 k=e.root.children.reduce((P,ut)=>P+ut.geometry.attributes.position.count,0),V=Math.max(1,Math.ceil(k/6e4)),O=e.root.children.map(P=>{let ut=P.geometry.attributes.position,wt=new Float32Array(Math.ceil(ut.count/V)*3),I=new C;for(let b=0,Y=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 O.entries())if(e.root.children[I].visible)for(let Y=0;Y{U||(U=requestAnimationFrame(z))},G=new C,Z=null,st=()=>{if(Z){B.hidden=!v(Z.position.z),g(B,Z.position,!0),B.style.rotate=`${Math.PI/2-Z.yaw}rad`;return}B.hidden=!1,g(B,s.camera.position,!0),s.camera.getWorldDirection(G),B.style.rotate=`${Math.atan2(G.x,G.y)}rad`};E.addEventListener("toggle",q),n.root.addEventListener("change",P=>{P.detail.kind==="visibility"&&q()}),s.addEventListener("change",st);let nt=document.createElement("div");nt.className="scan-map-controls";let lt=document.createElement("select");lt.setAttribute("aria-label",$("scanMap.size"));for(let P of["small","medium","large"])lt.add(new Option($(`scanMap.${P}`),P));lt.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=lt.value,lt.addEventListener("change",()=>{i.dataset.scanMapSize=lt.value});let H=(P,ut=0,wt=0)=>{h=kp(h,P,ut,wt),q()},K=()=>{h={...c},q()};nt.append(lt,Kn($("scanMap.zoomOut"),"\u2212",()=>H(.8)),Kn($("scanMap.zoomIn"),"+",()=>H(1.25)),Kn($("scanMap.reset"),"\u21BA",K)),E.insertBefore(nt,L),N.addEventListener("wheel",P=>{P.preventDefault();let ut=N.getBoundingClientRect();H(P.deltaY<0?1.15:1/1.15,(P.clientX-ut.left)/ut.width-.5,(P.clientY-ut.top)/ut.height-.5)},{passive:!1});let ct;N.addEventListener("pointerdown",P=>{P.button!==0||ct||(N.setPointerCapture(P.pointerId),ct={id:P.pointerId,x:P.clientX,y:P.clientY})}),N.addEventListener("pointermove",P=>{if(ct?.id!==P.pointerId)return;let ut=h.side/(h.zoom*Math.max(1,N.clientWidth));h.x-=(P.clientX-ct.x)*ut,h.y+=(P.clientY-ct.y)*ut,ct.x=P.clientX,ct.y=P.clientY,q()}),N.addEventListener("lostpointercapture",P=>{P.pointerId===ct?.id&&(ct=void 0)}),N.addEventListener("keydown",P=>{let ut={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[P.key];if(ut){let wt=h.side/h.zoom/10;h.x+=ut[0]*wt,h.y+=ut[1]*wt,q()}else if(P.key==="+"||P.key==="="||P.key==="-")H(P.key==="-"?.8:1.25);else if(P.key==="0")K();else return;P.preventDefault(),P.stopPropagation()});let Ct=document.createElement("div");Ct.className="scan-map-controls";let ft=document.createElement("select");ft.setAttribute("aria-label",$("scanMap.levels"));let Bt=document.createElement("p");Bt.className="scan-map-feedback",Bt.setAttribute("role","status");function he(){try{localStorage.setItem(y,JSON.stringify(x))}catch{Bt.textContent=$("scanMap.levelTemporary")}}function Gt(){ft.replaceChildren(new Option($("scanMap.allLevels"),"-1")),x.forEach((P,ut)=>ft.add(new Option(`${$("scanMap.level").replace("{n}",ut+1)} \xB7 ${Nl(P.min)} \u2013 ${Nl(P.max)}`,String(ut)))),ft.value=String(S),pt.disabled=S<0;for(let[P,ut]of p.entries())qt.options[P+1].hidden=!v(ut.z);q(),r()}ft.addEventListener("change",()=>{S=Number(ft.value),Bt.textContent="",Gt()});let Zt=Kn($("scanMap.addLevel"),"+",()=>{if(Ot.isClosed()){let P=p.findIndex(ut=>v(ut.z));Lt(Math.max(0,P))}Ot.pickLevel()});Zt.disabled=!m.length;let ee=Kn($("scanMap.autoLevels"),$("scanMap.autoButton"),()=>{let P=w(),ut=P.filter(wt=>!x.some(I=>I.min{S<0||(x.splice(S,1),S=-1,Bt.textContent="",he(),Gt())});if(Ct.append(ft,Zt,ee,pt),m.length){let P=Kn($("scanMap.spheres"),"\u25C9",()=>{A=!A,P.setAttribute("aria-pressed",String(A)),r()});P.setAttribute("aria-pressed","true"),Ct.append(P)}E.append(Ct,Bt);let Ot=m.length?xM(i,t,e,Lt,P=>{Z=P,P||dt.forEach(ut=>ut.classList.remove("current")),st()},P=>{S=x.push(P)-1,Bt.textContent=$("scanMap.levelAdded"),he(),Gt()}):null,qt=document.createElement("select");qt.setAttribute("aria-label",$("scanMap.choosePhoto"));let ae=new Option($("scanMap.choosePhoto"),"");ae.disabled=!0,qt.add(ae);let dt=[];for(let[P,ut]of m.entries()){let wt=ut.name||t.meta.elements[ut.element].name||String(P+1);qt.add(new Option(wt,String(P)));let I=document.createElement("button");I.type="button",I.className="scan-map-station",I.title=wt,I.setAttribute("aria-label",`${$("scanMap.photo")} \xB7 ${wt}`),I.addEventListener("click",()=>Lt(P)),dt.push(I),L.append(I)}qt.value="",qt.addEventListener("change",()=>Lt(Number(qt.value))),qt.hidden=!m.length,E.append(qt),Gt(),!M&&x.length&&he();function Lt(P,ut=!1){E.open=!0,qt.value=String(P),dt.forEach((wt,I)=>wt.classList.toggle("current",P===I)),Ot.open(P,ut),qt.value=""}return{open:Lt,showSphere:(P,ut)=>A&&v(ut)&&n.isVisible(P)}}function xM(i,t,e,n,s,r){let o=document.createElement("section");o.className="ioviewer-floating scan-photo",o.setAttribute("aria-label",$("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=Kn($("scanMap.enlargePhoto"),$("scanMap.enlargePhoto"),()=>{let dt=o.classList.toggle("is-expanded"),Lt=$(dt?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Lt,h.setAttribute("aria-label",Lt),h.setAttribute("aria-pressed",String(dt))});h.setAttribute("aria-pressed","false");let d=document.createElement("button");d.type="button",d.textContent=$("close"),d.addEventListener("click",Gt);let u=!1,f=Kn($("scanMap.intensity"),$("scanMap.intensity"),()=>{u=!u,ae(!1)});f.className="scan-photo-intensity",f.hidden=!0,c.append(f,h,d),a.append(l,c);let g=document.createElement("canvas");g.tabIndex=0,g.setAttribute("aria-label",$("scanMap.photoControls"));let _=document.createElement("p");_.setAttribute("role","status");let m=document.createElement("div");m.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,Kn($("scanMap.cancel"),$("scanMap.cancel"),ee)),m.append(g,p,_),o.append(a,y,m),i.append(o);let M=t.meta.panoramas.map((dt,Lt)=>{let P=dt.name||t.meta.elements[dt.element].name||String(Lt+1),ut=document.createElement("button");return ut.className="scan-photo-link",ut.type="button",ut.title=P,ut.setAttribute("aria-label",$("scanMap.goToStation").replace("{name}",P)),ut.hidden=!0,ut.addEventListener("click",()=>n(Lt,!0)),m.append(ut),{photo:dt,name:P,button:ut,position:new C(...dt.position)}}),x=t.readView(t.meta.points.element),S=new Xn;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,k,V,O=0,U=!1,z=!1,q=0,G=0,Z=null,st,nt,lt=new pn,H=new Ue(72,1,.1,20);H.up.set(0,0,1);let K=new Gn(10,56,28);K.rotateX(Math.PI/2);let ct=new Je({side:ze}),Ct=new ge(K,ct);lt.add(Ct);let ft=()=>{if(!(o.hidden||!k&&!z)){F.setSize(g.clientWidth,g.clientHeight,!1),H.aspect=g.clientWidth/Math.max(1,g.clientHeight),H.updateProjectionMatrix(),H.lookAt(gM(A,q,G)),z?V.draw(F,H,A):F.render(lt,H),H.getWorldDirection(A);for(let dt of R){if(N){dt.button.hidden=!0;continue}E.copy(dt.position).sub(st.position).normalize(),v.copy(E).project(H);let Lt=E.dot(A)>0&&Math.abs(v.x)<.92&&Math.abs(v.y)<.88;dt.button.hidden=!Lt,Lt&&(dt.button.style.left=`${(1+v.x)*50}%`,dt.button.style.top=`${(1-v.y)*50}%`)}s({position:st.position,yaw:q})}},Bt=(dt,Lt)=>{q+=dt,G=re.clamp(G+Lt,-1.55,1.55),ft()};new ResizeObserver(ft).observe(g),g.addEventListener("pointerdown",dt=>{dt.button!==0||Z||(g.setPointerCapture(dt.pointerId),Z={id:dt.pointerId,x:dt.clientX,y:dt.clientY,moved:!1})}),g.addEventListener("pointermove",dt=>{Z?.id===dt.pointerId&&(N&&!Z.moved&&Math.hypot(dt.clientX-Z.x,dt.clientY-Z.y)<5||(Z.moved=!0,Bt(...mM(dt.clientX-Z.x,dt.clientY-Z.y)),Z.x=dt.clientX,Z.y=dt.clientY))}),g.addEventListener("pointerup",dt=>{if(Z?.id!==dt.pointerId||Z.moved||!N)return;let Lt=g.getBoundingClientRect();Ot((dt.clientX-Lt.left)*2/Lt.width-1,1-(dt.clientY-Lt.top)*2/Lt.height)}),g.addEventListener("lostpointercapture",dt=>{Z?.id===dt.pointerId&&(Z=null)}),g.addEventListener("keydown",dt=>{if(N&&dt.key==="Enter"){dt.preventDefault(),Ot(0,0);return}let Lt={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[dt.key];Lt&&(dt.preventDefault(),dt.stopPropagation(),Bt(...Lt))}),g.addEventListener("wheel",dt=>{dt.preventDefault(),H.fov=re.clamp(H.fov+Math.sign(dt.deltaY)*5,32,95),ft()},{passive:!1}),o.addEventListener("keydown",dt=>{dt.key==="Escape"&&(N?ee():Gt()),dt.stopPropagation()});function Gt(){o.hidden=!0,ee(),O++,Z=null,Zt(),s(null),nt?.focus()}function Zt(){z=!1,k?.dispose(),k=void 0,ct.map=null;for(let dt of R)dt.button.hidden=!0;R=[]}function ee(){N=!1,B=void 0,o.classList.remove("is-picking"),y.hidden=!0,ft()}function pt(){N=!0,B=void 0,o.classList.add("is-picking"),w.textContent=$("scanMap.pickLower"),y.hidden=!1,ft(),(k||z)&&g.focus()}function Ot(dt,Lt){if(!k&&!z)return;let P=_M(H,st.position,L,dt,Lt,g.clientWidth,g.clientHeight);if(P===void 0){w.textContent=$(B===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let ut=P+D;B===void 0?(B=ut,w.textContent=$("scanMap.pickUpper").replace("{z}",Nl(ut))):ut<=B?w.textContent=$("scanMap.upperAboveLower").replace("{z}",Nl(B)):(r({min:B,max:ut}),ee())}function qt(dt,Lt){let P=o.hidden;if(P&&(nt=document.activeElement),Zt(),st=M[dt],o.hidden=!1,l.textContent=st.name,Ct.rotation.z=re.degToRad(st.photo.yaw),L=e.root.children.filter((ut,wt)=>x[wt]===st.photo.element),U=L.some(ut=>ut.geometry.getAttribute("intensity")),f.hidden=!U&&!st.photo.intensity,R=M.filter(ut=>{if(ut===st)return!1;let wt=E.copy(ut.position).sub(st.position).length();return wt<=.25?!1:(S.set(st.position,E.multiplyScalar(1/wt)),S.far=wt-.25,!S.intersectObjects(L,!1).length)}),P||!Lt){let ut=R.reduce((wt,I)=>!wt||I.position.distanceToSquared(st.position){Lt===O&&(_.textContent=$("scanMap.photoError"))},wt;try{if(F??(F=new Ti({canvas:g,antialias:!0})),F.setPixelRatio(Math.min(devicePixelRatio,2)),P&&U){V??(V=Hp()),V.setScan(L,st.position),z=!0,_.textContent="",g.style.visibility="visible",ft(),dt&&g.focus();return}let I=P?st.photo.intensity:st.photo.image;wt=URL.createObjectURL(new Blob([t.readView(I)],{type:"image/jpeg"}))}catch{ut();return}new fr().load(wt,I=>{if(URL.revokeObjectURL(wt),Lt!==O||I.image.width!==2*I.image.height){I.dispose(),ut();return}k?.dispose(),k=I,k.colorSpace=me,ct.map=k,ct.needsUpdate=!0,_.textContent="",g.style.visibility="visible",ft(),dt&&g.focus()},void 0,()=>{URL.revokeObjectURL(wt),ut()})}return{open:qt,pickLevel:pt,isClosed:()=>o.hidden}}var Xs=7;function Gp(i){if(!i?.length)return null;let t=i.map(({position:l})=>new C(...l)),e=new ur({color:"#72bfff",depthTest:!1,depthWrite:!1}),n=new xi(new Gn(1,12,8),e,i.length);n.count=0,n.frustumCulled=!1,n.renderOrder=10,n.instanceMatrix.setUsage(Cr);let s=[],r=new Yt,o=new C,a=new Wt;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 g=(o.x+1)*c.width/2,_=(1-o.y)*c.height/2;if(g<-Xs||g>c.width+Xs||_<-Xs||_>c.height+Xs)continue;let m=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,p=Xs*m/c.height;n.setMatrixAt(n.count++,r.makeScale(p,p,p).setPosition(u)),s.push({index:d,depth:f,x:g+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 bM(i,t){let e=i.width/i.height*Jh,n=MM(i.text,e,t),s=re.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/Jh*i.height);let l=n.length*Xp*i.height,c=-a*r/2,h=l*o/2,d=new se,u=new C,f=Math.cos(i.rotation),g=Math.sin(i.rotation);for(let _ of[c,c+a])for(let m of[h-l,h])u.set(i.position[0]+_*f-m*g,i.position[1]+_*g+m*f,i.position[2]),d.expandByPoint(u);return{lines:n,box:d,hAlign:r,vAlign:o}}var Ul=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=`${Jh}px ${Wp}`),this.layouts=this._ctx?this.annotations.map(n=>bM(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 Yt().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(re.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 ${Wp}`,a.fillStyle=`rgb(${R},${L},${N})`,a.textAlign=vM[_],a.textBaseline=yM[m];let B=w*Xp,D=-(g.length-1)*B*m/2;for(let F=0;F{}};let l=new Set(a.flatMap(_=>_.elements)),c=et("div","ioviewer-sheets ioviewer-floating");c.setAttribute("role","tablist"),c.setAttribute("aria-label",$("sheets.label"));let h=new zi(new ce,new sn({color:"#94a3b8",transparent:!0,opacity:.55}));h.visible=!1,t.add(h);let d=null,u=new Map;function f(_,m=!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,!m);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 m=et("button","ioviewer-sheet-tab",_.name);m.type="button",m.setAttribute("role","tab"),m.dataset.sheet=_.key,m.addEventListener("click",()=>f(_.key,!1)),u.set(_.key,m),c.append(m)}a.length>1&&i.append(c);let g=e.options?.initialSheet??a[0].key;return f(g,!0),{get active(){return d},setSheet:_=>f(_,!1)}}document.documentElement.lang=ai;var Ln=document.getElementById("ioviewer-canvas"),jh=window.IOVIEWER_TEST??{},Zr=jh.startup;function Kr(i){let t=document.getElementById("ioviewer-message");t.textContent=i,t.hidden=!1}try{let i=mh(document,Zr);i.title&&(document.title=i.title);let t=Ln.getContext("webgl2",{antialias:!0,stencil:!0});t?SM(df(document,Zr,i),t):Kr($("noWebGL"))}catch(i){if(!(i instanceof Qt))throw i;Kr($("badData"))}function SM(i,t){let e=new Ti({canvas:Ln,context:t,antialias:!0,stencil:!0,logarithmicDepthBuffer:Yf(i.meta)});e.setPixelRatio(window.devicePixelRatio),e.autoClearStencil=!1,e.localClippingEnabled=!0;let n=new pn,s=i.meta.options?.initialBackground||"#1f2228",r=new kt(s);e.setClearColor(r,1);let o=new mr("#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 gr("#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 Ul(h,i),u=d.layouts;Zr?.("sceneStart");let f=L(),g=new al(i),_=new ll(i);Zr?.("sceneEnd"),i.releaseBinary(),!c&&f.totalCost===0&&g.count===0&&_.count===0&&!u.length&&Kr($("noGeometry"));let m=new _l(f,V,Math.min(f.totalCost,2e7));n.add(f.root),n.add(g.root),n.add(_.root);let p=g.count?Gp(i.meta.panoramas):null;p&&n.add(p.mesh);let y=()=>f.visibleBox(),w=new wl(f,y(),i.meta.sections);g.syncVisibility(f),g.syncAppearance(f),_.syncVisibility(f),_.syncAppearance(f);let M=()=>{let{planes:pt,intersection:Ot}=w.clipping();g.setClipping(pt,Ot),_.setClipping(pt,Ot)};M();let x=f.slotCount>0,S=x&&t.getContextAttributes()?.stencil===!0,A,v=new Al(w,Ln);n.add(v.group);let E=new Cl(h),R=new Ll(h,i.meta.grids??[]);n.add(E.group,R.group);function L(){try{return new Hr(i,{...jh,maxTextureSize:e.capabilities.maxTextureSize,annotationLayouts:u})}catch(pt){if(!(pt instanceof kr))throw pt;c=!0,Kr($("tooLarge").replace("{count}",pt.count).replace("{limit}",pt.limit));let Ot=ae=>({o:0,n:0,t:ae}),qt={count:0,geometry:Ot("u32"),material:Ot("u32"),element:Ot("i32"),matrix:Ot("f32")};return new Hr({...i,meta:{...i.meta,instances:qt}},{annotationLayouts:u})}}let N=!1;Ln.addEventListener("webglcontextlost",()=>{N=!0,Kr($("contextLost"))});let B,D=new Promise(pt=>B=pt),F=Zr,k=!1;function V(){k||N||(k=!0,m.requested(performance.now()),requestAnimationFrame(()=>{if(k=!1,N)return;let pt=Ln.getBoundingClientRect();nt.camera.updateMatrixWorld(),Zt&&p?.update(nt.camera,pt,Zt.showSphere),v.update(nt.camera),E.update(nt.camera,pt),R.update(nt.camera,pt),d.update(nt.camera,pt,f),m.begin(nt.camera,pt.height,performance.now()),F?.("renderStart"),w.fill&&S?(A??(A=new Rl(f,w,i)),A.render(e,n,nt.camera)):e.render(n,nt.camera),F&&(F("renderEnd"),F=void 0),m.end(performance.now()),lt.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 O=new ml(e,f,a,{points:g,lines:_,pickFloat:jh.pickFloat}),U=new Pl(O,w,i),z=0,q=null;function G(){cancelAnimationFrame(z),z=0,q=null,E.setPreview(null)}function Z(){z=0,q&&E.setPreview(U.target(...q))}function st(){q&&(E.setPreview(null),cancelAnimationFrame(z),z=requestAnimationFrame(()=>{z=requestAnimationFrame(Z)}))}Ln.addEventListener("pointermove",pt=>{if(!E.active||pt.buttons)return G();q=[pt.clientX,pt.clientY],z||(z=requestAnimationFrame(Z))});for(let pt of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Ln.addEventListener(pt,G);f.root.addEventListener("change",pt=>{pt.detail.kind!=="appearance"&&st()});let nt=new ul(a,Ln,{pick:(pt,Ot)=>O.pick(pt,Ot)?.point??null,visibleBox:y});nt.addEventListener("change",()=>{O.camera=nt.camera,st(),V()}),f.root.addEventListener("change",pt=>{pt.detail.kind==="appearance"&&(g.syncAppearance(f),_.syncAppearance(f)),(pt.detail.kind==="appearance"||pt.detail.kind==="visibility")&&d.update(nt.camera,Ln.getBoundingClientRect(),f),pt.detail.kind==="visibility"&&(g.syncVisibility(f),_.syncVisibility(f),nt.invalidateBounds(),nt.resize())});let lt,H=new vl;H.addEventListener("change",()=>f.setHighlighted([...H.values()]));let K=gp({root:h,data:i,scene:f,controls:nt,picker:O,selection:H,measure:E});nt.addEventListener("mode2d",()=>{K.sync2DState(),lt?.set2D(nt.is2D)}),wp({root:h,...K,sections:w,selection:H,canFill:S,hasMeshes:x});let{meta:ct}=i,Ct=Bp({...K,files:ct.linkedFiles??[],elements:ct.elements,scene:f});Ip({...K,controls:nt,scene:f,sections:w,selection:H,restoreLinkedModels:Ct,views:ct.viewpoints??[],bcfTopics:ct.bcfTopics??[]});let ft=Lp({...K,tests:ct.clashTests??[],elements:ct.elements,scene:f,controls:nt,selection:H});n.add(ft.group);let Bt=Fp({root:h,...K,timeliner:ct.timeliner,elements:ct.elements,scene:f}),he=pt=>{e.setClearColor(r.set(pt),1);let{r:Ot,g:qt,b:ae}=r,Lt=.2126*Ot+.7152*qt+.0722*ae>Math.sqrt(.0525)-.05,P=Lt?"#000":"#fff";h.style.setProperty("--viewport-text",pt===s?"":P),_.setLightBackground(Lt),d.setLightBackground(Lt),V()};{let{r:pt,g:Ot,b:qt}=r,ae=.2126*pt+.7152*Ot+.0722*qt>Math.sqrt(.0525)-.05;_.setLightBackground(ae),d.setLightBackground(ae),ae&&h.style.setProperty("--viewport-text","#000")}for(let pt of Cp({root:h,toolbar:K.toolbar,scene:f,meta:ct,grids:R,initialBackground:s,setBackground:he,hasMeshes:x}))K.onEscape(pt.close);K.toolbar.setHandler("distance",()=>{G(),E.setActive(!E.active),E.active||U.release(),K.toolbar.setActive("distance",E.active)}),K.toolbar.setActive("distance",!1),K.onEscape(()=>(G(),E.clear()));let Gt=()=>{nt.setExtraBounds("grids",R.visible?R.box:null),nt.setExtraBounds("measure",E.box)};R.addEventListener("change",Gt),E.addEventListener("change",Gt),Gt(),nt.addEventListener("click",pt=>{let{x:Ot,y:qt,ctrl:ae,shift:dt}=pt.detail;if(E.active){let wt=U.target(Ot,qt);wt&&E.add(wt.point);return}let Lt=!ae&&!dt?p?.pick(Ot,qt):void 0;if(Lt!==void 0){Zt.open(Lt);return}let ut=O.pick(Ot,qt)?.element??-1;ae?ut>=0&&H.toggle(ut):ut>=0?H.set([ut]):dt||H.clear()}),nt.addEventListener("boxselect",pt=>{if(E.active)return;let{rect:Ot,mode:qt,ctrl:ae,shift:dt}=pt.detail;if(Ot.width<4||Ot.height<4){!ae&&!dt&&H.clear();return}let Lt=new se,P=ep(Ot,qt,np(f,nt.camera,Ln.getBoundingClientRect())),ut=w.clipping(),wt=P.filter(I=>!w.isCut(f.elementBox(I,Lt),ut));H.set(ae?[...H.values(),...wt]:wt)}),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 Zt=Vp(h,i,g,f,nt,V);lt=new pl(document.getElementById("ioviewer-ui"),a,nt);let ee=qp({root:h,world:n,meta:ct,scene:f,apply2DMode:(pt,Ot,qt)=>{nt.set2DMode(pt,Ot,qt),pt||nt.fitBox(Ot,qt),K.sync2DState(),lt.set2D(nt.is2D)},setBackground:he,requestRender:V});!ct.sheets?.length&&ct.options?.initial2DMode&&(nt.set2DMode(!0,y(),!1),K.sync2DState(),lt.set2D(!0)),window.addEventListener("pointerdown",pt=>{(pt.target===Ln||lt.element.contains(pt.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:f,points:g,lines:_,annotationsOverlay:d,sheetsBar:ee,motionDetail:m,controls:nt,picker:O,selection:H,ui:K,viewCube:lt,sections:w,sectionGizmo:v,measure:E,measureSnap:U,grids:R,clashes:ft,timeliner:Bt,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 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}}}})(); /*! 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 b5496ca..0410af1 100644 --- a/src/IOViewer/Viewer/src/i18n.js +++ b/src/IOViewer/Viewer/src/i18n.js @@ -55,6 +55,32 @@ const dictionaries = { link: 'Связанный файл', panels: 'Панели', 'panel.model': 'Модель', + 'panel.elements': 'Таблица элементов', + 'csv.open': 'Открыть CSV элементов', + 'csv.download': 'Скачать CSV', + 'csv.choose': 'Выберите CSV, экспортированный вместе с этой моделью.', + 'csv.loading': 'Чтение CSV…', + 'csv.loaded': '{file} · Связано с 3D: {matched} из {total}', + 'csv.noMatch': '{file} · Нет совпадений. Проверьте, что CSV относится к этой модели.', + 'csv.invalid': 'Не удалось прочитать CSV. Выберите таблицу элементов RvtIO с уникальным elementId.', + 'csv.noGeometry': 'У этого элемента нет геометрии в модели.', + 'csv.search': 'Поиск по ID и имени', + 'csv.searchPlaceholder': 'ID или имя', + 'csv.allCategories': 'Все категории', + 'csv.groupByCategory': 'Группировать по категориям', + 'csv.categoryTotals': 'Итоги категории', + 'csv.totals': 'Итоги выборки', + 'csv.quantity.length_m': 'Длина', + 'csv.quantity.area_m2': 'Площадь', + 'csv.quantity.volume_m3': 'Объём', + 'csv.unit.length_m': 'м', + 'csv.unit.area_m2': 'м²', + 'csv.unit.volume_m3': 'м³', + 'csv.outsideFilters': 'Выбранный элемент вне фильтра.', + 'csv.noResults': 'Подходящих строк нет.', + 'csv.previous': 'Назад', + 'csv.next': 'Далее', + 'csv.range': '{first}–{last} из {total}', 'panel.views': 'Виды', 'panel.sections': 'Сечения', 'panel.clashes': 'Коллизии', @@ -224,6 +250,32 @@ const dictionaries = { 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…', + 'csv.loaded': '{file} · Linked to 3D: {matched} of {total}', + 'csv.noMatch': '{file} · 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²', + 'csv.unit.volume_m3': 'm³', + 'csv.outsideFilters': 'The selected element is outside the filter.', + 'csv.noResults': 'No matching rows.', + 'csv.previous': 'Previous', + 'csv.next': 'Next', + 'csv.range': '{first}–{last} of {total}', 'panel.views': 'Views', 'panel.sections': 'Sections', 'panel.clashes': 'Clashes', diff --git a/src/IOViewer/Viewer/src/model/elementCsv.js b/src/IOViewer/Viewer/src/model/elementCsv.js new file mode 100644 index 0000000..7d64486 --- /dev/null +++ b/src/IOViewer/Viewer/src/model/elementCsv.js @@ -0,0 +1,195 @@ +export const QUANTITY_COLUMNS = ['length_m', 'area_m2', 'volume_m3']; +const NUMERIC_COLUMNS = new Set(['elementId', 'categoryId', 'typeId', ...QUANTITY_COLUMNS]); +const DECIMAL = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/; +const textOrder = new Intl.Collator(undefined, { sensitivity: 'base' }); +const TOTAL_ROW_ID = 'TOTAL'; +const SUBTOTAL_ROW_ID = 'SUBTOTAL'; +const ELEMENT_COUNT_COLUMN = 'element_count'; + +// RFC 4180-style fields, including escaped quotes and line breaks inside a field. +function readRows(text) { + const rows = []; + let row = []; + let field = ''; + let quoted = false; + let closed = false; + for (let i = 0; i < text.length; i++) { + const ch = text[i]; + if (quoted) { + if (ch !== '"') field += ch; + else if (text[i + 1] === '"') { + field += '"'; + i++; + } else { + quoted = false; + closed = true; + } + } else if (ch === ',' || ch === '\r' || ch === '\n') { + row.push(field); + field = ''; + closed = false; + if (ch === ',') continue; + if (ch === '\r' && text[i + 1] === '\n') i++; + rows.push(row); + row = []; + } else if (ch === '"' && !field && !closed) { + quoted = true; + } else { + if (closed || ch === '"') throw new Error('Invalid CSV quoting'); + field += ch; + } + } + if (quoted) throw new Error('Unclosed CSV field'); + if (row.length || field || closed) rows.push([...row, field]); + return rows; +} + +export function parseElementCsv(text) { + const [columns, ...records] = readRows(text.replace(/^\uFEFF/, '')); + const idColumn = columns?.indexOf('elementId') ?? -1; + if (idColumn < 0 || new Set(columns).size !== columns.length) throw new Error('Missing or duplicate CSV columns'); + const footer = records[records.length - 1]; + const hasFooter = footer?.[idColumn] === TOTAL_ROW_ID && footer.length === columns.length && columns.includes(ELEMENT_COUNT_COLUMN); + // These rows summarize an earlier export. Re-import the elements and recalculate their totals. + const hasCategories = columns.includes('category'); + const rows = hasFooter ? records.filter((row, index) => + index !== records.length - 1 && !(hasCategories && row[idColumn] === SUBTOTAL_ROW_ID && row.length === columns.length)) : records; + const rowById = new Map(); + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + const id = row[idColumn]; + const number = Number(id); + if (row.length !== columns.length || !Number.isSafeInteger(number) || String(number) !== id || rowById.has(id)) { + throw new Error('Invalid or duplicate CSV element id'); + } + rowById.set(id, i); + } + return { columns, rows, idColumn, rowById }; +} + +export function filterElementRows(csv, search, category) { + const query = search.trim().toLowerCase(); + if (!query && category === null) return csv; + + const nameColumn = csv.columns.indexOf('name'); + const categoryColumn = csv.columns.indexOf('category'); + const rows = []; + const rowById = new Map(); + for (const row of csv.rows) { + const id = row[csv.idColumn]; + if (category !== null && row[categoryColumn] !== category) continue; + if (query && !id.includes(query) && !row[nameColumn]?.toLowerCase().includes(query)) continue; + rowById.set(id, rows.length); + rows.push(row); + } + return { rows, rowById }; +} + +export function sortElementRows(csv, results, column, ascending) { + return indexRows(csv, sortRows(results.rows, column, csv.columns[column], ascending)); +} + +function sortRows(rows, column, name, ascending) { + const numeric = NUMERIC_COLUMNS.has(name); + const keyed = rows.map((row) => { + const text = row[column].trim(); + const key = numeric ? decimalNumber(text) : text; + return { row, key, missing: numeric ? !Number.isFinite(key) : !text }; + }); + keyed.sort((a, b) => { + if (a.missing || b.missing) return Number(a.missing) - Number(b.missing); + const comparison = numeric ? a.key - b.key : textOrder.compare(a.key, b.key); + return ascending ? comparison : -comparison; + }); + return keyed.map(({ row }) => row); +} + +function indexRows(csv, rows) { + const rowById = new Map(); + rows.forEach((row, index) => rowById.set(row[csv.idColumn], index)); + return { rows, rowById }; +} + +export function groupElementRows(csv, results, sortColumn = -1, ascending = true) { + const categoryColumn = csv.columns.indexOf('category'); + if (categoryColumn < 0) return results; + const byCategory = new Map(); + for (const row of results.rows) { + const category = row[categoryColumn]; + if (!byCategory.has(category)) byCategory.set(category, []); + byCategory.get(category).push(row); + } + + const groups = [...byCategory].sort(([a], [b]) => { + if (!a || !b) return Number(!a) - Number(!b); + const order = textOrder.compare(a, b); + return sortColumn === categoryColumn && !ascending ? -order : order; + }).map(([category, rows]) => { + const totals = sumElementQuantities(csv, rows); + if (sortColumn >= 0 && sortColumn !== categoryColumn) rows = sortRows(rows, sortColumn, csv.columns[sortColumn], ascending); + return { category, rows, totals }; + }); + let offset = 0; + for (const group of groups) { + group.start = offset; + offset += group.rows.length; + } + return { ...indexRows(csv, groups.flatMap((group) => group.rows)), groups }; +} + +export function sumElementQuantities(csv, rows) { + return QUANTITY_COLUMNS.map((name) => { + const column = csv.columns.indexOf(name); + if (column < 0) return null; + let sum = 0; + let hasValue = false; + for (const row of rows) { + const value = decimalNumber(row[column].trim()); + if (!Number.isFinite(value)) continue; + sum += value; + hasValue = true; + } + return hasValue && Number.isFinite(sum) ? sum : null; + }); +} + +function decimalNumber(text) { + return DECIMAL.test(text) ? Number(text) : NaN; +} + +export function formatElementCsv(columns, rows, quantityTotals = null, groups = null) { + const appendCount = quantityTotals !== null && !columns.includes(ELEMENT_COUNT_COLUMN); + const headings = appendCount ? [...columns, ELEMENT_COUNT_COLUMN] : columns; + const lines = [headings.map(encodeField).join(',')]; + const appendRows = (elements) => { + for (const row of elements) lines.push(row.map(encodeField).join(',') + (appendCount ? ',' : '')); + }; + const appendTotal = (id, count, sums, category = '') => { + const row = headings.map((name) => { + if (name === 'elementId') return id; + if (name === ELEMENT_COUNT_COLUMN) return String(count); + if (name === 'category') return category; + const sum = sums[QUANTITY_COLUMNS.indexOf(name)]; + return sum == null ? '' : String(sum); + }); + lines.push(row.map(encodeField).join(',')); + }; + if (groups) { + for (const group of groups) { + appendRows(group.rows); + appendTotal(SUBTOTAL_ROW_ID, group.rows.length, group.totals, group.category); + } + } else { + appendRows(rows); + } + if (quantityTotals !== null) appendTotal(TOTAL_ROW_ID, rows.length, quantityTotals); + return '\uFEFF' + lines.join('\r\n') + '\r\n'; +} + +function encodeField(value) { + const trimmed = value.trimStart(); + // Plain signed numbers include Revit IDs and measurements. Other formula-like fields are written as text. + const signedNumber = /^[+-]/.test(trimmed) && DECIMAL.test(trimmed.trimEnd()); + if (/^[\t\r\n]/.test(value) || (!signedNumber && /^[=+@-]/.test(trimmed))) value = "'" + value; + return /[",\r\n]/.test(value) ? '"' + value.replace(/"/g, '""') + '"' : value; +} diff --git a/src/IOViewer/Viewer/src/ui/app.js b/src/IOViewer/Viewer/src/ui/app.js index 10e4427..b72d861 100644 --- a/src/IOViewer/Viewer/src/ui/app.js +++ b/src/IOViewer/Viewer/src/ui/app.js @@ -7,6 +7,7 @@ import { createContextMenu } from './contextMenu.js'; import { hotkeyAction } from './hotkeys.js'; import { mountStatusBar, mountTruncationBanner, showToast } from './statusBar.js'; import { mountProperties } from './properties.js'; +import { mountElementTable } from './elementTable.js'; // Copies text; the async clipboard API is missing or refused on some file:// pages, so it falls back to execCommand. async function copyText(text) { @@ -63,6 +64,13 @@ export function mountUI({ root, data, scene, controls, picker, selection, measur zoomToElement: (i) => controls.zoomToBox(scene.elementBox(i)), }), }); + if (meta.elementCsv) { + shell.registerPanel('elements', { + icon: icons.elements, + title: t('panel.elements'), + render: (body) => mountElementTable(body, meta.elements, selection), + }); + } const properties = document.createElement('aside'); properties.id = 'ioviewer-properties'; properties.className = 'ioviewer-floating'; diff --git a/src/IOViewer/Viewer/src/ui/elementTable.js b/src/IOViewer/Viewer/src/ui/elementTable.js new file mode 100644 index 0000000..30fae5a --- /dev/null +++ b/src/IOViewer/Viewer/src/ui/elementTable.js @@ -0,0 +1,303 @@ +import { formatCount, lang, t } from '../i18n.js'; +import { filterElementRows, formatElementCsv, groupElementRows, parseElementCsv, QUANTITY_COLUMNS, sortElementRows, sumElementQuantities } from '../model/elementCsv.js'; +import { el } from './dom.js'; + +const PAGE_SIZE = 100; +const FIRST_COLUMNS = ['elementId', 'name', 'category', ...QUANTITY_COLUMNS]; +const formatQuantity = new Intl.NumberFormat(lang, { maximumSignificantDigits: 6 }).format; +const message = (key, values) => t(key).replace(/\{(\w+)\}/g, (_, name) => values[name]); + +function createTotals(label) { + const element = el('dl', 'ioviewer-csv-totals'); + element.setAttribute('aria-label', label); + const values = ['elements', ...QUANTITY_COLUMNS.map((name) => `csv.quantity.${name}`)].map((key) => { + const value = el('dd'); + const item = el('div'); + item.append(el('dt', '', t(key)), value); + element.append(item); + return value; + }); + return { + element, + update(count, sums) { + values[0].textContent = formatCount(count); + sums.forEach((sum, i) => { + values[i + 1].textContent = sum === null ? '—' : `${formatQuantity(sum)} ${t(`csv.unit.${QUANTITY_COLUMNS[i]}`)}`; + }); + }, + }; +} + +export function mountElementTable(body, elements, selection) { + const elementById = new Map(); + elements.forEach((element, index) => { + if (element.sourceId != null) elementById.set(element.sourceId, index); + }); + + const input = el('input'); + input.type = 'file'; + input.accept = '.csv,text/csv'; + input.hidden = true; + input.setAttribute('aria-label', t('csv.open')); + const actions = el('div', 'ioviewer-csv-actions'); + const open = el('button', 'ioviewer-text-button', t('csv.open')); + const download = el('button', 'ioviewer-text-button', t('csv.download')); + open.type = download.type = 'button'; + download.disabled = true; + open.addEventListener('click', () => input.click()); + actions.append(open, download); + const status = el('p', 'ioviewer-csv-status', t('csv.choose')); + status.setAttribute('role', 'status'); + const filters = el('div', 'ioviewer-csv-filters'); + const search = el('input'); + search.type = 'search'; + search.placeholder = t('csv.searchPlaceholder'); + search.setAttribute('aria-label', t('csv.search')); + const category = el('select'); + category.setAttribute('aria-label', t('category')); + const groupToggle = el('label', 'ioviewer-csv-group-toggle'); + const groupByCategory = el('input'); + groupByCategory.type = 'checkbox'; + groupToggle.append(groupByCategory, el('span', '', t('csv.groupByCategory'))); + filters.append(search, category, groupToggle); + const totals = createTotals(t('csv.totals')); + totals.element.setAttribute('aria-live', 'polite'); + totals.element.setAttribute('aria-atomic', 'true'); + const outside = el('p', 'ioviewer-csv-feedback', t('csv.outsideFilters')); + outside.setAttribute('aria-live', 'polite'); + const empty = el('p', 'ioviewer-csv-feedback', t('csv.noResults')); + const scroller = el('div', 'ioviewer-csv-scroll'); + const table = el('table'); + table.setAttribute('aria-label', t('panel.elements')); + const header = table.createTHead(); + const pinnedRows = table.createTBody(); + scroller.append(table); + const pagination = el('div', 'ioviewer-csv-pagination'); + const previous = el('button', 'ioviewer-text-button', t('csv.previous')); + const next = el('button', 'ioviewer-text-button', t('csv.next')); + previous.type = next.type = 'button'; + const range = el('span'); + pagination.append(previous, range, next); + filters.hidden = totals.element.hidden = outside.hidden = empty.hidden = scroller.hidden = pagination.hidden = true; + body.append(actions, input, status, filters, totals.element, outside, scroller, empty, pagination); + + let csv; + let downloadName; + let results; + let quantityTotals; + let columnOrder; + let sortColumn = -1; + let ascending = true; + let page = 0; + let loadRequest = 0; + let visibleRows = new Map(); + let pageBodies = []; + let pinned; + + function markSelection() { + const linkedRows = pinned ? [...visibleRows.values(), pinned] : visibleRows.values(); + for (const { index, row, button } of linkedRows) { + const selected = String(selection.has(index)); + row.dataset.selected = selected; + button.setAttribute('aria-pressed', selected); + } + } + + function addRow(group, values) { + const id = values[csv.idColumn]; + const index = elementById.get(id); + const row = group.insertRow(); + let button; + for (const column of columnOrder) { + const cell = row.insertCell(); + if (column === csv.idColumn && index !== undefined) { + button = el('button', 'ioviewer-csv-element', id); + button.type = 'button'; + cell.append(button); + } else { + cell.textContent = values[column]; + cell.title = values[column]; + } + } + if (index === undefined) row.title = t('csv.noGeometry'); + else { + row.dataset.linked = 'true'; + row.addEventListener('click', () => selection.set([index])); + } + return { id, index, row, button }; + } + + function renderPage() { + for (const tbody of pageBodies) tbody.remove(); + pageBodies = []; + visibleRows = new Map(); + const start = page * PAGE_SIZE; + const end = Math.min(start + PAGE_SIZE, results.rows.length); + function addPageRows(tbody, first, last) { + for (let i = first; i < last; i++) { + const item = addRow(tbody, results.rows[i]); + if (item.button) visibleRows.set(item.index, item); + } + } + if (results.groups) { + for (const group of results.groups) { + const first = Math.max(start, group.start); + const last = Math.min(end, group.start + group.rows.length); + if (first >= last) continue; + const tbody = table.createTBody(); + pageBodies.push(tbody); + const heading = el('th', 'ioviewer-csv-group-heading'); + heading.scope = 'rowgroup'; + heading.colSpan = columnOrder.length; + const summary = el('div', 'ioviewer-csv-group-summary'); + const subtotal = createTotals(t('csv.categoryTotals')); + subtotal.update(group.rows.length, group.totals); + summary.append(el('strong', '', group.category || t('noCategory')), subtotal.element); + heading.append(summary); + tbody.insertRow().append(heading); + addPageRows(tbody, first, last); + } + } else { + const tbody = table.createTBody(); + pageBodies.push(tbody); + addPageRows(tbody, start, end); + } + markSelection(); + empty.hidden = results.rows.length !== 0; + pagination.hidden = results.rows.length <= PAGE_SIZE; + range.textContent = message('csv.range', { first: start + 1, last: end, total: results.rows.length }); + previous.disabled = page === 0; + next.disabled = end === results.rows.length; + } + + function syncSelection() { + if (!csv) return; + let selectedRow; + let outsideId; + for (const index of selection.values()) { + const id = elements[index]?.sourceId; + if (!csv.rowById.has(id)) continue; + const position = results.rowById.get(id); + if (position === undefined) { + outsideId = id; + break; + } + const selectedPage = Math.floor(position / PAGE_SIZE); + if (selectedPage !== page) { + page = selectedPage; + renderPage(); + } + selectedRow = visibleRows.get(index)?.row; + break; + } + if (outsideId !== pinned?.id) { + pinnedRows.replaceChildren(); + pinned = outsideId === undefined ? undefined : addRow(pinnedRows, csv.rows[csv.rowById.get(outsideId)]); + } + outside.hidden = !pinned; + scroller.hidden = !pinned && results.rows.length === 0; + markSelection(); + (pinned?.row ?? selectedRow)?.scrollIntoView({ block: 'nearest', inline: 'nearest' }); + } + + function applyFilters() { + results = filterElementRows(csv, search.value, category.selectedIndex > 0 ? category.value : null); + quantityTotals = sumElementQuantities(csv, results.rows); + totals.update(results.rows.length, quantityTotals); + totals.element.hidden = false; + if (groupByCategory.checked) results = groupElementRows(csv, results, sortColumn, ascending); + else if (sortColumn !== -1) results = sortElementRows(csv, results, sortColumn, ascending); + page = 0; + renderPage(); + scroller.scrollTop = 0; + syncSelection(); + } + + download.addEventListener('click', () => { + const blob = new Blob([formatElementCsv(csv.columns, results.rows, quantityTotals, results.groups)], { type: 'text/csv;charset=utf-8' }); + const url = URL.createObjectURL(blob); + const link = el('a'); + link.href = url; + link.download = downloadName; + link.hidden = true; + document.body.append(link); + try { + link.click(); + } finally { + link.remove(); + setTimeout(() => URL.revokeObjectURL(url), 1000); + } + }); + previous.addEventListener('click', () => { page--; renderPage(); scroller.scrollTop = 0; }); + next.addEventListener('click', () => { page++; renderPage(); scroller.scrollTop = 0; }); + search.addEventListener('input', applyFilters); + category.addEventListener('change', applyFilters); + groupByCategory.addEventListener('change', applyFilters); + selection.addEventListener('change', syncSelection); + input.addEventListener('change', async () => { + const file = input.files[0]; + if (!file) return; + const request = ++loadRequest; + input.value = ''; + download.disabled = true; + status.textContent = t('csv.loading'); + try { + const text = await file.text(); + if (request !== loadRequest) return; + csv = parseElementCsv(text); + downloadName = file.name.replace(/\.csv$/i, '') + '-filtered.csv'; + sortColumn = -1; + ascending = true; + columnOrder = [ + ...FIRST_COLUMNS.filter((name) => csv.columns.includes(name)), + ...csv.columns.filter((name) => !FIRST_COLUMNS.includes(name)), + ].map((name) => csv.columns.indexOf(name)); + header.replaceChildren(); + const headerRow = header.insertRow(); + for (const column of columnOrder) { + const cell = el('th'); + cell.scope = 'col'; + const name = csv.columns[column]; + const sort = el('button', 'ioviewer-csv-sort'); + sort.type = 'button'; + sort.title = name; + const indicator = el('span', 'ioviewer-csv-sort-indicator'); + indicator.setAttribute('aria-hidden', 'true'); + sort.append(el('span', 'ioviewer-csv-sort-label', name), indicator); + sort.addEventListener('click', () => { + ascending = sortColumn !== column || !ascending; + sortColumn = column; + headerRow.querySelector('[aria-sort]')?.removeAttribute('aria-sort'); + cell.setAttribute('aria-sort', ascending ? 'ascending' : 'descending'); + applyFilters(); + }); + cell.append(sort); + headerRow.append(cell); + } + 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 }); + const categoryColumn = csv.columns.indexOf('category'); + category.hidden = categoryColumn < 0; + groupToggle.hidden = category.hidden; + groupByCategory.checked = false; + category.replaceChildren(new Option(t('csv.allCategories'), '')); + if (categoryColumn >= 0) { + const categories = [...new Set(csv.rows.map((row) => row[categoryColumn]))]; + categories.sort((a, b) => a.localeCompare(b)); + for (const name of categories) category.add(new Option(name || t('noCategory'), name)); + } + filters.hidden = csv.rows.length === 0; + search.value = ''; + pinnedRows.replaceChildren(); + pinned = undefined; + applyFilters(); + download.disabled = false; + } catch { + if (request === loadRequest) { + status.textContent = t('csv.invalid'); + download.disabled = !csv; + } + } + }); +} diff --git a/src/IOViewer/Viewer/src/ui/icons.js b/src/IOViewer/Viewer/src/ui/icons.js index 777e3c0..cb6aaf4 100644 --- a/src/IOViewer/Viewer/src/ui/icons.js +++ b/src/IOViewer/Viewer/src/ui/icons.js @@ -8,6 +8,7 @@ const cube = ''), + elements: svg(''), views: svg(''), sections: svg(''), clashes: svg(''), diff --git a/src/IOViewer/Viewer/src/ui/shell.js b/src/IOViewer/Viewer/src/ui/shell.js index 4e873b0..c728e19 100644 --- a/src/IOViewer/Viewer/src/ui/shell.js +++ b/src/IOViewer/Viewer/src/ui/shell.js @@ -3,7 +3,7 @@ import { icons } from './icons.js'; import { el, iconButton } from './dom.js'; // Rail order is fixed, so a panel registered later (sections, by its own task) still lands in its place. -const ORDER = ['model', 'views', 'sections', 'clashes', 'bcf', 'timeliner', 'links']; +const ORDER = ['model', 'elements', 'views', 'sections', 'clashes', 'bcf', 'timeliner', 'links']; /** * Left icon rail with floating panels; one panel is open at a time and its active rail icon closes it. diff --git a/src/IOViewer/Viewer/styles/viewer.css b/src/IOViewer/Viewer/styles/viewer.css index 4d9f309..d41e7e5 100644 --- a/src/IOViewer/Viewer/styles/viewer.css +++ b/src/IOViewer/Viewer/styles/viewer.css @@ -498,6 +498,240 @@ input:focus-visible { overflow: auto; } +.ioviewer-side-panel[data-panel="elements"] { + width: clamp(294px, calc(48vw - 62px), 520px); +} + +.ioviewer-csv-actions { + display: flex; + flex-wrap: wrap; + gap: 6px; +} + +.ioviewer-csv-actions .ioviewer-text-button { + flex: none; +} + +.ioviewer-csv-status { + margin: 8px 0; + color: var(--text-dim); + overflow-wrap: anywhere; +} + +.ioviewer-csv-filters { + display: flex; + flex: none; + flex-wrap: wrap; + gap: 6px; + margin-bottom: 8px; +} + +.ioviewer-csv-filters input[type="search"], +.ioviewer-csv-filters select { + min-width: 0; + padding: 5px 7px; + border: 1px solid var(--border); + border-radius: 4px; + background: #1b1e24; + color: var(--text); + font: inherit; +} + +.ioviewer-csv-filters input[type="search"] { + flex: 1 1 110px; +} + +.ioviewer-csv-filters select { + flex: 0 1 46%; +} + +.ioviewer-csv-filters input::placeholder, +.ioviewer-csv-feedback { + color: var(--text-dim); +} + +.ioviewer-csv-filters select:focus-visible { + outline: 2px solid var(--accent-text); + outline-offset: 1px; +} + +.ioviewer-csv-group-toggle { + display: flex; + align-items: center; + gap: 5px; + color: var(--text); + white-space: nowrap; + cursor: pointer; +} + +.ioviewer-csv-group-toggle input { + margin: 0; + accent-color: var(--accent); +} + +.ioviewer-csv-feedback { + margin: 0 0 6px; +} + +.ioviewer-csv-totals { + display: flex; + flex: none; + flex-wrap: wrap; + gap: 3px 12px; + margin: 0 0 8px; +} + +.ioviewer-csv-totals div { + display: inline-flex; + flex-wrap: wrap; + gap: 0 4px; + min-width: 0; +} + +.ioviewer-csv-totals dt { + color: var(--text-dim); +} + +.ioviewer-csv-totals dd { + margin: 0; + font-variant-numeric: tabular-nums; + font-weight: 600; + overflow-wrap: anywhere; +} + +.ioviewer-csv-scroll { + min-height: 0; + container-type: inline-size; + overflow: auto; + border: 1px solid var(--border); + scroll-padding-block-start: 2.5em; +} + +.ioviewer-csv-scroll table { + width: 100%; + border-spacing: 0; + text-align: left; + white-space: nowrap; + font-variant-numeric: tabular-nums; +} + +.ioviewer-csv-scroll th, +.ioviewer-csv-scroll td { + max-width: 24ch; + padding: 6px 8px; + border-bottom: 1px solid var(--border); + overflow: hidden; + text-overflow: ellipsis; +} + +.ioviewer-csv-scroll thead th { + position: sticky; + top: 0; + z-index: 1; + background: var(--button); +} + +.ioviewer-csv-scroll .ioviewer-csv-group-heading { + overflow: visible; + white-space: normal; + background: var(--button); + font-weight: normal; +} + +.ioviewer-csv-group-summary { + position: sticky; + left: 8px; + width: calc(100cqi - 16px); + overflow-wrap: anywhere; +} + +.ioviewer-csv-group-summary .ioviewer-csv-totals { + margin: 2px 0 0; +} + +.ioviewer-csv-scroll th:has(.ioviewer-csv-sort:hover) { + background: var(--button-hover); +} + +.ioviewer-csv-sort { + display: flex; + align-items: center; + justify-content: space-between; + gap: 6px; + width: 100%; + padding: 0; + border: 0; + background: transparent; + font: inherit; + text-align: left; + cursor: pointer; +} + +.ioviewer-csv-sort-label { + overflow: hidden; + text-overflow: ellipsis; +} + +.ioviewer-csv-sort-indicator { + display: grid; + flex: none; + gap: 2px; + color: var(--text-dim); +} + +.ioviewer-csv-sort-indicator::before, +.ioviewer-csv-sort-indicator::after { + content: ""; + border-inline: 3px solid transparent; +} + +.ioviewer-csv-sort-indicator::before { + border-bottom: 4px solid currentColor; +} + +.ioviewer-csv-sort-indicator::after { + border-top: 4px solid currentColor; +} + +.ioviewer-csv-scroll [aria-sort] .ioviewer-csv-sort-indicator { + color: var(--accent-text); +} + +.ioviewer-csv-scroll [aria-sort="ascending"] .ioviewer-csv-sort-indicator::after, +.ioviewer-csv-scroll [aria-sort="descending"] .ioviewer-csv-sort-indicator::before { + visibility: hidden; +} + +.ioviewer-csv-scroll tr[data-linked] { + cursor: pointer; +} + +.ioviewer-csv-scroll tr[data-linked]:not([data-selected="true"]):hover { + background: var(--button-hover); +} + +.ioviewer-csv-scroll tr[data-selected="true"] { + background: var(--accent); + color: #fff; +} + +.ioviewer-csv-element { + padding: 0; + border: 0; + background: transparent; + text-decoration: underline; + text-underline-offset: 0.18em; + cursor: pointer; +} + +.ioviewer-csv-pagination { + display: flex; + justify-content: space-between; + align-items: center; + gap: 8px; + margin-top: 8px; +} + /* Model tree */ .ioviewer-tree-search { box-sizing: border-box; @@ -792,6 +1026,30 @@ input:focus-visible { z-index: 1; max-width: calc(100% - 100px); } + .ioviewer-side-panel[data-panel="elements"] { + top: auto; + bottom: var(--toolbar-space); + max-height: 36%; + } + + .ioviewer-csv-group-toggle { + flex-basis: 100%; + } + + .ioviewer-side-panel[data-panel="elements"]:has(.ioviewer-csv-group-toggle input:checked) { + max-height: 50%; + } + + .ioviewer-csv-totals { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 2px 6px; + font-size: 12px; + } + + #ioviewer-ui:has(.ioviewer-side-panel[data-panel="elements"]:not([hidden])) #ioviewer-properties { + display: none; + } .ioviewer-viewcube-home { z-index: 2; diff --git a/src/IOViewer/Viewer/test/e2e/element-table.spec.js b/src/IOViewer/Viewer/test/e2e/element-table.spec.js new file mode 100644 index 0000000..0a9145a --- /dev/null +++ b/src/IOViewer/Viewer/test/e2e/element-table.spec.js @@ -0,0 +1,229 @@ +import { test, expect } from '@playwright/test'; +import { readFile } from 'node:fs/promises'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { viewerDir } from './global-setup.js'; + +const screenAt = (page, index) => page.evaluate((i) => { + const { scene, camera } = window.__ioviewer; + const box = scene.elementBox(i); + const center = box.getCenter(box.min.clone()).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); + +test('CSV selects all GLB placements and picking in 3D finds the row on another page', async ({ page }) => { + const errors = []; + page.on('pageerror', (error) => errors.push(error.message)); + 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 chooser = page.waitForEvent('filechooser'); + await panel.getByRole('button', { name: 'Открыть CSV элементов' }).click(); + const unlinked = Array.from({ length: 100 }, (_, i) => `${1000 + i},Без геометрии,`); + await (await chooser).setFiles({ + name: 'elements.csv', + mimeType: 'text/csv', + buffer: Buffer.from(['\uFEFFelementId,name,length_m', '101,"Стена, А",1.2', ...unlinked, '202,Колонна,0'].join('\r\n')), + }); + await expect(panel.getByRole('status')).toContainText('2 из 102'); + const wall = panel.getByRole('row', { name: /Стена, А/ }); + await wall.getByText('Стена, А').click(); + await expect(wall.getByRole('button')).toHaveAttribute('aria-pressed', 'true'); + expect(await page.evaluate(() => [...window.__ioviewer.selection.values()])).toEqual([0]); + + await page.mouse.click(...(await screenAt(page, 1))); + const column = panel.getByRole('row', { name: /Колонна/ }); + await expect(column.getByRole('button')).toHaveAttribute('aria-pressed', 'true'); + expect(await page.evaluate(() => [...window.__ioviewer.selection.values()])).toEqual([1]); + await page.keyboard.press('Escape'); + await expect(column.getByRole('button')).toHaveAttribute('aria-pressed', 'false'); + await panel.locator('input[type=file]').setInputFiles({ + name: 'bad.csv', mimeType: 'text/csv', buffer: Buffer.from('elementId\n202\n202'), + }); + await expect(panel.getByRole('status')).toContainText('Не удалось прочитать CSV'); + await expect(column).toBeVisible(); + expect(errors).toEqual([]); +}); + +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); + await page.getByRole('button', { name: 'Таблица элементов' }).click(); + const panel = page.getByRole('region', { name: 'Таблица элементов' }); + const fillers = Array.from({ length: 100 }, (_, i) => `${1000 + i},Без геометрии,Колонны`); + await panel.locator('input[type=file]').setInputFiles({ + name: 'elements.csv', + mimeType: 'text/csv', + buffer: Buffer.from(['elementId,name,category', '101,Стена А,Стены', '125,Перегородка,Стены', + ...fillers, '202,Колонна Б,Колонны', '302,Прочее,'].join('\n')), + }); + + const search = panel.getByRole('searchbox', { name: 'Поиск по ID и имени' }); + const category = panel.getByRole('combobox', { name: 'Категория' }); + const wall = panel.getByRole('row', { name: /Стена А/ }); + const column = panel.getByRole('row', { name: /Колонна Б/ }); + const outside = panel.getByText('Выбранный элемент вне фильтра.'); + + await search.fill(' сТеНа '); + await category.selectOption('Стены'); + await expect(panel.locator('tbody tr')).toHaveCount(1); + await wall.getByRole('button').click(); + await expect(wall.getByRole('button')).toHaveAttribute('aria-pressed', 'true'); + expect(await page.evaluate(() => [...window.__ioviewer.selection.values()])).toEqual([0]); + + await page.mouse.click(...(await screenAt(page, 1))); + await expect(column.getByRole('button')).toHaveAttribute('aria-pressed', 'true'); + await expect(outside).toBeVisible(); + await expect(search).toHaveValue(' сТеНа '); + await expect(category).toHaveValue('Стены'); + await expect(wall.getByRole('button')).toHaveAttribute('aria-pressed', 'false'); + + await wall.getByRole('button').click(); + await expect(column).toHaveCount(0); + await expect(outside).toBeHidden(); + await search.fill(''); + await category.selectOption('Колонны'); + await page.mouse.click(...(await screenAt(page, 1))); + await expect(column.getByRole('button')).toHaveAttribute('aria-pressed', 'true'); + await expect(panel.getByText('101–101 из 101')).toBeVisible(); + await expect(outside).toBeHidden(); + + await search.fill('202'); + await expect(column.getByRole('button')).toHaveAttribute('aria-pressed', 'true'); + await expect(panel.locator('tbody tr')).toHaveCount(1); + await search.fill('нет совпадений'); + await expect(panel.getByText('Подходящих строк нет.')).toBeVisible(); + await expect(column.getByRole('button')).toHaveAttribute('aria-pressed', 'true'); + await expect(outside).toBeVisible(); + await page.mouse.click(920, 80); + await expect(outside).toBeHidden(); + await expect(column).toHaveCount(0); + await category.selectOption({ label: 'Без категории' }); + await search.fill('30'); + await expect(panel.getByRole('row', { name: /Прочее/ })).toBeVisible(); +}); + +test('downloads sorted matches and their totals, excluding the pinned row', 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 button = panel.getByRole('button', { name: 'Скачать CSV' }); + await expect(button).toBeDisabled(); + const heading = 'category,name,elementId,length_m,area_m2,volume_m3'; + const matching = ['Стены,Деталь А,101,0,2,3', + ...Array.from({ length: 100 }, (_, i) => `Стены,Деталь ${i},${i === 99 ? 2 : 1000 + i},${i + 1},0.5,0.25`)]; + await panel.locator('input[type=file]').setInputFiles({ + name: 'model.csv', + mimeType: 'text/csv', + buffer: Buffer.from([heading, ...matching, 'Колонны,Деталь Б,202,-1,50,60', 'Стены,Перегородка,303,,,'].join('\n')), + }); + await expect(button).toBeEnabled(); + + const search = panel.getByRole('searchbox'); + await search.fill('ДЕТАЛЬ'); + await panel.getByRole('combobox', { name: 'Категория' }).selectOption('Стены'); + const totals = panel.locator('dl[aria-label="Итоги выборки"]'); + await expect(totals.locator('dd')).toHaveText(['101', '5 050 м', '52 м²', '28 м³']); + + const id = panel.getByRole('columnheader', { name: 'elementId' }); + const length = panel.getByRole('columnheader', { name: 'length_m' }); + await id.getByRole('button').click(); + await expect(id).toHaveAttribute('aria-sort', 'ascending'); + await expect(panel.locator('tbody tr').first()).toContainText('Деталь 99'); + await length.getByRole('button').press('Enter'); + await expect(id).not.toHaveAttribute('aria-sort'); + await expect(length).toHaveAttribute('aria-sort', 'ascending'); + await expect(panel.locator('tbody tr').first()).toContainText('Деталь А'); + await length.getByRole('button').click(); + await expect(length).toHaveAttribute('aria-sort', 'descending'); + await expect(panel.locator('tbody tr').first()).toContainText('Деталь 99'); + + await panel.getByRole('button', { name: 'Далее' }).click(); + await expect(panel.getByText('101–101 из 101')).toBeVisible(); + await page.mouse.click(...(await screenAt(page, 1))); + await expect(panel.getByRole('button', { name: '202' })).toHaveAttribute('aria-pressed', 'true'); + await expect(totals.locator('dd')).toHaveText(['101', '5 050 м', '52 м²', '28 м³']); + + async function download() { + const pending = page.waitForEvent('download'); + await button.click(); + const file = await pending; + expect(file.suggestedFilename()).toBe('model-filtered.csv'); + return readFile(await file.path(), 'utf8'); + } + + const exportHeading = heading + ',element_count'; + const exported = await download(); + expect(exported).toBe('\uFEFF' + [ + exportHeading, ...[...matching].reverse().map((row) => row + ','), ',,TOTAL,5050,52,28,101', '', + ].join('\r\n')); + await panel.getByRole('combobox', { name: 'Категория' }).selectOption({ label: 'Все категории' }); + await expect(length).toHaveAttribute('aria-sort', 'descending'); + await expect(panel.getByText('101–102 из 102')).toBeVisible(); + await expect(panel.getByText('Выбранный элемент вне фильтра.')).toBeHidden(); + await expect(panel.getByRole('button', { name: '202' })).toHaveAttribute('aria-pressed', 'true'); + await expect(totals.locator('dd')).toHaveText(['102', '5 049 м', '102 м²', '88 м³']); + await search.fill('Нет совпадений'); + await expect(panel.getByRole('button', { name: '202' })).toHaveAttribute('aria-pressed', 'true'); + await expect(totals.locator('dd')).toHaveText(['0', '—', '—', '—']); + expect(await download()).toBe(`\uFEFF${exportHeading}\r\n,,TOTAL,,,,0\r\n`); + + await panel.locator('input[type=file]').setInputFiles({ + name: 'reopened.csv', + mimeType: 'text/csv', + buffer: Buffer.from(exported), + }); + await expect(panel.getByRole('status')).toContainText('1 из 101'); + await expect(totals.locator('dd')).toHaveText(['101', '5 050 м', '52 м²', '28 м³']); + await expect(panel.getByRole('row', { name: /TOTAL/ })).toHaveCount(0); +}); + +test('groups across pages, shows full category totals and downloads subtotals', 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,category,name,length_m,area_m2,volume_m3'; + const walls = ['101,Стены,Деталь А,0,2,3', + ...Array.from({ length: 100 }, (_, i) => `${1000 + i},Стены,Деталь ${i},${i + 1},0.5,0.25`)]; + const column = '202,Опоры,Деталь Б,-1,50,60'; + await panel.locator('input[type=file]').setInputFiles({ + name: 'model.csv', + mimeType: 'text/csv', + buffer: Buffer.from([heading, walls[0], column, ...walls.slice(1), '500,Стены,Перегородка,50,50,50'].join('\n')), + }); + await panel.getByRole('searchbox').fill('Деталь'); + await panel.getByRole('checkbox', { name: 'Группировать по категориям' }).check(); + const groups = panel.locator('.ioviewer-csv-group-heading'); + const wallsHeader = groups.filter({ has: page.getByText('Стены', { exact: true }) }); + const supports = groups.filter({ has: page.getByText('Опоры', { exact: true }) }); + await expect(groups.locator('strong')).toHaveText(['Опоры', 'Стены']); + await expect(wallsHeader.locator('dd')).toHaveText(['101', '5 050 м', '52 м²', '28 м³']); + await expect(supports.locator('dd')).toHaveText(['1', '-1 м', '50 м²', '60 м³']); + const sort = panel.getByRole('button', { name: 'length_m' }); + await sort.click(); + await sort.click(); + await expect(wallsHeader.locator('xpath=../following-sibling::tr[1]')).toContainText('Деталь 99'); + + await panel.getByRole('button', { name: 'Далее' }).click(); + await expect(groups.locator('strong')).toHaveText(['Стены']); + await expect(wallsHeader.locator('dd')).toHaveText(['101', '5 050 м', '52 м²', '28 м³']); + await page.mouse.click(...(await screenAt(page, 1))); + await expect(panel.getByRole('button', { name: '202' })).toHaveAttribute('aria-pressed', 'true'); + + 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', + column + ',', 'SUBTOTAL,Опоры,,-1,50,60,1', + ...[...walls].reverse().map(row => row + ','), 'SUBTOTAL,Стены,,5050,52,28,101', + 'TOTAL,,,5049,102,88,102', '', + ].join('\r\n')); + await panel.locator('input[type=file]').setInputFiles({ name: 'reopened.csv', mimeType: 'text/csv', buffer: Buffer.from(file) }); + await expect(panel.getByRole('status')).toContainText('2 из 102'); + await expect(panel.getByRole('row', { name: /(?:SUBTOTAL|TOTAL)/ })).toHaveCount(0); +}); diff --git a/src/IOViewer/Viewer/test/e2e/global-setup.js b/src/IOViewer/Viewer/test/e2e/global-setup.js index 40f88ff..b86c6df 100644 --- a/src/IOViewer/Viewer/test/e2e/global-setup.js +++ b/src/IOViewer/Viewer/test/e2e/global-setup.js @@ -8,17 +8,49 @@ export const LARGE_ELEMENTS = 20000; export const LARGE_CLASHES = 130000; // Exports a JSON document to test-results/.html with the CLI, as a user would; `options` are extra CLI flags. -function exportHtml(jsonPath, name, options = []) { +function exportHtml(modelPath, name, options = []) { // The CLI targets net8.0 and net10.0, so `dotnet run` needs an explicit framework. const args = ['run', '--project', '../../IOViewer.Cli', '-c', 'Release', '-f', 'net10.0', '--', - jsonPath, '-o', `test-results/${name}.html`, ...options]; + modelPath, '-o', `test-results/${name}.html`, ...options]; try { execFileSync('dotnet', args, { cwd: viewerDir, stdio: 'pipe' }); } catch (error) { - throw new Error(`Exporting ${jsonPath} failed:\n${error.stdout}\n${error.stderr}`, { cause: error }); + throw new Error(`Exporting ${modelPath} failed:\n${error.stdout}\n${error.stderr}`, { cause: error }); } } +// A shared cube with two source elements. One of them draws the cube twice. +function elementTableGlb() { + const box = largeModel(1).Geometries[0]; + const positions = box.Vertices.flatMap(({ X, Y, Z }) => [X * 3, Z * 3, -Y * 3]); + const bytes = Buffer.alloc((positions.length + box.Indices.length) * 4); + positions.forEach((value, index) => bytes.writeFloatLE(value, index * 4)); + box.Indices.forEach((value, index) => bytes.writeUInt32LE(value, (positions.length + index) * 4)); + const json = JSON.stringify({ + asset: { version: '2.0' }, + buffers: [{ byteLength: bytes.length }], + bufferViews: [{ buffer: 0, byteLength: positions.length * 4 }, + { buffer: 0, byteOffset: positions.length * 4, byteLength: box.Indices.length * 4 }], + 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 } })), + scenes: [{ nodes: [0, 1, 2] }], + }); + const metadata = Buffer.from(json.padEnd(Math.ceil(json.length / 4) * 4)); + const header = Buffer.alloc(20); + header.write('glTF'); + header.writeUInt32LE(2, 4); + header.writeUInt32LE(28 + metadata.length + bytes.length, 8); + header.writeUInt32LE(metadata.length, 12); + header.write('JSON', 16); + const binaryHeader = Buffer.alloc(8); + binaryHeader.writeUInt32LE(bytes.length, 0); + binaryHeader.write('BIN\0', 4); + return Buffer.concat([header, metadata, binaryHeader, bytes]); +} + // ViewerDocument JSON with `count` small boxes on one shared geometry, in 4 categories, all of type "Segment 50". function largeModel(count) { const v = (X, Y, Z) => ({ X, Y, Z }); @@ -56,6 +88,9 @@ export default function globalSetup() { } exportHtml(path.join(fixturesDir, 'building.json'), 'building-white', ['--white-mode']); mkdirSync(path.join(viewerDir, 'test-results'), { recursive: true }); + const csvGlb = path.join(viewerDir, 'test-results', 'element-table.glb'); + writeFileSync(csvGlb, elementTableGlb()); + exportHtml(csvGlb, 'element-table'); const large = path.join(viewerDir, 'test-results', 'large.json'); writeFileSync(large, JSON.stringify(largeModel(LARGE_ELEMENTS))); exportHtml(large, 'large'); diff --git a/src/IOViewer/Viewer/test/unit/elementCsv.test.js b/src/IOViewer/Viewer/test/unit/elementCsv.test.js new file mode 100644 index 0000000..0f5324e --- /dev/null +++ b/src/IOViewer/Viewer/test/unit/elementCsv.test.js @@ -0,0 +1,131 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { filterElementRows, formatElementCsv, groupElementRows, parseElementCsv, sortElementRows, sumElementQuantities } from '../../src/model/elementCsv.js'; + +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'); + assert.deepEqual(value.columns, ['elementId', 'name', 'volume_m3']); + assert.deepEqual(value.rows, [['-2', 'Стена, "А"\r\nсекция', ''], ['0', '', '0']]); + assert.equal(value.rowById.get('0'), 1); + assert.deepEqual(parseElementCsv('elementId,name\n').rows, []); +}); + +test('rejects missing and duplicate keys, malformed fields and noncanonical ids', () => { + for (const csv of ['name\nWall', 'elementId,elementId\n1,1', 'elementId\n1\n1', + 'elementId,name\n1', 'elementId,name\n1,"unfinished', 'elementId,name\n1,"x"oops', + 'elementId\n1e2', 'elementId\n"10\n"', 'elementId\n-0', 'elementId\n9007199254740993']) { + assert.throws(() => parseElementCsv(csv)); + } +}); + +test('matches partial IDs or names within a category and indexes filtered rows in CSV order', () => { + const csv = parseElementCsv('elementId,name,category\n21,Стена A,Стены\n2,Колонна,Опоры\n30,Стена Б,Стены\n31,,'); + const category = filterElementRows(csv, ' сТЕНА ', 'Стены'); + assert.deepEqual([...category.rowById], [['21', 0], ['30', 1]]); + assert.deepEqual([...filterElementRows(csv, '2', 'Опоры').rowById], [['2', 0]]); + assert.deepEqual([...filterElementRows(csv, '', '').rowById], [['31', 0]]); + assert.deepEqual(filterElementRows(csv, 'стена', 'Опоры').rows, []); + assert.equal(filterElementRows(csv, ' ', null), csv); + assert.equal(filterElementRows(parseElementCsv('elementId\n21'), '2', null).rows.length, 1); +}); + +test('writes UTF-8 CSV headings, quoted fields and negative numbers in the original column order', () => { + const columns = ['elementId', 'length_m', 'name']; + const rows = [['-2', '-1.2e-3', 'Стена, "А"\r\nсекция'], ['21', '0', '']]; + const output = formatElementCsv(columns, rows); + assert.equal(output, '\uFEFFelementId,length_m,name\r\n-2,-1.2e-3,"Стена, ""А""\r\nсекция"\r\n21,0,\r\n'); + assert.deepEqual(parseElementCsv(output).rows, rows); + assert.equal(formatElementCsv(columns, []), '\uFEFFelementId,length_m,name\r\n'); +}); + +test('sorts IDs and quantities numerically and keeps missing values last in either direction', () => { + const csv = parseElementCsv([ + 'elementId,categoryId,typeId,length_m,area_m2,volume_m3', + '10,-2,10,10,10,10', + '2,-10,2,2,2,2', + '-3,,,,,', + '4,-2,4,-0.4,4e-1,4e-1', + '11,-2,11,2,2,2', + '5,-2,5,n/a,n/a,n/a', + ].join('\n')); + const ids = (column, ascending) => [...sortElementRows(csv, csv, column, ascending).rowById.keys()]; + assert.deepEqual(ids(0, true), ['-3', '2', '4', '5', '10', '11']); + assert.deepEqual(ids(1, true), ['2', '10', '4', '11', '5', '-3']); + assert.deepEqual(ids(2, false), ['11', '10', '5', '4', '2', '-3']); + for (const column of [3, 4, 5]) { + assert.deepEqual(ids(column, true), ['4', '2', '11', '10', '-3', '5']); + assert.deepEqual(ids(column, false), ['10', '2', '11', '4', '-3', '5']); + } + assert.deepEqual([...csv.rowById.keys()], ['10', '2', '-3', '4', '11', '5']); +}); + +test('sorts filtered text rows alphabetically with stable ties and reindexes the rows', () => { + const csv = parseElementCsv('elementId,name,category\n10,Bravo,A\n3,,A\n9,alpha,A\n4,Alpha,A\n5,Able,B'); + const results = sortElementRows(csv, filterElementRows(csv, '', 'A'), 1, true); + assert.deepEqual([...results.rowById], [['9', 0], ['4', 1], ['10', 2], ['3', 3]]); +}); + +test('sums finite quantities in the filtered rows and distinguishes missing measurements from zero', () => { + const csv = parseElementCsv([ + 'elementId,category,name,volume_m3,length_m,area_m2', + '1,Стены,Стена А,1.25,2,0', + '2,Стены,Стена Б,,4.5e0,0', + '3,Стены,Стена В,2.75, n/a ,0x10', + '4,Стены,Дверь,90,99,99', + '5,Колонны,Стена Г,25,29,29', + '6,Стены,Стена Д,Infinity,-.5,', + ].join('\n')); + const { rows } = filterElementRows(csv, 'стена', 'Стены'); + assert.deepEqual(sumElementQuantities(csv, rows), [6, 0, 4]); + assert.deepEqual(sumElementQuantities(csv, []), [null, null, null]); + const lengthOnly = parseElementCsv('elementId,length_m\n1,0'); + assert.deepEqual(sumElementQuantities(lengthOnly, lengthOnly.rows), [0, null, null]); +}); + +test('appends and reopens a totals footer with the original quantity column order', () => { + const csv = parseElementCsv('name,length_m,elementId,volume_m3,area_m2\nA,10.5,2,,4\nB,-3,1,,'); + const { rows } = sortElementRows(csv, csv, csv.idColumn, true); + const output = formatElementCsv(csv.columns, rows, sumElementQuantities(csv, csv.rows)); + assert.equal(output, '\uFEFFname,length_m,elementId,volume_m3,area_m2,element_count\r\n' + + 'B,-3,1,,,\r\nA,10.5,2,,4,\r\n,7.5,TOTAL,,4,2\r\n'); + + const reopened = parseElementCsv(output.replace('TOTAL,,4,2', 'TOTAL,,4,99')); + assert.deepEqual([...reopened.rowById.keys()], ['1', '2']); + assert.equal(formatElementCsv(reopened.columns, reopened.rows, sumElementQuantities(reopened, reopened.rows)), output); + + for (const invalid of ['elementId\nTOTAL', 'elementId,element_count\nTOTAL,0\n1,', 'elementId,element_count\nTOTAL']) { + assert.throws(() => parseElementCsv(invalid)); + } +}); + +test('groups filtered rows, sorts inside each category and round-trips subtotal rows', () => { + const csv = parseElementCsv([ + 'elementId,category,length_m,name', '9,B,2,Keep', '3,A,5,Keep', '2,B,10,Keep', + '1,A,,Keep', '4,,1,Keep', '5,A,99,Other', + ].join('\n')); + const filtered = filterElementRows(csv, 'Keep', null); + const results = groupElementRows(csv, filtered, 2, false); + assert.deepEqual([...results.rowById], [['3', 0], ['1', 1], ['2', 2], ['9', 3], ['4', 4]]); + assert.deepEqual(results.groups.map(({ category, start, totals }) => [category, start, totals]), [ + ['A', 0, [5, null, null]], ['B', 2, [12, null, null]], ['', 4, [1, null, null]], + ]); + assert.deepEqual(groupElementRows(csv, filtered, 1, false).groups.map(group => group.category), ['B', 'A', '']); + + const output = formatElementCsv(csv.columns, results.rows, sumElementQuantities(csv, filtered.rows), results.groups); + assert.equal(output, '\uFEFF' + [ + 'elementId,category,length_m,name,element_count', + '3,A,5,Keep,', '1,A,,Keep,', 'SUBTOTAL,A,5,,2', + '2,B,10,Keep,', '9,B,2,Keep,', 'SUBTOTAL,B,12,,2', + '4,,1,Keep,', 'SUBTOTAL,,1,,1', 'TOTAL,,18,,5', '', + ].join('\r\n')); + assert.deepEqual(parseElementCsv(output).rows.map(row => row.slice(0, -1)), results.rows); + assert.throws(() => parseElementCsv('elementId,category,element_count\nSUBTOTAL,A,1')); +}); + +test('writes formula-like spreadsheet fields as text without doubling existing protection', () => { + const input = ['=1+2', ' +1+2', '-2-3', '@SUM(1)', '\t12', '\n12', "'=1+2", '+2.5']; + const csv = formatElementCsv(['elementId', 'name'], input.map((value, i) => [String(i), value])); + assert.deepEqual(parseElementCsv(csv).rows.map((row) => row[1]), [ + "'=1+2", "' +1+2", "'-2-3", "'@SUM(1)", "'\t12", "'\n12", "'=1+2", '+2.5', + ]); +}); diff --git a/tests/IOViewer.Tests/GlbSharedGeometryTests.cs b/tests/IOViewer.Tests/GlbSharedGeometryTests.cs index 3efa979..9c3a849 100644 --- a/tests/IOViewer.Tests/GlbSharedGeometryTests.cs +++ b/tests/IOViewer.Tests/GlbSharedGeometryTests.cs @@ -86,6 +86,24 @@ public void TwoNodesSharingMesh_ProduceOneGeometryTwoInstances() Assert.Empty(doc.Scene.Validate()); } + [Fact] + public void ExplicitSourceIdGroupsPlacementsWithoutUsingLocalSceneIds() + { + var doc = Import(""" + { "children": [1, 2], "extras": { "elementId": 430012 } }, + { "mesh": 0, "extras": { "elementId": 430012 } }, + { "mesh": 0, "translation": [10,0,0], "extras": { "elementId": 430012 } }, + { "mesh": 0, "extras": { "elementId": "430012" } }, + { "mesh": 0, "extras": null } + """, "0, 3, 4"); + + var linked = Assert.Single(doc.Scene.Elements, element => element.SourceId == "430012"); + Assert.Equal(3, doc.Scene.Elements.Count); + Assert.Equal(2, doc.Scene.Instances.Count(instance => instance.ElementId == linked.Id)); + AssertNear(new Vector3d(10, 0, 0), World(doc, 1)); + Assert.Empty(doc.Scene.Validate()); + } + [Fact] public void YUp_IsConvertedToZUp() {