From 23bcf9c824535609e41aa5a3110abbdde56214d5 Mon Sep 17 00:00:00 2001 From: mahach666 <79989386+mahach666@users.noreply.github.com> Date: Wed, 2 Dec 2026 15:05:21 +0300 Subject: [PATCH 1/3] Add integrated 2D CAD mode, vector lines, text annotations and sheets --- src/IOViewer.Cli/Program.cs | 2 +- src/IOViewer/Exporters/HtmlViewerOptions.cs | 2 + src/IOViewer/Exporters/ViewerPayloadWriter.cs | 192 +++++++- src/IOViewer/Model/ViewerAnnotation.cs | 36 ++ src/IOViewer/Model/ViewerDocument.cs | 9 + src/IOViewer/Model/ViewerSheet.cs | 30 ++ src/IOViewer/Viewer/dist/viewer.js | 446 ++++++++++-------- src/IOViewer/Viewer/src/data.js | 22 +- src/IOViewer/Viewer/src/engine/lineScene.js | 224 +++++++++ src/IOViewer/Viewer/src/engine/modelScene.js | 18 +- src/IOViewer/Viewer/src/engine/picking.js | 121 ++++- src/IOViewer/Viewer/src/engine/pointScene.js | 4 +- src/IOViewer/Viewer/src/i18n.js | 8 + src/IOViewer/Viewer/src/main.js | 65 ++- src/IOViewer/Viewer/src/nav/controls.js | 65 ++- src/IOViewer/Viewer/src/nav/viewCube.js | 4 + src/IOViewer/Viewer/src/tools/display.js | 12 +- src/IOViewer/Viewer/src/tools/measureSnap.js | 63 ++- .../Viewer/src/ui/annotationsOverlay.js | 107 +++++ src/IOViewer/Viewer/src/ui/app.js | 18 +- src/IOViewer/Viewer/src/ui/icons.js | 1 + src/IOViewer/Viewer/src/ui/sheetsBar.js | 91 ++++ src/IOViewer/Viewer/src/ui/toolbar.js | 2 +- src/IOViewer/Viewer/styles/viewer.css | 53 +++ .../IOViewer.Tests/HtmlViewerExporterTests.cs | 7 +- tests/IOViewer.Tests/LinePayloadTests.cs | 151 ++++++ .../ModelAndCliIntegrationTests.cs | 4 +- 27 files changed, 1503 insertions(+), 254 deletions(-) create mode 100644 src/IOViewer/Model/ViewerAnnotation.cs create mode 100644 src/IOViewer/Model/ViewerSheet.cs create mode 100644 src/IOViewer/Viewer/src/engine/lineScene.js create mode 100644 src/IOViewer/Viewer/src/ui/annotationsOverlay.js create mode 100644 src/IOViewer/Viewer/src/ui/sheetsBar.js create mode 100644 tests/IOViewer.Tests/LinePayloadTests.cs diff --git a/src/IOViewer.Cli/Program.cs b/src/IOViewer.Cli/Program.cs index 5e247b8..7df1422 100644 --- a/src/IOViewer.Cli/Program.cs +++ b/src/IOViewer.Cli/Program.cs @@ -333,7 +333,7 @@ public static int Main(string[] args) int undrawn = ViewerPayloadWriter.UndrawnInstances(doc.Scene); if (undrawn > 0) { - Console.Error.WriteLine($"Warning: {undrawn} meshes of lines or an unknown kind are not shown; the viewer draws triangles and point clouds."); + Console.Error.WriteLine($"Warning: {undrawn} meshes of an unknown kind are not shown; the viewer draws triangles, lines and point clouds."); } } diff --git a/src/IOViewer/Exporters/HtmlViewerOptions.cs b/src/IOViewer/Exporters/HtmlViewerOptions.cs index a78e5bb..51d4b63 100644 --- a/src/IOViewer/Exporters/HtmlViewerOptions.cs +++ b/src/IOViewer/Exporters/HtmlViewerOptions.cs @@ -13,6 +13,8 @@ public sealed class HtmlViewerOptions public bool IncludeClashes { get; set; } = true; public bool InitialWireframe { get; set; } public bool InitialWhiteMode { get; set; } + public bool Initial2DMode { get; set; } + public string? InitialBackground { get; set; } /// /// Maximum total number of mesh vertices written to the viewer (each mesh counts the vertices it draws). diff --git a/src/IOViewer/Exporters/ViewerPayloadWriter.cs b/src/IOViewer/Exporters/ViewerPayloadWriter.cs index 0046b92..6369f97 100644 --- a/src/IOViewer/Exporters/ViewerPayloadWriter.cs +++ b/src/IOViewer/Exporters/ViewerPayloadWriter.cs @@ -48,6 +48,10 @@ internal sealed class ViewerPayloadWriter private readonly List _pointMaterial = []; private readonly List _pointElement = []; private readonly List _pointMatrix = []; + private readonly List _lineGeometry = []; + private readonly List _lineMaterial = []; + private readonly List _lineElement = []; + private readonly List _lineMatrix = []; private readonly Dictionary _viewpointStates = new(StringComparer.Ordinal); private readonly List _bcfTopics; private readonly Dictionary _bcfStates = []; @@ -59,9 +63,13 @@ internal sealed class ViewerPayloadWriter private int _writtenMeshes; private InstanceViews _instances; private InstanceViews _pointViews; + private InstanceViews _lineViews; private readonly Dictionary _pointColors; private readonly Dictionary _pointIntensities; private readonly List<(int Element, Vector3d Position, double Yaw, BlobView Image, BlobView? Intensity, string? Name)> _panoramas = []; + private readonly List _annotations = []; + private readonly List _sheets = []; + private readonly string? _initialSheetKey; private ViewerPayloadWriter(ViewerDocument doc, HtmlViewerOptions options) { @@ -71,6 +79,7 @@ private ViewerPayloadWriter(ViewerDocument doc, HtmlViewerOptions options) _bcfTopics = doc.BcfTopics; _pointColors = doc.PointColors; _pointIntensities = doc.PointIntensities; + _initialSheetKey = doc.InitialSheetKey; _options = options; } @@ -82,6 +91,8 @@ public static ViewerPayloadWriter Create(ViewerDocument doc, HtmlViewerOptions o var elementIndex = writer.Build(); writer._sections = writer.BuildSections(doc.SectionPlanes, doc.SectionBox); writer.BuildViewpointStates(doc.ViewpointStates, elementIndex); + writer.BuildAnnotations(doc.Annotations, elementIndex); + writer.BuildSheets(doc.Sheets, elementIndex); foreach (var panorama in doc.Panoramas) { if (panorama is null || !elementIndex.TryGetValue(panorama.ElementId, out int element) @@ -266,7 +277,7 @@ public static int UndrawnInstances(SceneDocument scene) var topology = new Dictionary(); foreach (var geometry in scene.Geometries) topology.TryAdd(geometry.Id, geometry.Topology); return scene.Instances.Count(i => topology.TryGetValue(i.GeometryId, out var t) - && t != SceneTopology.Triangles && t != SceneTopology.Points); + && t != SceneTopology.Triangles && t != SceneTopology.Points && t != SceneTopology.Lines); } private Dictionary Build() @@ -279,6 +290,12 @@ private Dictionary Build() throw new InvalidDataException($"Geometry id {geometry.Id} is used by more than one geometry."); } if (geometry.Topology == SceneTopology.Triangles) CheckIndices(geometry.Indices, geometry.Vertices.Count, $"Geometry {geometry.Id}"); + else if (geometry.Topology == SceneTopology.Lines) + { + CheckIndices(geometry.Indices, geometry.Vertices.Count, $"Geometry {geometry.Id}"); + int segVerts = geometry.Indices.Count > 0 ? geometry.Indices.Count : geometry.Vertices.Count; + if (segVerts % 2 != 0) throw new InvalidDataException($"Line geometry {geometry.Id} has an odd vertex count."); + } if (!geometry.Vertices.All(IsFinite) || geometry.Normals?.All(IsFinite) == false || geometry.UVs?.All(uv => double.IsFinite(uv.X) && double.IsFinite(uv.Y)) == false) throw new InvalidDataException($"Geometry {geometry.Id} has a non-finite vertex, normal or UV coordinate."); @@ -350,6 +367,11 @@ private Dictionary Build() AddPointInstance(geometry, instance, elementIndex); continue; } + if (geometry.Topology == SceneTopology.Lines) + { + AddLineInstance(geometry, instance, uses[geometry.Id] > 1, sharedOutput, elementIndex); + continue; + } if (geometry.Topology != SceneTopology.Triangles) { _skipped++; @@ -400,9 +422,71 @@ private Dictionary Build() _blob.Add(CollectionsMarshal.AsSpan(_pointMaterial)), _blob.Add(CollectionsMarshal.AsSpan(_pointElement)), _blob.Add(CollectionsMarshal.AsSpan(_pointMatrix))); + _lineViews = new InstanceViews( + _blob.Add(CollectionsMarshal.AsSpan(_lineGeometry)), + _blob.Add(CollectionsMarshal.AsSpan(_lineMaterial)), + _blob.Add(CollectionsMarshal.AsSpan(_lineElement)), + _blob.Add(CollectionsMarshal.AsSpan(_lineMatrix))); return elementIndex; } + // CAD vector lines (especially 1:100 paper sheets) contain sub-millimetre details that would be + // distorted by the 1/1024 m triangle grid, so store local Float32 coordinates relative to min. + private void AddLineInstance( + SceneGeometry geometry, + SceneInstance instance, + bool shared, + Dictionary sharedOutput, + Dictionary elementIndex) + { + var transform = instance.Transform ?? Transform3d.Identity; + int geometryIndex; + Vector3d translation; + + if (shared) + { + if (!sharedOutput.TryGetValue(geometry.Id, out var written)) + { + var vertices = geometry.Vertices.ToArray(); + var indices = LineIndices(geometry); + var bounds = BoundingBox3d.Empty; + foreach (var v in vertices) bounds = bounds.Encapsulate(v); + var min = bounds.IsEmpty ? Vector3d.Zero : bounds.Min; + var local = bounds.IsEmpty ? bounds : new BoundingBox3d(Vector3d.Zero, bounds.Max - min); + written = (AddGeometry(null, Floats(vertices, min), null, indices, null, null, local, lines: true), min); + sharedOutput.Add(geometry.Id, written); + } + + geometryIndex = written.Index; + translation = transform.Apply(written.Origin) - _rtcOffset; + } + else + { + var vertices = geometry.Vertices; + var rtc = new Vector3d[vertices.Count]; + var box = BoundingBox3d.Empty; + for (int i = 0; i < rtc.Length; i++) + { + rtc[i] = transform.Apply(vertices[i]) - _rtcOffset; + box = box.Encapsulate(rtc[i]); + } + var indices = LineIndices(geometry); + var min = box.IsEmpty ? Vector3d.Zero : box.Min; + var bounds = box.IsEmpty ? box : new BoundingBox3d(Vector3d.Zero, box.Max - min); + geometryIndex = AddGeometry(null, Floats(rtc, min), null, indices, null, null, bounds, lines: true); + translation = min; + transform = Transform3d.Identity; + } + + _lineGeometry.Add((uint)geometryIndex); + _lineMaterial.Add((uint)MaterialIndex(instance)); + _lineElement.Add(elementIndex.TryGetValue(instance.ElementId, out int index) ? index : -1); + AddMatrix(transform, translation, _lineMatrix); + } + + private static IReadOnlyList LineIndices(SceneGeometry geometry) => + geometry.Indices.Count > 0 ? geometry.Indices : [.. Enumerable.Range(0, geometry.Vertices.Count - geometry.Vertices.Count % 2)]; + // A point instance is baked into RTC and written as a points geometry with optional RGB; // the viewer draws it as a point sprite cloud, separate from the merged triangle chunks. private void AddPointInstance(SceneGeometry geometry, SceneInstance instance, Dictionary elementIndex) @@ -594,7 +678,7 @@ private static float[] Floats(Vector3d[] vertices, Vector3d offset) // Returns the index of an identical geometry written before (same bytes and origin), or writes this one. Positions // are either grid steps q from origin, or f32 positions (origin null). private int AddGeometry(ushort[]? q, float[]? positions, Vector3d? origin, IReadOnlyList indices, short[]? normals, float[]? uvs, - BoundingBox3d bounds, bool points = false, byte[]? colors = null, byte[]? intensities = null) + BoundingBox3d bounds, bool points = false, bool lines = false, byte[]? colors = null, byte[]? intensities = null) { int vertexCount = (q?.Length ?? positions!.Length) / 3; ushort[]? indices16 = null; @@ -613,6 +697,7 @@ private int AddGeometry(ushort[]? q, float[]? positions, Vector3d? origin, IRead var hasher = new HashCode(); hasher.Add(origin); hasher.Add(points); + hasher.Add(lines); hasher.AddBytes(Bytes(q)); hasher.AddBytes(Bytes(positions)); hasher.AddBytes(Bytes(indices16)); @@ -636,6 +721,7 @@ private int AddGeometry(ushort[]? q, float[]? positions, Vector3d? origin, IRead { var entry = _geometries[candidate]; if (entry.Points == points + && entry.Lines == lines && entry.Origin == origin && (q is not null ? Same(q, entry.Positions) : Same(positions, entry.Positions)) && (indices16 is not null ? Same(indices16, entry.Indices) : Same(indices32, entry.Indices)) @@ -656,6 +742,7 @@ private int AddGeometry(ushort[]? q, float[]? positions, Vector3d? origin, IRead uvs is null ? null : _blob.Add(uvs), bounds, points, + lines, colors is null ? null : _blob.Add(colors.AsSpan()), intensities is null ? null : _blob.Add(intensities.AsSpan())); _geometries.Add(written); @@ -794,6 +881,7 @@ public void WriteMeta(Stream output) w.WritePropertyName("indices"); g.Indices.WriteTo(w); if (g.Points) w.WriteString("kind", "points"); + else if (g.Lines) w.WriteString("kind", "lines"); WriteView(w, "normals", g.Normals); WriteView(w, "uvs", g.Uvs); WriteView(w, "colors", g.Colors); @@ -831,6 +919,67 @@ public void WriteMeta(Stream output) w.WriteEndObject(); } + if (_lineGeometry.Count > 0) + { + w.WriteStartObject("lines"); + w.WriteNumber("count", _lineGeometry.Count); + w.WritePropertyName("geometry"); + _lineViews.Geometry.WriteTo(w); + w.WritePropertyName("material"); + _lineViews.Material.WriteTo(w); + w.WritePropertyName("element"); + _lineViews.Element.WriteTo(w); + w.WritePropertyName("matrix"); + _lineViews.Matrix.WriteTo(w); + w.WriteEndObject(); + } + + if (_annotations.Count > 0) + { + w.WriteStartArray("annotations"); + foreach (var a in _annotations) + { + w.WriteStartObject(); + w.WriteString("text", a.Text); + WriteVector(w, "position", a.Position); + w.WriteNumber("height", a.Height); + w.WriteNumber("rotation", a.Rotation); + w.WriteNumber("width", a.Width); + w.WriteNumber("attachment", a.Attachment); + w.WriteNumber("element", a.Element); + if (!string.IsNullOrEmpty(a.SheetKey)) w.WriteString("sheet", a.SheetKey); + if (a.Color is { } c) + { + w.WriteStartArray("color"); + w.WriteNumberValue(c.R / 255.0); + w.WriteNumberValue(c.G / 255.0); + w.WriteNumberValue(c.B / 255.0); + w.WriteEndArray(); + } + w.WriteEndObject(); + FlushIfLarge(w); + } + w.WriteEndArray(); + } + + if (_sheets.Count > 0) + { + w.WriteStartArray("sheets"); + foreach (var s in _sheets) + { + w.WriteStartObject(); + w.WriteString("key", s.Key); + w.WriteString("name", s.Name); + w.WriteBoolean("isModel", s.IsModelSpace); + w.WriteBoolean("is2D", s.Is2D); + if (!string.IsNullOrEmpty(s.Background)) w.WriteString("background", s.Background); + if (s.PaperBounds is { } b) WriteBox(w, "paperBounds", b, _rtcOffset); + WriteIndices(w, "elements", s.ElementIndices); + w.WriteEndObject(); + } + w.WriteEndArray(); + } + if (_panoramas.Count > 0) { w.WriteStartArray("panoramas"); @@ -856,6 +1005,9 @@ private void WriteOptions(Utf8JsonWriter w) w.WriteStartObject("options"); w.WriteBoolean("initialWireframe", _options.InitialWireframe); w.WriteBoolean("initialWhiteMode", _options.InitialWhiteMode); + if (_options.Initial2DMode) w.WriteBoolean("initial2DMode", true); + if (!string.IsNullOrWhiteSpace(_options.InitialBackground)) w.WriteString("initialBackground", _options.InitialBackground); + if (!string.IsNullOrWhiteSpace(_initialSheetKey)) w.WriteString("initialSheet", _initialSheetKey); w.WriteEndObject(); } @@ -1233,9 +1385,43 @@ private sealed record PreparedViewpoint(SectionState? Sections, int[]? HiddenEle private readonly record struct MaterialKey(byte R, byte G, byte B, double Opacity, int? Texture); + private void BuildAnnotations(List annotations, Dictionary elementIndex) + { + foreach (var a in annotations) + { + if (a is null || string.IsNullOrWhiteSpace(a.Text)) continue; + var pos = a.Position - _rtcOffset; + if (!IsFinite(pos) || !double.IsFinite(a.Height) || a.Height <= 0 || !double.IsFinite(a.RotationRadians) || !double.IsFinite(a.Width)) + throw new InvalidDataException("A viewer annotation needs finite coordinates, rotation, width and positive height."); + int el = a.ElementId is long id && elementIndex.TryGetValue(id, out int idx) ? idx : -1; + _annotations.Add(new PreparedAnnotation(a.Text, pos, a.Height, a.RotationRadians, Math.Max(0, a.Width), a.Attachment, el, a.SheetKey, a.Color)); + } + } + + private void BuildSheets(List sheets, Dictionary elementIndex) + { + foreach (var s in sheets) + { + if (s is null || string.IsNullOrWhiteSpace(s.Key)) continue; + var indices = new List(s.ElementIds.Count); + foreach (long id in s.ElementIds) + { + if (elementIndex.TryGetValue(id, out int idx)) indices.Add(idx); + } + _sheets.Add(new PreparedSheet(s.Key, string.IsNullOrEmpty(s.Name) ? s.Key : s.Name, s.IsModelSpace, s.Is2D, + s.BackgroundColor, s.PaperBounds is { IsEmpty: false } pb ? pb : null, indices)); + } + } + + private sealed record PreparedAnnotation(string Text, Vector3d Position, double Height, double Rotation, double Width, + int Attachment, int Element, string? SheetKey, RgbaColor? Color); + + private sealed record PreparedSheet(string Key, string Name, bool IsModelSpace, bool Is2D, + string? Background, BoundingBox3d? PaperBounds, List ElementIndices); + // Origin is META q.o: set for u16 grid-step positions, null for f32. Points marks a point-sprite geometry (no indices). private sealed record GeometryEntry(BlobView Positions, Vector3d? Origin, BlobView Indices, BlobView? Normals, BlobView? Uvs, - BoundingBox3d Bounds, bool Points, BlobView? Colors, BlobView? Intensities); + BoundingBox3d Bounds, bool Points, bool Lines, BlobView? Colors, BlobView? Intensities); // An own-vertex mesh baked into RTC: Relative = float32 positions relative to Min, the exact minimum corner; Indices // with the winding reversed under a mirroring transform. diff --git a/src/IOViewer/Model/ViewerAnnotation.cs b/src/IOViewer/Model/ViewerAnnotation.cs new file mode 100644 index 0000000..40c39ac --- /dev/null +++ b/src/IOViewer/Model/ViewerAnnotation.cs @@ -0,0 +1,36 @@ +using IOScene; + +namespace IOViewer.Model; + +/// +/// A 2D/3D text label attached to the drawing (such as CAD TEXT or MTEXT) rendered in the viewer overlay. +/// +public sealed class ViewerAnnotation +{ + /// Text string to display (newlines separate lines). + public string Text { get; set; } = string.Empty; + + /// Anchor position in scene coordinates (metres, Z up). + public Vector3d Position { get; set; } + + /// Text height in scene units (metres). + public double Height { get; set; } = 0.25; + + /// Counter-clockwise rotation angle in the XY plane, in radians. + public double RotationRadians { get; set; } + + /// Optional wrapping box width in scene units (0 disables wrapping). + public double Width { get; set; } + + /// AutoCAD-compatible attachment point (1=TL, 2=TC, 3=TR, 4=ML, 5=MC, 6=MR, 7=BL, 8=BC, 9=BR). + public int Attachment { get; set; } = 1; + + /// Optional foreground colour (sRGB); null falls back to adaptive foreground ink. + public RgbaColor? Color { get; set; } + + /// Optional owning element id in so hiding/isolating hides the text too. + public long? ElementId { get; set; } + + /// Optional sheet key in when the annotation belongs to a specific sheet/space. + public string? SheetKey { get; set; } +} diff --git a/src/IOViewer/Model/ViewerDocument.cs b/src/IOViewer/Model/ViewerDocument.cs index 128fa29..f0ed8a0 100644 --- a/src/IOViewer/Model/ViewerDocument.cs +++ b/src/IOViewer/Model/ViewerDocument.cs @@ -58,6 +58,15 @@ public ViewerDocument(SceneDocument scene) /// Equirectangular photographs attached to scan elements. public List Panoramas { get; set; } = []; + /// 2D/3D text annotations overlaid on the drawing. + public List Annotations { get; set; } = []; + + /// Switchable spaces and paper layouts (e.g. Model Space and Paper Space sheets). + public List Sheets { get; set; } = []; + + /// Optional key of the initial sheet to show on load. + public string? InitialSheetKey { get; set; } + /// Title of the scene: reads and writes . [JsonIgnore] public string Title diff --git a/src/IOViewer/Model/ViewerSheet.cs b/src/IOViewer/Model/ViewerSheet.cs new file mode 100644 index 0000000..0b86605 --- /dev/null +++ b/src/IOViewer/Model/ViewerSheet.cs @@ -0,0 +1,30 @@ +using IOScene; + +namespace IOViewer.Model; + +/// +/// A switchable drawing space or paper layout inside (such as Model Space or Paper Space Sheet). +/// +public sealed class ViewerSheet +{ + /// Unique sheet/space key (e.g. model, Layout1). + public string Key { get; set; } = string.Empty; + + /// Display label shown in the viewer sheet switcher. + public string Name { get; set; } = string.Empty; + + /// True when this sheet represents Model Space rather than a Paper Space layout. + public bool IsModelSpace { get; set; } + + /// Preferred 2D CAD view lock when switching to this sheet. + public bool Is2D { get; set; } = true; + + /// Optional preferred background hex colour (#RRGGBB) when activating this sheet. + public string? BackgroundColor { get; set; } + + /// Optional paper extents drawn as a subtle sheet frame when active. + public BoundingBox3d? PaperBounds { get; set; } + + /// Element ids belonging to this sheet (elements absent from active sheet are hidden when it is selected). + public IReadOnlyList ElementIds { get; set; } = []; +} diff --git a/src/IOViewer/Viewer/dist/viewer.js b/src/IOViewer/Viewer/dist/viewer.js index 3da3db3..8a42e4e 100644 --- a/src/IOViewer/Viewer/dist/viewer.js +++ b/src/IOViewer/Viewer/dist/viewer.js @@ -1,10 +1,10 @@ -(()=>{var tu=i=>{throw TypeError(i)};var Ll=(i,t,e)=>t.has(i)||tu("Cannot "+e);var ui=(i,t,e)=>(Ll(i,t,"read from private field"),e?e.call(i):t.get(i)),Dl=(i,t,e)=>t.has(i)?tu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),eu=(i,t,e,n)=>(Ll(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),Jr=(i,t,e)=>(Ll(i,t,"access private method"),e);var Uu=0,dc=1,Fu=2;var gr=1,Bu=2,As=3,Wn=0,Be=1,Oe=2,Xn=0,Rs=1,fc=2,pc=3,mc=4,Ou=5;var Hi=100,zu=101,ku=102,Hu=103,Vu=104,Gu=200,Wu=201,Xu=202,qu=203,gc=204,_c=205,Yu=206,$u=207,Zu=208,Ju=209,Ku=210,ju=211,Qu=212,td=213,ed=214,Ro=0,Co=1,Io=2,fs=3,Po=4,Lo=5,Do=6,No=7,_r=0,nd=1,id=2,wn=0,xc=1,vc=2,yc=3,Mc=4,bc=5,Sc=6,wc=7;var Ec=300,Mi=301,Vi=302,aa=303,la=304,xr=306,ps=1e3,Dn=1001,Uo=1002,Ve=1003,sd=1004;var vr=1005;var qe=1006,ca=1007;var bi=1008;var nn=1009,Tc=1010,Ac=1011,Cs=1012,ha=1013,En=1014,Ye=1015,Tn=1016,ua=1017,da=1018,Is=1020,Rc=35902,Cc=35899,Ic=1021,Pc=1022,sn=1023,Nn=1026,Si=1027,Ps=1028,fa=1029,wi=1030,pa=1031;var ma=1033,yr=33776,Mr=33777,br=33778,Sr=33779,ga=35840,_a=35841,xa=35842,va=35843,ya=36196,Ma=37492,ba=37496,Sa=37488,wa=37489,wr=37490,Ea=37491,Ta=37808,Aa=37809,Ra=37810,Ca=37811,Ia=37812,Pa=37813,La=37814,Da=37815,Na=37816,Ua=37817,Fa=37818,Ba=37819,Oa=37820,za=37821,ka=36492,Ha=36494,Va=36495,Ga=36283,Wa=36284,Er=36285,Xa=36286;var Ks=2300,Fo=2301,Eo=2302,ic=2303,sc=2400,rc=2401,oc=2402;var rd=3200;var Tr=0,od=1,ri="",Me="srgb",js="srgb-linear",Qs="linear",ue="srgb";var To=7680;var Lc=34055,Dc=34056;var Nc=517;var ad=519,ld=512,cd=513,hd=514,qa=515,ud=516,dd=517,Ya=518,fd=519,Uc=35044,Ar=35048;var Fc="300 es",yn=2e3,ms=2001;function Vp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Gp(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function gs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function pd(){let i=gs("canvas");return i.style.display="block",i}var nu={},_s=null;function tr(...i){let t="THREE."+i.shift();_s?_s("log",t,...i):console.log(t,...i)}function md(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 kt(...i){i=md(i);let t="THREE."+i.shift();if(_s)_s("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Wt(...i){i=md(i);let t="THREE."+i.shift();if(_s)_s("error",t,...i);else{let e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Ui(...i){let t=i.join(" ");t in nu||(nu[t]=!0,kt(...i))}function gd(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 _d={[Ro]:Co,[Io]:Do,[Po]:No,[fs]:Lo,[Co]:Ro,[Do]:Io,[No]:Po,[Lo]:fs},Un=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 ne(i,t,e){return Math.max(t,Math.min(e,i))}function Bc(i,t){return(i%t+t)%t}function Wp(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Xp(i,t,e){return i!==t?(e-i)/(t-i):0}function Js(i,t,e){return(1-e)*i+e*t}function qp(i,t,e,n){return Js(i,t,1-Math.exp(-e*n))}function Yp(i,t=1){return t-Math.abs(Bc(i,t*2)-t)}function $p(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Zp(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Jp(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Kp(i,t){return i+Math.random()*(t-i)}function jp(i){return i*(.5-Math.random())}function Qp(i){i!==void 0&&(iu=i);let t=iu+=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 tm(i){return i*us}function em(i){return i*xs}function nm(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function im(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function sm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function rm(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:kt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function vn(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 de(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var le={DEG2RAD:us,RAD2DEG:xs,generateUUID:ni,clamp:ne,euclideanModulo:Bc,mapLinear:Wp,inverseLerp:Xp,lerp:Js,damp:qp,pingpong:Yp,smoothstep:$p,smootherstep:Zp,randInt:Jp,randFloat:Kp,randFloatSpread:jp,seededRandom:Qp,degToRad:tm,radToDeg:em,isPowerOfTwo:nm,ceilPowerOfTwo:im,floorPowerOfTwo:sm,setQuaternionFromProperEuler:rm,normalize:de,denormalize:vn},Vc=class Vc{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=ne(this.x,t.x,e.x),this.y=ne(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ne(this.x,t,e),this.y=ne(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ne(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(ne(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}};Vc.prototype.isVector2=!0;var Gt=Vc,De=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 M=Math.acos(g),T=Math.sin(M);p=Math.sin(p*M)/T,a=Math.sin(a*M)/T,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 M=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=M,c*=M,h*=M,d*=M}}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:kt("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(ne(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}},Gc=class Gc{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(su.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(su.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=ne(this.x,t.x,e.x),this.y=ne(this.y,t.y,e.y),this.z=ne(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ne(this.x,t,e),this.y=ne(this.y,t,e),this.z=ne(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ne(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 Nl.copy(this).projectOnVector(t),this.sub(Nl)}reflect(t){return this.sub(Nl.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(ne(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}};Gc.prototype.isVector3=!0;var P=Gc,Nl=new P,su=new De,Wc=class Wc{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],M=s[1],T=s[4],S=s[7],v=s[2],b=s[5],A=s[8];return r[0]=o*_+a*M+l*v,r[3]=o*g+a*T+l*b,r[6]=o*p+a*S+l*A,r[1]=c*_+h*M+d*v,r[4]=c*g+h*T+d*b,r[7]=c*p+h*S+d*A,r[2]=u*_+f*M+m*v,r[5]=u*g+f*T+m*b,r[8]=u*p+f*S+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 Ui("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ul.makeScale(t,e)),this}rotate(t){return Ui("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ul.makeRotation(-t)),this}translate(t,e){return Ui("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ul.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)}};Wc.prototype.isMatrix3=!0;var Yt=Wc,Ul=new Yt,ru=new Yt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ou=new Yt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function om(){let i={enabled:!0,workingColorSpace:js,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===ue&&(s.r=ii(s.r),s.g=ii(s.g),s.b=ii(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===ue&&(s.r=ds(s.r),s.g=ds(s.g),s.b=ds(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===ri?Qs: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 Ui("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ui("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({[js]:{primaries:t,whitePoint:n,transfer:Qs,toXYZ:ru,fromXYZ:ou,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Me},outputColorSpaceConfig:{drawingBufferColorSpace:Me}},[Me]:{primaries:t,whitePoint:n,transfer:ue,toXYZ:ru,fromXYZ:ou,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Me}}}),i}var ee=om();function ii(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ds(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Ji,Bo=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=gs("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=gs("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(Bl).x}get height(){return this.source.getSize(Bl).y}get depth(){return this.source.getSize(Bl).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){kt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){kt(`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!==Ec)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ps:t.x=t.x-Math.floor(t.x);break;case Dn:t.x=t.x<0?0:1;break;case Uo: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 ps:t.y=t.y-Math.floor(t.y);break;case Dn:t.y=t.y<0?0:1;break;case Uo: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++}};Ge.DEFAULT_IMAGE=null;Ge.DEFAULT_MAPPING=Ec;Ge.DEFAULT_ANISOTROPY=1;var Xc=class Xc{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 T=(c+1)/2,S=(f+1)/2,v=(p+1)/2,b=(h+u)/4,A=(d+_)/4,x=(m+g)/4;return T>S&&T>v?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=b/n,r=A/n):S>v?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=b/s,r=x/s):v<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(v),n=A/r,s=x/r),this.set(n,s,r,e),this}let M=Math.sqrt((g-m)*(g-m)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(M)<.001&&(M=1),this.x=(g-m)/M,this.y=(d-_)/M,this.z=(u-h)/M,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=ne(this.x,t.x,e.x),this.y=ne(this.y,t.y,e.y),this.z=ne(this.z,t.z,e.z),this.w=ne(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=ne(this.x,t,e),this.y=ne(this.y,t,e),this.z=ne(this.z,t,e),this.w=ne(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ne(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}};Xc.prototype.isVector4=!0;var xe=Xc,Oo=class extends Un{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 xe(0,0,t,e),this.scissorTest=!1,this.viewport=new xe(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new Ge(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(mm)))}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]}},xd={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},fi={h:0,s:0,l:0},Qr={h:0,s:0,l:0};function zl(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 Ht=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,ee.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=ee.workingColorSpace){return this.r=t,this.g=e,this.b=n,ee.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=ee.workingColorSpace){if(t=Bc(t,1),e=ne(e,0,1),n=ne(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=zl(o,r,t+1/3),this.g=zl(o,r,t),this.b=zl(o,r,t-1/3)}return ee.colorSpaceToWorking(this,s),this}setStyle(t,e=Me){function n(r){r!==void 0&&parseFloat(r)<1&&kt("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:kt("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);kt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Me){let n=xd[t.toLowerCase()];return n!==void 0?this.setHex(n,e):kt("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=ii(t.r),this.g=ii(t.g),this.b=ii(t.b),this}copyLinearToSRGB(t){return this.r=ds(t.r),this.g=ds(t.g),this.b=ds(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Me){return ee.workingToColorSpace(Je.copy(this),t),Math.round(ne(Je.r*255,0,255))*65536+Math.round(ne(Je.g*255,0,255))*256+Math.round(ne(Je.b*255,0,255))}getHexString(t=Me){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ee.workingColorSpace){ee.workingToColorSpace(Je.copy(this),e);let n=Je.r,s=Je.g,r=Je.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){_n.subVectors(s,e),Kn.subVectors(n,e),kl.subVectors(t,e);let o=_n.dot(_n),a=_n.dot(Kn),l=_n.dot(kl),c=Kn.dot(Kn),h=Kn.dot(kl),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,jn)===null?!1:jn.x>=0&&jn.y>=0&&jn.x+jn.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,jn)===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,jn.x),l.addScaledVector(o,jn.y),l.addScaledVector(a,jn.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return Wl.setScalar(0),Xl.setScalar(0),ql.setScalar(0),Wl.fromBufferAttribute(t,e),Xl.fromBufferAttribute(t,n),ql.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(Wl,r.x),o.addScaledVector(Xl,r.y),o.addScaledVector(ql,r.z),o}static isFrontFacing(t,e,n,s){return _n.subVectors(n,e),Kn.subVectors(t,e),_n.cross(Kn).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 _n.subVectors(this.c,this.b),Kn.subVectors(this.a,this.b),_n.cross(Kn).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;ts.subVectors(s,n),es.subVectors(r,n),Hl.subVectors(t,n);let l=ts.dot(Hl),c=es.dot(Hl);if(l<=0&&c<=0)return e.copy(n);Vl.subVectors(t,s);let h=ts.dot(Vl),d=es.dot(Vl);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(ts,o);Gl.subVectors(t,r);let f=ts.dot(Gl),m=es.dot(Gl);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(es,a);let g=h*m-f*d;if(g<=0&&d-h>=0&&f-m>=0)return pu.subVectors(r,s),a=(d-h)/(d-h+(f-m)),e.copy(s).addScaledVector(pu,a);let p=1/(g+_+u);return o=_*p,a=u*p,e.copy(n).addScaledVector(ts,o).addScaledVector(es,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},ae=class{constructor(t=new P(1/0,1/0,1/0),e=new P(-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,xn),xn.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(Ws),eo.subVectors(this.max,Ws),ns.subVectors(t.a,Ws),is.subVectors(t.b,Ws),ss.subVectors(t.c,Ws),pi.subVectors(is,ns),mi.subVectors(ss,is),Pi.subVectors(ns,ss);let e=[0,-pi.z,pi.y,0,-mi.z,mi.y,0,-Pi.z,Pi.y,pi.z,0,-pi.x,mi.z,0,-mi.x,Pi.z,0,-Pi.x,-pi.y,pi.x,0,-mi.y,mi.x,0,-Pi.y,Pi.x,0];return!Yl(e,ns,is,ss,eo)||(e=[1,0,0,0,1,0,0,0,1],!Yl(e,ns,is,ss,eo))?!1:(no.crossVectors(pi,mi),e=[no.x,no.y,no.z],Yl(e,ns,is,ss,eo))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,xn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(xn).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:(Qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Qn),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}},Qn=[new P,new P,new P,new P,new P,new P,new P,new P],xn=new P,to=new ae,ns=new P,is=new P,ss=new P,pi=new P,mi=new P,Pi=new P,Ws=new P,eo=new P,no=new P,Li=new P;function Yl(i,t,e,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Li.fromArray(i,r);let a=s.x*Math.abs(Li.x)+s.y*Math.abs(Li.y)+s.z*Math.abs(Li.z),l=t.dot(Li),c=e.dot(Li),h=n.dot(Li);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Pe=new P,io=new Gt,gm=0,Ae=class extends Un{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:gm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Uc,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;Xs.subVectors(t,this.center);let e=Xs.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Xs,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):($l.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Xs.copy(t.center).add($l)),this.expandByPoint(Xs.copy(t.center).sub($l))),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}},xm=0,dn=new Zt,Zl=new We,rs=new P,on=new ae,qs=new ae,He=new P,fe=class i extends Un{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:xm++}),this.uuid=ni(),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(Vp(t)?ir:nr)(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 Yt().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 dn.makeRotationFromQuaternion(t),this.applyMatrix4(dn),this}rotateX(t){return dn.makeRotationX(t),this.applyMatrix4(dn),this}rotateY(t){return dn.makeRotationY(t),this.applyMatrix4(dn),this}rotateZ(t){return dn.makeRotationZ(t),this.applyMatrix4(dn),this}translate(t,e,n){return dn.makeTranslation(t,e,n),this.applyMatrix4(dn),this}scale(t,e,n){return dn.makeScale(t,e,n),this.applyMatrix4(dn),this}lookAt(t){return Zl.lookAt(t),Zl.updateMatrix(),this.applyMatrix4(Zl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rs).negate(),this.translate(rs.x,rs.y,rs.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;se.count&&kt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ae);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Wt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(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||ym.getNormalMatrix(t),s=this.coplanarPoint(Jl).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}},Mm=0,Mn=class extends Un{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Mm++}),this.uuid=ni(),this.name="",this.type="Material",this.blending=Rs,this.side=Wn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=gc,this.blendDst=_c,this.blendEquation=Hi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ht(0,0,0),this.blendAlpha=0,this.depthFunc=fs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ad,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=To,this.stencilZFail=To,this.stencilZPass=To,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){kt(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){kt(`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 Ht().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 Te().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 Gt().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 Gt().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 ti=new P,Kl=new P,so=new P,ro=new P,Fi=class{constructor(t=new P,e=new P(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,ti)),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=ti.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ti.copy(this.origin).addScaledVector(this.direction,e),ti.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Kl.copy(t).add(e).multiplyScalar(.5),so.copy(e).sub(t).normalize(),ro.copy(this.origin).sub(Kl);let r=t.distanceTo(e)*.5,o=-this.direction.dot(so),a=ro.dot(this.direction),l=-ro.dot(so),c=ro.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(Kl).addScaledVector(so,u),f}intersectSphere(t,e){if(t.radius<0)return null;ti.subVectors(t.center,this.origin);let n=ti.dot(this.direction),s=ti.dot(ti)-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,ti)!==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,M=n.y-o.y,T=n.z-o.z,S=Math.abs(l),v=Math.abs(c),b=Math.abs(h),A,x,w,R,D,N,B,L,U,W,V,O;if(S>=v&&S>=b?(w=l,N=d,U=m,O=p,l>=0?(A=c,x=h,R=u,D=f,B=_,L=g,W=M,V=T):(A=h,x=c,R=f,D=u,B=g,L=_,W=T,V=M)):v>=b?(w=c,N=u,U=_,O=M,c>=0?(A=h,x=l,R=f,D=d,B=g,L=m,W=T,V=p):(A=l,x=h,R=d,D=f,B=m,L=g,W=p,V=T)):(w=h,N=f,U=g,O=T,h>=0?(A=l,x=c,R=d,D=u,B=m,L=_,W=p,V=M):(A=c,x=l,R=u,D=d,B=_,L=m,W=M,V=p)),w===0)return null;let F=A/w,G=x/w,Y=1/w,z=R-F*N,$=D-G*N,nt=B-F*U,lt=L-G*U,at=W-F*O,X=V-G*O,tt=at*lt-X*nt,ht=z*X-$*at,Rt=nt*$-lt*z;if(s){if(tt<0||ht<0||Rt<0)return null}else if((tt<0||ht<0||Rt<0)&&(tt>0||ht>0||Rt>0))return null;let ft=tt+ht+Rt;if(ft===0)return null;let Ot=Y*(tt*N+ht*U+Rt*O);return(ft>0?Ot<0:Ot>0)?null:this.at(Ot/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)}},Ke=class extends Mn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ht(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 Fn,this.combine=_r,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}},mu=new Zt,Di=new Fi,oo=new Xe,gu=new P,ao=new P,lo=new P,co=new P,jl=new P,ho=new P,_u=new P,uo=new P,pe=class extends We{constructor(t=new fe,e=new Ke){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))&&(mu.copy(r).invert(),Di.copy(t.ray).applyMatrix4(mu),!(n.boundingBox!==null&&Di.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Di)))}_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],M=Math.max(g.start,f.start),T=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let S=M,v=T;Se.far?null:{distance:c,point:uo.clone(),object:i}}function fo(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,ao),i.getVertexPosition(l,lo),i.getVertexPosition(c,co);let h=bm(i,t,e,n,ao,lo,co,_u);if(h){let d=new P;ei.getBarycoord(_u,ao,lo,co,d),s&&(h.uv=ei.getInterpolatedAttribute(s,a,l,c,d,new Gt)),r&&(h.uv1=ei.getInterpolatedAttribute(r,a,l,c,d,new Gt)),o&&(h.normal=ei.getInterpolatedAttribute(o,a,l,c,d,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new P,materialIndex:0};ei.getNormal(ao,lo,co,u.normal),h.face=u,h.barycoord=d}return h}var Bn=class extends Ge{constructor(t=null,e=1,n=1,s,r,o,a,l,c=Ve,h=Ve,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 si=class extends Ae{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}},os=new Zt,xu=new Zt,po=[],vu=new ae,Sm=new Zt,Ys=new pe,$s=new Xe,_i=class extends pe{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new si(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,mo.y=s.normal.y>0?t.max.y:t.min.y,mo.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(mo)<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 an=class extends Mn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ht(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}},Ho=new P,Vo=new P,yu=new Zt,Zs=new Fi,go=new Xe,Ql=new P,Mu=new P,Bi=class extends We{constructor(t=new fe,e=new an){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;Ql.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(Ql);if(!(ct.far))return{distance:c,point:Mu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var bu=new P,Su=new P,bn=class extends Bi{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 rr=class extends Ge{constructor(t=[],e=Mi,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}},or=class extends Ge{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 kn=class extends Ge{constructor(t,e,n=En,s,r,o,a=Ve,l=Ve,c,h=Nn,d=1){if(h!==Nn&&h!==Si)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 vs(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},Go=class extends kn{constructor(t,e=En,n=Mi,s,r,o=Ve,a=Ve,l,c=Nn){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}},ar=class extends Ge{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},pn=class i extends fe{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 be(c,3)),this.setAttribute("normal",new be(h,3)),this.setAttribute("uv",new be(d,2));function m(_,g,p,M,T,S,v,b,A,x,w){let R=S/A,D=v/x,N=S/2,B=v/2,L=b/2,U=A+1,W=x+1,V=0,O=0,F=new P;for(let G=0;G0?1:-1,h.push(F.x,F.y,F.z),d.push(z/A),d.push(1-G/x),V+=1}}for(let G=0;G0&&T(!0),e>0&&T(!1)),this.setIndex(h),this.setAttribute("position",new be(d,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(f,2));function M(){let S=new P,v=new P,b=0,A=(e-t)/n;for(let x=0;x<=r;x++){let w=[],R=x/r,D=R*(e-t)+t;for(let N=0;N<=s;N++){let B=N/s,L=B*l+a,U=Math.sin(L),W=Math.cos(L);v.x=D*U,v.y=-R*n+g,v.z=D*W,d.push(v.x,v.y,v.z),S.set(U,A,W).normalize(),u.push(S.x,S.y,S.z),f.push(B,1-R),w.push(m++)}_.push(w)}for(let x=0;x0||w!==0)&&(h.push(R,D,B),b+=3),(e>0||w!==r-1)&&(h.push(D,N,B),b+=3)}c.addGroup(p,b,0),p+=b}function T(S){let v=m,b=new Gt,A=new P,x=0,w=S===!0?t:e,R=S===!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 D=m;for(let N=0;N<=s;N++){let L=N/s*l+a,U=Math.cos(L),W=Math.sin(L);A.x=w*W,A.y=g*R,A.z=w*U,d.push(A.x,A.y,A.z),u.push(0,R,0),b.x=U*.5+.5,b.y=W*.5*R+.5,f.push(b.x,b.y),m++}for(let N=0;N0)&&f.push(T,S,b),(p!==n-1||l{var lu=i=>{throw TypeError(i)};var Ol=(i,t,e)=>t.has(i)||lu("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)?lu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),cu=(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 Gu=0,xc=1,Wu=2;var xr=1,Xu=2,Cs=3,qn=0,ze=1,ke=2,Yn=0,Is=1,vc=2,yc=3,Mc=4,qu=5;var Gi=100,Yu=101,$u=102,Zu=103,Ku=104,Ju=200,ju=201,Qu=202,td=203,bc=204,Sc=205,ed=206,nd=207,id=208,sd=209,rd=210,od=211,ad=212,ld=213,cd=214,Po=0,Lo=1,Do=2,ms=3,No=4,Uo=5,Fo=6,Bo=7,vr=0,hd=1,ud=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,dd=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 fd=3200;var Rr=0,pd=1,oi="",pe="srgb",er="srgb-linear",nr="linear",de="srgb";var Co=7680;var Oc=34055,zc=34056;var kc=517;var md=519,gd=512,_d=513,xd=514,Za=515,vd=516,yd=517,Ka=518,Md=519,Hc=35044,Cr=35048;var Vc="300 es",bn=2e3,_s=2001;function Jp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function jp(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function xs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function bd(){let i=xs("canvas");return i.style.display="block",i}var hu={},vs=null;function ir(...i){let t="THREE."+i.shift();vs?vs("log",t,...i):console.log(t,...i)}function Sd(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=Sd(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=Sd(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 hu||(hu[t]=!0,Ht(...i))}function wd(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 Ed={[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 Qp(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function tm(i,t,e){return i!==t?(e-i)/(t-i):0}function Qs(i,t,e){return(1-e)*i+e*t}function em(i,t,e,n){return Qs(i,t,1-Math.exp(-e*n))}function nm(i,t=1){return t-Math.abs(Gc(i,t*2)-t)}function im(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function sm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function rm(i,t){return i+Math.floor(Math.random()*(t-i+1))}function om(i,t){return i+Math.random()*(t-i)}function am(i){return i*(.5-Math.random())}function lm(i){i!==void 0&&(uu=i);let t=uu+=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 cm(i){return i*fs}function hm(i){return i*ys}function um(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function dm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function fm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function pm(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),u=r((t-n)/2),d=o((t-n)/2),f=r((n-t)/2),g=o((n-t)/2);switch(s){case"XYX":i.set(a*h,l*u,l*d,a*c);break;case"YZY":i.set(l*d,a*h,l*u,a*c);break;case"ZXZ":i.set(l*u,l*d,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 fe(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 oe={DEG2RAD:fs,RAD2DEG:ys,generateUUID:ii,clamp:ie,euclideanModulo:Gc,mapLinear:Qp,inverseLerp:tm,lerp:Qs,damp:em,pingpong:nm,smoothstep:im,smootherstep:sm,randInt:rm,randFloat:om,randFloatSpread:am,seededRandom:lm,degToRad:cm,radToDeg:hm,isPowerOfTwo:um,ceilPowerOfTwo:dm,floorPowerOfTwo:fm,setQuaternionFromProperEuler:pm,normalize:fe,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],u=n[s+3],d=r[o+0],f=r[o+1],g=r[o+2],_=r[o+3];if(u!==_||l!==d||c!==f||h!==g){let p=l*d+c*f+h*g+u*_;p<0&&(d=-d,f=-f,g=-g,_=-_,p=-p);let m=1-a;if(p<.9995){let b=Math.acos(p),w=Math.sin(b);m=Math.sin(m*b)/w,a=Math.sin(a*b)/w,l=l*m+d*a,c=c*m+f*a,h=h*m+g*a,u=u*m+_*a}else{l=l*m+d*a,c=c*m+f*a,h=h*m+g*a,u=u*m+_*a;let b=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=b,c*=b,h*=b,u*=b}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[o],d=r[o+1],f=r[o+2],g=r[o+3];return t[e]=a*g+h*u+l*f-c*d,t[e+1]=l*g+h*d+c*u-a*f,t[e+2]=c*g+h*f+a*d-l*u,t[e+3]=h*g-a*u-l*d-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),u=a(r/2),d=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*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],u=e[10],d=n+a+u;if(d>0){let f=.5/Math.sqrt(d+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>u){let f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);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+u-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(du.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(du.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),u=2*(r*n-o*e);return this.x=e+l*c+o*u-a*h,this.y=n+l*h+a*c-r*u,this.z=s+l*u+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 R=Zc,kl=new R,du=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],u=n[7],d=n[2],f=n[5],g=n[8],_=s[0],p=s[3],m=s[6],b=s[1],w=s[4],S=s[7],v=s[2],y=s[5],A=s[8];return r[0]=o*_+a*b+l*v,r[3]=o*p+a*w+l*y,r[6]=o*m+a*S+l*A,r[1]=c*_+h*b+u*v,r[4]=c*p+h*w+u*y,r[7]=c*m+h*S+u*A,r[2]=d*_+f*b+g*v,r[5]=d*p+f*w+g*y,r[8]=d*m+f*S+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],u=h*o-a*c,d=a*l-h*r,f=c*r-o*l,g=e*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;return t[0]=u*_,t[1]=(s*c-h*n)*_,t[2]=(a*n-s*o)*_,t[3]=d*_,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 Zt=Kc,Hl=new Zt,fu=new Zt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),pu=new Zt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function mm(){let i={enabled:!0,workingColorSpace:er,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===de&&(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===de&&(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:fu,fromXYZ:pu,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:pe},outputColorSpaceConfig:{drawingBufferColorSpace:pe}},[pe]:{primaries:t,whitePoint:n,transfer:de,toXYZ:fu,fromXYZ:pu,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:pe}}}),i}var ne=mm();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],u=l[8],d=l[1],f=l[5],g=l[9],_=l[2],p=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+p)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let w=(c+1)/2,S=(f+1)/2,v=(m+1)/2,y=(h+d)/4,A=(u+_)/4,x=(g+p)/4;return w>S&&w>v?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=y/n,r=A/n):S>v?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=y/s,r=x/s):v<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(v),n=A/r,s=x/r),this.set(n,s,r,e),this}let b=Math.sqrt((p-g)*(p-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(p-g)/b,this.y=(u-_)/b,this.z=(d-h)/b,this.w=Math.acos((c+f+m-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 xe=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 xe(0,0,t,e),this.scissorTest=!1,this.viewport=new xe(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),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),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&&d<=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(wm)))}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]}},Td={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=pe){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=pe){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=pe){let n=Td[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=pe){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=pe){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 u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(s-r)/u+(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),u=o*c-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(c*l-a*h)*d,g=(o*h-a*l)*d;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),u=is.dot($l);if(h>=0&&u<=h)return e.copy(s);let d=l*u-h*c;if(d<=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 p=h*g-f*u;if(p<=0&&u-h>=0&&f-g>=0)return bu.subVectors(r,s),a=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector(bu,a);let m=1/(p+_+d);return o=_*m,a=d*m,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 R(1/0,1/0,1/0),e=new R(-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 R,new R,new R,new R,new R,new R,new R,new R],yn=new R,io=new se,ss=new R,rs=new R,os=new R,mi=new R,gi=new R,Li=new R,Ys=new R,so=new R,ro=new R,Di=new R;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 R,oo=new Wt,Em=0,_e=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:Em++}),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}},Am=0,fn=new Yt,ec=new Xe,as=new R,an=new se,Zs=new se,Ge=new R,ce=class i extends On{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Am++}),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(Jp(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 Zt().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 R(-1/0,-1/0,-1/0),new R(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 u=0,d=c.length;u0&&(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=[],u=r[c];for(let d=0,f=u.length;d1)?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||Cm.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}},Im=0,Sn=class extends On{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Im++}),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=md,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 R,ic=new R,ao=new R,lo=new R,Bi=class{constructor(t=new R,e=new R(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),u,d,f,g;if(h>0)if(u=o*l-a,d=o*a-l,g=r*h,u>=0)if(d>=-g)if(d<=g){let _=1/h;u*=_,d*=_,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-o*r+a)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(o*r+a)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=o>0?-r:r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(ic).addScaledVector(ao,d),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,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),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,u=t.x-o.x,d=t.y-o.y,f=t.z-o.z,g=e.x-o.x,_=e.y-o.y,p=e.z-o.z,m=n.x-o.x,b=n.y-o.y,w=n.z-o.z,S=Math.abs(l),v=Math.abs(c),y=Math.abs(h),A,x,E,I,D,N,B,L,F,k,W,O;if(S>=v&&S>=y?(E=l,N=u,F=g,O=m,l>=0?(A=c,x=h,I=d,D=f,B=_,L=p,k=b,W=w):(A=h,x=c,I=f,D=d,B=p,L=_,k=w,W=b)):v>=y?(E=c,N=d,F=_,O=b,c>=0?(A=h,x=l,I=f,D=u,B=p,L=g,k=w,W=m):(A=l,x=h,I=u,D=f,B=g,L=p,k=m,W=w)):(E=h,N=f,F=p,O=w,h>=0?(A=l,x=c,I=u,D=d,B=g,L=_,k=m,W=b):(A=c,x=l,I=d,D=u,B=_,L=g,k=b,W=m)),E===0)return null;let U=A/E,z=x/E,q=1/E,V=I-U*N,Z=D-z*N,K=B-U*F,lt=L-z*F,rt=k-U*O,H=W-z*O,Q=rt*lt-H*K,ut=V*H-Z*rt,It=K*Z-lt*V;if(s){if(Q<0||ut<0||It<0)return null}else if((Q<0||ut<0||It<0)&&(Q>0||ut>0||It>0))return null;let ft=Q+ut+It;if(ft===0)return null;let Ut=q*(Q*N+ut*F+It*O);return(ft>0?Ut<0:Ut>0)?null:this.at(Ut/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}},Su=new Yt,Ni=new Bi,co=new Oe,wu=new R,ho=new R,uo=new R,fo=new R,sc=new R,po=new R,Eu=new R,mo=new R,me=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))&&(Su.copy(r).invert(),Ni.copy(t.ray).applyMatrix4(Su),!(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,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,_=d.length;g<_;g++){let p=d[g],m=o[p.materialIndex],b=Math.max(p.start,f.start),w=Math.min(a.count,Math.min(p.start+p.count,f.start+f.count));for(let S=b,v=w;Se.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=Pm(i,t,e,n,ho,uo,fo,Eu);if(h){let u=new R;ni.getBarycoord(Eu,ho,uo,fo,u),s&&(h.uv=ni.getInterpolatedAttribute(s,a,l,c,u,new Wt)),r&&(h.uv1=ni.getInterpolatedAttribute(r,a,l,c,u,new Wt)),o&&(h.normal=ni.getInterpolatedAttribute(o,a,l,c,u,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:l,c,normal:new R,materialIndex:0};ni.getNormal(ho,uo,fo,d.normal),h.face=d,h.barycoord=u}return h}var mn=class extends We{constructor(t=null,e=1,n=1,s,r,o,a,l,c=Le,h=Le,u,d){super(null,o,a,l,c,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var ri=class extends _e{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,Tu=new Yt,_o=[],Au=new se,Lm=new Yt,Ks=new me,Js=new Oe,xi=class extends me{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 R,Xo=new R,Ru=new Yt,js=new Bi,vo=new Oe,rc=new R,Cu=new R,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:Cu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Iu=new R,Pu=new R,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,u=1){if(h!==Bn&&h!==wi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:t,height:e,depth:u};super(d,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},u=[h,h,h,h,h,h];super(t,t,e,n,s,r,o,a,l,c),this.image=u,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=[],u=[],d=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(u,2));function g(_,p,m,b,w,S,v,y,A,x,E){let I=S/A,D=v/x,N=S/2,B=v/2,L=y/2,F=A+1,k=x+1,W=0,O=0,U=new R;for(let z=0;z0?1:-1,h.push(U.x,U.y,U.z),u.push(V/A),u.push(1-z/x),W+=1}}for(let z=0;z0&&w(!0),e>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new we(u,3)),this.setAttribute("normal",new we(d,3)),this.setAttribute("uv",new we(f,2));function b(){let S=new R,v=new R,y=0,A=(e-t)/n;for(let x=0;x<=r;x++){let E=[],I=x/r,D=I*(e-t)+t;for(let N=0;N<=s;N++){let B=N/s,L=B*l+a,F=Math.sin(L),k=Math.cos(L);v.x=D*F,v.y=-I*n+p,v.z=D*k,u.push(v.x,v.y,v.z),S.set(F,A,k).normalize(),d.push(S.x,S.y,S.z),f.push(B,1-I),E.push(g++)}_.push(E)}for(let x=0;x0||E!==0)&&(h.push(I,D,B),y+=3),(e>0||E!==r-1)&&(h.push(D,N,B),y+=3)}c.addGroup(m,y,0),m+=y}function w(S){let v=g,y=new Wt,A=new R,x=0,E=S===!0?t:e,I=S===!0?1:-1;for(let N=1;N<=s;N++)u.push(0,p*I,0),d.push(0,I,0),f.push(.5,.5),g++;let D=g;for(let N=0;N<=s;N++){let L=N/s*l+a,F=Math.cos(L),k=Math.sin(L);A.x=E*k,A.y=p*I,A.z=E*F,u.push(A.x,A.y,A.z),d.push(0,I,0),y.x=F*.5+.5,y.y=k*.5*I+.5,f.push(y.x,y.y),g++}for(let N=0;N0)&&f.push(w,S,y),(m!==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 Ht().setHex(s.value);break;case"v2":this.uniforms[n].value=new Gt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new P().fromArray(s.value);break;case"v4":this.uniforms[n].value=new xe().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Yt().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}},Wo=class extends Ue{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var cr=class extends Mn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ht(16777215),this.specular=new Ht(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Tr,this.normalScale=new Gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Fn,this.combine=_r,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 ws=class extends Mn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Tr,this.normalScale=new Gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Fn,this.combine=_r,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}},Xo=class extends Mn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rd,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}},qo=class extends Mn{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 as(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function ec(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var xi=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&&(Wt("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Wt("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)){Wt("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Wt("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(s!==void 0&&Gp(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Wt("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()===Eo,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,ec(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Au(i,t){for(let e=0,n=i.length;e!==n;e+=2)i[e]*=t}cn.prototype.ValueTypeName="";cn.prototype.TimeBufferType=Float32Array;cn.prototype.ValueBufferType=Float32Array;cn.prototype.DefaultInterpolation=Fo;var vi=class extends cn{constructor(t,e,n){super(t,e,n)}};vi.prototype.ValueTypeName="bool";vi.prototype.ValueBufferType=Array;vi.prototype.DefaultInterpolation=Ks;vi.prototype.InterpolantFactoryMethodLinear=void 0;vi.prototype.InterpolantFactoryMethodSmooth=void 0;var Ko=class extends cn{constructor(t,e,n,s){super(t,e,n,s)}};Ko.prototype.ValueTypeName="color";var jo=class extends cn{constructor(t,e,n,s){super(t,e,n,s)}};jo.prototype.ValueTypeName="number";var Qo=class extends xi{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)De.slerpFlat(r,0,o,c-a,o,c,l);return r}},hr=class extends cn{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new Qo(this.times,this.values,this.getValueSize(),t)}};hr.prototype.ValueTypeName="quaternion";hr.prototype.InterpolantFactoryMethodSmooth=void 0;var yi=class extends cn{constructor(t,e,n){super(t,e,n)}};yi.prototype.ValueTypeName="string";yi.prototype.ValueBufferType=Array;yi.prototype.DefaultInterpolation=Ks;yi.prototype.InterpolantFactoryMethodLinear=void 0;yi.prototype.InterpolantFactoryMethodSmooth=void 0;var ta=class extends cn{constructor(t,e,n,s){super(t,e,n,s)}};ta.prototype.ValueTypeName="vector";var Ao={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(Ru(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Ru(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Ru(i){try{let t=i.slice(i.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}var ea=class{constructor(t,e,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;df.start-m.start);let u=0;for(let f=1;f0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new kt().setHex(s.value);break;case"v2":this.uniforms[n].value=new Wt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new R().fromArray(s.value);break;case"v4":this.uniforms[n].value=new xe().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Zt().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=fd,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&&jp(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 Uu(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&&(Fu(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Fu(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Fu(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,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;uf.start-g.start);let d=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`,ig=`#if NUM_CLIPPING_PLANES > 0 +#endif`,dg=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,sg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,fg=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,rg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,pg=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,og=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,mg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; -#endif`,ag=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,gg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; -#endif`,lg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,_g=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; -#endif`,cg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,xg=`#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`,hg=`#define PI 3.141592653589793 +#endif`,vg=`#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`,ug=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,yg=`#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`,dg=`vec3 transformedNormal = objectNormal; +#endif`,Mg=`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`,fg=`#ifdef USE_DISPLACEMENTMAP +#endif`,bg=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,pg=`#ifdef USE_DISPLACEMENTMAP +#endif`,Sg=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,mg=`#ifdef USE_EMISSIVEMAP +#endif`,wg=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,gg=`#ifdef USE_EMISSIVEMAP +#endif`,Eg=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,_g="gl_FragColor = linearToOutputTexel( gl_FragColor );",xg=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,Tg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ag=`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 ); -}`,vg=`#ifdef USE_ENVMAP +}`,Rg=`#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`,yg=`#ifdef USE_ENVMAP +#endif`,Cg=`#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`,Mg=`#ifdef USE_ENVMAP +#endif`,Ig=`#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`,bg=`#ifdef USE_ENVMAP +#endif`,Pg=`#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`,Sg=`#ifdef USE_ENVMAP +#endif`,Lg=`#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`,wg=`#ifdef USE_FOG +#endif`,Dg=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,Eg=`#ifdef USE_FOG +#endif`,Ng=`#ifdef USE_FOG varying float vFogDepth; -#endif`,Tg=`#ifdef USE_FOG +#endif`,Ug=`#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`,Ag=`#ifdef USE_FOG +#endif`,Fg=`#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`,Rg=`#ifdef USE_GRADIENTMAP +#endif`,Bg=`#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 -}`,Cg=`#ifdef USE_LIGHTMAP +}`,Og=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,Ig=`LambertMaterial material; +#endif`,zg=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,Pg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,kg=`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`,Lg=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Hg=`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 `,Dg=`#ifdef USE_ENVMAP +#include `,Vg=`#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`,Ng=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Ug=`varying vec3 vViewPosition; +#endif`,Gg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Wg=`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`,Fg=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Xg=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,Bg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,qg=`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`,Og=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Yg=`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`,zg=`uniform sampler2D dfgLUT; +#endif`,$g=`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 ); -}`,kg=` +}`,Zg=` 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`,Hg=`#if defined( RE_IndirectDiffuse ) +#endif`,Kg=`#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`,Vg=`#if defined( RE_IndirectDiffuse ) +#endif`,Jg=`#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`,Gg=`#ifdef USE_LIGHT_PROBES_GRID +#endif`,jg=`#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`,Wg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,Qg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,Xg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,t0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,qg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,e0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,Yg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,n0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,$g=`#ifdef USE_MAP +#endif`,i0=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,Zg=`#ifdef USE_MAP +#endif`,s0=`#ifdef USE_MAP uniform sampler2D map; -#endif`,Jg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,r0=`#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`,Kg=`#if defined( USE_POINTS_UV ) +#endif`,o0=`#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`,jg=`float metalnessFactor = metalness; +#endif`,a0=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,Qg=`#ifdef USE_METALNESSMAP +#endif`,l0=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,t_=`#ifdef USE_INSTANCING_MORPH +#endif`,c0=`#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`,e_=`#if defined( USE_MORPHCOLORS ) +#endif`,h0=`#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`,n_=`#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`,i_=`#ifdef USE_MORPHTARGETS +#endif`,d0=`#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`,s_=`#ifdef USE_MORPHTARGETS +#endif`,f0=`#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`,r_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,p0=`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;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,m0=`#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;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,a_=`#ifndef FLAT_SHADED +#endif`,g0=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,l_=`#ifndef FLAT_SHADED +#endif`,_0=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,c_=`#ifndef FLAT_SHADED +#endif`,x0=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,h_=`#ifdef USE_NORMALMAP +#endif`,v0=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,u_=`#ifdef USE_CLEARCOAT +#endif`,y0=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,d_=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,M0=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,f_=`#ifdef USE_CLEARCOATMAP +#endif`,b0=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,p_=`#ifdef USE_IRIDESCENCEMAP +#endif`,S0=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,m_=`#ifdef OPAQUE +#endif`,w0=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,g_=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,E0=`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 -}`,__=`#ifdef PREMULTIPLIED_ALPHA +}`,T0=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,x_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,A0=`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;`,v_=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,R0=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,y_=`#ifdef DITHERING +#endif`,C0=`#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`,M_=`float roughnessFactor = roughness; +#endif`,I0=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,b_=`#ifdef USE_ROUGHNESSMAP +#endif`,P0=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,S_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,L0=`#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;`,v_=`#ifdef DITHERING } #endif #endif -#endif`,w_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,D0=`#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;`,v_=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,E_=`#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`,N0=`#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;`,v_=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,T_=`float getShadowMask() { +#endif`,U0=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,v_=`#ifdef DITHERING #endif #endif return shadow; -}`,A_=`#ifdef USE_SKINNING +}`,F0=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,R_=`#ifdef USE_SKINNING +#endif`,B0=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,v_=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,C_=`#ifdef USE_SKINNING +#endif`,O0=`#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;`,v_=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,I_=`#ifdef USE_SKINNING +#endif`,z0=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,v_=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,P_=`float specularStrength; +#endif`,k0=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,L_=`#ifdef USE_SPECULARMAP +#endif`,H0=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,D_=`#if defined( TONE_MAPPING ) +#endif`,V0=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,N_=`#ifndef saturate +#endif`,G0=`#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; }`,U_=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,W0=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,U_=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,F_=`#ifdef USE_TRANSMISSION +#endif`,X0=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,U_=`#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`,B_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,q0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,U_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,O_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Y0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,U_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,$0=`#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; }`,U_=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,k_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,Z0=`#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; }`,U_=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,H_=`varying vec2 vUv; +#endif`,K0=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,V_=`uniform sampler2D t2D; +}`,J0=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2780,14 +2780,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,G_=`varying vec3 vWorldDirection; +}`,j0=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,W_=`#ifdef ENVMAP_TYPE_CUBE +}`,Q0=`#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 -}`,X_=`varying vec3 vWorldDirection; +}`,t_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,q_=`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 -}`,Y_=`#include +}`,n_=`#include #include #include #include @@ -2853,7 +2853,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,$_=`#if DEPTH_PACKING == 3200 +}`,i_=`#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 -}`,Z_=`#define DISTANCE +}`,s_=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2918,7 +2918,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,J_=`#define DISTANCE +}`,r_=`#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 ); -}`,K_=`varying vec3 vWorldDirection; +}`,o_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,j_=`uniform sampler2D tEquirect; +}`,a_=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2956,7 +2956,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,Q_=`uniform float scale; +}`,l_=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2978,7 +2978,7 @@ void main() { #include #include #include -}`,t0=`uniform vec3 diffuse; +}`,c_=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3006,7 +3006,7 @@ void main() { #include #include #include -}`,e0=`#include +}`,h_=`#include #include #include #include @@ -3038,7 +3038,7 @@ void main() { #include #include #include -}`,n0=`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 -}`,i0=`#define LAMBERT +}`,d_=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3125,7 +3125,7 @@ void main() { #include #include #include -}`,s0=`#define LAMBERT +}`,f_=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3183,7 +3183,7 @@ void main() { #include #include #include -}`,r0=`#define MATCAP +}`,p_=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3217,7 +3217,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,o0=`#define MATCAP +}`,m_=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3263,7 +3263,7 @@ void main() { #include #include #include -}`,a0=`#define NORMAL +}`,g_=`#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 -}`,l0=`#define NORMAL +}`,__=`#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 -}`,c0=`#define PHONG +}`,x_=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3356,7 +3356,7 @@ void main() { #include #include #include -}`,h0=`#define PHONG +}`,v_=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3416,7 +3416,7 @@ void main() { #include #include #include -}`,u0=`#define STANDARD +}`,y_=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3459,7 +3459,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,d0=`#define STANDARD +}`,M_=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3587,7 +3587,7 @@ void main() { #include #include #include -}`,f0=`#define TOON +}`,b_=`#define TOON varying vec3 vViewPosition; #include #include @@ -3624,7 +3624,7 @@ void main() { #include #include #include -}`,p0=`#define TOON +}`,S_=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3676,7 +3676,7 @@ void main() { #include #include #include -}`,m0=`uniform float size; +}`,w_=`uniform float size; uniform float scale; #include #include @@ -3707,7 +3707,7 @@ void main() { #include #include #include -}`,g0=`uniform vec3 diffuse; +}`,E_=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3732,7 +3732,7 @@ void main() { #include #include #include -}`,_0=`#include +}`,T_=`#include #include #include #include @@ -3755,7 +3755,7 @@ void main() { #include #include #include -}`,x0=`uniform vec3 color; +}`,A_=`uniform vec3 color; uniform float opacity; #include #include @@ -3771,7 +3771,7 @@ void main() { #include #include #include -}`,v0=`uniform float rotation; +}`,R_=`uniform float rotation; uniform vec2 center; #include #include @@ -3795,7 +3795,7 @@ void main() { #include #include #include -}`,y0=`uniform vec3 diffuse; +}`,C_=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3820,7 +3820,7 @@ void main() { #include #include #include -}`,jt={alphahash_fragment:Hm,alphahash_pars_fragment:Vm,alphamap_fragment:Gm,alphamap_pars_fragment:Wm,alphatest_fragment:Xm,alphatest_pars_fragment:qm,aomap_fragment:Ym,aomap_pars_fragment:$m,batching_pars_vertex:Zm,batching_vertex:Jm,begin_vertex:Km,beginnormal_vertex:jm,bsdfs:Qm,iridescence_fragment:tg,bumpmap_pars_fragment:eg,clipping_planes_fragment:ng,clipping_planes_pars_fragment:ig,clipping_planes_pars_vertex:sg,clipping_planes_vertex:rg,color_fragment:og,color_pars_fragment:ag,color_pars_vertex:lg,color_vertex:cg,common:hg,cube_uv_reflection_fragment:ug,defaultnormal_vertex:dg,displacementmap_pars_vertex:fg,displacementmap_vertex:pg,emissivemap_fragment:mg,emissivemap_pars_fragment:gg,colorspace_fragment:_g,colorspace_pars_fragment:xg,envmap_fragment:vg,envmap_common_pars_fragment:yg,envmap_pars_fragment:Mg,envmap_pars_vertex:bg,envmap_physical_pars_fragment:Dg,envmap_vertex:Sg,fog_vertex:wg,fog_pars_vertex:Eg,fog_fragment:Tg,fog_pars_fragment:Ag,gradientmap_pars_fragment:Rg,lightmap_pars_fragment:Cg,lights_lambert_fragment:Ig,lights_lambert_pars_fragment:Pg,lights_pars_begin:Lg,lights_toon_fragment:Ng,lights_toon_pars_fragment:Ug,lights_phong_fragment:Fg,lights_phong_pars_fragment:Bg,lights_physical_fragment:Og,lights_physical_pars_fragment:zg,lights_fragment_begin:kg,lights_fragment_maps:Hg,lights_fragment_end:Vg,lightprobes_pars_fragment:Gg,logdepthbuf_fragment:Wg,logdepthbuf_pars_fragment:Xg,logdepthbuf_pars_vertex:qg,logdepthbuf_vertex:Yg,map_fragment:$g,map_pars_fragment:Zg,map_particle_fragment:Jg,map_particle_pars_fragment:Kg,metalnessmap_fragment:jg,metalnessmap_pars_fragment:Qg,morphinstance_vertex:t_,morphcolor_vertex:e_,morphnormal_vertex:n_,morphtarget_pars_vertex:i_,morphtarget_vertex:s_,normal_fragment_begin:r_,normal_fragment_maps:o_,normal_pars_fragment:a_,normal_pars_vertex:l_,normal_vertex:c_,normalmap_pars_fragment:h_,clearcoat_normal_fragment_begin:u_,clearcoat_normal_fragment_maps:d_,clearcoat_pars_fragment:f_,iridescence_pars_fragment:p_,opaque_fragment:m_,packing:g_,premultiplied_alpha_fragment:__,project_vertex:x_,dithering_fragment:v_,dithering_pars_fragment:y_,roughnessmap_fragment:M_,roughnessmap_pars_fragment:b_,shadowmap_pars_fragment:S_,shadowmap_pars_vertex:w_,shadowmap_vertex:E_,shadowmask_pars_fragment:T_,skinbase_vertex:A_,skinning_pars_vertex:R_,skinning_vertex:C_,skinnormal_vertex:I_,specularmap_fragment:P_,specularmap_pars_fragment:L_,tonemapping_fragment:D_,tonemapping_pars_fragment:N_,transmission_fragment:U_,transmission_pars_fragment:F_,uv_pars_fragment:B_,uv_pars_vertex:O_,uv_vertex:z_,worldpos_vertex:k_,background_vert:H_,background_frag:V_,backgroundCube_vert:G_,backgroundCube_frag:W_,cube_vert:X_,cube_frag:q_,depth_vert:Y_,depth_frag:$_,distance_vert:Z_,distance_frag:J_,equirect_vert:K_,equirect_frag:j_,linedashed_vert:Q_,linedashed_frag:t0,meshbasic_vert:e0,meshbasic_frag:n0,meshlambert_vert:i0,meshlambert_frag:s0,meshmatcap_vert:r0,meshmatcap_frag:o0,meshnormal_vert:a0,meshnormal_frag:l0,meshphong_vert:c0,meshphong_frag:h0,meshphysical_vert:u0,meshphysical_frag:d0,meshtoon_vert:f0,meshtoon_frag:p0,points_vert:m0,points_frag:g0,shadow_vert:_0,shadow_frag:x0,sprite_vert:v0,sprite_frag:y0},Mt={common:{diffuse:{value:new Ht(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yt}},envmap:{envMap:{value:null},envMapRotation:{value:new Yt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yt},normalScale:{value:new Gt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ht(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 P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new Ht(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0},uvTransform:{value:new Yt}},sprite:{diffuse:{value:new Ht(16777215)},opacity:{value:1},center:{value:new Gt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}}},Yn={basic:{uniforms:je([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:je([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,Mt.lights,{emissive:{value:new Ht(0)},envMapIntensity:{value:1}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:je([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,Mt.lights,{emissive:{value:new Ht(0)},specular:{value:new Ht(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:je([Mt.common,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.roughnessmap,Mt.metalnessmap,Mt.fog,Mt.lights,{emissive:{value:new Ht(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:je([Mt.common,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.gradientmap,Mt.fog,Mt.lights,{emissive:{value:new Ht(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:je([Mt.common,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:je([Mt.points,Mt.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:je([Mt.common,Mt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:je([Mt.common,Mt.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:je([Mt.common,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:je([Mt.sprite,Mt.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new Yt},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 Yt}},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:je([Mt.common,Mt.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jt.distance_vert,fragmentShader:jt.distance_frag},shadow:{uniforms:je([Mt.lights,Mt.fog,{color:{value:new Ht(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};Yn.physical={uniforms:je([Yn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yt},clearcoatNormalScale:{value:new Gt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yt},sheen:{value:0},sheenColor:{value:new Ht(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yt},transmissionSamplerSize:{value:new Gt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yt},attenuationDistance:{value:0},attenuationColor:{value:new Ht(0)},specularColor:{value:new Ht(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yt},anisotropyVector:{value:new Gt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yt}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};var $a={r:0,b:0,g:0},M0=new Zt,Wd=new Yt;Wd.set(-1,0,0,0,1,0,0,0,1);function b0(i,t,e,n,s,r){let o=new Ht(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(M){let T=M.isScene===!0?M.background:null;if(T&&T.isTexture){let S=M.backgroundBlurriness>0;T=t.get(T,S)}return T}function m(M){let T=!1,S=f(M);S===null?g(o,a):S&&S.isColor&&(g(S,1),T=!0);let v=i.xr.getEnvironmentBlendMode();v==="additive"?e.buffers.color.setClear(0,0,0,1,r):v==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(M,T){let S=f(T);S&&(S.isCubeTexture||S.mapping===xr)?(c===void 0&&(c=new pe(new pn(1,1,1),new Ue({name:"BackgroundCubeMaterial",uniforms:Gi(Yn.backgroundCube.uniforms),vertexShader:Yn.backgroundCube.vertexShader,fragmentShader:Yn.backgroundCube.fragmentShader,side:Be,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(v,b,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=S,c.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(M0.makeRotationFromEuler(T.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Wd),c.material.toneMapped=ee.getTransfer(S.colorSpace)!==ue,(h!==S||d!==S.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)):S&&S.isTexture&&(l===void 0&&(l=new pe(new ln(2,2),new Ue({name:"BackgroundMaterial",uniforms:Gi(Yn.background.uniforms),vertexShader:Yn.background.vertexShader,fragmentShader:Yn.background.fragmentShader,side:Wn,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=S,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.toneMapped=ee.getTransfer(S.colorSpace)!==ue,S.matrixAutoUpdate===!0&&S.updateMatrix(),l.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||d!==S.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null))}function g(M,T){M.getRGB($a,Oc(i)),e.buffers.color.setClear($a.r,$a.g,$a.b,T,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(M,T=1){o.set(M),a=T,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,g(o,a)},render:m,addToRenderList:_,dispose:p}}function S0(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(D,N,B,L,U){let W=!1,V=d(D,L,B,N);r!==V&&(r=V,c(r.object)),W=f(D,L,B,U),W&&m(D,L,B,U),U!==null&&t.update(U,i.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,S(D,N,B,L),U!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(U).buffer))}function l(){return i.createVertexArray()}function c(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function d(D,N,B,L){let U=L.wireframe===!0,W=n[N.id];W===void 0&&(W={},n[N.id]=W);let V=D.isInstancedMesh===!0?D.id:0,O=W[V];O===void 0&&(O={},W[V]=O);let F=O[B.id];F===void 0&&(F={},O[B.id]=F);let G=F[U];return G===void 0&&(G=u(l()),F[U]=G),G}function u(D){let N=[],B=[],L=[];for(let U=0;U=0){let Y=U[F],z=W[F];if(z===void 0&&(F==="instanceMatrix"&&D.instanceMatrix&&(z=D.instanceMatrix),F==="instanceColor"&&D.instanceColor&&(z=D.instanceColor)),Y===void 0||Y.attribute!==z||z&&Y.data!==z.data)return!0;V++}return r.attributesNum!==V||r.index!==L}function m(D,N,B,L){let U={},W=N.attributes,V=0,O=B.getAttributes();for(let F in O)if(O[F].location>=0){let Y=W[F];Y===void 0&&(F==="instanceMatrix"&&D.instanceMatrix&&(Y=D.instanceMatrix),F==="instanceColor"&&D.instanceColor&&(Y=D.instanceColor));let z={};z.attribute=Y,Y&&Y.data&&(z.data=Y.data),U[F]=z,V++}r.attributes=U,r.attributesNum=V,r.index=L}function _(){let D=r.newAttributes;for(let N=0,B=D.length;N=0){let G=U[O];if(G===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(G=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(G=D.instanceColor)),G!==void 0){let Y=G.normalized,z=G.itemSize,$=t.get(G);if($===void 0)continue;let nt=$.buffer,lt=$.type,at=$.bytesPerElement,X=lt===i.INT||lt===i.UNSIGNED_INT||G.gpuType===ha;if(G.isInterleavedBufferAttribute){let tt=G.data,ht=tt.stride,Rt=G.offset;if(tt.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&&(kt("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&&kt("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),M=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),v=i.getParameter(i.MAX_SAMPLES),b=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:M,maxVaryings:T,maxFragmentUniforms:S,maxSamples:v,samples:b}}function T0(i){let t=this,e=null,n=0,s=!1,r=!1,o=new Te,a=new Yt,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 M=r?0:n,T=M*4,S=p.clippingState||null;l.value=S,S=h(m,u,T,f);for(let v=0;v!==T;++v)S[v]=e[v];p.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=M}};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,M=u.matrixWorldInverse;a.getNormalMatrix(M),(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=Ed(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=wd(),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?v:0,v,v),d.setRenderTarget(s),p&&d.render(_,l),d.render(t,l)}d.toneMapping=f,d.autoClear=u,t.background=M}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===Mi||t.mapping===Vi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ed()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=wd());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;Ls(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Rr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rm-Ds?n-m+Ds:0),p=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=m-e,Ls(r,g,p,3*_,2*_),s.setRenderTarget(r),s.render(a,Rr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-n,Ls(t,g,p,3*_,2*_),s.setRenderTarget(t),s.render(a,Rr)}_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-Ds?s-this._lodMax+Ds:0),u=4*(this._cubeSize-h);Ls(e,d,u,3*h,2*h),o.setRenderTarget(e),o.render(l,Rr)}};function P0(i){let t=[],e=[],n=i,s=i-Ds+1+A0;for(let r=0;r2?0:-1,S=[M,T,0,M+2/3,T,0,M+2/3,T+1,0,M,T,0,M+2/3,T+1,0,M,T+1,0];m.set(S,f*u*p);for(let v=0;vDs&&n--}return{lodMeshes:e,sizeLods:t}}function Sd(i,t,e){let n=new Ne(i,t,e);return n.texture.mapping=xr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ls(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function L0(i,t,e){return new Ue({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:C0,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:ja(),fragmentShader:` +}`,Qt={alphahash_fragment:Km,alphahash_pars_fragment:Jm,alphamap_fragment:jm,alphamap_pars_fragment:Qm,alphatest_fragment:tg,alphatest_pars_fragment:eg,aomap_fragment:ng,aomap_pars_fragment:ig,batching_pars_vertex:sg,batching_vertex:rg,begin_vertex:og,beginnormal_vertex:ag,bsdfs:lg,iridescence_fragment:cg,bumpmap_pars_fragment:hg,clipping_planes_fragment:ug,clipping_planes_pars_fragment:dg,clipping_planes_pars_vertex:fg,clipping_planes_vertex:pg,color_fragment:mg,color_pars_fragment:gg,color_pars_vertex:_g,color_vertex:xg,common:vg,cube_uv_reflection_fragment:yg,defaultnormal_vertex:Mg,displacementmap_pars_vertex:bg,displacementmap_vertex:Sg,emissivemap_fragment:wg,emissivemap_pars_fragment:Eg,colorspace_fragment:Tg,colorspace_pars_fragment:Ag,envmap_fragment:Rg,envmap_common_pars_fragment:Cg,envmap_pars_fragment:Ig,envmap_pars_vertex:Pg,envmap_physical_pars_fragment:Vg,envmap_vertex:Lg,fog_vertex:Dg,fog_pars_vertex:Ng,fog_fragment:Ug,fog_pars_fragment:Fg,gradientmap_pars_fragment:Bg,lightmap_pars_fragment:Og,lights_lambert_fragment:zg,lights_lambert_pars_fragment:kg,lights_pars_begin:Hg,lights_toon_fragment:Gg,lights_toon_pars_fragment:Wg,lights_phong_fragment:Xg,lights_phong_pars_fragment:qg,lights_physical_fragment:Yg,lights_physical_pars_fragment:$g,lights_fragment_begin:Zg,lights_fragment_maps:Kg,lights_fragment_end:Jg,lightprobes_pars_fragment:jg,logdepthbuf_fragment:Qg,logdepthbuf_pars_fragment:t0,logdepthbuf_pars_vertex:e0,logdepthbuf_vertex:n0,map_fragment:i0,map_pars_fragment:s0,map_particle_fragment:r0,map_particle_pars_fragment:o0,metalnessmap_fragment:a0,metalnessmap_pars_fragment:l0,morphinstance_vertex:c0,morphcolor_vertex:h0,morphnormal_vertex:u0,morphtarget_pars_vertex:d0,morphtarget_vertex:f0,normal_fragment_begin:p0,normal_fragment_maps:m0,normal_pars_fragment:g0,normal_pars_vertex:_0,normal_vertex:x0,normalmap_pars_fragment:v0,clearcoat_normal_fragment_begin:y0,clearcoat_normal_fragment_maps:M0,clearcoat_pars_fragment:b0,iridescence_pars_fragment:S0,opaque_fragment:w0,packing:E0,premultiplied_alpha_fragment:T0,project_vertex:A0,dithering_fragment:R0,dithering_pars_fragment:C0,roughnessmap_fragment:I0,roughnessmap_pars_fragment:P0,shadowmap_pars_fragment:L0,shadowmap_pars_vertex:D0,shadowmap_vertex:N0,shadowmask_pars_fragment:U0,skinbase_vertex:F0,skinning_pars_vertex:B0,skinning_vertex:O0,skinnormal_vertex:z0,specularmap_fragment:k0,specularmap_pars_fragment:H0,tonemapping_fragment:V0,tonemapping_pars_fragment:G0,transmission_fragment:W0,transmission_pars_fragment:X0,uv_pars_fragment:q0,uv_pars_vertex:Y0,uv_vertex:$0,worldpos_vertex:Z0,background_vert:K0,background_frag:J0,backgroundCube_vert:j0,backgroundCube_frag:Q0,cube_vert:t_,cube_frag:e_,depth_vert:n_,depth_frag:i_,distance_vert:s_,distance_frag:r_,equirect_vert:o_,equirect_frag:a_,linedashed_vert:l_,linedashed_frag:c_,meshbasic_vert:h_,meshbasic_frag:u_,meshlambert_vert:d_,meshlambert_frag:f_,meshmatcap_vert:p_,meshmatcap_frag:m_,meshnormal_vert:g_,meshnormal_frag:__,meshphong_vert:x_,meshphong_frag:v_,meshphysical_vert:y_,meshphysical_frag:M_,meshtoon_vert:b_,meshtoon_frag:S_,points_vert:w_,points_frag:E_,shadow_vert:T_,shadow_frag:A_,sprite_vert:R_,sprite_frag:C_},bt={common:{diffuse:{value:new kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Zt},alphaMap:{value:null},alphaMapTransform:{value:new Zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Zt}},envmap:{envMap:{value:null},envMapRotation:{value:new Zt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Zt},normalScale:{value:new Wt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Zt}},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 R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Zt},alphaTest:{value:0},uvTransform:{value:new Zt}},sprite:{diffuse:{value:new kt(16777215)},opacity:{value:1},center:{value:new Wt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Zt},alphaMap:{value:null},alphaMapTransform:{value:new Zt},alphaTest:{value:0}}},Zn={basic:{uniforms:Qe([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:Qt.meshbasic_vert,fragmentShader:Qt.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:Qt.meshlambert_vert,fragmentShader:Qt.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:Qt.meshphong_vert,fragmentShader:Qt.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:Qt.meshphysical_vert,fragmentShader:Qt.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:Qt.meshtoon_vert,fragmentShader:Qt.meshtoon_frag},matcap:{uniforms:Qe([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:Qt.meshmatcap_vert,fragmentShader:Qt.meshmatcap_frag},points:{uniforms:Qe([bt.points,bt.fog]),vertexShader:Qt.points_vert,fragmentShader:Qt.points_frag},dashed:{uniforms:Qe([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qt.linedashed_vert,fragmentShader:Qt.linedashed_frag},depth:{uniforms:Qe([bt.common,bt.displacementmap]),vertexShader:Qt.depth_vert,fragmentShader:Qt.depth_frag},normal:{uniforms:Qe([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:Qt.meshnormal_vert,fragmentShader:Qt.meshnormal_frag},sprite:{uniforms:Qe([bt.sprite,bt.fog]),vertexShader:Qt.sprite_vert,fragmentShader:Qt.sprite_frag},background:{uniforms:{uvTransform:{value:new Zt},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 Zt}},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([bt.common,bt.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qt.distance_vert,fragmentShader:Qt.distance_frag},shadow:{uniforms:Qe([bt.lights,bt.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:Qt.shadow_vert,fragmentShader:Qt.shadow_frag}};Zn.physical={uniforms:Qe([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Zt},clearcoatNormalScale:{value:new Wt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Zt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Zt},sheen:{value:0},sheenColor:{value:new kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Zt},transmissionSamplerSize:{value:new Wt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Zt},attenuationDistance:{value:0},attenuationColor:{value:new kt(0)},specularColor:{value:new kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Zt},anisotropyVector:{value:new Wt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Zt}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag};var Ja={r:0,b:0,g:0},I_=new Yt,jd=new Zt;jd.set(-1,0,0,0,1,0,0,0,1);function P_(i,t,e,n,s,r){let o=new kt(0),a=s===!0?0:1,l,c,h=null,u=0,d=null;function f(b){let w=b.isScene===!0?b.background:null;if(w&&w.isTexture){let S=b.backgroundBlurriness>0;w=t.get(w,S)}return w}function g(b){let w=!1,S=f(b);S===null?p(o,a):S&&S.isColor&&(p(S,1),w=!0);let v=i.xr.getEnvironmentBlendMode();v==="additive"?e.buffers.color.setClear(0,0,0,1,r):v==="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 _(b,w){let S=f(w);S&&(S.isCubeTexture||S.mapping===yr)?(c===void 0&&(c=new me(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(v,y,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=S,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(I_.makeRotationFromEuler(w.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(jd),c.material.toneMapped=ne.getTransfer(S.colorSpace)!==de,(h!==S||u!==S.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):S&&S.isTexture&&(l===void 0&&(l=new me(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=S,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=ne.getTransfer(S.colorSpace)!==de,S.matrixAutoUpdate===!0&&S.updateMatrix(),l.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||u!==S.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function p(b,w){b.getRGB(Ja,Wc(i)),e.buffers.color.setClear(Ja.r,Ja.g,Ja.b,w,r)}function m(){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(b,w=1){o.set(b),a=w,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(b){a=b,p(o,a)},render:g,addToRenderList:_,dispose:m}}function L_(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null),r=s,o=!1;function a(D,N,B,L,F){let k=!1,W=u(D,L,B,N);r!==W&&(r=W,c(r.object)),k=f(D,L,B,F),k&&g(D,L,B,F),F!==null&&t.update(F,i.ELEMENT_ARRAY_BUFFER),(k||o)&&(o=!1,S(D,N,B,L),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(F).buffer))}function l(){return i.createVertexArray()}function c(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function u(D,N,B,L){let F=L.wireframe===!0,k=n[N.id];k===void 0&&(k={},n[N.id]=k);let W=D.isInstancedMesh===!0?D.id:0,O=k[W];O===void 0&&(O={},k[W]=O);let U=O[B.id];U===void 0&&(U={},O[B.id]=U);let z=U[F];return z===void 0&&(z=d(l()),U[F]=z),z}function d(D){let N=[],B=[],L=[];for(let F=0;F=0){let q=F[U],V=k[U];if(V===void 0&&(U==="instanceMatrix"&&D.instanceMatrix&&(V=D.instanceMatrix),U==="instanceColor"&&D.instanceColor&&(V=D.instanceColor)),q===void 0||q.attribute!==V||V&&q.data!==V.data)return!0;W++}return r.attributesNum!==W||r.index!==L}function g(D,N,B,L){let F={},k=N.attributes,W=0,O=B.getAttributes();for(let U in O)if(O[U].location>=0){let q=k[U];q===void 0&&(U==="instanceMatrix"&&D.instanceMatrix&&(q=D.instanceMatrix),U==="instanceColor"&&D.instanceColor&&(q=D.instanceColor));let V={};V.attribute=q,q&&q.data&&(V.data=q.data),F[U]=V,W++}r.attributes=F,r.attributesNum=W,r.index=L}function _(){let D=r.newAttributes;for(let N=0,B=D.length;N=0){let z=F[O];if(z===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(z=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(z=D.instanceColor)),z!==void 0){let q=z.normalized,V=z.itemSize,Z=t.get(z);if(Z===void 0)continue;let K=Z.buffer,lt=Z.type,rt=Z.bytesPerElement,H=lt===i.INT||lt===i.UNSIGNED_INT||z.gpuType===fa;if(z.isInterleavedBufferAttribute){let Q=z.data,ut=Q.stride,It=z.offset;if(Q.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 u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!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),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),m=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),v=i.getParameter(i.MAX_SAMPLES),y=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:b,maxVaryings:w,maxFragmentUniforms:S,maxSamples:v,samples:y}}function U_(i){let t=this,e=null,n=0,s=!1,r=!1,o=new Ae,a=new Zt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){let g=u.clippingPlanes,_=u.clipIntersection,p=u.clipShadows,m=i.get(u);if(!s||g===null||g.length===0||r&&!p)r?h(null):c();else{let b=r?0:n,w=b*4,S=m.clippingState||null;l.value=S,S=h(g,d,w,f);for(let v=0;v!==w;++v)S[v]=e[v];m.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){let _=u!==null?u.length:0,p=null;if(_!==0){if(p=l.value,g!==!0||p===null){let m=f+_*4,b=d.matrixWorldInverse;a.getNormalMatrix(b),(p===null||p.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=Dd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ld(),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?v:0,v,v),u.setRenderTarget(s),m&&u.render(_,l),u.render(t,l)}u.toneMapping=f,u.autoClear=d,t.background=b}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===bi||t.mapping===Wi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Dd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ld());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),m=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=g-e,Ns(r,p,m,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,p,m,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],u=3*h*(s>this._lodMax-Us?s-this._lodMax+Us:0),d=4*(this._cubeSize-h);Ns(e,u,d,3*h,2*h),o.setRenderTarget(e),o.render(l,Ir)}};function k_(i){let t=[],e=[],n=i,s=i-Us+1+F_;for(let r=0;r2?0:-1,S=[b,w,0,b+2/3,w,0,b+2/3,w+1,0,b,w,0,b+2/3,w+1,0,b,w+1,0];g.set(S,f*d*m);for(let v=0;vUs&&n--}return{lodMeshes:e,sizeLods:t}}function Pd(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 H_(i,t,e){return new Ie({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:O_,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:` precision highp float; precision highp int; @@ -3924,7 +3924,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:Xn,depthTest:!1,depthWrite:!1})}function D0(i,t,e){return new Ue({name:"SphericalGaussianBlur",defines:{SAMPLES:R0,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:ja(),fragmentShader:` + `,blending:Yn,depthTest:!1,depthWrite:!1})}function V_(i,t,e){return new Ie({name:"SphericalGaussianBlur",defines:{SAMPLES:B_,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:` precision highp float; precision highp int; @@ -3984,7 +3984,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `,blending:Xn,depthTest:!1,depthWrite:!1})}function wd(){return new Ue({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ja(),fragmentShader:` + `,blending:Yn,depthTest:!1,depthWrite:!1})}function Ld(){return new Ie({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:el(),fragmentShader:` precision mediump float; precision mediump int; @@ -4003,7 +4003,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:Xn,depthTest:!1,depthWrite:!1})}function Ed(){return new Ue({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ja(),fragmentShader:` + `,blending:Yn,depthTest:!1,depthWrite:!1})}function Dd(){return new Ie({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:el(),fragmentShader:` precision mediump float; precision mediump int; @@ -4019,7 +4019,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:Xn,depthTest:!1,depthWrite:!1})}function ja(){return` + `,blending:Yn,depthTest:!1,depthWrite:!1})}function el(){return` precision mediump float; precision mediump int; @@ -4034,7 +4034,7 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}var Ka=class extends Ne{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 rr(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 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:` varying vec3 vWorldDirection; @@ -4069,7 +4069,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},s=new pn(5,5,5),r=new Ue({name:"CubemapFromEquirect",uniforms:Gi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Be,blending:Xn});r.uniforms.tEquirect.value=e;let o=new pe(s,r),a=e.minFilter;return e.minFilter===bi&&(e.minFilter=qe),new sa(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 N0(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===aa||f===la)if(t.has(u)){let m=t.get(u).texture;return a(m,u.mapping)}else{let m=u.image;if(m&&m.height>0){let _=new Ka(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===aa||f===la,_=f===Mi||f===Vi;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 Ja(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 M=u.image;return m&&M&&M.height>0||_&&M&&l(M)?(n===null&&(n=new Ja(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===aa?u.mapping=Mi:f===la&&(u.mapping=Vi),u}function l(u){let f=0,m=6;for(let _=0;_=65535?ir:nr)(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&&(v=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize);let b=new Float32Array(S*v*4*d),A=new er(b,S,v,d);A.type=Ye,A.needsUpdate=!0;let x=T*4;for(let R=0;R0){let _=new tl(g.height);return _.fromEquirectangularTexture(i,d),t.set(d,_),d.addEventListener("dispose",c),a(_.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){let f=d.mapping,g=f===ha||f===ua,_=f===bi||f===Wi;if(g||_){let p=e.get(d),m=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==m)return n===null&&(n=new Qa(i)),p=g?n.fromEquirectangular(d,p):n.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,e.set(d,p),p.texture;if(p!==void 0)return p.texture;{let b=d.image;return g&&b&&b.height>0||_&&b&&l(b)?(n===null&&(n=new Qa(i)),p=g?n.fromEquirectangular(d):n.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,e.set(d,p),d.addEventListener("dispose",h),p.texture):null}}}return d}function a(d,f){return f===ha?d.mapping=bi:f===ua&&(d.mapping=Wi),d}function l(d){let f=0,g=6;for(let _=0;_=65535?or:rr)(d,1);p.version=_;let m=r.get(u);m&&t.remove(m),r.set(u,p)}function h(u){let d=r.get(u);if(d){let f=u.index;f!==null&&d.versiont.maxTextureSize&&(v=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize);let y=new Float32Array(S*v*4*u),A=new sr(y,S,v,u);A.type=Ye,A.needsUpdate=!0;let x=w*4;for(let I=0;I0&&M[0].isRenderPass===!0;let v=o.width,b=o.height;M.length>0&&a===null&&(a=new Ne(v,b,{type:Tn,depthBuffer:!1,stencilBuffer:!1}),l=new Ne(v,b,{type:Tn,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=Td[s];if(r===void 0&&(r=new Float32Array(s),Td[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 ze(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 Ld(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var Ix=37297,Px=0;function Lx(i,t){let e=i.split(` + }`,depthTest:!1,depthWrite:!1}),u=new me(c,h),d=new Wn(-1,1,1,-1,0,1),f=null,g=null,_=!1,p,m=null,b=[],w=!1;this.setSize=function(S,v){o.setSize(S,v),a!==null&&a.setSize(S,v),l!==null&&l.setSize(S,v);for(let y=0;y0&&b[0].isRenderPass===!0;let v=o.width,y=o.height;b.length>0&&a===null&&(a=new Be(v,y,{type:An,depthBuffer:!1,stencilBuffer:!1}),l=new Be(v,y,{type:An,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=Nd[s];if(r===void 0&&(r=new Float32Array(s),Nd[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 kd(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var zx=37297,kx=0;function Hx(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 Dd=new Yt;function Dx(i){ee._getMatrix(Dd,ee.workingColorSpace,i);let t=`mat3( ${Dd.elements.map(e=>e.toFixed(4))} )`;switch(ee.getTransfer(i)){case Qs:return[t,"LinearTransferOETF"];case ue:return[t,"sRGBTransferOETF"];default:return kt("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Nd(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 Hd=new Zt;function Vx(i){ne._getMatrix(Hd,ne.workingColorSpace,i);let t=`mat3( ${Hd.elements.map(e=>e.toFixed(4))} )`;switch(ne.getTransfer(i)){case nr:return[t,"LinearTransferOETF"];case de:return[t,"sRGBTransferOETF"];default:return Ht("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Vd(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+` -`+Lx(i.getShaderSource(t),a)}else return r}function Nx(i,t){let e=Dx(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` -`)}var Ux={[xc]:"Linear",[vc]:"Reinhard",[yc]:"Cineon",[Mc]:"ACESFilmic",[Sc]:"AgX",[wc]:"Neutral",[bc]:"Custom"};function Fx(i,t){let e=Ux[t];return e===void 0?(kt("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var Za=new P;function Bx(){ee.getLuminanceCoefficients(Za);let i=Za.x.toFixed(4),t=Za.y.toFixed(4),e=Za.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(` -`)}function Ox(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ir).join(` -`)}function zx(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` -`)}function kx(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function ih(i){return i.replace(Hx,Gx)}var Vx=new Map;function Gx(i,t){let e=jt[t];if(e===void 0){let n=Vx.get(t);if(n!==void 0)e=jt[n],kt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return ih(e)}var Wx=/#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 Bd(i){return i.replace(Wx,Xx)}function Xx(i,t,e,n){let s="";for(let r=parseInt(t);r/gm;function ch(i){return i.replace(Kx,jx)}var Jx=new Map;function jx(i,t){let e=Qt[t];if(e===void 0){let n=Jx.get(t);if(n!==void 0)e=Qt[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 Qx=/#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 Xd(i){return i.replace(Qx,tv)}function tv(i,t,e,n){let s="";for(let r=parseInt(t);r0&&(g+=` -`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Ir).join(` +#define LOW_PRECISION`),t}var ev={[xr]:"SHADOWMAP_TYPE_PCF",[Cs]:"SHADOWMAP_TYPE_VSM"};function nv(i){return ev[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var iv={[bi]:"ENVMAP_TYPE_CUBE",[Wi]:"ENVMAP_TYPE_CUBE",[yr]:"ENVMAP_TYPE_CUBE_UV"};function sv(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":iv[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var rv={[Wi]:"ENVMAP_MODE_REFRACTION"};function ov(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":rv[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var av={[vr]:"ENVMAP_BLENDING_MULTIPLY",[hd]:"ENVMAP_BLENDING_MIX",[ud]:"ENVMAP_BLENDING_ADD"};function lv(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":av[i.combine]||"ENVMAP_BLENDING_NONE"}function cv(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 hv(i,t,e,n){let s=i.getContext(),r=e.defines,o=e.vertexShader,a=e.fragmentShader,l=nv(e),c=sv(e),h=ov(e),u=lv(e),d=cv(e),f=Yx(e),g=$x(r),_=s.createProgram(),p,m,b=e.glslVersion?"#version "+e.glslVersion+` +`:"";e.isRawShaderMaterial?(p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Lr).join(` `),p.length>0&&(p+=` -`)):(g=[Od(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(Ir).join(` -`),p=[Od(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!==wn?"#define TONE_MAPPING":"",e.toneMapping!==wn?jt.tonemapping_pars_fragment:"",e.toneMapping!==wn?Fx("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",jt.colorspace_pars_fragment,Nx("linearToOutputTexel",e.outputColorSpace),Bx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` -`].filter(Ir).join(` -`)),o=ih(o),o=Ud(o,e),o=Fd(o,e),a=ih(a),a=Ud(a,e),a=Fd(a,e),o=Bd(o),a=Bd(a),e.isRawShaderMaterial!==!0&&(M=`#version 300 es -`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`),m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Lr).join(` +`),m.length>0&&(m+=` +`)):(p=[qd(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(` +`),m=[qd(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 "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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?Xx("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Qt.colorspace_pars_fragment,Gx("linearToOutputTexel",e.outputColorSpace),qx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(Lr).join(` +`)),o=ch(o),o=Gd(o,e),o=Wd(o,e),a=ch(a),a=Gd(a,e),a=Wd(a,e),o=Xd(o),a=Xd(a),e.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+g,p=["#define varying in",e.glslVersion===Fc?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Fc?"":"#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,m=["#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(` `)+` -`+p);let T=M+g+o,S=M+p+a,v=Ld(s,s.VERTEX_SHADER,T),b=Ld(s,s.FRAGMENT_SHADER,S);s.attachShader(_,v),s.attachShader(_,b),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(D){if(i.debug.checkShaderErrors){let N=s.getProgramInfoLog(_)||"",B=s.getShaderInfoLog(v)||"",L=s.getShaderInfoLog(b)||"",U=N.trim(),W=B.trim(),V=L.trim(),O=!0,F=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(O=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,v,b);else{let G=Nd(s,v,"vertex"),Y=Nd(s,b,"fragment");Wt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` +`+m);let w=b+p+o,S=b+m+a,v=kd(s,s.VERTEX_SHADER,w),y=kd(s,s.FRAGMENT_SHADER,S);s.attachShader(_,v),s.attachShader(_,y),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(D){if(i.debug.checkShaderErrors){let N=s.getProgramInfoLog(_)||"",B=s.getShaderInfoLog(v)||"",L=s.getShaderInfoLog(y)||"",F=N.trim(),k=B.trim(),W=L.trim(),O=!0,U=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(O=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,v,y);else{let z=Vd(s,v,"vertex"),q=Vd(s,y,"fragment");Xt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` Material Name: `+D.name+` Material Type: `+D.type+` -Program Info Log: `+U+` -`+G+` -`+Y)}else U!==""?kt("WebGLProgram: Program Info Log:",U):(W===""||V==="")&&(F=!1);F&&(D.diagnostics={runnable:O,programLog:U,vertexShader:{log:W,prefix:g},fragmentShader:{log:V,prefix:p}})}s.deleteShader(v),s.deleteShader(b),x=new Ns(s,_),w=kx(s,_)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};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(_,Ix)),R},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Px++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=v,this.fragmentShader=b,this}var nv=0,sh=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 rh(t),e.set(t,n)),n}},rh=class{constructor(t){this.id=nv++,this.code=t,this.usedTimes=0}};function iv(i){return i===wi||i===wr||i===Er}function sv(i,t,e,n,s,r){let o=new ys,a=new sh,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(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,w,R,D,N,B){let L=D.fog,U=N.geometry,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,V=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=t.get(x.envMap||W,V),F=O&&O.mapping===xr?O.image.height:null,G=f[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&kt("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));let Y=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,z=Y!==void 0?Y.length:0,$=0;U.morphAttributes.position!==void 0&&($=1),U.morphAttributes.normal!==void 0&&($=2),U.morphAttributes.color!==void 0&&($=3);let nt,lt,at,X;if(G){let ve=Yn[G];nt=ve.vertexShader,lt=ve.fragmentShader}else{nt=x.vertexShader,lt=x.fragmentShader;let ve=a.getVertexShaderStage(x),ce=a.getFragmentShaderStage(x);a.update(x,ve,ce),at=ve.id,X=ce.id}let tt=i.getRenderTarget(),ht=i.state.buffers.depth.getReversed(),Rt=N.isInstancedMesh===!0,ft=N.isBatchedMesh===!0,Ot=!!x.map,Ct=!!x.matcap,It=!!O,Xt=!!x.aoMap,$t=!!x.lightMap,qt=!!x.bumpMap&&x.wireframe===!1,Qt=!!x.normalMap,ie=!!x.displacementMap,ge=!!x.emissiveMap,dt=!!x.metalnessMap,zt=!!x.roughnessMap,I=x.anisotropy>0,ut=x.clearcoat>0,Et=x.dispersion>0,C=x.retroreflectivity>0,y=x.iridescence>0,q=x.sheen>0,j=x.transmission>0,it=I&&!!x.anisotropyMap,pt=ut&&!!x.clearcoatMap,mt=ut&&!!x.clearcoatNormalMap,st=ut&&!!x.clearcoatRoughnessMap,ot=y&&!!x.iridescenceMap,gt=y&&!!x.iridescenceThicknessMap,Ut=q&&!!x.sheenColorMap,yt=q&&!!x.sheenRoughnessMap,_t=!!x.specularMap,Ft=!!x.specularColorMap,Vt=!!x.specularIntensityMap,Jt=j&&!!x.transmissionMap,H=j&&!!x.thicknessMap,xt=!!x.gradientMap,rt=!!x.alphaMap,vt=x.alphaTest>0,wt=!!x.alphaHash,ct=!!x.extensions,Bt=wn;x.toneMapped&&(tt===null||tt.isXRRenderTarget===!0)&&(Bt=i.toneMapping);let Dt={shaderID:G,shaderType:x.type,shaderName:x.name,vertexShader:nt,fragmentShader:lt,defines:x.defines,customVertexShaderID:at,customFragmentShaderID:X,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:ft,batchingColor:ft&&N._colorsTexture!==null,instancing:Rt,instancingColor:Rt&&N.instanceColor!==null,instancingMorph:Rt&&N.morphTexture!==null,outputColorSpace:tt===null?i.outputColorSpace:tt.isXRRenderTarget===!0?tt.texture.colorSpace:ee.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ot,matcap:Ct,envMap:It,envMapMode:It&&O.mapping,envMapCubeUVHeight:F,aoMap:Xt,lightMap:$t,bumpMap:qt,normalMap:Qt,displacementMap:ie,emissiveMap:ge,normalMapObjectSpace:Qt&&x.normalMapType===od,normalMapTangentSpace:Qt&&x.normalMapType===Tr,packedNormalMap:Qt&&x.normalMapType===Tr&&iv(x.normalMap.format),metalnessMap:dt,roughnessMap:zt,anisotropy:I,anisotropyMap:it,clearcoat:ut,clearcoatMap:pt,clearcoatNormalMap:mt,clearcoatRoughnessMap:st,dispersion:Et,retroreflection:C,iridescence:y,iridescenceMap:ot,iridescenceThicknessMap:gt,sheen:q,sheenColorMap:Ut,sheenRoughnessMap:yt,specularMap:_t,specularColorMap:Ft,specularIntensityMap:Vt,transmission:j,transmissionMap:Jt,thicknessMap:H,gradientMap:xt,opaque:x.transparent===!1&&x.blending===Rs&&x.alphaToCoverage===!1,alphaMap:rt,alphaTest:vt,alphaHash:wt,combine:x.combine,mapUv:Ot&&m(x.map.channel),aoMapUv:Xt&&m(x.aoMap.channel),lightMapUv:$t&&m(x.lightMap.channel),bumpMapUv:qt&&m(x.bumpMap.channel),normalMapUv:Qt&&m(x.normalMap.channel),displacementMapUv:ie&&m(x.displacementMap.channel),emissiveMapUv:ge&&m(x.emissiveMap.channel),metalnessMapUv:dt&&m(x.metalnessMap.channel),roughnessMapUv:zt&&m(x.roughnessMap.channel),anisotropyMapUv:it&&m(x.anisotropyMap.channel),clearcoatMapUv:pt&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:mt&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:st&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:ot&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:gt&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ut&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:yt&&m(x.sheenRoughnessMap.channel),specularMapUv:_t&&m(x.specularMap.channel),specularColorMapUv:Ft&&m(x.specularColorMap.channel),specularIntensityMapUv:Vt&&m(x.specularIntensityMap.channel),transmissionMapUv:Jt&&m(x.transmissionMap.channel),thicknessMapUv:H&&m(x.thicknessMap.channel),alphaMapUv:rt&&m(x.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(Qt||I),vertexNormals:!!U.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!U.attributes.uv&&(Ot||rt),fog:!!L,useFog:x.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||U.attributes.normal===void 0&&Qt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ht,skinning:N.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:$,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:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&R.length>0,shadowMapType:i.shadowMap.type,toneMapping:Bt,decodeVideoTexture:Ot&&x.map.isVideoTexture===!0&&ee.getTransfer(x.map.colorSpace)===ue,decodeVideoTextureEmissive:ge&&x.emissiveMap.isVideoTexture===!0&&ee.getTransfer(x.emissiveMap.colorSpace)===ue,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Oe,flipSided:x.side===Be,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ct&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ct&&x.extensions.multiDraw===!0||ft)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Dt.vertexUv1s=l.has(1),Dt.vertexUv2s=l.has(2),Dt.vertexUv3s=l.has(3),l.clear(),Dt}function g(x){let w=[];if(x.shaderID?w.push(x.shaderID):(w.push(x.customVertexShaderID),w.push(x.customFragmentShaderID)),x.defines!==void 0)for(let R in x.defines)w.push(R),w.push(x.defines[R]);return x.isRawShaderMaterial===!1&&(p(w,x),M(w,x),w.push(i.outputColorSpace)),w.push(x.customProgramCacheKey),w.join()}function p(x,w){x.push(w.precision),x.push(w.outputColorSpace),x.push(w.envMapMode),x.push(w.envMapCubeUVHeight),x.push(w.mapUv),x.push(w.alphaMapUv),x.push(w.lightMapUv),x.push(w.aoMapUv),x.push(w.bumpMapUv),x.push(w.normalMapUv),x.push(w.displacementMapUv),x.push(w.emissiveMapUv),x.push(w.metalnessMapUv),x.push(w.roughnessMapUv),x.push(w.anisotropyMapUv),x.push(w.clearcoatMapUv),x.push(w.clearcoatNormalMapUv),x.push(w.clearcoatRoughnessMapUv),x.push(w.iridescenceMapUv),x.push(w.iridescenceThicknessMapUv),x.push(w.sheenColorMapUv),x.push(w.sheenRoughnessMapUv),x.push(w.specularMapUv),x.push(w.specularColorMapUv),x.push(w.specularIntensityMapUv),x.push(w.transmissionMapUv),x.push(w.thicknessMapUv),x.push(w.combine),x.push(w.fogExp2),x.push(w.sizeAttenuation),x.push(w.morphTargetsCount),x.push(w.morphAttributeCount),x.push(w.numSunLights),x.push(w.numDirLights),x.push(w.numPointLights),x.push(w.numSpotLights),x.push(w.numSpotLightMaps),x.push(w.numHemiLights),x.push(w.numRectAreaLights),x.push(w.numSunLightShadows),x.push(w.numDirLightShadows),x.push(w.numPointLightShadows),x.push(w.numSpotLightShadows),x.push(w.numSpotLightShadowsWithMaps),x.push(w.numLightProbes),x.push(w.shadowMapType),x.push(w.toneMapping),x.push(w.numClippingPlanes),x.push(w.numClipIntersection),x.push(w.depthPacking)}function M(x,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),x.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),x.push(o.mask)}function T(x){let w=f[x.type],R;if(w){let D=Yn[w];R=vd.clone(D.uniforms)}else R=x.uniforms;return R}function S(x,w){let R=h.get(w);return R!==void 0?++R.usedTimes:(R=new ev(i,w,x,s),c.push(R),h.set(w,R)),R}function v(x){if(--x.usedTimes===0){let w=c.indexOf(x);c[w]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){a.remove(x)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:g,getUniforms:T,acquireProgram:S,releaseProgram:v,releaseShaderCache:b,programs:c,dispose:A}}function rv(){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 ov(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 zd(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 kd(){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 M=i[t];return M===void 0?(M={id:u.id,object:u,geometry:f,material:m,materialVariant:o(u),groupOrder:_,renderOrder:u.renderOrder,z:g,group:p},i[t]=M):(M.id=u.id,M.object=u,M.geometry=f,M.material=m,M.materialVariant=o(u),M.groupOrder=_,M.renderOrder=u.renderOrder,M.z=g,M.group=p),t++,M}function l(u,f,m,_,g,p,M){M.reversedDepth===!0&&(g=-g);let T=a(u,f,m,_,g,p);m.transmission>0?n.push(T):m.transparent===!0?s.push(T):e.push(T)}function c(u,f,m,_,g,p){let M=a(u,f,m,_,g,p);m.transmission>0?n.unshift(M):m.transparent===!0?s.unshift(M):e.unshift(M)}function h(u,f){e.length>1&&e.sort(u||ov),n.length>1&&n.sort(f||zd),s.length>1&&s.sort(f||zd)}function d(){for(let u=t,f=i.length;u=r.length?(o=new kd,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function lv(){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 P,color:new Ht};break;case"SpotLight":e={position:new P,direction:new P,color:new Ht,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new Ht,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new Ht,groundColor:new Ht};break;case"RectAreaLight":e={color:new Ht,position:new P,halfWidth:new P,halfHeight:new P};break}return i[t.id]=e,e}}}function cv(){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 Gt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Gt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Gt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var hv=0;function uv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function dv(i){let t=new lv,e=cv(),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 P);let s=new P,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,M=0,T=0,S=0,v=0,b=0,A=0,x=0,w=0,R=0;c.sort(uv);for(let N=0,B=c.length;N0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Mt.LTC_FLOAT_1,n.rectAreaLTC2=Mt.LTC_FLOAT_2):(n.rectAreaLTC1=Mt.LTC_HALF_1,n.rectAreaLTC2=Mt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let D=n.hash;(D.sunLength!==f||D.directionalLength!==g||D.pointLength!==p||D.spotLength!==M||D.rectAreaLength!==T||D.hemiLength!==S||D.numSunShadows!==m||D.numDirectionalShadows!==v||D.numPointShadows!==b||D.numSpotShadows!==A||D.numSpotMaps!==x||D.numLightProbes!==R)&&(n.sun.length=f,n.directional.length=g,n.spot.length=M,n.rectArea.length=T,n.point.length=p,n.hemi.length=S,n.sunShadow.length=m,n.sunShadowMap.length=m,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.directionalShadowMatrix.length=v,n.pointShadow.length=b,n.pointShadowMap.length=b,n.pointShadowMatrix.length=b,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-w,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,D.sunLength=f,D.directionalLength=g,D.pointLength=p,D.spotLength=M,D.rectAreaLength=T,D.hemiLength=S,D.numSunShadows=m,D.numDirectionalShadows=v,D.numPointShadows=b,D.numSpotShadows=A,D.numSpotMaps=x,D.numLightProbes=R,n.version=hv++)}function l(c,h){let d=0,u=0,f=0,m=0,_=0,g=0,p=h.matrixWorldInverse;for(let M=0,T=c.length;M=o.length?(a=new Hd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var pv=`void main() { +Program Info Log: `+F+` +`+z+` +`+q)}else F!==""?Ht("WebGLProgram: Program Info Log:",F):(k===""||W==="")&&(U=!1);U&&(D.diagnostics={runnable:O,programLog:F,vertexShader:{log:k,prefix:p},fragmentShader:{log:W,prefix:m}})}s.deleteShader(v),s.deleteShader(y),x=new Fs(s,_),E=Zx(s,_)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let E;this.getAttributes=function(){return E===void 0&&A(this),E};let I=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,zx)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=kx++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=v,this.fragmentShader=y,this}var uv=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=uv++,this.code=t,this.usedTimes=0}};function dv(i){return i===Ei||i===Tr||i===Ar}function fv(i,t,e,n,s,r){let o=new bs,a=new hh,l=new Set,c=[],h=new Map,u=n.logarithmicDepthBuffer,d=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(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,E,I,D,N,B){let L=D.fog,F=N.geometry,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=t.get(x.envMap||k,W),U=O&&O.mapping===yr?O.image.height:null,z=f[x.type];x.precision!==null&&(d=n.getMaxPrecision(x.precision),d!==x.precision&&Ht("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));let q=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,V=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 K,lt,rt,H;if(z){let be=Zn[z];K=be.vertexShader,lt=be.fragmentShader}else{K=x.vertexShader,lt=x.fragmentShader;let be=a.getVertexShaderStage(x),he=a.getFragmentShaderStage(x);a.update(x,be,he),rt=be.id,H=he.id}let Q=i.getRenderTarget(),ut=i.state.buffers.depth.getReversed(),It=N.isInstancedMesh===!0,ft=N.isBatchedMesh===!0,Ut=!!x.map,ae=!!x.matcap,Gt=!!O,Jt=!!x.aoMap,mt=!!x.lightMap,Ct=!!x.bumpMap&&x.wireframe===!1,$t=!!x.normalMap,qt=!!x.displacementMap,Me=!!x.emissiveMap,dt=!!x.metalnessMap,Ft=!!x.roughnessMap,C=x.anisotropy>0,ht=x.clearcoat>0,Tt=x.dispersion>0,P=x.retroreflectivity>0,M=x.iridescence>0,Y=x.sheen>0,tt=x.transmission>0,it=C&&!!x.anisotropyMap,pt=ht&&!!x.clearcoatMap,gt=ht&&!!x.clearcoatNormalMap,st=ht&&!!x.clearcoatRoughnessMap,at=M&&!!x.iridescenceMap,_t=M&&!!x.iridescenceThicknessMap,Bt=Y&&!!x.sheenColorMap,Mt=Y&&!!x.sheenRoughnessMap,xt=!!x.specularMap,Ot=!!x.specularColorMap,Vt=!!x.specularIntensityMap,Kt=tt&&!!x.transmissionMap,X=tt&&!!x.thicknessMap,vt=!!x.gradientMap,ot=!!x.alphaMap,yt=x.alphaTest>0,Et=!!x.alphaHash,ct=!!x.extensions,zt=En;x.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(zt=i.toneMapping);let Dt={shaderID:z,shaderType:x.type,shaderName:x.name,vertexShader:K,fragmentShader:lt,defines:x.defines,customVertexShaderID:rt,customFragmentShaderID:H,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:ft,batchingColor:ft&&N._colorsTexture!==null,instancing:It,instancingColor:It&&N.instanceColor!==null,instancingMorph:It&&N.morphTexture!==null,outputColorSpace:Q===null?i.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:ne.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ut,matcap:ae,envMap:Gt,envMapMode:Gt&&O.mapping,envMapCubeUVHeight:U,aoMap:Jt,lightMap:mt,bumpMap:Ct,normalMap:$t,displacementMap:qt,emissiveMap:Me,normalMapObjectSpace:$t&&x.normalMapType===pd,normalMapTangentSpace:$t&&x.normalMapType===Rr,packedNormalMap:$t&&x.normalMapType===Rr&&dv(x.normalMap.format),metalnessMap:dt,roughnessMap:Ft,anisotropy:C,anisotropyMap:it,clearcoat:ht,clearcoatMap:pt,clearcoatNormalMap:gt,clearcoatRoughnessMap:st,dispersion:Tt,retroreflection:P,iridescence:M,iridescenceMap:at,iridescenceThicknessMap:_t,sheen:Y,sheenColorMap:Bt,sheenRoughnessMap:Mt,specularMap:xt,specularColorMap:Ot,specularIntensityMap:Vt,transmission:tt,transmissionMap:Kt,thicknessMap:X,gradientMap:vt,opaque:x.transparent===!1&&x.blending===Is&&x.alphaToCoverage===!1,alphaMap:ot,alphaTest:yt,alphaHash:Et,combine:x.combine,mapUv:Ut&&g(x.map.channel),aoMapUv:Jt&&g(x.aoMap.channel),lightMapUv:mt&&g(x.lightMap.channel),bumpMapUv:Ct&&g(x.bumpMap.channel),normalMapUv:$t&&g(x.normalMap.channel),displacementMapUv:qt&&g(x.displacementMap.channel),emissiveMapUv:Me&&g(x.emissiveMap.channel),metalnessMapUv:dt&&g(x.metalnessMap.channel),roughnessMapUv:Ft&&g(x.roughnessMap.channel),anisotropyMapUv:it&&g(x.anisotropyMap.channel),clearcoatMapUv:pt&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:gt&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:st&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:at&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:_t&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:Bt&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&g(x.sheenRoughnessMap.channel),specularMapUv:xt&&g(x.specularMap.channel),specularColorMapUv:Ot&&g(x.specularColorMap.channel),specularIntensityMapUv:Vt&&g(x.specularIntensityMap.channel),transmissionMapUv:Kt&&g(x.transmissionMap.channel),thicknessMapUv:X&&g(x.thicknessMap.channel),alphaMapUv:ot&&g(x.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&($t||C),vertexNormals:!!F.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!F.attributes.uv&&(Ut||ot),fog:!!L,useFog:x.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||F.attributes.normal===void 0&&$t===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:ut,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:V,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:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:zt,decodeVideoTexture:Ut&&x.map.isVideoTexture===!0&&ne.getTransfer(x.map.colorSpace)===de,decodeVideoTextureEmissive:Me&&x.emissiveMap.isVideoTexture===!0&&ne.getTransfer(x.emissiveMap.colorSpace)===de,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===ke,flipSided:x.side===ze,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ct&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ct&&x.extensions.multiDraw===!0||ft)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Dt.vertexUv1s=l.has(1),Dt.vertexUv2s=l.has(2),Dt.vertexUv3s=l.has(3),l.clear(),Dt}function p(x){let E=[];if(x.shaderID?E.push(x.shaderID):(E.push(x.customVertexShaderID),E.push(x.customFragmentShaderID)),x.defines!==void 0)for(let I in x.defines)E.push(I),E.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(m(E,x),b(E,x),E.push(i.outputColorSpace)),E.push(x.customProgramCacheKey),E.join()}function m(x,E){x.push(E.precision),x.push(E.outputColorSpace),x.push(E.envMapMode),x.push(E.envMapCubeUVHeight),x.push(E.mapUv),x.push(E.alphaMapUv),x.push(E.lightMapUv),x.push(E.aoMapUv),x.push(E.bumpMapUv),x.push(E.normalMapUv),x.push(E.displacementMapUv),x.push(E.emissiveMapUv),x.push(E.metalnessMapUv),x.push(E.roughnessMapUv),x.push(E.anisotropyMapUv),x.push(E.clearcoatMapUv),x.push(E.clearcoatNormalMapUv),x.push(E.clearcoatRoughnessMapUv),x.push(E.iridescenceMapUv),x.push(E.iridescenceThicknessMapUv),x.push(E.sheenColorMapUv),x.push(E.sheenRoughnessMapUv),x.push(E.specularMapUv),x.push(E.specularColorMapUv),x.push(E.specularIntensityMapUv),x.push(E.transmissionMapUv),x.push(E.thicknessMapUv),x.push(E.combine),x.push(E.fogExp2),x.push(E.sizeAttenuation),x.push(E.morphTargetsCount),x.push(E.morphAttributeCount),x.push(E.numSunLights),x.push(E.numDirLights),x.push(E.numPointLights),x.push(E.numSpotLights),x.push(E.numSpotLightMaps),x.push(E.numHemiLights),x.push(E.numRectAreaLights),x.push(E.numSunLightShadows),x.push(E.numDirLightShadows),x.push(E.numPointLightShadows),x.push(E.numSpotLightShadows),x.push(E.numSpotLightShadowsWithMaps),x.push(E.numLightProbes),x.push(E.shadowMapType),x.push(E.toneMapping),x.push(E.numClippingPlanes),x.push(E.numClipIntersection),x.push(E.depthPacking)}function b(x,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),x.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),x.push(o.mask)}function w(x){let E=f[x.type],I;if(E){let D=Zn[E];I=Ad.clone(D.uniforms)}else I=x.uniforms;return I}function S(x,E){let I=h.get(E);return I!==void 0?++I.usedTimes:(I=new hv(i,E,x,s),c.push(I),h.set(E,I)),I}function v(x){if(--x.usedTimes===0){let E=c.indexOf(x);c[E]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function y(x){a.remove(x)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:w,acquireProgram:S,releaseProgram:v,releaseShaderCache:y,programs:c,dispose:A}}function pv(){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 mv(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 Yd(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 $d(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function o(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function a(d,f,g,_,p,m){let b=i[t];return b===void 0?(b={id:d.id,object:d,geometry:f,material:g,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:m},i[t]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=g,b.materialVariant=o(d),b.groupOrder=_,b.renderOrder=d.renderOrder,b.z=p,b.group=m),t++,b}function l(d,f,g,_,p,m,b){b.reversedDepth===!0&&(p=-p);let w=a(d,f,g,_,p,m);g.transmission>0?n.push(w):g.transparent===!0?s.push(w):e.push(w)}function c(d,f,g,_,p,m){let b=a(d,f,g,_,p,m);g.transmission>0?n.unshift(b):g.transparent===!0?s.unshift(b):e.unshift(b)}function h(d,f){e.length>1&&e.sort(d||mv),n.length>1&&n.sort(f||Yd),s.length>1&&s.sort(f||Yd)}function u(){for(let d=t,f=i.length;d=r.length?(o=new $d,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function _v(){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 R,color:new kt};break;case"SpotLight":e={position:new R,direction:new R,color:new kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new kt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new kt,groundColor:new kt};break;case"RectAreaLight":e={color:new kt,position:new R,halfWidth:new R,halfHeight:new R};break}return i[t.id]=e,e}}}function xv(){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 vv=0;function yv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Mv(i){let t=new _v,e=xv(),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 R);let s=new R,r=new Yt,o=new Yt;function a(c){let h=0,u=0,d=0;for(let N=0;N<9;N++)n.probe[N].set(0,0,0);let f=0,g=0,_=0,p=0,m=0,b=0,w=0,S=0,v=0,y=0,A=0,x=0,E=0,I=0;c.sort(yv);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]=u,n.ambient[2]=d;let D=n.hash;(D.sunLength!==f||D.directionalLength!==p||D.pointLength!==m||D.spotLength!==b||D.rectAreaLength!==w||D.hemiLength!==S||D.numSunShadows!==g||D.numDirectionalShadows!==v||D.numPointShadows!==y||D.numSpotShadows!==A||D.numSpotMaps!==x||D.numLightProbes!==I)&&(n.sun.length=f,n.directional.length=p,n.spot.length=b,n.rectArea.length=w,n.point.length=m,n.hemi.length=S,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.directionalShadowMatrix.length=v,n.pointShadow.length=y,n.pointShadowMap.length=y,n.pointShadowMatrix.length=y,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-E,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=I,D.sunLength=f,D.directionalLength=p,D.pointLength=m,D.spotLength=b,D.rectAreaLength=w,D.hemiLength=S,D.numSunShadows=g,D.numDirectionalShadows=v,D.numPointShadows=y,D.numSpotShadows=A,D.numSpotMaps=x,D.numLightProbes=I,n.version=vv++)}function l(c,h){let u=0,d=0,f=0,g=0,_=0,p=0,m=h.matrixWorldInverse;for(let b=0,w=c.length;b=o.length?(a=new Zd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var Sv=`void main() { gl_Position = vec4( position, 1.0 ); -}`,mv=`uniform sampler2D shadow_pass; +}`,wv=`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 ); -}`,gv=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],_v=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],Vd=new Zt,Cr=new P,jc=new P;function xv(i,t,e){let n=new On,s=new Gt,r=new Gt,o=new xe,a=new Xo,l=new qo,c={},h=e.maxTextureSize,d={[Wn]:Be,[Be]:Wn,[Oe]:Oe},u=new Ue({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Gt},radius:{value:4}},vertexShader:pv,fragmentShader:mv}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let m=new fe;m.setAttribute("position",new Ae(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new pe(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gr;let p=this.type;this.render=function(b,A,x){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;this.type===Bu&&(kt("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=gr);let w=i.getRenderTarget(),R=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),N=i.state;N.setBlending(Xn),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(L){L.material&&(Array.isArray(L.material)?L.material.forEach(U=>U.needsUpdate=!0):L.material.needsUpdate=!0)});for(let L=0,U=b.length;Lh||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 F=i.state.buffers.depth.getReversed();if(V.camera._reversedDepth=F,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===As){if(W.isPointLight){kt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new Ne(s.x,s.y,{format:wi,type:Tn,minFilter:qe,magFilter:qe,generateMipmaps:!1}),V.map.texture.name=W.name+".shadowMap",V.map.depthTexture=new kn(s.x,s.y,Ye),V.map.depthTexture.name=W.name+".shadowMapDepth",V.map.depthTexture.format=Nn,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ve,V.map.depthTexture.magFilter=Ve}else W.isPointLight?(V.map=new Ka(s.x),V.map.depthTexture=new Go(s.x,En)):(V.map=new Ne(s.x,s.y),V.map.depthTexture=new kn(s.x,s.y,En)),V.map.depthTexture.name=W.name+".shadowMap",V.map.depthTexture.format=Nn,this.type===gr?(V.map.depthTexture.compareFunction=F?Ya:qa,V.map.depthTexture.minFilter=qe,V.map.depthTexture.magFilter=qe):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ve,V.map.depthTexture.magFilter=Ve);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 G=V.map.isWebGLCubeRenderTarget?6:V.getViewportCount();W.isPointLight!==!0&&V.updateMatrices(W,x);for(let Y=0;Y0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let N=R.uuid,B=A.uuid,L=c[N];L===void 0&&(L={},c[N]=L);let U=L[B];U===void 0&&(U=R.clone(),L[B]=U,A.addEventListener("dispose",v)),R=U}if(R.visible=A.visible,R.wireframe=A.wireframe,w===As?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,x.isPointLight===!0&&R.isMeshDistanceMaterial===!0){let N=i.properties.get(R);N.light=x}return R}function S(b,A,x,w,R){if(b.visible===!1)return;if(b.layers.test(A.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&R===As)&&(!b.frustumCulled||b.intersectsFrustum(n))){b.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,b.matrixWorld);let B=t.update(b),L=b.material;if(Array.isArray(L)){let U=B.groups;for(let W=0,V=U.length;W=1):F.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),V=O>=2);let G=null,Y={},z=i.getParameter(i.SCISSOR_BOX),$=i.getParameter(i.VIEWPORT),nt=new xe().fromArray(z),lt=new xe().fromArray($);function at(H,xt,rt,vt){let wt=new Uint8Array(4),ct=i.createTexture();i.bindTexture(H,ct),i.texParameteri(H,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(H,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Bt=0;Bt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Gt,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 _(C,y){return m?new OffscreenCanvas(C,y):gs("canvas")}function g(C,y,q){let j=1,it=Et(C);if((it.width>q||it.height>q)&&(j=q/Math.max(it.width,it.height)),j<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){let pt=Math.floor(j*it.width),mt=Math.floor(j*it.height);u===void 0&&(u=_(pt,mt));let st=y?_(pt,mt):u;return st.width=pt,st.height=mt,st.getContext("2d").drawImage(C,0,0,pt,mt),kt("WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+pt+"x"+mt+")."),st}else return"data"in C&&kt("WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+")."),C;return C}function p(C){return C.generateMipmaps}function M(C){i.generateMipmap(C)}function T(C){return C.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?i.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(C,y,q,j,it,pt=!1){if(C!==null){if(i[C]!==void 0)return i[C];kt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let mt;j&&(mt=t.get("EXT_texture_norm16"),mt||kt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let st=y;if(y===i.RED&&(q===i.FLOAT&&(st=i.R32F),q===i.HALF_FLOAT&&(st=i.R16F),q===i.UNSIGNED_BYTE&&(st=i.R8),q===i.UNSIGNED_SHORT&&mt&&(st=mt.R16_EXT),q===i.SHORT&&mt&&(st=mt.R16_SNORM_EXT)),y===i.RED_INTEGER&&(q===i.UNSIGNED_BYTE&&(st=i.R8UI),q===i.UNSIGNED_SHORT&&(st=i.R16UI),q===i.UNSIGNED_INT&&(st=i.R32UI),q===i.BYTE&&(st=i.R8I),q===i.SHORT&&(st=i.R16I),q===i.INT&&(st=i.R32I)),y===i.RG&&(q===i.FLOAT&&(st=i.RG32F),q===i.HALF_FLOAT&&(st=i.RG16F),q===i.UNSIGNED_BYTE&&(st=i.RG8),q===i.UNSIGNED_SHORT&&mt&&(st=mt.RG16_EXT),q===i.SHORT&&mt&&(st=mt.RG16_SNORM_EXT)),y===i.RG_INTEGER&&(q===i.UNSIGNED_BYTE&&(st=i.RG8UI),q===i.UNSIGNED_SHORT&&(st=i.RG16UI),q===i.UNSIGNED_INT&&(st=i.RG32UI),q===i.BYTE&&(st=i.RG8I),q===i.SHORT&&(st=i.RG16I),q===i.INT&&(st=i.RG32I)),y===i.RGB_INTEGER&&(q===i.UNSIGNED_BYTE&&(st=i.RGB8UI),q===i.UNSIGNED_SHORT&&(st=i.RGB16UI),q===i.UNSIGNED_INT&&(st=i.RGB32UI),q===i.BYTE&&(st=i.RGB8I),q===i.SHORT&&(st=i.RGB16I),q===i.INT&&(st=i.RGB32I)),y===i.RGBA_INTEGER&&(q===i.UNSIGNED_BYTE&&(st=i.RGBA8UI),q===i.UNSIGNED_SHORT&&(st=i.RGBA16UI),q===i.UNSIGNED_INT&&(st=i.RGBA32UI),q===i.BYTE&&(st=i.RGBA8I),q===i.SHORT&&(st=i.RGBA16I),q===i.INT&&(st=i.RGBA32I)),y===i.RGB&&(q===i.UNSIGNED_SHORT&&mt&&(st=mt.RGB16_EXT),q===i.SHORT&&mt&&(st=mt.RGB16_SNORM_EXT),q===i.UNSIGNED_INT_5_9_9_9_REV&&(st=i.RGB9_E5),q===i.UNSIGNED_INT_10F_11F_11F_REV&&(st=i.R11F_G11F_B10F)),y===i.RGBA){let ot=pt?Qs:ee.getTransfer(it);q===i.FLOAT&&(st=i.RGBA32F),q===i.HALF_FLOAT&&(st=i.RGBA16F),q===i.UNSIGNED_BYTE&&(st=ot===ue?i.SRGB8_ALPHA8:i.RGBA8),q===i.UNSIGNED_SHORT&&mt&&(st=mt.RGBA16_EXT),q===i.SHORT&&mt&&(st=mt.RGBA16_SNORM_EXT),q===i.UNSIGNED_SHORT_4_4_4_4&&(st=i.RGBA4),q===i.UNSIGNED_SHORT_5_5_5_1&&(st=i.RGB5_A1)}return(st===i.R16F||st===i.R32F||st===i.RG16F||st===i.RG32F||st===i.RGBA16F||st===i.RGBA32F)&&t.get("EXT_color_buffer_float"),st}function v(C,y){let q;return C?y===null||y===En||y===Is?q=i.DEPTH24_STENCIL8:y===Ye?q=i.DEPTH32F_STENCIL8:y===Cs&&(q=i.DEPTH24_STENCIL8,kt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===En||y===Is?q=i.DEPTH_COMPONENT24:y===Ye?q=i.DEPTH_COMPONENT32F:y===Cs&&(q=i.DEPTH_COMPONENT16),q}function b(C,y){return p(C)===!0||C.isFramebufferTexture&&C.minFilter!==Ve&&C.minFilter!==qe?Math.log2(Math.max(y.width,y.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?y.mipmaps.length:1}function A(C){let y=C.target;y.removeEventListener("dispose",A),w(y),y.isVideoTexture&&h.delete(y),y.isHTMLTexture&&d.delete(y)}function x(C){let y=C.target;y.removeEventListener("dispose",x),D(y)}function w(C){let y=n.get(C);if(y.__webglInit===void 0)return;let q=C.source,j=f.get(q);if(j){let it=j[y.__cacheKey];it.usedTimes--,it.usedTimes===0&&R(C),Object.keys(j).length===0&&f.delete(q)}n.remove(C)}function R(C){let y=n.get(C);i.deleteTexture(y.__webglTexture);let q=C.source,j=f.get(q);delete j[y.__cacheKey],o.memory.textures--}function D(C){let y=n.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),n.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let j=0;j<6;j++){if(Array.isArray(y.__webglFramebuffer[j]))for(let it=0;it=s.maxTextures&&kt("WebGLTextures: Trying to use "+(C+1)+" texture units while this GPU supports only "+s.maxTextures),N+=1,C}function V(C){let y=[];return y.push(C.wrapS),y.push(C.wrapT),y.push(C.wrapR||0),y.push(C.magFilter),y.push(C.minFilter),y.push(C.anisotropy),y.push(C.internalFormat),y.push(C.format),y.push(C.type),y.push(C.generateMipmaps),y.push(C.premultiplyAlpha),y.push(C.flipY),y.push(C.unpackAlignment),y.push(C.colorSpace),y.join()}function O(C,y){let q=n.get(C);if(C.isVideoTexture&&I(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&q.__version!==C.version){let j=C.image;if(j===null)kt("WebGLRenderer: Texture marked for update but no image data found.");else if(j.complete===!1)kt("WebGLRenderer: Texture marked for update but image is incomplete");else{ht(q,C,y);return}}else C.isExternalTexture&&(q.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,q.__webglTexture,i.TEXTURE0+y)}function F(C,y){let q=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&q.__version!==C.version){ht(q,C,y);return}else C.isExternalTexture&&(q.__webglTexture=C.sourceTexture?C.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,q.__webglTexture,i.TEXTURE0+y)}function G(C,y){let q=n.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&q.__version!==C.version){ht(q,C,y);return}e.bindTexture(i.TEXTURE_3D,q.__webglTexture,i.TEXTURE0+y)}function Y(C,y){let q=n.get(C);if(C.isCubeDepthTexture!==!0&&C.version>0&&q.__version!==C.version){Rt(q,C,y);return}e.bindTexture(i.TEXTURE_CUBE_MAP,q.__webglTexture,i.TEXTURE0+y)}let z={[ps]:i.REPEAT,[Dn]:i.CLAMP_TO_EDGE,[Uo]:i.MIRRORED_REPEAT},$={[Ve]:i.NEAREST,[sd]:i.NEAREST_MIPMAP_NEAREST,[vr]:i.NEAREST_MIPMAP_LINEAR,[qe]:i.LINEAR,[ca]:i.LINEAR_MIPMAP_NEAREST,[bi]:i.LINEAR_MIPMAP_LINEAR},nt={[ld]:i.NEVER,[fd]:i.ALWAYS,[cd]:i.LESS,[qa]:i.LEQUAL,[hd]:i.EQUAL,[Ya]:i.GEQUAL,[ud]:i.GREATER,[dd]:i.NOTEQUAL};function lt(C,y){if(y.type===Ye&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===qe||y.magFilter===ca||y.magFilter===vr||y.magFilter===bi||y.minFilter===qe||y.minFilter===ca||y.minFilter===vr||y.minFilter===bi)&&kt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(C,i.TEXTURE_WRAP_S,z[y.wrapS]),i.texParameteri(C,i.TEXTURE_WRAP_T,z[y.wrapT]),(C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY)&&i.texParameteri(C,i.TEXTURE_WRAP_R,z[y.wrapR]),i.texParameteri(C,i.TEXTURE_MAG_FILTER,$[y.magFilter]),i.texParameteri(C,i.TEXTURE_MIN_FILTER,$[y.minFilter]),y.compareFunction&&(i.texParameteri(C,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(C,i.TEXTURE_COMPARE_FUNC,nt[y.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Ve||y.minFilter!==vr&&y.minFilter!==bi||y.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){let q=t.get("EXT_texture_filter_anisotropic");i.texParameterf(C,q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,s.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function at(C,y){let q=!1;C.__webglInit===void 0&&(C.__webglInit=!0,y.addEventListener("dispose",A));let j=y.source,it=f.get(j);it===void 0&&(it={},f.set(j,it));let pt=V(y);if(pt!==C.__cacheKey){it[pt]===void 0&&(it[pt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,q=!0),it[pt].usedTimes++;let mt=it[C.__cacheKey];mt!==void 0&&(it[C.__cacheKey].usedTimes--,mt.usedTimes===0&&R(y)),C.__cacheKey=pt,C.__webglTexture=it[pt].texture}return q}function X(C,y,q){return Math.floor(Math.floor(C/q)/y)}function tt(C,y,q,j){let pt=C.updateRanges;if(pt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,y.width,y.height,q,j,y.data);else{pt.sort((Ut,yt)=>Ut.start-yt.start);let mt=0;for(let Ut=1;Ut0){Vt&&Jt&&e.texStorage2D(i.TEXTURE_2D,xt,yt,Ft[0].width,Ft[0].height);for(let rt=0,vt=Ft.length;rt0){let wt=Hc(_t.width,_t.height,y.format,y.type);for(let ct of y.layerUpdates){let Bt=_t.data.subarray(ct*wt/_t.data.BYTES_PER_ELEMENT,(ct+1)*wt/_t.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,rt,0,0,ct,_t.width,_t.height,1,gt,Bt)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,rt,0,0,0,_t.width,_t.height,ot.depth,gt,_t.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,rt,yt,_t.width,_t.height,ot.depth,0,_t.data,0,0);else kt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Vt?H&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,rt,0,0,0,_t.width,_t.height,ot.depth,gt,Ut,_t.data):e.texImage3D(i.TEXTURE_2D_ARRAY,rt,yt,_t.width,_t.height,ot.depth,0,gt,Ut,_t.data);y.layerUpdates.size>0&&y.clearLayerUpdates()}else{Vt&&Jt&&e.texStorage2D(i.TEXTURE_2D,xt,yt,Ft[0].width,Ft[0].height);for(let rt=0,vt=Ft.length;rt0){let rt=Hc(ot.width,ot.height,y.format,y.type);for(let vt of y.layerUpdates){let wt=ot.data.subarray(vt*rt/ot.data.BYTES_PER_ELEMENT,(vt+1)*rt/ot.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,vt,ot.width,ot.height,1,gt,Ut,wt)}y.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ot.width,ot.height,ot.depth,gt,Ut,ot.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,yt,ot.width,ot.height,ot.depth,0,gt,Ut,ot.data);else if(y.isData3DTexture)Vt?(Jt&&e.texStorage3D(i.TEXTURE_3D,xt,yt,ot.width,ot.height,ot.depth),H&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ot.width,ot.height,ot.depth,gt,Ut,ot.data)):e.texImage3D(i.TEXTURE_3D,0,yt,ot.width,ot.height,ot.depth,0,gt,Ut,ot.data);else if(y.isFramebufferTexture){if(Jt)if(Vt)e.texStorage2D(i.TEXTURE_2D,xt,yt,ot.width,ot.height);else{let rt=ot.width,vt=ot.height;for(let wt=0;wt>=1,vt>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in i){let rt=i.canvas;if(rt.hasAttribute("layoutsubtree")||rt.setAttribute("layoutsubtree","true"),ot.parentNode!==rt){rt.appendChild(ot),d.add(y),rt.onpaint=vt=>{let wt=vt.changedElements;for(let ct of d)wt.includes(ct.image)&&(ct.needsUpdate=!0)},rt.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,ot);else{let wt=i.RGBA,ct=i.RGBA,Bt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,wt,ct,Bt,ot)}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&&Jt){let rt=Et(Ft[0]);e.texStorage2D(i.TEXTURE_2D,xt,yt,rt.width,rt.height)}for(let rt=0,vt=Ft.length;rt0&&vt++;let ct=Et(yt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,vt,Jt,ct.width,ct.height)}for(let ct=0;ct<6;ct++)if(Ut){H?rt&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,0,0,yt[ct].width,yt[ct].height,Ft,Vt,yt[ct].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,Jt,yt[ct].width,yt[ct].height,0,Ft,Vt,yt[ct].data);for(let Bt=0;Bt>pt),_t=Math.max(1,y.height>>pt);it===i.TEXTURE_3D||it===i.TEXTURE_2D_ARRAY?e.texImage3D(it,pt,ot,yt,_t,y.depth,0,mt,st,null):e.texImage2D(it,pt,ot,yt,_t,0,mt,st,null)}e.bindFramebuffer(i.FRAMEBUFFER,C),zt(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,j,it,Ut.__webglTexture,0,dt(y)):(it===i.TEXTURE_2D||it>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,j,it,Ut.__webglTexture,pt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ot(C,y,q){if(i.bindRenderbuffer(i.RENDERBUFFER,C),y.depthBuffer){let j=y.depthTexture,it=j&&j.isDepthTexture?j.type:null,pt=v(y.stencilBuffer,it),mt=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;zt(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,dt(y),pt,y.width,y.height):q?i.renderbufferStorageMultisample(i.RENDERBUFFER,dt(y),pt,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,pt,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,mt,i.RENDERBUFFER,C)}else{let j=y.textures;for(let it=0;it{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,j.removeEventListener("dispose",it)};j.addEventListener("dispose",it),y.__depthDisposeCallback=it}y.__boundDepthTexture=j}if(C.depthTexture&&!y.__autoAllocateDepthBuffer)if(q)for(let j=0;j<6;j++)Ct(y.__webglFramebuffer[j],C,j);else{let j=C.texture.mipmaps;j&&j.length>0?Ct(y.__webglFramebuffer[0],C,0):Ct(y.__webglFramebuffer,C,0)}else if(q){y.__webglDepthbuffer=[];for(let j=0;j<6;j++)if(e.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[j]),y.__webglDepthbuffer[j]===void 0)y.__webglDepthbuffer[j]=i.createRenderbuffer(),Ot(y.__webglDepthbuffer[j],C,!1);else{let it=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=y.__webglDepthbuffer[j];i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,pt)}}else{let j=C.texture.mipmaps;if(j&&j.length>0?e.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=i.createRenderbuffer(),Ot(y.__webglDepthbuffer,C,!1);else{let it=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=y.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,pt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Xt(C,y,q){let j=n.get(C);y!==void 0&&ft(j.__webglFramebuffer,C,C.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),q!==void 0&&It(C)}function $t(C){let y=C.texture,q=n.get(C),j=n.get(y);C.addEventListener("dispose",x);let it=C.textures,pt=C.isWebGLCubeRenderTarget===!0,mt=it.length>1;if(mt||(j.__webglTexture===void 0&&(j.__webglTexture=i.createTexture()),j.__version=y.version,o.memory.textures++),pt){q.__webglFramebuffer=[];for(let st=0;st<6;st++)if(y.mipmaps&&y.mipmaps.length>0){q.__webglFramebuffer[st]=[];for(let ot=0;ot0){q.__webglFramebuffer=[];for(let st=0;st0&&zt(C)===!1){q.__webglMultisampledFramebuffer=i.createFramebuffer(),q.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,q.__webglMultisampledFramebuffer);for(let st=0;st0)for(let ot=0;ot0)for(let ot=0;ot0){if(zt(C)===!1){let y=C.textures,q=C.width,j=C.height,it=i.COLOR_BUFFER_BIT,pt=C.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,mt=n.get(C),st=y.length>1;if(st)for(let gt=0;gt0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,mt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,mt.__webglFramebuffer);for(let gt=0;gt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function I(C){let y=o.render.frame;h.get(C)!==y&&(h.set(C,y),C.update())}function ut(C,y){let q=C.colorSpace,j=C.format,it=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||q!==js&&q!==ri&&(ee.getTransfer(q)===ue?(j!==sn||it!==nn)&&kt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Wt("WebGLTextures: Unsupported texture color space:",q)),y}function Et(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=B,this.getTextureUnits=L,this.setTextureUnits=U,this.setTexture2D=O,this.setTexture2DArray=F,this.setTexture3D=G,this.setTextureCube=Y,this.rebindTextures=Xt,this.setupRenderTarget=$t,this.updateRenderTargetMipmap=qt,this.updateMultisampleRenderTarget=ge,this.setupDepthRenderbuffer=It,this.setupFrameBufferTexture=ft,this.useMultisampledRTT=zt,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function Mv(i,t){function e(n,s=ri){let r,o=ee.getTransfer(s);if(n===nn)return i.UNSIGNED_BYTE;if(n===ua)return i.UNSIGNED_SHORT_4_4_4_4;if(n===da)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Rc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Cc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Tc)return i.BYTE;if(n===Ac)return i.SHORT;if(n===Cs)return i.UNSIGNED_SHORT;if(n===ha)return i.INT;if(n===En)return i.UNSIGNED_INT;if(n===Ye)return i.FLOAT;if(n===Tn)return i.HALF_FLOAT;if(n===Ic)return i.ALPHA;if(n===Pc)return i.RGB;if(n===sn)return i.RGBA;if(n===Nn)return i.DEPTH_COMPONENT;if(n===Si)return i.DEPTH_STENCIL;if(n===Ps)return i.RED;if(n===fa)return i.RED_INTEGER;if(n===wi)return i.RG;if(n===pa)return i.RG_INTEGER;if(n===ma)return i.RGBA_INTEGER;if(n===yr||n===Mr||n===br||n===Sr)if(o===ue)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===yr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===br)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Sr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===yr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===br)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Sr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ga||n===_a||n===xa||n===va)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ga)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===_a)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===xa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===va)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ya||n===Ma||n===ba||n===Sa||n===wa||n===wr||n===Ea)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ya||n===Ma)return o===ue?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ba)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Sa)return r.COMPRESSED_R11_EAC;if(n===wa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===wr)return r.COMPRESSED_RG11_EAC;if(n===Ea)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ta||n===Aa||n===Ra||n===Ca||n===Ia||n===Pa||n===La||n===Da||n===Na||n===Ua||n===Fa||n===Ba||n===Oa||n===za)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ta)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Aa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ra)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ca)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ia)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Pa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===La)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Da)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Na)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ua)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Fa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ba)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Oa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===za)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ka||n===Ha||n===Va)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===ka)return o===ue?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ha)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Va)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ga||n===Wa||n===Er||n===Xa)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ga)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Wa)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Er)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Xa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Is?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var bv=` +}`,Ev=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],Tv=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],Kd=new Yt,Pr=new R,sh=new R;function Av(i,t,e){let n=new kn,s=new Wt,r=new Wt,o=new xe,a=new $o,l=new Zo,c={},h=e.maxTextureSize,u={[qn]:ze,[ze]:qn,[ke]:ke},d=new Ie({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Wt},radius:{value:4}},vertexShader:Sv,fragmentShader:wv}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let g=new ce;g.setAttribute("position",new _e(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new me(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xr;let m=this.type;this.render=function(y,A,x){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||y.length===0)return;this.type===Xu&&(Ht("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=xr);let E=i.getRenderTarget(),I=i.getActiveCubeFace(),D=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=m!==this.type;B&&A.traverse(function(L){L.material&&(Array.isArray(L.material)?L.material.forEach(F=>F.needsUpdate=!0):L.material.needsUpdate=!0)});for(let L=0,F=y.length;Lh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/O.x),s.x=r.x*O.x,W.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/O.y),s.y=r.y*O.y,W.mapSize.y=r.y));let U=i.state.buffers.depth.getReversed();if(W.camera._reversedDepth=U,W.map===null||B===!0){if(W.map!==null&&(W.map.depthTexture!==null&&(W.map.depthTexture.dispose(),W.map.depthTexture=null),W.map.dispose()),this.type===Cs){if(k.isPointLight){Ht("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}W.map=new Be(s.x,s.y,{format:Ei,type:An,minFilter:qe,magFilter:qe,generateMipmaps:!1}),W.map.texture.name=k.name+".shadowMap",W.map.depthTexture=new Vn(s.x,s.y,Ye),W.map.depthTexture.name=k.name+".shadowMapDepth",W.map.depthTexture.format=Bn,W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Le,W.map.depthTexture.magFilter=Le}else k.isPointLight?(W.map=new tl(s.x),W.map.depthTexture=new qo(s.x,Tn)):(W.map=new Be(s.x,s.y),W.map.depthTexture=new Vn(s.x,s.y,Tn)),W.map.depthTexture.name=k.name+".shadowMap",W.map.depthTexture.format=Bn,this.type===xr?(W.map.depthTexture.compareFunction=U?Ka:Za,W.map.depthTexture.minFilter=qe,W.map.depthTexture.magFilter=qe):(W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Le,W.map.depthTexture.magFilter=Le);W.camera.updateProjectionMatrix()}W.map.isWebGLCubeRenderTarget!==!0&&(W.map.width!==s.x||W.map.height!==s.y)&&W.map.setSize(s.x,s.y);let z=W.map.isWebGLCubeRenderTarget?6:W.getViewportCount();k.isPointLight!==!0&&W.updateMatrices(k,x);for(let q=0;q0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let N=I.uuid,B=A.uuid,L=c[N];L===void 0&&(L={},c[N]=L);let F=L[B];F===void 0&&(F=I.clone(),L[B]=F,A.addEventListener("dispose",v)),I=F}if(I.visible=A.visible,I.wireframe=A.wireframe,E===Cs?I.side=A.shadowSide!==null?A.shadowSide:A.side:I.side=A.shadowSide!==null?A.shadowSide:u[A.side],I.alphaMap=A.alphaMap,I.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,I.map=A.map,I.clipShadows=A.clipShadows,I.clippingPlanes=A.clippingPlanes,I.clipIntersection=A.clipIntersection,I.displacementMap=A.displacementMap,I.displacementScale=A.displacementScale,I.displacementBias=A.displacementBias,I.wireframeLinewidth=A.wireframeLinewidth,I.linewidth=A.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){let N=i.properties.get(I);N.light=x}return I}function S(y,A,x,E,I){if(y.visible===!1)return;if(y.layers.test(A.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&I===Cs)&&(!y.frustumCulled||y.intersectsFrustum(n))){y.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,y.matrixWorld);let B=t.update(y),L=y.material;if(Array.isArray(L)){let F=B.groups;for(let k=0,W=F.length;k=1):U.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),W=O>=2);let z=null,q={},V=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),K=new xe().fromArray(V),lt=new xe().fromArray(Z);function rt(X,vt,ot,yt){let Et=new Uint8Array(4),ct=i.createTexture();i.bindTexture(X,ct),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,u=new Set,d,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(P,M){return g?new OffscreenCanvas(P,M):xs("canvas")}function p(P,M,Y){let tt=1,it=Tt(P);if((it.width>Y||it.height>Y)&&(tt=Y/Math.max(it.width,it.height)),tt<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){let pt=Math.floor(tt*it.width),gt=Math.floor(tt*it.height);d===void 0&&(d=_(pt,gt));let st=M?_(pt,gt):d;return st.width=pt,st.height=gt,st.getContext("2d").drawImage(P,0,0,pt,gt),Ht("WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+pt+"x"+gt+")."),st}else return"data"in P&&Ht("WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+")."),P;return P}function m(P){return P.generateMipmaps}function b(P){i.generateMipmap(P)}function w(P){return P.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:P.isWebGL3DRenderTarget?i.TEXTURE_3D:P.isWebGLArrayRenderTarget||P.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(P,M,Y,tt,it,pt=!1){if(P!==null){if(i[P]!==void 0)return i[P];Ht("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let gt;tt&&(gt=t.get("EXT_texture_norm16"),gt||Ht("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let st=M;if(M===i.RED&&(Y===i.FLOAT&&(st=i.R32F),Y===i.HALF_FLOAT&&(st=i.R16F),Y===i.UNSIGNED_BYTE&&(st=i.R8),Y===i.UNSIGNED_SHORT&>&&(st=gt.R16_EXT),Y===i.SHORT&>&&(st=gt.R16_SNORM_EXT)),M===i.RED_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.R8UI),Y===i.UNSIGNED_SHORT&&(st=i.R16UI),Y===i.UNSIGNED_INT&&(st=i.R32UI),Y===i.BYTE&&(st=i.R8I),Y===i.SHORT&&(st=i.R16I),Y===i.INT&&(st=i.R32I)),M===i.RG&&(Y===i.FLOAT&&(st=i.RG32F),Y===i.HALF_FLOAT&&(st=i.RG16F),Y===i.UNSIGNED_BYTE&&(st=i.RG8),Y===i.UNSIGNED_SHORT&>&&(st=gt.RG16_EXT),Y===i.SHORT&>&&(st=gt.RG16_SNORM_EXT)),M===i.RG_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.RG8UI),Y===i.UNSIGNED_SHORT&&(st=i.RG16UI),Y===i.UNSIGNED_INT&&(st=i.RG32UI),Y===i.BYTE&&(st=i.RG8I),Y===i.SHORT&&(st=i.RG16I),Y===i.INT&&(st=i.RG32I)),M===i.RGB_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.RGB8UI),Y===i.UNSIGNED_SHORT&&(st=i.RGB16UI),Y===i.UNSIGNED_INT&&(st=i.RGB32UI),Y===i.BYTE&&(st=i.RGB8I),Y===i.SHORT&&(st=i.RGB16I),Y===i.INT&&(st=i.RGB32I)),M===i.RGBA_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.RGBA8UI),Y===i.UNSIGNED_SHORT&&(st=i.RGBA16UI),Y===i.UNSIGNED_INT&&(st=i.RGBA32UI),Y===i.BYTE&&(st=i.RGBA8I),Y===i.SHORT&&(st=i.RGBA16I),Y===i.INT&&(st=i.RGBA32I)),M===i.RGB&&(Y===i.UNSIGNED_SHORT&>&&(st=gt.RGB16_EXT),Y===i.SHORT&>&&(st=gt.RGB16_SNORM_EXT),Y===i.UNSIGNED_INT_5_9_9_9_REV&&(st=i.RGB9_E5),Y===i.UNSIGNED_INT_10F_11F_11F_REV&&(st=i.R11F_G11F_B10F)),M===i.RGBA){let at=pt?nr:ne.getTransfer(it);Y===i.FLOAT&&(st=i.RGBA32F),Y===i.HALF_FLOAT&&(st=i.RGBA16F),Y===i.UNSIGNED_BYTE&&(st=at===de?i.SRGB8_ALPHA8:i.RGBA8),Y===i.UNSIGNED_SHORT&>&&(st=gt.RGBA16_EXT),Y===i.SHORT&>&&(st=gt.RGBA16_SNORM_EXT),Y===i.UNSIGNED_SHORT_4_4_4_4&&(st=i.RGBA4),Y===i.UNSIGNED_SHORT_5_5_5_1&&(st=i.RGB5_A1)}return(st===i.R16F||st===i.R32F||st===i.RG16F||st===i.RG32F||st===i.RGBA16F||st===i.RGBA32F)&&t.get("EXT_color_buffer_float"),st}function v(P,M){let Y;return P?M===null||M===Tn||M===Ls?Y=i.DEPTH24_STENCIL8:M===Ye?Y=i.DEPTH32F_STENCIL8:M===Ps&&(Y=i.DEPTH24_STENCIL8,Ht("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Tn||M===Ls?Y=i.DEPTH_COMPONENT24:M===Ye?Y=i.DEPTH_COMPONENT32F:M===Ps&&(Y=i.DEPTH_COMPONENT16),Y}function y(P,M){return m(P)===!0||P.isFramebufferTexture&&P.minFilter!==Le&&P.minFilter!==qe?Math.log2(Math.max(M.width,M.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?M.mipmaps.length:1}function A(P){let M=P.target;M.removeEventListener("dispose",A),E(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&u.delete(M)}function x(P){let M=P.target;M.removeEventListener("dispose",x),D(M)}function E(P){let M=n.get(P);if(M.__webglInit===void 0)return;let Y=P.source,tt=f.get(Y);if(tt){let it=tt[M.__cacheKey];it.usedTimes--,it.usedTimes===0&&I(P),Object.keys(tt).length===0&&f.delete(Y)}n.remove(P)}function I(P){let M=n.get(P);i.deleteTexture(M.__webglTexture);let Y=P.source,tt=f.get(Y);delete tt[M.__cacheKey],o.memory.textures--}function D(P){let M=n.get(P);if(P.depthTexture&&(P.depthTexture.dispose(),n.remove(P.depthTexture)),P.isWebGLCubeRenderTarget)for(let tt=0;tt<6;tt++){if(Array.isArray(M.__webglFramebuffer[tt]))for(let it=0;it=s.maxTextures&&Ht("WebGLTextures: Trying to use "+(P+1)+" texture units while this GPU supports only "+s.maxTextures),N+=1,P}function W(P){let M=[];return M.push(P.wrapS),M.push(P.wrapT),M.push(P.wrapR||0),M.push(P.magFilter),M.push(P.minFilter),M.push(P.anisotropy),M.push(P.internalFormat),M.push(P.format),M.push(P.type),M.push(P.generateMipmaps),M.push(P.premultiplyAlpha),M.push(P.flipY),M.push(P.unpackAlignment),M.push(P.colorSpace),M.join()}function O(P,M){let Y=n.get(P);if(P.isVideoTexture&&C(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&Y.__version!==P.version){let tt=P.image;if(tt===null)Ht("WebGLRenderer: Texture marked for update but no image data found.");else if(tt.complete===!1)Ht("WebGLRenderer: Texture marked for update but image is incomplete");else{ut(Y,P,M);return}}else P.isExternalTexture&&(Y.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,Y.__webglTexture,i.TEXTURE0+M)}function U(P,M){let Y=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&Y.__version!==P.version){ut(Y,P,M);return}else P.isExternalTexture&&(Y.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,Y.__webglTexture,i.TEXTURE0+M)}function z(P,M){let Y=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&Y.__version!==P.version){ut(Y,P,M);return}e.bindTexture(i.TEXTURE_3D,Y.__webglTexture,i.TEXTURE0+M)}function q(P,M){let Y=n.get(P);if(P.isCubeDepthTexture!==!0&&P.version>0&&Y.__version!==P.version){It(Y,P,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture,i.TEXTURE0+M)}let V={[gs]:i.REPEAT,[Fn]:i.CLAMP_TO_EDGE,[Oo]:i.MIRRORED_REPEAT},Z={[Le]:i.NEAREST,[dd]:i.NEAREST_MIPMAP_NEAREST,[Mr]:i.NEAREST_MIPMAP_LINEAR,[qe]:i.LINEAR,[da]:i.LINEAR_MIPMAP_NEAREST,[Si]:i.LINEAR_MIPMAP_LINEAR},K={[gd]:i.NEVER,[Md]:i.ALWAYS,[_d]:i.LESS,[Za]:i.LEQUAL,[xd]:i.EQUAL,[Ka]:i.GEQUAL,[vd]:i.GREATER,[yd]:i.NOTEQUAL};function lt(P,M){if(M.type===Ye&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===qe||M.magFilter===da||M.magFilter===Mr||M.magFilter===Si||M.minFilter===qe||M.minFilter===da||M.minFilter===Mr||M.minFilter===Si)&&Ht("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(P,i.TEXTURE_WRAP_S,V[M.wrapS]),i.texParameteri(P,i.TEXTURE_WRAP_T,V[M.wrapT]),(P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY)&&i.texParameteri(P,i.TEXTURE_WRAP_R,V[M.wrapR]),i.texParameteri(P,i.TEXTURE_MAG_FILTER,Z[M.magFilter]),i.texParameteri(P,i.TEXTURE_MIN_FILTER,Z[M.minFilter]),M.compareFunction&&(i.texParameteri(P,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(P,i.TEXTURE_COMPARE_FUNC,K[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Le||M.minFilter!==Mr&&M.minFilter!==Si||M.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){let Y=t.get("EXT_texture_filter_anisotropic");i.texParameterf(P,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function rt(P,M){let Y=!1;P.__webglInit===void 0&&(P.__webglInit=!0,M.addEventListener("dispose",A));let tt=M.source,it=f.get(tt);it===void 0&&(it={},f.set(tt,it));let pt=W(M);if(pt!==P.__cacheKey){it[pt]===void 0&&(it[pt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),it[pt].usedTimes++;let gt=it[P.__cacheKey];gt!==void 0&&(it[P.__cacheKey].usedTimes--,gt.usedTimes===0&&I(M)),P.__cacheKey=pt,P.__webglTexture=it[pt].texture}return Y}function H(P,M,Y){return Math.floor(Math.floor(P/Y)/M)}function Q(P,M,Y,tt){let pt=P.updateRanges;if(pt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,M.width,M.height,Y,tt,M.data);else{pt.sort((Bt,Mt)=>Bt.start-Mt.start);let gt=0;for(let Bt=1;Bt0){Vt&&Kt&&e.texStorage2D(i.TEXTURE_2D,vt,Mt,Ot[0].width,Ot[0].height);for(let ot=0,yt=Ot.length;ot0){let Et=Yc(xt.width,xt.height,M.format,M.type);for(let ct of M.layerUpdates){let zt=xt.data.subarray(ct*Et/xt.data.BYTES_PER_ELEMENT,(ct+1)*Et/xt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,ct,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,Bt,xt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,ot,Mt,xt.width,xt.height,at.depth,0,_t,Bt,xt.data);M.layerUpdates.size>0&&M.clearLayerUpdates()}else{Vt&&Kt&&e.texStorage2D(i.TEXTURE_2D,vt,Mt,Ot[0].width,Ot[0].height);for(let ot=0,yt=Ot.length;ot0){let ot=Yc(at.width,at.height,M.format,M.type);for(let yt of M.layerUpdates){let Et=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,Bt,Et)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,at.width,at.height,at.depth,_t,Bt,at.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Mt,at.width,at.height,at.depth,0,_t,Bt,at.data);else if(M.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,Bt,at.data)):e.texImage3D(i.TEXTURE_3D,0,Mt,at.width,at.height,at.depth,0,_t,Bt,at.data);else if(M.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 Et=0;Et>=1,yt>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in i){let ot=i.canvas;if(ot.hasAttribute("layoutsubtree")||ot.setAttribute("layoutsubtree","true"),at.parentNode!==ot){ot.appendChild(at),u.add(M),ot.onpaint=yt=>{let Et=yt.changedElements;for(let ct of u)Et.includes(ct.image)&&(ct.needsUpdate=!0)},ot.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,at);else{let Et=i.RGBA,ct=i.RGBA,zt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Et,ct,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(Ot.length>0){if(Vt&&Kt){let ot=Tt(Ot[0]);e.texStorage2D(i.TEXTURE_2D,vt,Mt,ot.width,ot.height)}for(let ot=0,yt=Ot.length;ot0&&yt++;let ct=Tt(Mt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,yt,Kt,ct.width,ct.height)}for(let ct=0;ct<6;ct++)if(Bt){X?ot&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,0,0,Mt[ct].width,Mt[ct].height,Ot,Vt,Mt[ct].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,Kt,Mt[ct].width,Mt[ct].height,0,Ot,Vt,Mt[ct].data);for(let zt=0;zt>pt),xt=Math.max(1,M.height>>pt);it===i.TEXTURE_3D||it===i.TEXTURE_2D_ARRAY?e.texImage3D(it,pt,at,Mt,xt,M.depth,0,gt,st,null):e.texImage2D(it,pt,at,Mt,xt,0,gt,st,null)}e.bindFramebuffer(i.FRAMEBUFFER,P),Ft(M)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,tt,it,Bt.__webglTexture,0,dt(M)):(it===i.TEXTURE_2D||it>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,tt,it,Bt.__webglTexture,pt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ut(P,M,Y){if(i.bindRenderbuffer(i.RENDERBUFFER,P),M.depthBuffer){let tt=M.depthTexture,it=tt&&tt.isDepthTexture?tt.type:null,pt=v(M.stencilBuffer,it),gt=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Ft(M)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,dt(M),pt,M.width,M.height):Y?i.renderbufferStorageMultisample(i.RENDERBUFFER,dt(M),pt,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,pt,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,gt,i.RENDERBUFFER,P)}else{let tt=M.textures;for(let it=0;it{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,tt.removeEventListener("dispose",it)};tt.addEventListener("dispose",it),M.__depthDisposeCallback=it}M.__boundDepthTexture=tt}if(P.depthTexture&&!M.__autoAllocateDepthBuffer)if(Y)for(let tt=0;tt<6;tt++)ae(M.__webglFramebuffer[tt],P,tt);else{let tt=P.texture.mipmaps;tt&&tt.length>0?ae(M.__webglFramebuffer[0],P,0):ae(M.__webglFramebuffer,P,0)}else if(Y){M.__webglDepthbuffer=[];for(let tt=0;tt<6;tt++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[tt]),M.__webglDepthbuffer[tt]===void 0)M.__webglDepthbuffer[tt]=i.createRenderbuffer(),Ut(M.__webglDepthbuffer[tt],P,!1);else{let it=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=M.__webglDepthbuffer[tt];i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,pt)}}else{let tt=P.texture.mipmaps;if(tt&&tt.length>0?e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Ut(M.__webglDepthbuffer,P,!1);else{let it=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,pt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Jt(P,M,Y){let tt=n.get(P);M!==void 0&&ft(tt.__webglFramebuffer,P,P.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Y!==void 0&&Gt(P)}function mt(P){let M=P.texture,Y=n.get(P),tt=n.get(M);P.addEventListener("dispose",x);let it=P.textures,pt=P.isWebGLCubeRenderTarget===!0,gt=it.length>1;if(gt||(tt.__webglTexture===void 0&&(tt.__webglTexture=i.createTexture()),tt.__version=M.version,o.memory.textures++),pt){Y.__webglFramebuffer=[];for(let st=0;st<6;st++)if(M.mipmaps&&M.mipmaps.length>0){Y.__webglFramebuffer[st]=[];for(let at=0;at0){Y.__webglFramebuffer=[];for(let st=0;st0&&Ft(P)===!1){Y.__webglMultisampledFramebuffer=i.createFramebuffer(),Y.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let st=0;st0)for(let at=0;at0)for(let at=0;at0){if(Ft(P)===!1){let M=P.textures,Y=P.width,tt=P.height,it=i.COLOR_BUFFER_BIT,pt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,gt=n.get(P),st=M.length>1;if(st)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&&M.__useRenderToTexture!==!1}function C(P){let M=o.render.frame;h.get(P)!==M&&(h.set(P,M),P.update())}function ht(P,M){let Y=P.colorSpace,tt=P.format,it=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||Y!==er&&Y!==oi&&(ne.getTransfer(Y)===de?(tt!==je||it!==rn)&&Ht("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xt("WebGLTextures: Unsupported texture color space:",Y)),M}function Tt(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=B,this.getTextureUnits=L,this.setTextureUnits=F,this.setTexture2D=O,this.setTexture2DArray=U,this.setTexture3D=z,this.setTextureCube=q,this.rebindTextures=Jt,this.setupRenderTarget=mt,this.updateRenderTargetMipmap=Ct,this.updateMultisampleRenderTarget=Me,this.setupDepthRenderbuffer=Gt,this.setupFrameBufferTexture=ft,this.useMultisampledRTT=Ft,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function Iv(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===de)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===de?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ea)return o===de?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===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ia)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Pa)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===La)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Da)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Na)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ua)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Fa)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ba)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Oa)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===za)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ka)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ha)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Va)return o===de?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===de?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 Pv=` void main() { gl_Position = vec4( position, 1.0 ); -}`,Sv=` +}`,Lv=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4217,7 +4217,7 @@ void main() { } -}`,oh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ar(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 Ue({vertexShader:bv,fragmentShader:Sv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new pe(new ln(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},ah=class extends Un{constructor(t,e){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,m=null,_=typeof XRWebGLBinding<"u",g=new oh,p={},M=e.getContextAttributes(),T=null,S=null,v=[],b=[],A=new Gt,x=null,w=null,R=new Le;R.viewport=new xe;let D=new Le;D.viewport=new xe;let N=[R,D],B=new ra,L=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let tt=v[X];return tt===void 0&&(tt=new Ms,v[X]=tt),tt.getTargetRaySpace()},this.getControllerGrip=function(X){let tt=v[X];return tt===void 0&&(tt=new Ms,v[X]=tt),tt.getGripSpace()},this.getHand=function(X){let tt=v[X];return tt===void 0&&(tt=new Ms,v[X]=tt),tt.getHandSpace()};function W(X){let tt=b.indexOf(X.inputSource);if(tt===-1)return;let ht=v[tt];ht!==void 0&&(ht.update(X.inputSource,X.frame,c||o),ht.dispatchEvent({type:X.type,data:X.inputSource}))}function V(){s.removeEventListener("select",W),s.removeEventListener("selectstart",W),s.removeEventListener("selectend",W),s.removeEventListener("squeeze",W),s.removeEventListener("squeezestart",W),s.removeEventListener("squeezeend",W),s.removeEventListener("end",V),s.removeEventListener("inputsourceschange",O);for(let X=0;X=0&&(b[Rt]=null,v[Rt].disconnect(ht))}for(let tt=0;tt=b.length){b.push(ht),Rt=Ot;break}else if(b[Ot]===null){b[Ot]=ht,Rt=Ot;break}if(Rt===-1)break}let ft=v[Rt];ft&&ft.connect(ht)}}let F=new P,G=new P;function Y(X,tt,ht){F.setFromMatrixPosition(tt.matrixWorld),G.setFromMatrixPosition(ht.matrixWorld);let Rt=F.distanceTo(G),ft=tt.projectionMatrix.elements,Ot=ht.projectionMatrix.elements,Ct=ft[14]/(ft[10]-1),It=ft[14]/(ft[10]+1),Xt=(ft[9]+1)/ft[5],$t=(ft[9]-1)/ft[5],qt=(ft[8]-1)/ft[0],Qt=(Ot[8]+1)/Ot[0],ie=Ct*qt,ge=Ct*Qt,dt=Rt/(-qt+Qt),zt=dt*-qt;if(tt.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(zt),X.translateZ(dt),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),ft[10]===-1)X.projectionMatrix.copy(tt.projectionMatrix),X.projectionMatrixInverse.copy(tt.projectionMatrixInverse);else{let I=Ct+dt,ut=It+dt,Et=ie-zt,C=ge+(Rt-zt),y=Xt*It/ut*I,q=$t*It/ut*I;X.projectionMatrix.makePerspective(Et,C,y,q,I,ut),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function z(X,tt){tt===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(tt.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(s===null)return;let tt=X.near,ht=X.far;g.texture!==null&&(g.depthNear>0&&(tt=g.depthNear),g.depthFar>0&&(ht=g.depthFar)),B.near=D.near=R.near=tt,B.far=D.far=R.far=ht,(L!==B.near||U!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),L=B.near,U=B.far),B.layers.mask=X.layers.mask|6,R.layers.mask=B.layers.mask&-5,D.layers.mask=B.layers.mask&-3;let Rt=X.parent,ft=B.cameras;z(B,Rt);for(let Ot=0;Ot0&&(g.alphaTest.value=p.alphaTest);let M=t.get(p),T=M.envMap,S=M.envMapRotation;T&&(g.envMap.value=T,g.envMapRotation.value.setFromMatrix4(wv.makeRotationFromEuler(S)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(Zd),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,M,T){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*M,g.scale.value=T*.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,M){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===Be&&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=M.texture,g.transmissionSamplerSize.value.set(M.width,M.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 M=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(M.matrixWorld),g.nearDistance.value=M.shadow.camera.near,g.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Tv(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,v){let b=v.program;n.uniformBlockBinding(S,b)}function c(S,v){let b=s[S.id];b===void 0&&(g(S),b=h(S),s[S.id]=b,S.addEventListener("dispose",M));let A=v.program;n.updateUBOMapping(S,A);let x=t.render.frame;r[S.id]!==x&&(u(S),r[S.id]=x)}function h(S){let v=d();S.__bindingPointIndex=v;let b=i.createBuffer(),A=S.__size,x=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,v,b),b}function d(){for(let S=0;S0&&(b+=A-x),S.__size=b,S.__cache={},this}function p(S){let v={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(v.boundary=4,v.storage=4):S.isVector2?(v.boundary=8,v.storage=8):S.isVector3||S.isColor?(v.boundary=16,v.storage=12):S.isVector4?(v.boundary=16,v.storage=16):S.isMatrix3?(v.boundary=48,v.storage=48):S.isMatrix4?(v.boundary=64,v.storage=64):S.isTexture?kt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(v.boundary=16,v.storage=S.byteLength):kt("WebGLRenderer: Unsupported uniform value type.",S),v}function M(S){let v=S.target;v.removeEventListener("dispose",M);let b=o.indexOf(v.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(s[v.id]),delete s[v.id],delete r[v.id]}function T(){for(let S in s)i.deleteBuffer(s[S]);o=[],s={},r={}}return{bind:l,update:c,dispose:T}}var Av=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]),qn=null;function Rv(){return qn===null&&(qn=new Bn(Av,16,16,wi,Tn),qn.name="DFG_LUT",qn.minFilter=qe,qn.magFilter=qe,qn.wrapS=Dn,qn.wrapT=Dn,qn.generateMipmaps=!1,qn.needsUpdate=!0),qn}var Ei=class{constructor(t={}){let{canvas:e=pd(),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=nn}=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([ma,pa,fa]),p=new Set([nn,En,Cs,Is,ua,da]),M=new Uint32Array(4),T=new Int32Array(4),S=new P,v=null,b=null,A=[],x=[],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=wn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let R=this,D=!1,N=null,B=null,L=null,U=null;this._outputColorSpace=Me;let W=0,V=0,O=null,F=-1,G=null,Y=new xe,z=new xe,$=null,nt=new Ht(0),lt=0,at=e.width,X=e.height,tt=1,ht=null,Rt=null,ft=new xe(0,0,at,X),Ot=new xe(0,0,at,X),Ct=!1,It=new On,Xt=!1,$t=!1,qt=new Zt,Qt=new P,ie=new xe,ge={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},dt=!1;function zt(){return O===null?tt:1}let I=n;function ut(E,k){return e.getContext(E,k)}let Et,C,y,q,j,it,pt,mt,st,ot,gt,Ut,yt,_t,Ft,Vt,Jt,H,xt,rt,vt,wt,ct;try{let E={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",ve,!1),e.addEventListener("webglcontextrestored",ce,!1),e.addEventListener("webglcontextcreationerror",mn,!1),I===null){let k="webgl2";if(I=ut(k,E),I===null)throw ut(k)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Bt()}catch(E){throw e.removeEventListener("webglcontextlost",ve,!1),e.removeEventListener("webglcontextrestored",ce,!1),e.removeEventListener("webglcontextcreationerror",mn,!1),Wt("WebGLRenderer: "+E.message),E}function Bt(){Et=new U0(I),Et.init(),vt=new Mv(I,Et),C=new E0(I,Et,t,vt),y=new vv(I,Et),C.reversedDepthBuffer&&u&&y.buffers.depth.setReversed(!0),B=I.createFramebuffer(),L=I.createFramebuffer(),U=I.createFramebuffer(),q=new O0(I),j=new rv,it=new yv(I,Et,y,j,C,vt,q),pt=new N0(R),mt=new km(I),wt=new S0(I,mt),st=new F0(I,mt,q,wt),ot=new k0(I,st,mt,wt,q),H=new z0(I,C,it),Ft=new T0(j),gt=new sv(R,pt,Et,C,wt,Ft),Ut=new Ev(R,j),yt=new av,_t=new fv(Et),Jt=new b0(R,pt,y,ot,m,l),Vt=new xv(R,ot,C),ct=new Tv(I,q,C,y),xt=new w0(I,Et,q),rt=new B0(I,Et,q),q.programs=gt.programs,R.capabilities=C,R.extensions=Et,R.properties=j,R.renderLists=yt,R.shadowMap=Vt,R.state=y,R.info=q}_!==nn&&(w=new V0(_,e.width,e.height,a,s,r));let Dt=new ah(R,I);this.xr=Dt,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){let E=Et.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=Et.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return tt},this.setPixelRatio=function(E){E!==void 0&&(tt=E,this.setSize(at,X,!1))},this.getSize=function(E){return E.set(at,X)},this.setSize=function(E,k,Q=!0){if(Dt.isPresenting){kt("WebGLRenderer: Can't change size while VR device is presenting.");return}at=E,X=k,e.width=Math.floor(E*tt),e.height=Math.floor(k*tt),Q===!0&&(e.style.width=E+"px",e.style.height=k+"px"),w!==null&&w.setSize(e.width,e.height),this.setViewport(0,0,E,k)},this.getDrawingBufferSize=function(E){return E.set(at*tt,X*tt).floor()},this.setDrawingBufferSize=function(E,k,Q){at=E,X=k,tt=Q,e.width=Math.floor(E*Q),e.height=Math.floor(k*Q),this.setViewport(0,0,E,k)},this.setEffects=function(E){if(_===nn){Wt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let k=0;k{function St(){if(J.forEach(function(At){let Pt=j.get(At).currentProgram;(Pt===void 0||Pt.isReady())&&J.delete(At)}),J.size===0){K(E);return}setTimeout(St,10)}Et.get("KHR_parallel_shader_compile")!==null?St():setTimeout(St,10)})};let Il=null;function Bp(E){Il&&Il(E)}function Xh(){Ii.stop()}function qh(){Ii.start()}let Ii=new Gd;Ii.setAnimationLoop(Bp),typeof self<"u"&&Ii.setContext(self),this.setAnimationLoop=function(E){Il=E,Dt.setAnimationLoop(E),E===null?Ii.stop():Ii.start()},Dt.addEventListener("sessionstart",Xh),Dt.addEventListener("sessionend",qh),this.render=function(E,k){if(k!==void 0&&k.isCamera!==!0){Wt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;N!==null&&N.renderStart(E,k);let Q=Dt.enabled===!0&&Dt.isPresenting===!0,J=w!==null&&(O===null||Q)&&w.begin(R,O);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),Dt.enabled===!0&&Dt.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Dt.cameraAutoUpdate===!0&&Dt.updateCamera(k),k=Dt.getCamera()),E.isScene===!0&&E.onBeforeRender(R,E,k,O),b=_t.get(E,x.length),b.init(k),b.state.textureUnits=it.getTextureUnits(),x.push(b),qt.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),It.setFromProjectionMatrix(qt,yn,k.reversedDepth),$t=this.localClippingEnabled,Xt=Ft.init(this.clippingPlanes,$t),v=yt.get(E,A.length),v.init(),A.push(v),Dt.enabled===!0&&Dt.isPresenting===!0){let At=R.xr.getDepthSensingMesh();At!==null&&Pl(At,k,-1/0,R.sortObjects)}Pl(E,k,0,R.sortObjects),v.finish(),N!==null&&N.updateLights(b.state.lightsArray),R.sortObjects===!0&&v.sort(ht,Rt),dt=Dt.enabled===!1||Dt.isPresenting===!1||Dt.hasDepthSensing()===!1,dt&&Jt.addToRenderList(v,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Xt===!0&&Ft.beginShadows();let K=b.state.shadowsArray;if(Vt.render(K,E,k),Xt===!0&&Ft.endShadows(),(J&&w.hasRenderPass())===!1){let At=v.opaque,bt=v.transmissive;if(b.setupLights(),k.isArrayCamera){let Pt=k.cameras;if(bt.length>0)for(let Nt=0,Kt=Pt.length;Nt0&&$h(At,bt,E,k),dt&&Jt.render(E),Yh(v,E,k)}O!==null&&V===0&&(it.updateMultisampleRenderTarget(O),it.updateRenderTargetMipmap(O)),J&&w.end(R),E.isScene===!0&&E.onAfterRender(R,E,k),wt.resetDefaultState(),F=-1,G=null,x.pop(),x.length>0?(b=x[x.length-1],it.setTextureUnits(b.state.textureUnits),Xt===!0&&Ft.setGlobalState(R.clippingPlanes,b.state.camera)):b=null,A.pop(),A.length>0?v=A[A.length-1]:v=null,N!==null&&N.renderEnd()};function Pl(E,k,Q,J){if(E.visible===!1)return;if(E.layers.test(k.layers)){if(E.isGroup)Q=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(k);else if(E.isLightProbeGrid)b.pushLightProbeGrid(E);else if(E.isLight)b.pushLight(E),E.castShadow&&b.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||E.intersectsFrustum(It)){J&&ie.setFromMatrixPosition(E.matrixWorld).applyMatrix4(qt);let At=ot.update(E),bt=E.material;bt.visible&&v.push(E,At,bt,Q,ie.z,null,k)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||E.intersectsFrustum(It))){let At=ot.update(E),bt=E.material;if(J&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),ie.copy(E.boundingSphere.center)):(At.boundingSphere===null&&At.computeBoundingSphere(),ie.copy(At.boundingSphere.center)),ie.applyMatrix4(E.matrixWorld).applyMatrix4(qt)),Array.isArray(bt)){let Pt=At.groups;for(let Nt=0,Kt=Pt.length;Nt0&&$r(K,k,Q),St.length>0&&$r(St,k,Q),At.length>0&&$r(At,k,Q),y.buffers.depth.setTest(!0),y.buffers.depth.setMask(!0),y.buffers.color.setMask(!0),y.setPolygonOffset(!1)}function $h(E,k,Q,J){if((Q.isScene===!0?Q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[J.id]===void 0){let Lt=Et.has("EXT_color_buffer_half_float")||Et.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[J.id]=new Ne(1,1,{generateMipmaps:!0,type:Lt?Tn:nn,minFilter:bi,samples:Math.max(4,C.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ee.workingColorSpace})}let St=b.state.transmissionRenderTarget[J.id],At=J.viewport||Y;St.setSize(At.z*R.transmissionResolutionScale,At.w*R.transmissionResolutionScale);let bt=R.getRenderTarget(),Pt=R.getActiveCubeFace(),Nt=R.getActiveMipmapLevel();R.setRenderTarget(St),R.getClearColor(nt),lt=R.getClearAlpha(),lt<1&&R.setClearColor(16777215,.5),R.clear(),dt&&Jt.render(Q);let Kt=R.toneMapping;R.toneMapping=wn;let te=J.viewport;if(J.viewport!==void 0&&(J.viewport=void 0),b.setupLightsView(J),Xt===!0&&Ft.setGlobalState(R.clippingPlanes,J),$r(E,Q,J),it.updateMultisampleRenderTarget(St),it.updateRenderTargetMipmap(St),Et.has("WEBGL_multisampled_render_to_texture")===!1){let Lt=!1;for(let he=0,Ie=k.length;he0,J.currentProgram=te,J.uniformsList=null,te}function Jh(E){if(E.uniformsList===null){let k=E.currentProgram.getUniforms();E.uniformsList=Ns.seqWithValue(k.seq,E.uniforms)}return E.uniformsList}function Kh(E,k){let Q=j.get(E);Q.outputColorSpace=k.outputColorSpace,Q.batching=k.batching,Q.batchingColor=k.batchingColor,Q.instancing=k.instancing,Q.instancingColor=k.instancingColor,Q.instancingMorph=k.instancingMorph,Q.skinning=k.skinning,Q.morphTargets=k.morphTargets,Q.morphNormals=k.morphNormals,Q.morphColors=k.morphColors,Q.morphTargetsCount=k.morphTargetsCount,Q.numClippingPlanes=k.numClippingPlanes,Q.numIntersection=k.numClipIntersection,Q.vertexAlphas=k.vertexAlphas,Q.vertexTangents=k.vertexTangents,Q.toneMapping=k.toneMapping}function Op(E,k){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;S.setFromMatrixPosition(k.matrixWorld);for(let Q=0,J=E.length;Q0),Lt=!!Q.morphAttributes.position,he=!!Q.morphAttributes.normal,Ie=!!Q.morphAttributes.color,we=wn;J.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(we=R.toneMapping);let _e=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,$e=_e!==void 0?_e.length:0,Tt=j.get(J),tn=b.state.lights;if(Xt===!0&&($t===!0||E!==G)){let ye=E===G&&J.id===F;Ft.setState(J,E,ye)}let oe=!1;J.version===Tt.__version?(Tt.needsLights&&Tt.lightsStateVersion!==tn.state.version||Tt.outputColorSpace!==bt||K.isBatchedMesh&&Tt.batching===!1||!K.isBatchedMesh&&Tt.batching===!0||K.isBatchedMesh&&Tt.batchingColor===!0&&K._colorsTexture===null||K.isBatchedMesh&&Tt.batchingColor===!1&&K._colorsTexture!==null||K.isInstancedMesh&&Tt.instancing===!1||!K.isInstancedMesh&&Tt.instancing===!0||K.isSkinnedMesh&&Tt.skinning===!1||!K.isSkinnedMesh&&Tt.skinning===!0||K.isInstancedMesh&&Tt.instancingColor===!0&&K.instanceColor===null||K.isInstancedMesh&&Tt.instancingColor===!1&&K.instanceColor!==null||K.isInstancedMesh&&Tt.instancingMorph===!0&&K.morphTexture===null||K.isInstancedMesh&&Tt.instancingMorph===!1&&K.morphTexture!==null||Tt.envMap!==Nt||J.fog===!0&&Tt.fog!==St||Tt.numClippingPlanes!==void 0&&(Tt.numClippingPlanes!==Ft.numPlanes||Tt.numIntersection!==Ft.numIntersection)||Tt.vertexAlphas!==Kt||Tt.vertexTangents!==te||Tt.morphTargets!==Lt||Tt.morphNormals!==he||Tt.morphColors!==Ie||Tt.toneMapping!==we||Tt.morphTargetsCount!==$e||!!Tt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(oe=!0):(oe=!0,Tt.__version=J.version);let un=Tt.currentProgram;oe===!0&&(un=Zr(J,k,K),N&&J.isNodeMaterial&&N.onUpdateProgram(J,un,Tt));let Pn=!1,li=!1,$i=!1,me=un.getUniforms(),Ce=Tt.uniforms;if(y.useProgram(un.program)&&(Pn=!0,li=!0,$i=!0),J.id!==F&&(F=J.id,li=!0),Tt.needsLights){let ye=Op(b.state.lightProbeGridArray,K);Tt.lightProbeGrid!==ye&&(Tt.lightProbeGrid=ye,li=!0)}if(Pn||G!==E){y.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),me.setValue(I,"projectionMatrix",E.projectionMatrix),me.setValue(I,"viewMatrix",E.matrixWorldInverse);let hi=me.map.cameraPosition;hi!==void 0&&hi.setValue(I,Qt.setFromMatrixPosition(E.matrixWorld)),C.logarithmicDepthBuffer&&me.setValue(I,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&me.setValue(I,"isOrthographic",E.isOrthographicCamera===!0),G!==E&&(G=E,li=!0,$i=!0)}if(Tt.needsLights&&(tn.state.sunShadowMap.length>0&&me.setValue(I,"sunShadowMap",tn.state.sunShadowMap,it),tn.state.directionalShadowMap.length>0&&me.setValue(I,"directionalShadowMap",tn.state.directionalShadowMap,it),tn.state.spotShadowMap.length>0&&me.setValue(I,"spotShadowMap",tn.state.spotShadowMap,it),tn.state.pointShadowMap.length>0&&me.setValue(I,"pointShadowMap",tn.state.pointShadowMap,it)),K.isSkinnedMesh){me.setOptional(I,K,"bindMatrix"),me.setOptional(I,K,"bindMatrixInverse");let ye=K.skeleton;ye&&(ye.boneTexture===null&&ye.computeBoneTexture(),me.setValue(I,"boneTexture",ye.boneTexture,it))}K.isBatchedMesh&&(me.setOptional(I,K,"batchingTexture"),me.setValue(I,"batchingTexture",K._matricesTexture,it),me.setOptional(I,K,"batchingIdTexture"),me.setValue(I,"batchingIdTexture",K._indirectTexture,it),me.setOptional(I,K,"batchingColorTexture"),K._colorsTexture!==null&&me.setValue(I,"batchingColorTexture",K._colorsTexture,it));let ci=Q.morphAttributes;if((ci.position!==void 0||ci.normal!==void 0||ci.color!==void 0)&&H.update(K,Q,un),(li||Tt.receiveShadow!==K.receiveShadow)&&(Tt.receiveShadow=K.receiveShadow,me.setValue(I,"receiveShadow",K.receiveShadow)),(J.isMeshStandardMaterial||J.isMeshLambertMaterial||J.isMeshPhongMaterial)&&J.envMap===null&&k.environment!==null&&(Ce.envMapIntensity.value=k.environmentIntensity),Ce.dfgLUT!==void 0&&(Ce.dfgLUT.value=Rv()),li){if(me.setValue(I,"toneMappingExposure",R.toneMappingExposure),Tt.needsLights&&kp(Ce,$i),St&&J.fog===!0&&Ut.refreshFogUniforms(Ce,St),Ut.refreshMaterialUniforms(Ce,J,tt,X,b.state.transmissionRenderTarget[E.id]),Tt.needsLights&&Tt.lightProbeGrid){let ye=Tt.lightProbeGrid;Ce.probesSH.value=ye.texture,Ce.probesMin.value.copy(ye.boundingBox.min),Ce.probesMax.value.copy(ye.boundingBox.max),Ce.probesResolution.value.copy(ye.resolution)}Ns.upload(I,Jh(Tt),Ce,it)}if(J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Ns.upload(I,Jh(Tt),Ce,it),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&me.setValue(I,"center",K.center),me.setValue(I,"modelViewMatrix",K.modelViewMatrix),me.setValue(I,"normalMatrix",K.normalMatrix),me.setValue(I,"modelMatrix",K.matrixWorld),J.uniformsGroups!==void 0){let ye=J.uniformsGroups;for(let hi=0,Zi=ye.length;hi0&&it.useMultisampledRTT(E)===!1?J=j.get(E).__webglMultisampledFramebuffer:Array.isArray(Nt)?J=Nt[Q]:J=Nt,Y.copy(E.viewport),z.copy(E.scissor),$=E.scissorTest}else Y.copy(ft).multiplyScalar(tt).floor(),z.copy(Ot).multiplyScalar(tt).floor(),$=Ct;if(Q!==0&&(J=B),y.bindFramebuffer(I.FRAMEBUFFER,J)&&y.drawBuffers(E,J),y.viewport(Y),y.scissor(z),y.setScissorTest($),K){let bt=j.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+k,bt.__webglTexture,Q)}else if(St){let bt=k;for(let Pt=0;Pt1&&I.readBuffer(I.COLOR_ATTACHMENT0+bt);let Lt=jh(Nt);if(Lt.__formatReadable===!1){Wt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Lt.__typeReadable===!1){Wt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=E.width-J&&Q>=0&&Q<=E.height-K&&I.readPixels(k,Q,J,K,vt.convert(Kt),vt.convert(te),St)}finally{let Nt=O!==null?j.get(O).__webglFramebuffer:null;y.bindFramebuffer(I.FRAMEBUFFER,Nt)}}},this.readRenderTargetPixelsAsync=async function(E,k,Q,J,K,St,At,bt=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pt=j.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&At!==void 0&&(Pt=Pt[At]),Pt)if(k>=0&&k<=E.width-J&&Q>=0&&Q<=E.height-K){y.bindFramebuffer(I.FRAMEBUFFER,Pt);let Nt=E.textures[bt],Kt=Nt.format,te=Nt.type;E.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+bt);let Lt=jh(Nt);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 he=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,he),I.bufferData(I.PIXEL_PACK_BUFFER,St.byteLength,I.STREAM_READ),I.readPixels(k,Q,J,K,vt.convert(Kt),vt.convert(te),0),I.bindBuffer(I.PIXEL_PACK_BUFFER,null);let Ie=O!==null?j.get(O).__webglFramebuffer:null;y.bindFramebuffer(I.FRAMEBUFFER,Ie);let we=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await gd(I,we,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,he),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,St),I.bindBuffer(I.PIXEL_PACK_BUFFER,null),I.deleteBuffer(he),I.deleteSync(we),St}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,k=null,Q=0){let J=Math.pow(2,-Q),K=Math.floor(E.image.width*J),St=Math.floor(E.image.height*J),At=k!==null?k.x:0,bt=k!==null?k.y:0;it.setTexture2D(E,0),I.copyTexSubImage2D(I.TEXTURE_2D,Q,0,0,At,bt,K,St),y.unbindTexture()},this.copyTextureToTexture=function(E,k,Q=null,J=null,K=0,St=0){let At,bt,Pt,Nt,Kt,te,Lt,he,Ie,we=E.isCompressedTexture?E.mipmaps[St]:E.image;if(Q!==null)At=Q.max.x-Q.min.x,bt=Q.max.y-Q.min.y,Pt=Q.isBox3?Q.max.z-Q.min.z:1,Nt=Q.min.x,Kt=Q.min.y,te=Q.isBox3?Q.min.z:0;else{let Ce=Math.pow(2,-K);At=Math.floor(we.width*Ce),bt=Math.floor(we.height*Ce),E.isDataArrayTexture?Pt=we.depth:E.isData3DTexture?Pt=Math.floor(we.depth*Ce):Pt=1,Nt=0,Kt=0,te=0}J!==null?(Lt=J.x,he=J.y,Ie=J.z):(Lt=0,he=0,Ie=0);let _e=vt.convert(k.format),$e=vt.convert(k.type),Tt;k.isData3DTexture?(it.setTexture3D(k,0),Tt=I.TEXTURE_3D):k.isDataArrayTexture||k.isCompressedArrayTexture?(it.setTexture2DArray(k,0),Tt=I.TEXTURE_2D_ARRAY):(it.setTexture2D(k,0),Tt=I.TEXTURE_2D),y.activeTexture(I.TEXTURE0),y.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,k.flipY),y.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),y.pixelStorei(I.UNPACK_ALIGNMENT,k.unpackAlignment);let tn=y.getParameter(I.UNPACK_ROW_LENGTH),oe=y.getParameter(I.UNPACK_IMAGE_HEIGHT),un=y.getParameter(I.UNPACK_SKIP_PIXELS),Pn=y.getParameter(I.UNPACK_SKIP_ROWS),li=y.getParameter(I.UNPACK_SKIP_IMAGES);y.pixelStorei(I.UNPACK_ROW_LENGTH,we.width),y.pixelStorei(I.UNPACK_IMAGE_HEIGHT,we.height),y.pixelStorei(I.UNPACK_SKIP_PIXELS,Nt),y.pixelStorei(I.UNPACK_SKIP_ROWS,Kt),y.pixelStorei(I.UNPACK_SKIP_IMAGES,te);let $i=E.isDataArrayTexture||E.isData3DTexture,me=k.isDataArrayTexture||k.isData3DTexture;if(E.isDepthTexture){let Ce=j.get(E),ci=j.get(k),ye=j.get(Ce.__renderTarget),hi=j.get(ci.__renderTarget);y.bindFramebuffer(I.READ_FRAMEBUFFER,ye.__webglFramebuffer),y.bindFramebuffer(I.DRAW_FRAMEBUFFER,hi.__webglFramebuffer);for(let Zi=0;Zi=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(lh(l,0,a.join(""))i!==null&&typeof i=="object"&&!Array.isArray(i),oi=i=>Array.isArray(i)&&i.every(Xi),Ti=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number"),ef=i=>Xi(i)&&Ti(i.min)&&Ti(i.max),jd=i=>i==null||Xi(i)&&oi(i.planes)&&i.planes.every(t=>Ti(t.normal)&&t.normal.every(Number.isFinite)&&t.normal.some(e=>e!==0)&&Number.isFinite(t.offset))&&(i.box==null||ef(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function Pv(i){if(!Xi(i)||!oi(i.elements)||!oi(i.geometries)||!oi(i.materials)||!Xi(i.instances))throw new se("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new se("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new se("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 se(`Invalid META instance ${n} view.`);for(let n of i.geometries){let s=n.q;if(!ef(n.bbox)||!["u16","u32"].includes(n.indices?.t)||n.positions?.t!==(s?"u16":"f32")||s&&(!Ti(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.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 se("Invalid META geometry.")}if(i.points!=null){let n=i.points;if(!Xi(n)||!Number.isSafeInteger(n.count)||n.count<0)throw new se("Invalid META point count.");for(let[s,r,o]of[["geometry","u32",n.count],["material","u32",n.count],["element","i32",n.count],["matrix","f32",n.count*12]])if(n[s]?.t!==r||n[s].n!==o)throw new se(`Invalid META point ${s} view.`)}if(i.panoramas!=null&&(!oi(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"||!Ti(n.position)||!n.position.every(Number.isFinite)||!Number.isFinite(n.yaw)||!e(n.image)||n.intensity!=null&&!e(n.intensity))))throw new se("Invalid META panorama.");function e(n){return n?.t==="u8"&&Number.isSafeInteger(n.n)&&n.n>=4&&n.n<=16*1024*1024}Lv(i);for(let n of i.materials){let s=n.texture;if(!Ti(n.color)||typeof n.opacity!="number"||s!=null&&(!Number.isInteger(s)||s<0||s>=(i.textures?.length??0)))throw new se("Invalid META material.")}}function Lv(i){if(!Xi(i)||!oi(i.elements)||i.title!=null&&typeof i.title!="string")throw new se("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!oi(i[l]))throw new se(`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 se("Invalid META model or level identity.");let t=l=>l==null||Array.isArray(l)&&l.every(c=>Number.isInteger(c)&&c>=0&&cTi(l)&&l.every(Number.isFinite),n=l=>l==null||typeof l=="string",s=l=>e(l.camera?.position)&&e(l.camera?.target)&&jd(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=Pr(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=>!oi(l.clashes)||l.clashes.some(c=>!Ti(c.point))))throw new se("Invalid META grids, viewpoints or clashes.");if(i.bcfTopics?.some(l=>typeof l.title!="string"||!n(l.description)||!n(l.status)||!oi(l.viewpoints)||l.viewpoints.some(c=>!o(c))))throw new se("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new se("Invalid META linked file members.");if(!jd(i.sections))throw new se("Invalid META sections.")}function Dv(i){let t;try{t=JSON.parse(i)}catch(e){throw new se(e.message,{cause:e})}return Pv(t),t}function ch(i=document,t){t?.("metadataStart");let e;try{e=tf(i,"ioviewer-meta")}catch(s){throw s instanceof se?s:new se(s.message,{cause:s})}let n=Dv(e);return t?.("metadataEnd"),n}function Qd(i,t){let e=Cv[i?.t];if(!e)throw new se(`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 se(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function nf(i=document,t,e=ch(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}=Kd(s)),t?.("binaryEnd")}catch(c){throw new se(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=Qd(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=Qd(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=Kd(s).bytes));let d=n??o;return d?new h(d.buffer,c.o,c.n):new h(Iv(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(tf(i,"ioviewer-props"))),l[c]??null}}}var sf=new Zt,rf=new On,hh=32;function uh(i,t=new Float64Array(24)){return sf.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),rf.setFromProjectionMatrix(sf,i.coordinateSystem,i.reversedDepth),rf.planes.forEach(({normal:e,constant:n},s)=>t.set([e.x,e.y,e.z,n],s*4)),t}function dh(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 of(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 An=.0009765625,ph=32767,Lr=i=>i<0?-1:1;function lf(i){let t=Math.min(Math.max(i,-1),1)*ph;return Lr(t)*Math.round(Math.abs(t))}function Dr(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))*Lr(o),(1-Math.abs(o))*Lr(a)]),i[t]=lf(o),i[t+1]=lf(a)}function cf(i,t,e,n){let s=Math.max(e/ph,-1),r=Math.max(n/ph,-1),o=1-Math.abs(s)-Math.abs(r);o<0&&([s,r]=[(1-Math.abs(r))*Lr(s),(1-Math.abs(s))*Lr(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 Nr(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 tl(i,t){let e=Nr(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=Uv(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 gf(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&&Fv(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+=mf(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function Fv(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 _f(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 gh=384*2**20;function xf(i,{cap:t=gh,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 el(i,t){return i>65535?new Uint32Array(t):new Uint16Array(t)}function _h(i,t){return i.sort((e,n)=>t[n]-t[e]||e-n)}function vf(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function yf(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function Mf(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===An){for(let a=0;a<3;a++)n[a]=s[9+a]+e.q.o[a];return df}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/An)*An,Math.ceil((c-n[a])/An)<=ff||(o=!1)}return o||n.fill(0),o?Nv:Bs}function bf(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]]===Bs,o=r?new Float32Array(n*4):new Uint16Array(n*4),a=new Int16Array(n*2),l=t.textured?new Float32Array(n*2):null,c=el(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/An),0),ff);function Sf(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 nl(i){if(!i.normals&&i.oct){i.normals=new Float32Array(i.vertices*3);for(let t=0;t=0&&(y[It]=null,v[It].disconnect(ut))}for(let Q=0;Q=y.length){y.push(ut),It=Ut;break}else if(y[Ut]===null){y[Ut]=ut,It=Ut;break}if(It===-1)break}let ft=v[It];ft&&ft.connect(ut)}}let U=new R,z=new R;function q(H,Q,ut){U.setFromMatrixPosition(Q.matrixWorld),z.setFromMatrixPosition(ut.matrixWorld);let It=U.distanceTo(z),ft=Q.projectionMatrix.elements,Ut=ut.projectionMatrix.elements,ae=ft[14]/(ft[10]-1),Gt=ft[14]/(ft[10]+1),Jt=(ft[9]+1)/ft[5],mt=(ft[9]-1)/ft[5],Ct=(ft[8]-1)/ft[0],$t=(Ut[8]+1)/Ut[0],qt=ae*Ct,Me=ae*$t,dt=It/(-Ct+$t),Ft=dt*-Ct;if(Q.matrixWorld.decompose(H.position,H.quaternion,H.scale),H.translateX(Ft),H.translateZ(dt),H.matrixWorld.compose(H.position,H.quaternion,H.scale),H.matrixWorldInverse.copy(H.matrixWorld).invert(),ft[10]===-1)H.projectionMatrix.copy(Q.projectionMatrix),H.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{let C=ae+dt,ht=Gt+dt,Tt=qt-Ft,P=Me+(It-Ft),M=Jt*Gt/ht*C,Y=mt*Gt/ht*C;H.projectionMatrix.makePerspective(Tt,P,M,Y,C,ht),H.projectionMatrixInverse.copy(H.projectionMatrix).invert()}}function V(H,Q){Q===null?H.matrixWorld.copy(H.matrix):H.matrixWorld.multiplyMatrices(Q.matrixWorld,H.matrix),H.matrixWorldInverse.copy(H.matrixWorld).invert()}this.updateCamera=function(H){if(s===null)return;let Q=H.near,ut=H.far;p.texture!==null&&(p.depthNear>0&&(Q=p.depthNear),p.depthFar>0&&(ut=p.depthFar)),B.near=D.near=I.near=Q,B.far=D.far=I.far=ut,(L!==B.near||F!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),L=B.near,F=B.far),B.layers.mask=H.layers.mask|6,I.layers.mask=B.layers.mask&-5,D.layers.mask=B.layers.mask&-3;let It=H.parent,ft=B.cameras;V(B,It);for(let Ut=0;Ut0&&(p.alphaTest.value=m.alphaTest);let b=t.get(m),w=b.envMap,S=b.envMapRotation;w&&(p.envMap.value=w,p.envMapRotation.value.setFromMatrix4(Dv.makeRotationFromEuler(S)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(sf),p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,p.aoMapTransform))}function o(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform))}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,b,w){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*b,p.scale.value=w*.5,m.map&&(p.map.value=m.map,e(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,b){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===ze&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.retroreflectivity>0&&(p.retroreflectivity.value=m.retroreflectivity),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=b.texture,p.transmissionSamplerSize.value.set(b.width,b.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function _(p,m){let b=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(b.matrixWorld),p.nearDistance.value=b.shadow.camera.near,p.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Uv(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,v){let y=v.program;n.uniformBlockBinding(S,y)}function c(S,v){let y=s[S.id];y===void 0&&(p(S),y=h(S),s[S.id]=y,S.addEventListener("dispose",b));let A=v.program;n.updateUBOMapping(S,A);let x=t.render.frame;r[S.id]!==x&&(d(S),r[S.id]=x)}function h(S){let v=u();S.__bindingPointIndex=v;let y=i.createBuffer(),A=S.__size,x=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,y),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,v,y),y}function u(){for(let S=0;S0&&(y+=A-x),S.__size=y,S.__cache={},this}function m(S){let v={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(v.boundary=4,v.storage=4):S.isVector2?(v.boundary=8,v.storage=8):S.isVector3||S.isColor?(v.boundary=16,v.storage=12):S.isVector4?(v.boundary=16,v.storage=16):S.isMatrix3?(v.boundary=48,v.storage=48):S.isMatrix4?(v.boundary=64,v.storage=64):S.isTexture?Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(v.boundary=16,v.storage=S.byteLength):Ht("WebGLRenderer: Unsupported uniform value type.",S),v}function b(S){let v=S.target;v.removeEventListener("dispose",b);let y=o.indexOf(v.__bindingPointIndex);o.splice(y,1),i.deleteBuffer(s[v.id]),delete s[v.id],delete r[v.id]}function w(){for(let S in s)i.deleteBuffer(s[S]);o=[],s={},r={}}return{bind:l,update:c,dispose:w}}var Fv=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 Bv(){return $n===null&&($n=new mn(Fv,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=bd(),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:u=!1,reversedDepthBuffer:d=!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,p=new Set([xa,_a,ga]),m=new Set([rn,Tn,Ps,Ls,pa,ma]),b=new Uint32Array(4),w=new Int32Array(4),S=new R,v=null,y=null,A=[],x=[],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 I=this,D=!1,N=null,B=null,L=null,F=null;this._outputColorSpace=pe;let k=0,W=0,O=null,U=-1,z=null,q=new xe,V=new xe,Z=null,K=new kt(0),lt=0,rt=e.width,H=e.height,Q=1,ut=null,It=null,ft=new xe(0,0,rt,H),Ut=new xe(0,0,rt,H),ae=!1,Gt=new kn,Jt=!1,mt=!1,Ct=new Yt,$t=new R,qt=new xe,Me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},dt=!1;function Ft(){return O===null?Q:1}let C=n;function ht(T,G){return e.getContext(T,G)}let Tt,P,M,Y,tt,it,pt,gt,st,at,_t,Bt,Mt,xt,Ot,Vt,Kt,X,vt,ot,yt,Et,ct;try{let T={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",be,!1),e.addEventListener("webglcontextrestored",he,!1),e.addEventListener("webglcontextcreationerror",_n,!1),C===null){let G="webgl2";if(C=ht(G,T),C===null)throw ht(G)?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",he,!1),e.removeEventListener("webglcontextcreationerror",_n,!1),Xt("WebGLRenderer: "+T.message),T}function zt(){Tt=new W_(C),Tt.init(),yt=new Iv(C,Tt),P=new N_(C,Tt,t,yt),M=new Rv(C,Tt),P.reversedDepthBuffer&&d&&M.buffers.depth.setReversed(!0),B=C.createFramebuffer(),L=C.createFramebuffer(),F=C.createFramebuffer(),Y=new Y_(C),tt=new pv,it=new Cv(C,Tt,M,tt,P,yt,Y),pt=new G_(I),gt=new Zm(C),Et=new L_(C,gt),st=new X_(C,gt,Y,Et),at=new Z_(C,st,gt,Et,Y),X=new $_(C,P,it),Ot=new U_(tt),_t=new fv(I,pt,Tt,P,Et,Ot),Bt=new Nv(I,tt),Mt=new gv,xt=new bv(Tt),Kt=new P_(I,pt,M,at,g,l),Vt=new Av(I,at,P),ct=new Uv(C,Y,P,M),vt=new D_(C,Tt,Y),ot=new q_(C,Tt,Y),Y.programs=_t.programs,I.capabilities=P,I.extensions=Tt,I.properties=tt,I.renderLists=Mt,I.shadowMap=Vt,I.state=M,I.info=Y}_!==rn&&(E=new J_(_,e.width,e.height,a,s,r));let Dt=new fh(I,C);this.xr=Dt,this.getContext=function(){return C},this.getContextAttributes=function(){return C.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 Q},this.setPixelRatio=function(T){T!==void 0&&(Q=T,this.setSize(rt,H,!1))},this.getSize=function(T){return T.set(rt,H)},this.setSize=function(T,G,et=!0){if(Dt.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}rt=T,H=G,e.width=Math.floor(T*Q),e.height=Math.floor(G*Q),et===!0&&(e.style.width=T+"px",e.style.height=G+"px"),E!==null&&E.setSize(e.width,e.height),this.setViewport(0,0,T,G)},this.getDrawingBufferSize=function(T){return T.set(rt*Q,H*Q).floor()},this.setDrawingBufferSize=function(T,G,et){rt=T,H=G,Q=et,e.width=Math.floor(T*et),e.height=Math.floor(G*et),this.setViewport(0,0,T,G)},this.setEffects=function(T){if(_===rn){Xt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(T){for(let G=0;G{function wt(){if(J.forEach(function(Rt){let Pt=tt.get(Rt).currentProgram;(Pt===void 0||Pt.isReady())&&J.delete(Rt)}),J.size===0){j(T);return}setTimeout(wt,10)}Tt.get("KHR_parallel_shader_compile")!==null?wt():setTimeout(wt,10)})};let Fl=null;function qp(T){Fl&&Fl(T)}function Qh(){Pi.stop()}function tu(){Pi.start()}let Pi=new Jd;Pi.setAnimationLoop(qp),typeof self<"u"&&Pi.setContext(self),this.setAnimationLoop=function(T){Fl=T,Dt.setAnimationLoop(T),T===null?Pi.stop():Pi.start()},Dt.addEventListener("sessionstart",Qh),Dt.addEventListener("sessionend",tu),this.render=function(T,G){if(G!==void 0&&G.isCamera!==!0){Xt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;N!==null&&N.renderStart(T,G);let et=Dt.enabled===!0&&Dt.isPresenting===!0,J=E!==null&&(O===null||et)&&E.begin(I,O);if(T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),G.parent===null&&G.matrixWorldAutoUpdate===!0&&G.updateMatrixWorld(),Dt.enabled===!0&&Dt.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Dt.cameraAutoUpdate===!0&&Dt.updateCamera(G),G=Dt.getCamera()),T.isScene===!0&&T.onBeforeRender(I,T,G,O),y=xt.get(T,x.length),y.init(G),y.state.textureUnits=it.getTextureUnits(),x.push(y),Ct.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse),Gt.setFromProjectionMatrix(Ct,bn,G.reversedDepth),mt=this.localClippingEnabled,Jt=Ot.init(this.clippingPlanes,mt),v=Mt.get(T,A.length),v.init(),A.push(v),Dt.enabled===!0&&Dt.isPresenting===!0){let Rt=I.xr.getDepthSensingMesh();Rt!==null&&Bl(Rt,G,-1/0,I.sortObjects)}Bl(T,G,0,I.sortObjects),v.finish(),N!==null&&N.updateLights(y.state.lightsArray),I.sortObjects===!0&&v.sort(ut,It),dt=Dt.enabled===!1||Dt.isPresenting===!1||Dt.hasDepthSensing()===!1,dt&&Kt.addToRenderList(v,T),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Jt===!0&&Ot.beginShadows();let j=y.state.shadowsArray;if(Vt.render(j,T,G),Jt===!0&&Ot.endShadows(),(J&&E.hasRenderPass())===!1){let Rt=v.opaque,St=v.transmissive;if(y.setupLights(),G.isArrayCamera){let Pt=G.cameras;if(St.length>0)for(let Nt=0,jt=Pt.length;Nt0&&nu(Rt,St,T,G),dt&&Kt.render(T),eu(v,T,G)}O!==null&&W===0&&(it.updateMultisampleRenderTarget(O),it.updateRenderTargetMipmap(O)),J&&E.end(I),T.isScene===!0&&T.onAfterRender(I,T,G),Et.resetDefaultState(),U=-1,z=null,x.pop(),x.length>0?(y=x[x.length-1],it.setTextureUnits(y.state.textureUnits),Jt===!0&&Ot.setGlobalState(I.clippingPlanes,y.state.camera)):y=null,A.pop(),A.length>0?v=A[A.length-1]:v=null,N!==null&&N.renderEnd()};function Bl(T,G,et,J){if(T.visible===!1)return;if(T.layers.test(G.layers)){if(T.isGroup)et=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(G);else if(T.isLightProbeGrid)y.pushLightProbeGrid(T);else if(T.isLight)y.pushLight(T),T.castShadow&&y.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||T.intersectsFrustum(Gt)){J&&qt.setFromMatrixPosition(T.matrixWorld).applyMatrix4(Ct);let Rt=at.update(T),St=T.material;St.visible&&v.push(T,Rt,St,et,qt.z,null,G)}}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(Ct)),Array.isArray(St)){let Pt=Rt.groups;for(let Nt=0,jt=Pt.length;Nt0&&Jr(j,G,et),wt.length>0&&Jr(wt,G,et),Rt.length>0&&Jr(Rt,G,et),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function nu(T,G,et,J){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;if(y.state.transmissionRenderTarget[J.id]===void 0){let Lt=Tt.has("EXT_color_buffer_half_float")||Tt.has("EXT_color_buffer_float");y.state.transmissionRenderTarget[J.id]=new Be(1,1,{generateMipmaps:!0,type:Lt?An:rn,minFilter:Si,samples:Math.max(4,P.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ne.workingColorSpace})}let wt=y.state.transmissionRenderTarget[J.id],Rt=J.viewport||q;wt.setSize(Rt.z*I.transmissionResolutionScale,Rt.w*I.transmissionResolutionScale);let St=I.getRenderTarget(),Pt=I.getActiveCubeFace(),Nt=I.getActiveMipmapLevel();I.setRenderTarget(wt),I.getClearColor(K),lt=I.getClearAlpha(),lt<1&&I.setClearColor(16777215,.5),I.clear(),dt&&Kt.render(et);let jt=I.toneMapping;I.toneMapping=En;let ee=J.viewport;if(J.viewport!==void 0&&(J.viewport=void 0),y.setupLightsView(J),Jt===!0&&Ot.setGlobalState(I.clippingPlanes,J),Jr(T,et,J),it.updateMultisampleRenderTarget(wt),it.updateRenderTargetMipmap(wt),Tt.has("WEBGL_multisampled_render_to_texture")===!1){let Lt=!1;for(let ue=0,De=G.length;ue0,J.currentProgram=ee,J.uniformsList=null,ee}function su(T){if(T.uniformsList===null){let G=T.currentProgram.getUniforms();T.uniformsList=Fs.seqWithValue(G.seq,T.uniforms)}return T.uniformsList}function ru(T,G){let et=tt.get(T);et.outputColorSpace=G.outputColorSpace,et.batching=G.batching,et.batchingColor=G.batchingColor,et.instancing=G.instancing,et.instancingColor=G.instancingColor,et.instancingMorph=G.instancingMorph,et.skinning=G.skinning,et.morphTargets=G.morphTargets,et.morphNormals=G.morphNormals,et.morphColors=G.morphColors,et.morphTargetsCount=G.morphTargetsCount,et.numClippingPlanes=G.numClippingPlanes,et.numIntersection=G.numClipIntersection,et.vertexAlphas=G.vertexAlphas,et.vertexTangents=G.vertexTangents,et.toneMapping=G.toneMapping}function Yp(T,G){if(T.length===0)return null;if(T.length===1)return T[0].texture!==null?T[0]:null;S.setFromMatrixPosition(G.matrixWorld);for(let et=0,J=T.length;et0),Lt=!!et.morphAttributes.position,ue=!!et.morphAttributes.normal,De=!!et.morphAttributes.color,Ee=En;J.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(Ee=I.toneMapping);let ve=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,$e=ve!==void 0?ve.length:0,At=tt.get(J),en=y.state.lights;if(Jt===!0&&(mt===!0||T!==z)){let Se=T===z&&J.id===U;Ot.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!==wt||At.numClippingPlanes!==void 0&&(At.numClippingPlanes!==Ot.numPlanes||At.numIntersection!==Ot.numIntersection)||At.vertexAlphas!==jt||At.vertexTangents!==ee||At.morphTargets!==Lt||At.morphNormals!==ue||At.morphColors!==De||At.toneMapping!==Ee||At.morphTargetsCount!==$e||!!At.lightProbeGrid!=y.state.lightProbeGridArray.length>0)&&(le=!0):(le=!0,At.__version=J.version);let dn=At.currentProgram;le===!0&&(dn=jr(J,G,j),N&&J.isNodeMaterial&&N.onUpdateProgram(J,dn,At));let Nn=!1,ci=!1,Ki=!1,ge=dn.getUniforms(),Pe=At.uniforms;if(M.useProgram(dn.program)&&(Nn=!0,ci=!0,Ki=!0),J.id!==U&&(U=J.id,ci=!0),At.needsLights){let Se=Yp(y.state.lightProbeGridArray,j);At.lightProbeGrid!==Se&&(At.lightProbeGrid=Se,ci=!0)}if(Nn||z!==T){M.buffers.depth.getReversed()&&T.reversedDepth!==!0&&(T._reversedDepth=!0,T.updateProjectionMatrix()),ge.setValue(C,"projectionMatrix",T.projectionMatrix),ge.setValue(C,"viewMatrix",T.matrixWorldInverse);let ui=ge.map.cameraPosition;ui!==void 0&&ui.setValue(C,$t.setFromMatrixPosition(T.matrixWorld)),P.logarithmicDepthBuffer&&ge.setValue(C,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&ge.setValue(C,"isOrthographic",T.isOrthographicCamera===!0),z!==T&&(z=T,ci=!0,Ki=!0)}if(At.needsLights&&(en.state.sunShadowMap.length>0&&ge.setValue(C,"sunShadowMap",en.state.sunShadowMap,it),en.state.directionalShadowMap.length>0&&ge.setValue(C,"directionalShadowMap",en.state.directionalShadowMap,it),en.state.spotShadowMap.length>0&&ge.setValue(C,"spotShadowMap",en.state.spotShadowMap,it),en.state.pointShadowMap.length>0&&ge.setValue(C,"pointShadowMap",en.state.pointShadowMap,it)),j.isSkinnedMesh){ge.setOptional(C,j,"bindMatrix"),ge.setOptional(C,j,"bindMatrixInverse");let Se=j.skeleton;Se&&(Se.boneTexture===null&&Se.computeBoneTexture(),ge.setValue(C,"boneTexture",Se.boneTexture,it))}j.isBatchedMesh&&(ge.setOptional(C,j,"batchingTexture"),ge.setValue(C,"batchingTexture",j._matricesTexture,it),ge.setOptional(C,j,"batchingIdTexture"),ge.setValue(C,"batchingIdTexture",j._indirectTexture,it),ge.setOptional(C,j,"batchingColorTexture"),j._colorsTexture!==null&&ge.setValue(C,"batchingColorTexture",j._colorsTexture,it));let hi=et.morphAttributes;if((hi.position!==void 0||hi.normal!==void 0||hi.color!==void 0)&&X.update(j,et,dn),(ci||At.receiveShadow!==j.receiveShadow)&&(At.receiveShadow=j.receiveShadow,ge.setValue(C,"receiveShadow",j.receiveShadow)),(J.isMeshStandardMaterial||J.isMeshLambertMaterial||J.isMeshPhongMaterial)&&J.envMap===null&&G.environment!==null&&(Pe.envMapIntensity.value=G.environmentIntensity),Pe.dfgLUT!==void 0&&(Pe.dfgLUT.value=Bv()),ci){if(ge.setValue(C,"toneMappingExposure",I.toneMappingExposure),At.needsLights&&Zp(Pe,Ki),wt&&J.fog===!0&&Bt.refreshFogUniforms(Pe,wt),Bt.refreshMaterialUniforms(Pe,J,Q,H,y.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(C,su(At),Pe,it)}if(J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Fs.upload(C,su(At),Pe,it),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&ge.setValue(C,"center",j.center),ge.setValue(C,"modelViewMatrix",j.modelViewMatrix),ge.setValue(C,"normalMatrix",j.normalMatrix),ge.setValue(C,"modelMatrix",j.matrixWorld),J.uniformsGroups!==void 0){let Se=J.uniformsGroups;for(let ui=0,Ji=Se.length;ui0&&it.useMultisampledRTT(T)===!1?J=tt.get(T).__webglMultisampledFramebuffer:Array.isArray(Nt)?J=Nt[et]:J=Nt,q.copy(T.viewport),V.copy(T.scissor),Z=T.scissorTest}else q.copy(ft).multiplyScalar(Q).floor(),V.copy(Ut).multiplyScalar(Q).floor(),Z=ae;if(et!==0&&(J=B),M.bindFramebuffer(C.FRAMEBUFFER,J)&&M.drawBuffers(T,J),M.viewport(q),M.scissor(V),M.setScissorTest(Z),j){let St=tt.get(T.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+G,St.__webglTexture,et)}else if(wt){let St=G;for(let Pt=0;Pt1&&C.readBuffer(C.COLOR_ATTACHMENT0+St);let Lt=ou(Nt);if(Lt.__formatReadable===!1){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Lt.__typeReadable===!1){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}G>=0&&G<=T.width-J&&et>=0&&et<=T.height-j&&C.readPixels(G,et,J,j,yt.convert(jt),yt.convert(ee),wt)}finally{let Nt=O!==null?tt.get(O).__webglFramebuffer:null;M.bindFramebuffer(C.FRAMEBUFFER,Nt)}}},this.readRenderTargetPixelsAsync=async function(T,G,et,J,j,wt,Rt,St=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&&Rt!==void 0&&(Pt=Pt[Rt]),Pt)if(G>=0&&G<=T.width-J&&et>=0&&et<=T.height-j){M.bindFramebuffer(C.FRAMEBUFFER,Pt);let Nt=T.textures[St],jt=Nt.format,ee=Nt.type;T.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+St);let Lt=ou(Nt);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 ue=C.createBuffer();C.bindBuffer(C.PIXEL_PACK_BUFFER,ue),C.bufferData(C.PIXEL_PACK_BUFFER,wt.byteLength,C.STREAM_READ),C.readPixels(G,et,J,j,yt.convert(jt),yt.convert(ee),0),C.bindBuffer(C.PIXEL_PACK_BUFFER,null);let De=O!==null?tt.get(O).__webglFramebuffer:null;M.bindFramebuffer(C.FRAMEBUFFER,De);let Ee=C.fenceSync(C.SYNC_GPU_COMMANDS_COMPLETE,0);return C.flush(),await wd(C,Ee,4),C.bindBuffer(C.PIXEL_PACK_BUFFER,ue),C.getBufferSubData(C.PIXEL_PACK_BUFFER,0,wt),C.bindBuffer(C.PIXEL_PACK_BUFFER,null),C.deleteBuffer(ue),C.deleteSync(Ee),wt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,G=null,et=0){let J=Math.pow(2,-et),j=Math.floor(T.image.width*J),wt=Math.floor(T.image.height*J),Rt=G!==null?G.x:0,St=G!==null?G.y:0;it.setTexture2D(T,0),C.copyTexSubImage2D(C.TEXTURE_2D,et,0,0,Rt,St,j,wt),M.unbindTexture()},this.copyTextureToTexture=function(T,G,et=null,J=null,j=0,wt=0){let Rt,St,Pt,Nt,jt,ee,Lt,ue,De,Ee=T.isCompressedTexture?T.mipmaps[wt]:T.image;if(et!==null)Rt=et.max.x-et.min.x,St=et.max.y-et.min.y,Pt=et.isBox3?et.max.z-et.min.z:1,Nt=et.min.x,jt=et.min.y,ee=et.isBox3?et.min.z:0;else{let Pe=Math.pow(2,-j);Rt=Math.floor(Ee.width*Pe),St=Math.floor(Ee.height*Pe),T.isDataArrayTexture?Pt=Ee.depth:T.isData3DTexture?Pt=Math.floor(Ee.depth*Pe):Pt=1,Nt=0,jt=0,ee=0}J!==null?(Lt=J.x,ue=J.y,De=J.z):(Lt=0,ue=0,De=0);let ve=yt.convert(G.format),$e=yt.convert(G.type),At;G.isData3DTexture?(it.setTexture3D(G,0),At=C.TEXTURE_3D):G.isDataArrayTexture||G.isCompressedArrayTexture?(it.setTexture2DArray(G,0),At=C.TEXTURE_2D_ARRAY):(it.setTexture2D(G,0),At=C.TEXTURE_2D),M.activeTexture(C.TEXTURE0),M.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,G.flipY),M.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),M.pixelStorei(C.UNPACK_ALIGNMENT,G.unpackAlignment);let en=M.getParameter(C.UNPACK_ROW_LENGTH),le=M.getParameter(C.UNPACK_IMAGE_HEIGHT),dn=M.getParameter(C.UNPACK_SKIP_PIXELS),Nn=M.getParameter(C.UNPACK_SKIP_ROWS),ci=M.getParameter(C.UNPACK_SKIP_IMAGES);M.pixelStorei(C.UNPACK_ROW_LENGTH,Ee.width),M.pixelStorei(C.UNPACK_IMAGE_HEIGHT,Ee.height),M.pixelStorei(C.UNPACK_SKIP_PIXELS,Nt),M.pixelStorei(C.UNPACK_SKIP_ROWS,jt),M.pixelStorei(C.UNPACK_SKIP_IMAGES,ee);let Ki=T.isDataArrayTexture||T.isData3DTexture,ge=G.isDataArrayTexture||G.isData3DTexture;if(T.isDepthTexture){let Pe=tt.get(T),hi=tt.get(G),Se=tt.get(Pe.__renderTarget),ui=tt.get(hi.__renderTarget);M.bindFramebuffer(C.READ_FRAMEBUFFER,Se.__webglFramebuffer),M.bindFramebuffer(C.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"),hf=i=>Yi(i)&&Ai(i.min)&&Ai(i.max),af=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||hf(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function kv(i){if(!Yi(i)||!Rn(i.elements)||!Rn(i.geometries)||!Rn(i.materials)||!Yi(i.instances))throw new te("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new te("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new te("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 te(`Invalid META instance ${n} view.`);for(let n of i.geometries){let s=n.q;if(!hf(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 te("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 te(`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 te(`Invalid META ${n} ${r} view.`)}if(i.annotations!=null&&!Rn(i.annotations))throw new te("Invalid META annotations.");if(i.sheets!=null&&!Rn(i.sheets))throw new te("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 te("Invalid META panorama.");function e(n){return n?.t==="u8"&&Number.isSafeInteger(n.n)&&n.n>=4&&n.n<=16*1024*1024}Hv(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 te("Invalid META material.")}}function Hv(i){if(!Yi(i)||!Rn(i.elements)||i.title!=null&&typeof i.title!="string")throw new te("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!Rn(i[l]))throw new te(`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 te("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)&&af(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 te("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 te("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new te("Invalid META linked file members.");if(!af(i.sections))throw new te("Invalid META sections.")}function Vv(i){let t;try{t=JSON.parse(i)}catch(e){throw new te(e.message,{cause:e})}return kv(t),t}function mh(i=document,t){t?.("metadataStart");let e;try{e=cf(i,"ioviewer-meta")}catch(s){throw s instanceof te?s:new te(s.message,{cause:s})}let n=Vv(e);return t?.("metadataEnd"),n}function lf(i,t){let e=Ov[i?.t];if(!e)throw new te(`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 te(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function uf(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}=of(s)),t?.("binaryEnd")}catch(c){throw new te(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=lf(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=lf(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=of(s).bytes));let u=n??o;return u?new h(u.buffer,c.o,c.n):new h(zv(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(cf(i,"ioviewer-props"))),l[c]??null}}}var df=new Yt,ff=new kn,gh=32;function _h(i,t=new Float64Array(24)){return df.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ff.setFromProjectionMatrix(df,i.coordinateSystem,i.reversedDepth),ff.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 pf(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 gf(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]=gf(o),i[t+1]=gf(a)}function _f(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[u]&&(s[u]=d))}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(d)?Math.round((d-n[r])/o*a):0;l[h]=f*2**32+u}let c=0;e<0?l.sort():c=Wv(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,u=n;for(;h<=u;){for(;i[h]c;)u--;if(h<=u){let d=i[h];i[h++]=i[u],i[u--]=d}}if(t<=u)n=u;else if(t>=h)e=h;else return a}return a}function wf(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&&Xv(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+=Sf(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function Xv(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],u=t[l*3+2];cr&&(r=c),ho&&(o=h),ua&&(a=u)}return Math.hypot(r-e,o-n,a-s)/2}function Ef(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 Tf(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,u)=>a(u)-a(h)||i[u].k-i[h].k||h-u);let c=0;for(let h of l){let u=i[h].cells??Math.ceil(i[h].k/n);c+u>s||(r[h]=1,c+=u)}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 Af(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function Rf(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function Cf(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 yf}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 u=s[h*3+a]*e.min[h],d=s[h*3+a]*e.max[h];l+=Math.min(u,d),c+=Math.max(u,d)}n[a]=Math.floor(l/Cn)*Cn,Math.ceil((c-n[a])/Cn)<=Mf||(o=!1)}return o||n.fill(0),o?Gv:ks}function If(i,t){let e=i.length,n=0,s=0;for(let p of i){let m=t.source(t.geometryOf[p]);n+=m.vertices,s+=m.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),u=new Float32Array(e*3),d=new Float32Array(e),f=new Float64Array(3),g=0,_=0;for(let p=0;pMath.min(Math.max(Math.round(i/Cn),0),Mf);function Pf(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]=u)}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.0 ? - t : t, n.y >= 0.0 ? - t : t ); return n; -}`,Fr=` +}`,Or=` 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;`,xh=` +vec3 slotPosition = info.xyz + q.xyz * info.w;`,wh=` #ifndef IO_NO_HIDE_BRANCH if ( state.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); -#endif`,kv=` +#endif`,Zv=` vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); @@ -4248,19 +4248,57 @@ transformedNormal = mat3( cross( im[ 1 ], im[ 2 ] ), cross( im[ 2 ], im[ 0 ] ), transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; -#endif`;function Ai(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 Hv(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ai(i.vertexShader,"#include ",`#include -${Ur}`);t=Ai(t,"#include ",`${Fr} -vTint = state.rgb;`),t=Ai(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ai(t,"#include ",kv),t=Ai(t,"#include ","vec3 transformed = slotPosition;"),t=Ai(t,"#include ",`#include -${xh}`),i.vertexShader=t;let e=Ai(i.fragmentShader,"#include ",`#include -varying vec3 vTint;`);e=Ai(e,"#include ","diffuseColor.rgb *= vTint;"),i.fragmentShader=e}function vh(i,t,e=!1){return i.userData.slotUniforms=t,i.onBeforeCompile=Hv,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var Sh=["materials","textures","white","wireframe"],Vv=[245,158,11],Gv=[235,235,237],Br=4294967295,qi=2048,yh=256,Wv=16,Mh=1024,Xv=.1,qv=8192,Yv=1.4,sl=2**-20,il=17;function $v(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 Zv(){this.array=null}function Rn(i,t,e=!1,n=Ae){return new n(i,t,e).onUpload(Zv)}var Or=class extends RangeError{constructor(t,e){super(`${t} drawable instances exceed the limit of ${e}.`),this.name="ModelTooLargeError",this.count=t,this.limit=e}},wf=(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+sl*Math.abs(l)))return!0}return!1}function Ef(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 Kv=i=>{let t=i.getHex(Me);return[t>>16&255,t>>8&255,t&255]},zr=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=r+h;this.root=new Re,this.elementCount=n.elements.length,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(d),this._elementOf.set(t.view(s.element)),this._bucketOf=new Uint32Array(r),this._visible=new Uint8Array(d).fill(1),this._layers=new Map,this._layerHides=new Uint8Array(d),this._highlight=new Uint8Array(d),this._highlighted=[],this._tint=new Map,this._boxes=new Float32Array(d*6),this._minPixels=0,this._viewHeight=1,this.visibleCost=0;let u=!!e.noHideBranch;if(this.slotUniforms={slotInfo:{value:null},slotState:{value:null}},this._buckets=this._createBuckets(n,a,u),h){this._elementOf.set(t.view(c.element),r),this._pointMaterials=t.view(c.material).slice();let m=t.view(c.geometry),_=t.view(c.matrix),g=this._boxes.subarray(r*6);for(let p=0;pthis._shown(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=uh(n,this._planes);let{x:r,y:o,z:a}=n.position;this._pickViewPadding=sl*(Math.abs(r)+Math.abs(o)+Math.abs(a))}for(let r of this._units)r.mesh.material=t,s?(r.mesh.visible=(r.mesh.visible||!!r.lines?.visible)&&r.bucket.material.opacity>0,r.lines&&(r.lines.visible=!1)):this._showUnit(r);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!1);try{return e()}finally{this._picking=!1,this._pickFrustum=null;for(let r of this._units)r.mesh.material=r.bucket.material,this._showUnit(r);for(let r of this._cut)r.mesh.visible=!1,r.lines&&(r.lines.visible=!1);if(!s)for(let r of this._compactCells)this._cellAttributes(r,!0)}}elementBox(t,e=new ae){this._checkElement(t),e.makeEmpty();for(let n=this._elementStart[t];n=0&&t<=1))throw new RangeError(`Opacity must be within 0..1, got ${t}.`);this._opacity=t;for(let e of this._buckets)this._applyOpacity(e);this._changed("appearance")}get opacity(){return this._opacity}setDetail(t,e=1){this._minPixels=t,this._viewHeight=e;for(let s of this._cut)this._showUnit(s);this._cut.length=0;for(let s of this._detailCells)s.detailCount=null;this._detailCells.length=0;for(let s of this._compactCells)this._cellAttributes(s,!1);this._compactCells.length=0;let n=this._unitScale;this._unitScale=null,!(!(t>0)||!n)&&(this._cutInView=0,this._cutFrame=null,this._units.forEach((s,r)=>{if(!(!(n[r]>=0)||s.shown===0)){if(s.dirty&&this._span(s),s.cell&&this._detailUsesInstances){if(s.detailHigh>=t&&this._detailCell(s,t))return}else if(this._slotRadius[s.slotBase+s.first]*n[r]>=t)return;s.mesh.visible=!1,s.lines&&(s.lines.visible=!1),this._cut.push(s),this._cutInView+=bh(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 M=m.cell&&this._detailUsesInstances,T=M&&!of(r,_[0],_[1],_[2],_[3]+m.pickPadding),S=m.slotBase+m.n,v=-1;if(M){let R=this._slotRadius[m.slotBase],D=this._slotRadius[S-1],N=g+_[3],B=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],L=N-B-R,U=N+B-D,W=Math.fround(o[7]?L>0?R*o[6]/L:1/0:R*p),V=Math.fround(o[7]?U>0?D*o[6]/U:1/0:D*p);Fs(V)===Fs(W)&&(v=W)}if(v>=0&&!T){m.detailLow=m.detailHigh=v,m.detailEnd=m.n;let R=this._slotCost[m.slotBase]*m.shown;l[Fs(v)]+=R,u+=R;continue}let b=0,A=1/0,x=-1,w=0;for(let R=m.slotBase;R=0){b++;continue}let F=(W-o[0])*o[3]+(V-o[1])*o[4]+(O-o[2])*o[5]-D;N=o[7]?F>0?o[6]/F:1/0:o[6]}let B=N===1/0?1/0:Math.fround(D*N);M&&(a[R]=B,A=Math.min(A,B),x=Math.max(x,B));let L=this._slotCost[R];l[Fs(B)]+=L,u+=L}if(M){if(b){A=x=v;let R=b*this._slotCost[m.slotBase];l[Fs(v)]+=R,u+=R}m.detailLow=A,m.detailHigh=x,m.detailEnd=w}}return this.visibleCost=u,af(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+=bh(r,r.first,Math.max(r.last+1,r.first)),e+=bh(r,r.first,Math.max(r.end,r.first)),s++);return{drawn:e,inView:n,draws:s}}drawnInstances(t){t.updateMatrixWorld();let e=new On().setFromProjectionMatrix(new Zt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),n={info:{render:{frame:-1}}},s=new Xe,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 F=l.get(O);if(!F){let G=a.geometries[O],Y=t.view(G.indices),z=G.uvs?t.view(G.uvs):null;F=Sf(Nr(t,G),G.q??null,hf(t,G),Y,z),F.drawable=F.indices.length>=3&&F.min.every(Number.isFinite)&&F.max.every(Number.isFinite),l.set(O,F)}return F},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 O=0;OO-F).map(O=>{let F=g.get(O),G=c(e[F[0]]),Y=this._buckets[this._bucketOf[F[0]]].texture!==null,z=[0,1,2].every(nt=>(G.max[nt]-G.min[nt])/An<=65535),$=G.vertices*((z?12:20)+(Y?8:0))+G.indices.length*(G.vertices>65535?4:2);return{k:F.length,bytes:$,members:F,textured:Y}}),S=s.mergedCap??gh,v=s.minRepeats??Wv;if(T.reduce((O,F)=>O+F.k*F.bytes,0)>S){let O=s.cellExtent==null?_f(p,f)*Xv:this.visibleBox().getSize(new P).length()*s.cellExtent;for(let F of T)F.k{if(b[F]){for(let G of O.leaves)w.push({shape:O,members:_h(G,m)});return}for(let G of O.members){x[e[G]]++;let Y=this._bucketOf[G]*2+(h[G]===Bs?1:0),z=A.get(Y);z||A.set(Y,z=[]),z.push(G)}});let R=[];for(let O of[...A.keys()].sort((F,G)=>F-G))for(let F of pf(u,f,A.get(O),s.chunkVertices??uf))R.push(_h(F,m));let D=[...R,...w.map(O=>O.members)].reduce((O,F)=>O+F.length,0);if(D>r)throw new Or(D,r);let N=Math.max(1,Math.ceil(D/qi)),B=new Float32Array(qi*N*4);this._state=new Bn(new Uint8Array(qi*N*4),qi,N),this._state.colorSpace=Me,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(yh),this._dirtyCount=0;let L=new Bn(B,qi,N,sn,Ye);L.needsUpdate=!0,L.onUpdate=()=>L.image.data=null,this.slotUniforms.slotInfo.value=L,this.slotUniforms.slotState.value=this._state,this._stateBytes=qi*N*20,this._slotOf=new Uint32Array(this._visible.length).fill(Br),this._slotInstance=new Uint32Array(D),this._slotUnit=new Uint32Array(D),this._slotRadius=new Float32Array(D),this._slotCost=new Float32Array(D),this._pixels=new Float32Array(D),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(Mh),this._detailBins=new Float64Array(hh),this._detailBytes=0,this._unitScale=null,this._cutInView=0,this._cutFrame=-1,this._mergedBytes=0,this._instancedBytes=0,this._lineBytes=0;let U={matrices:n,geometryOf:e,mirrored:_,kind:h,origins:d,source:c,textured:!1};this._lineSources=new Map;let W=0;for(let O of R){let F=this._buckets[this._bucketOf[O[0]]];U.textured=F.texture!==null;let G=bf(O,U);for(let Y=0;YO+F,0);let V=new Map;for(let{shape:O,members:F}of w){let G=F[0],Y=c(e[G]),z=V.get(O);if(!z){let $=a.geometries[e[G]].bbox;z=this._shape(Y,_[G]===1,O.textured);let nt=at=>Math.max(...at.map(Math.abs)),lt=Math.max(nt(Y.min),nt(Y.max));z.pickExtent=lt,z.pickPadding=Math.max(0,...Y.min.map((at,X)=>$.min[X]-at),...Y.max.map((at,X)=>at-$.max[X]))+(Y.q?sl*(nt(Y.q.o)+65535*Math.abs(Y.q.s)):0),V.set(O,z)}for(let $=0;$O+F,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,si);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Af(this._boxes,e),h=new Xe(new P(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let d=new _i(a,t.material,0),u=new Float32Array(o*16),f=new Float32Array(o*12),m=0;for(let g=0;gthis._range(_,g,M,d),d.visible=!1,this.root.add(d),_}_chunk(t,e,n,s,r,o){let a=new Ts;a.instanceCount=1,a.setAttribute("q",Rn(s.q,4)),a.setAttribute("normal",Rn(s.o,2,!0)),s.uv&&a.setAttribute("uv",Rn(s.uv,2)),a.setAttribute("slotBase",Rn(new Float32Array([n]),1,!1,si)),a.setIndex(Rn(s.index,1));let l=Af(this._boxes,e);a.boundingSphere=new Xe(new P(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 pe(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 _i(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=el(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]&&!Jv(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&&(fh(n,this._viewHeight,this._frameView),this._frameViewAt=o);let a=this._frameView,l=Tf(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,vf(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]=yf(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:vh(new ws({side:Oe}),this.slotUniforms,n),wire:vh(new ws({side:Oe,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 Ge(s),e.colorSpace=Me,e.wrapS=e.wrapT=ps,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]?Vv:this._tint.get(t)??(this._mode==="white"?Gv: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!==Br&&(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===Br)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._dirtyCountyh)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(!wf(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 bh(i,t,e){return e<=t?0:i.cell?(e-t)*i.triangles:(i.starts[e]-i.starts[t])/3}function Tf(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function Af(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 rl=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{M!==u&&(M.uniforms.pointIndex.value=o,M.uniforms.pointSize.value=u.opacity>0?u.size:0,M.uniformsNeedUpdate=!0)},f.matrixAutoUpdate=!1,f.matrix.fromArray(jv(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.instanceCount-this.count;for(let[n,s]of this.root.children.entries())s.visible=t.isInstanceVisible(e+n)}syncAppearance(t){let e=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 jv(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 Qv={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.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","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.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","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",kr=new Intl.NumberFormat(ai).format;function Z(i,t=ai){let e=Qv[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Rf=new P(0,0,1),ol=Math.PI/2-.01;function If(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function Pf(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 De().setFromAxisAngle(Rf,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Rf);if(h.lengthSq()>1e-12){let d=Math.asin(le.clamp(c.z,-1,1)),u=le.clamp(s*r,d-ol,d+ol);l(new De().setFromAxisAngle(h.normalize(),-u))}return{position:o.add(e),target:a.add(e)}}function Lf(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var ty=.85,ey=100/3;function Df(i,t,e){let n=i*(t===1?ey:t===2?e:1);return le.clamp(ty**(-n/100),.5,2)}var wh=(i,t)=>t>=i?"window":"crossing";function Nf(i,t,e){let n=Cf(i.position,i.target),s=Cf(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=le.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,g)=>_+(g-_)*e,c=r+a*e,h=le.clamp(l(n.elevation,s.elevation),-ol,ol),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 P(f*Math.cos(c),f*Math.sin(c),Math.sin(h)*d)),target:u}}function Uf(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 De().setFromUnitVectors(s,r),c=e.clone().applyQuaternion(l),h=new P().setFromMatrixColumn(new Zt().lookAt(t.position,t.target,n),1),d=r.dot(new P().crossVectors(c,h)),u=Math.atan2(Math.abs(d)<1e-9?0:d,c.dot(h)),f=new De;return m=>{f.identity().slerp(l,m);let _=s.clone().applyQuaternion(f),g=i.target.clone().lerp(t.target,m),p=_.clone().multiplyScalar(le.lerp(o,a,m)).add(g),M=e.clone().applyQuaternion(f).applyAxisAngle(_,u*m);return{position:p,target:g,up:M}}}function Cf(i,t){let e=i.clone().sub(t),n=e.length(),s=Math.hypot(e.x,e.y);return{distance:n,elevation:n>1e-12?Math.asin(le.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var ny=.005,iy=new P(1,-1,.8).normalize(),Th=.01,Ff=1e-6,sy=64,Bf=1.05,ry=5e3,Eh=(i,t)=>new CustomEvent(i,{detail:t});function Of({bbox:i,grids:t}){let e=r=>Array.isArray(r)&&r.length===3&&r.every(Number.isFinite);if(!e(i?.min)||!e(i?.max))return!0;let n=new ae(new P(...i.min),new P(...i.max));if(n.isEmpty())return!0;let s=new P;for(let r of t??[])for(let o of Pr(r)){if(!e(o))return!0;n.expandByPoint(s.fromArray(o))}return n.getSize(s).length()*Bf>Th*ry}var al=class extends EventTarget{constructor(t,e,{pick:n=()=>null,visibleBox:s=()=>new ae}={}){super(),this.dom=e,this.pick=n,this.visibleBox=s,this.target=new P,this.leftButtonMode="orbit",this._perspective=t,this._defaultFov=t.fov,this._orthographic=new Vn(-1,1,1,-1),this.camera=t,this._drag=null,this._wheelPick=null,this._animation=0,this._overlay=null,this._bounds=null,this._extraBounds=new Map,e.style.touchAction="none",e.addEventListener("pointerdown",r=>this._down(r)),e.addEventListener("pointermove",r=>this._move(r)),e.addEventListener("pointerup",r=>this._up(r)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",r=>this._lostCapture(r)),window.addEventListener("blur",()=>this._end()),e.addEventListener("wheel",r=>this._wheel(r),{passive:!1}),e.addEventListener("contextmenu",r=>r.preventDefault())}setLeftButtonMode(t){if(t!=="orbit"&&t!=="pan")throw new RangeError(`Unknown left button mode: ${t}`);this.leftButtonMode=t}setProjection(t){if(t!=="perspective"&&t!=="orthographic")throw new RangeError(`Unknown projection: ${t}`);let e=t==="perspective"?this._perspective:this._orthographic,n=this.camera;if(e!==n){this._stopAnimation(),e.position.copy(n.position),n.isOrthographicCamera&&e.position.sub(this.target).divideScalar(n.zoom).add(this.target),e.zoom=1,e.quaternion.copy(n.quaternion),e.up.copy(n.up),n.parent?.add(e),n.parent?.remove(n);for(let s of[...n.children])e.add(s);this.camera=e,this.resize()}}resize(){let t=this.camera,e=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),n=Math.max(t.position.distanceTo(this.target),1e-6);if(t.isPerspectiveCamera)t.aspect=e;else{let r=n*Math.tan(le.degToRad(this._perspective.fov/2));Object.assign(t,{top:r,bottom:-r,left:-r*e,right:r*e})}let s=this._rangeSphere();if(s){let r=s.center.clone().sub(t.position),o=new P(0,0,-1).applyQuaternion(t.quaternion);t.far=Math.max(1e-6,(r.length()+s.radius)*Bf);let a=r.dot(o)-s.radius;t.near=Math.max(a*.95,Math.min(Th,t.far/2))}t.updateProjectionMatrix(),this.dispatchEvent(new Event("change"))}setExtraBounds(t,e){e&&!e.isEmpty()?this._extraBounds.set(t,e.clone()):this._extraBounds.delete(t),this.resize()}_rangeSphere(){let t=this._visibleBounds()?.sphere??null;if(this._extraBounds.size===0)return t;let e=t?this._bounds.box.clone():new ae;for(let n of this._extraBounds.values())e.union(n);return e.getBoundingSphere(new Xe)}invalidateBounds(){this._bounds=null}_visibleBounds(){if(!this._bounds){let t=this.visibleBox();this._bounds={box:t,sphere:t.isEmpty()?null:t.getBoundingSphere(new Xe)}}return this._bounds.sphere&&this._bounds}fitBox(t,e=!0){if(t.isEmpty())return;let n=t.getBoundingSphere(new Xe),s=Math.max(n.radius,.001),r=le.degToRad(this._perspective.fov/2),o=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),a=s/Math.sin(Math.min(r,Math.atan(Math.tan(r)*o))),l=this.camera.position.clone().sub(this.target);l.lengthSq()<1e-12&&l.copy(iy);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))}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 P(...t),a=new P(...e);if(this.resetCameraStyle(),!n){this.animateTo({position:o,target:a});return}this._stopAnimation(),this.camera.up.fromArray(n),this._perspective.fov=s??this._defaultFov;let l=Math.max(o.distanceTo(a),1e-6);this.camera.zoom=r==null?1:2*l*Math.tan(le.degToRad(this._perspective.fov/2))/r,this._set(o,a)}animateTo({position:t,target:e,zoom:n=1,overPole:s=!1},r=400){this._stopAnimation();let o={position:this.camera.position.clone(),target:this.target.clone()},a={position:t??o.position,target:e??o.target},l=this.camera.zoom,c=s?Uf(o,a,new P(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):u=>Nf(o,a,u),h=performance.now(),d=u=>{let f=Math.min((u-h)/r,1),m=f*f*(3-2*f),_=c(m);this.camera.isOrthographicCamera&&(this.camera.zoom=le.lerp(l,n,m)),this._set(_.position,_.target,_.up),this._animation=f<1?requestAnimationFrame(d):0};this._animation=requestAnimationFrame(d)}get animating(){return this._animation!==0}_stopAnimation(){cancelAnimationFrame(this._animation),this._animation=0}_set(t,e,n){if(this.camera.position.copy(t),this.target.copy(e),n){let s=this.camera.up.clone();this.camera.up.copy(n),this.camera.lookAt(e),this.camera.up.copy(s)}else this.camera.lookAt(e);this.resize()}_down(t){this._end(),this._stopAnimation(),this.dom.setPointerCapture(t.pointerId),t.preventDefault();let e=t.button===0&&t.shiftKey?"box":t.button===0&&this.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(Ff,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&&If(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=Pf(this.camera.position,this.target,e.pivot,s,r,ny);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 P))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(le.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new P(1,0,0).applyQuaternion(n.quaternion),a=new P(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=wh(e.down.x,n.x);this.dispatchEvent(Eh("boxselect",{rect:s,mode:r,ctrl:t.ctrlKey,shift:t.shiftKey}))}else!e.moved&&e.button===0?this.dispatchEvent(Eh("click",{x:n.x,y:n.y,button:0,ctrl:t.ctrlKey,shift:t.shiftKey})):!e.moved&&e.button===2&&this.dispatchEvent(Eh("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:wh(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=Df(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=sy*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:g,width:p,height:M}=this.dom.getBoundingClientRect();if(!p||!M)return;let T=le.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(T===n.zoom)return;let S=new P((2*(t.clientX-_)/p-1)*n.right,(1-2*(t.clientY-g)/M)*n.top,0).multiplyScalar(1/n.zoom-1/T).applyQuaternion(n.quaternion);n.zoom=T,this._set(n.position.clone().add(S),this.target.clone().add(S));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new P),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Th,Math.max(Ff,r)),h=le.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let d=n.position.clone().addScaledVector(a,l),u=this._wheelPick.point,f=u&&u.clone().sub(n.position).dot(a)>=c?u:d,m=Lf(n.position,d,f,h);this._set(m.position,m.target)}};function et(i,t,e){let n=document.createElement(i);return t&&(n.className=t),e!==void 0&&(n.textContent=e),n}function Qe(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 Os(i){i.preventDefault(),i.stopPropagation()}function ll(i){Os(i);let t=i.button===2,e=()=>{window.removeEventListener("pointerup",n,!0),setTimeout(()=>{window.removeEventListener("click",Os,!0),t&&window.removeEventListener("contextmenu",Os,!0)})},n=s=>{Os(s),e()};window.addEventListener("pointerup",n,!0),window.addEventListener("click",Os,!0),t&&window.addEventListener("contextmenu",Os,!0)}function Hr(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 Se=i=>``,zf='',re={model:Se(''),views:Se(''),sections:Se(''),clashes:Se(''),bcf:Se(''),timeliner:Se(''),links:Se(''),orbit:Se(''),pan:Se(''),fit:Se(''),projection:Se(zf),plane:Se(''),box:Se(`${zf}`),resetSections:Se(''),distance:Se(''),displayMode:Se(''),grids:Se(''),opacity:Se(''),fullscreen:Se(''),close:Se(''),chevron:Se(''),flip:Se(''),remove:Se(''),play:Se(''),pause:Se(''),home:Se('')};var Vr=new P(0,0,1),hn={right:new P(1,0,0),left:new P(-1,0,0),back:new P(0,1,0),front:new P(0,-1,0),top:new P(0,0,1),bottom:new P(0,0,-1)},oy={right:Vr,left:Vr,back:Vr,front:Vr,top:hn.back,bottom:hn.front},Yi=.7,ay=le.degToRad(1),kf=.01,Hf=96,cl=1.75;function Vf(i){let t=i.split("-"),e=new P;for(let n of t){if(!Object.hasOwn(hn,n))throw new RangeError(`Unknown view cube region: ${i}`);e.add(hn[n])}if(new Set(t).size!==t.length||e.lengthSq()!==t.length)throw new RangeError(`Unknown view cube region: ${i}`);return e.normalize()}function ly(i){let t=[];return Math.abs(i.z)>=Yi&&t.push(i.z>0?"top":"bottom"),Math.abs(i.y)>=Yi&&t.push(i.y>0?"back":"front"),Math.abs(i.x)>=Yi&&t.push(i.x>0?"right":"left"),t.join("-")}function Ah(i,t=ay){let e=i.clone().normalize(),n=Math.cos(t);return Object.keys(hn).find(s=>e.dot(hn[s])>=n)??null}function Gf(i){let t=new P(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(hn[s])));return e.find(s=>t.dot(hn[s])>=n-1e-9)}function Rh(i,t){return hn[Gf(t)].clone().multiplyScalar(Math.sin(kf)).addScaledVector(hn[i],Math.cos(kf))}function cy(i,t){let e=Ah(i);if(!e)return null;let n=e==="top"||e==="bottom";if(t==="left"||t==="right")return(n?Rh(e,i):Vf(e)).applyAxisAngle(Vr,t==="right"?Math.PI/2:-Math.PI/2);if(t!=="up"&&t!=="down")throw new RangeError(`Unknown arrow: ${t}`);if(!n)return Rh(t==="up"?"top":"bottom",i);let s=hn[Gf(i)];return t==="up"==(e==="top")?s.clone().negate():s.clone()}function hy(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 or(e);return r.colorSpace=Me,r}var hl=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=Z("cube.title"),this.canvas.setAttribute("aria-label",Z("cube.title")),this.element.append(this.canvas),this.error=null,this.renderer=this._createRenderer(),this.scene=new fn,this.camera=new Vn(-cl,cl,cl,-cl,.1,10),this.faces=new Re;let s=getComputedStyle(t).fontFamily;for(let[l,c]of Object.entries(hn)){let h=Z(`face.${l}`),d=new pe(new ln(2,2),new Ke({map:hy(h,s)})),u=oy[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 bn(new zi(new pn(2,2,2)),new an({color:"#5b6575"}));this.highlight=new pe(new pn(1,1,1),new Ke({color:"#2563eb",transparent:!0,opacity:.6})),this.highlight.visible=!1,this.scene.add(this.faces,r,this.highlight),this._raycaster=new Gn,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?Rh(c,n.camera.position.clone().sub(n.target)):Vf(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=Qe("ioviewer-viewcube-arrow",re.chevron,Z(`cube.${l}`));return c.dataset.arrow=l,c.addEventListener("click",h=>{h.detail&&c.blur(),this._arrow(l)}),c});let a=Qe("ioviewer-viewcube-home",re.home,Z("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 Ei({canvas:this.canvas,context:t,alpha:!0,antialias:!0});return e.setPixelRatio(window.devicePixelRatio),e.setSize(Hf,Hf),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)}}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=Ah(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 Gt((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?ly(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(hn[l]),new P),n=a=>a===0?[-Yi,Yi]:a>0?[Yi,1.02]:[-1.02,-Yi],[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=cy(n,t);if(!s)return;let r=Ah(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 uy=` +#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 Kv(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 ",Zv),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=Kv,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var Ih=["materials","textures","white","wireframe"],Jv=[245,158,11],jv=[235,235,237],zr=4294967295,$i=2048,Th=256,Qv=16,Ah=1024,ty=.1,ey=8192,ny=1.4,ol=2**-20,rl=17;function iy(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 sy(){this.array=null}function In(i,t,e=!1,n=_e){return new n(i,t,e).onUpload(sy)}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}},Lf=(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],u=i[r+a+9],d=l*e[0],f=l*n[0],g=c*e[1],_=c*n[1],p=h*e[2],m=h*n[2];s[o+a]=Math.min(d,f)+Math.min(g,_)+Math.min(p,m)+u,s[o+a+3]=Math.max(d,f)+Math.max(g,_)+Math.max(p,m)+u}}var oy=i=>{let t=i.getHex(pe);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,u=n.lines,d=u?.count??0,f=r+h+d;this.root=new Re,this.elementCount=n.elements.length,this.pointOffset=r,this.lineOffset=r+h,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(f),this._elementOf.set(t.view(s.element)),this._bucketOf=new Uint32Array(r),this._visible=new Uint8Array(f).fill(1),this._layers=new Map,this._layerHides=new Uint8Array(f),this._highlight=new Uint8Array(f),this._highlighted=[],this._tint=new Map,this._boxes=new Float32Array(f*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 p=t.view(c.geometry),m=t.view(c.matrix),b=this._boxes.subarray(r*6);for(let w=0;wthis._shown(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 d=0;d<=s;d++){let f=this._pixels[n+d];f<0||(fc.count;for(let d=0;d0?o[6]/p:1/0:o[6];u[f]=m;let b=g.cell&&this._detailUsesInstances,w=b&&!pf(r,_[0],_[1],_[2],_[3]+g.pickPadding),S=g.slotBase+g.n,v=-1;if(b){let I=this._slotRadius[g.slotBase],D=this._slotRadius[S-1],N=p+_[3],B=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],L=N-B-I,F=N+B-D,k=Math.fround(o[7]?L>0?I*o[6]/L:1/0:I*m),W=Math.fround(o[7]?F>0?D*o[6]/F:1/0:D*m);Os(W)===Os(k)&&(v=k)}if(v>=0&&!w){g.detailLow=g.detailHigh=v,g.detailEnd=g.n;let I=this._slotCost[g.slotBase]*g.shown;l[Os(v)]+=I,d+=I;continue}let y=0,A=1/0,x=-1,E=0;for(let I=g.slotBase;I=0){y++;continue}let U=(k-o[0])*o[3]+(W-o[1])*o[4]+(O-o[2])*o[5]-D;N=o[7]?U>0?o[6]/U:1/0:o[6]}let B=N===1/0?1/0:Math.fround(D*N);b&&(a[I]=B,A=Math.min(A,B),x=Math.max(x,B));let L=this._slotCost[I];l[Os(B)]+=L,d+=L}if(b){if(y){A=x=v;let I=y*this._slotCost[g.slotBase];l[Os(v)]+=I,d+=I}g.detailLow=A,g.detailHigh=x,g.detailEnd=E}}return this.visibleCost=d,mf(l,d,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),V=z.uvs?t.view(z.uvs):null;U=Pf(Fr(t,z),z.q??null,xf(t,z),q,V),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),u=new Float64Array(o*3),d=new Float32Array(o*3),f=new Uint32Array(o),g=new Float32Array(o),_=new Uint8Array(o),p=new Map,m=this._boxes;for(let O=0;OO-U).map(O=>{let U=p.get(O),z=c(e[U[0]]),q=this._buckets[this._bucketOf[U[0]]].texture!==null,V=[0,1,2].every(K=>(z.max[K]-z.min[K])/Cn<=65535),Z=z.vertices*((V?12:20)+(q?8:0))+z.indices.length*(z.vertices>65535?4:2);return{k:U.length,bytes:Z,members:U,textured:q}}),S=s.mergedCap??bh,v=s.minRepeats??Qv;if(w.reduce((O,U)=>O+U.k*U.bytes,0)>S){let O=s.cellExtent==null?Ef(m,f)*ty:this.visibleBox().getSize(new R).length()*s.cellExtent;for(let U of w)U.k{if(y[U]){for(let z of O.leaves)E.push({shape:O,members:Sh(z,g)});return}for(let z of O.members){x[e[z]]++;let q=this._bucketOf[z]*2+(h[z]===ks?1:0),V=A.get(q);V||A.set(q,V=[]),V.push(z)}});let I=[];for(let O of[...A.keys()].sort((U,z)=>U-z))for(let U of bf(d,f,A.get(O),s.chunkVertices??vf))I.push(Sh(U,g));let D=[...I,...E.map(O=>O.members)].reduce((O,U)=>O+U.length,0);if(D>r)throw new kr(D,r);let N=Math.max(1,Math.ceil(D/$i)),B=new Float32Array($i*N*4);this._state=new mn(new Uint8Array($i*N*4),$i,N),this._state.colorSpace=pe,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(Th),this._dirtyCount=0;let L=new mn(B,$i,N,je,Ye);L.needsUpdate=!0,L.onUpdate=()=>L.image.data=null,this.slotUniforms.slotInfo.value=L,this.slotUniforms.slotState.value=this._state,this._stateBytes=$i*N*20,this._slotOf=new Uint32Array(this._visible.length).fill(zr),this._slotInstance=new Uint32Array(D),this._slotUnit=new Uint32Array(D),this._slotRadius=new Float32Array(D),this._slotCost=new Float32Array(D),this._pixels=new Float32Array(D),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:u,source:c,textured:!1};this._lineSources=new Map;let k=0;for(let O of I){let U=this._buckets[this._bucketOf[O[0]]];F.textured=U.texture!==null;let z=If(O,F);for(let q=0;qO+U,0);let W=new Map;for(let{shape:O,members:U}of E){let z=U[0],q=c(e[z]),V=W.get(O);if(!V){let Z=a.geometries[e[z]].bbox;V=this._shape(q,_[z]===1,O.textured);let K=rt=>Math.max(...rt.map(Math.abs)),lt=Math.max(K(q.min),K(q.max));V.pickExtent=lt,V.pickPadding=Math.max(0,...q.min.map((rt,H)=>Z.min[H]-rt),...q.max.map((rt,H)=>rt-Z.max[H]))+(q.q?ol*(K(q.q.o)+65535*Math.abs(q.q.s)):0),W.set(O,V)}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+m),1,!1,ri);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Nf(this._boxes,e),h=new Oe(new R(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let u=new xi(a,t.material,0),d=new Float32Array(o*16),f=new Float32Array(o*12),g=0;for(let p=0;pthis._range(_,p,b,u),u.visible=!1,this.root.add(u),_}_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=Nf(this._boxes,e);a.boundingSphere=new Oe(new R(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 me(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=(u,d,f)=>this._range(h,u,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=(u,d,f)=>this._range(n,u,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 u=this._lineSources.get(e[h]),d=t[h]===1;for(let f=0;fthis._range(n,h,d,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]&&!ry(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=Df(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,Af(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]=Rf(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=pe,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]?Jv:this._tint.get(t)??(this._mode==="white"?jv: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(!Lf(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 Df(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function Nf(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{b!==d&&(b.uniforms.pointIndex.value=o,b.uniforms.pointSize.value=d.opacity>0?d.size:0,b.uniformsNeedUpdate=!0)},f.matrixAutoUpdate=!1,f.matrix.fromArray(ay(r,o)),f.matrixWorldNeedsUpdate=!0,f.frustumCulled=!0,c.computeBoundingSphere(),this.root.add(f),this._materials.push({material:d,color:d.color.clone(),opacity:h?.opacity??1,vertexColors:u})}}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 ay(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,ly=524288,Lh=[245,158,11],Dh=[235,235,237],cy=` +#include +attribute float lineSlot; +uniform sampler2D lineState; +varying vec3 vColor; +#include +#include +void main() { + int slot = int(lineSlot + 0.5); + vec4 state = texelFetch(lineState, ivec2(slot & 2047, slot >> 11), 0); + vColor = state.rgb; + vec3 transformed = position; + #include + #include + #include + if (state.a < 0.5) gl_Position = vec4(0.0, 0.0, 2.0, 1.0); +}`,hy=` +#include +#include +#include +uniform float opacity; +uniform float lightBg; +varying vec3 vColor; +void main() { + #include + #include + vec3 c = vColor; + // AutoCAD-style ACI 7 adaptive contrast when switching between dark CAD and light paper backgrounds. + if (lightBg > 0.5 && c.r > 0.90 && c.g > 0.90 && c.b > 0.90) { + c = vec3(0.07, 0.09, 0.14); + } else if (lightBg < 0.5 && c.r < 0.08 && c.g < 0.08 && c.b < 0.08) { + 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=pe,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 te(`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=[],u=[],d=()=>{if(h.length===0)return;let f=new ce;f.setAttribute("position",new _e(new Float32Array(h),3)),f.setAttribute("lineSlot",new _e(new Float32Array(u),1)),f.computeBoundingSphere();let g=new ln(f,this._material);g.frustumCulled=!1,this.root.add(g),h=[],u=[]};for(let f=0;fly&&u.length>0&&d();for(let L=0;L>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 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.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=uy[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Uf=new R(0,0,1),cl=Math.PI/2-.01;function Bf(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function Of(i,t,e,n,s,r){let o=i.clone().sub(e),a=t.clone().sub(e),l=u=>(o.applyQuaternion(u),a.applyQuaternion(u));l(new Fe().setFromAxisAngle(Uf,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Uf);if(h.lengthSq()>1e-12){let u=Math.asin(oe.clamp(c.z,-1,1)),d=oe.clamp(s*r,u-cl,u+cl);l(new Fe().setFromAxisAngle(h.normalize(),-d))}return{position:o.add(e),target:a.add(e)}}function zf(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var dy=.85,fy=100/3;function kf(i,t,e){let n=i*(t===1?fy:t===2?e:1);return oe.clamp(dy**(-n/100),.5,2)}var Nh=(i,t)=>t>=i?"window":"crossing";function Hf(i,t,e){let n=Ff(i.position,i.target),s=Ff(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=oe.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,p)=>_+(p-_)*e,c=r+a*e,h=oe.clamp(l(n.elevation,s.elevation),-cl,cl),u=l(n.distance,s.distance),d=i.target.clone().lerp(t.target,e),f=Math.cos(h)*u;return{position:d.clone().add(new R(f*Math.cos(c),f*Math.sin(c),Math.sin(h)*u)),target:d}}function Vf(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 R().setFromMatrixColumn(new Yt().lookAt(t.position,t.target,n),1),u=r.dot(new R().crossVectors(c,h)),d=Math.atan2(Math.abs(u)<1e-9?0:u,c.dot(h)),f=new Fe;return g=>{f.identity().slerp(l,g);let _=s.clone().applyQuaternion(f),p=i.target.clone().lerp(t.target,g),m=_.clone().multiplyScalar(oe.lerp(o,a,g)).add(p),b=e.clone().applyQuaternion(f).applyAxisAngle(_,d*g);return{position:m,target:p,up:b}}}function Ff(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(oe.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var py=.005,Gf=new R(1,-1,.8).normalize(),Uh=.01,Wf=1e-6,my=64,Xf=1.05,gy=5e3,hl=(i,t)=>new CustomEvent(i,{detail:t});function qf({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 R(...i.min),new R(...i.max));if(n.isEmpty())return!0;let s=new R;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()*Xf>Uh*gy}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 R,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(oe.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 R(0,0,-1).applyQuaternion(t.quaternion);t.far=Math.max(1e-6,(r.length()+s.radius)*Xf);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 R),u=Math.max(h.x,h.y,n.radius*2,.01),d=t.getCenter(new R),f=new R(d.x,d.y,t.max.z+u*2);this._set(f,d);let g=Math.max(this.dom.clientWidth/Math.max(this.dom.clientHeight,1),.001),_=Math.max(this.camera.top,1e-6),p=Math.max(h.y/2,h.x/(2*g),1e-4)*1.06;this.camera.zoom=_/p,this.resize();return}let s=Math.max(n.radius,.001),r=oe.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(Gf);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 R),l=Math.max(o.getBoundingSphere(new Oe).radius,1);this._set(a.clone().addScaledVector(Gf,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 R(...t),a=new R(...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(oe.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?Vf(o,a,new R(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):d=>Hf(o,a,d),h=performance.now(),u=d=>{let f=Math.min((d-h)/r,1),g=f*f*(3-2*f),_=c(g);this.camera.isOrthographicCamera&&(this.camera.zoom=oe.lerp(l,n,g)),this._set(_.position,_.target,_.up),this._animation=f<1?requestAnimationFrame(u):0};this._animation=requestAnimationFrame(u)}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(Wf,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&&Bf(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=Of(this.camera.position,this.target,e.pivot,s,r,py);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 R))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(oe.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new R(1,0,0).applyQuaternion(n.quaternion),a=new R(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=kf(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=my*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:p,width:m,height:b}=this.dom.getBoundingClientRect();if(!m||!b)return;let w=oe.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(w===n.zoom)return;let S=new R((2*(t.clientX-_)/m-1)*n.right,(1-2*(t.clientY-p)/b)*n.top,0).multiplyScalar(1/n.zoom-1/w).applyQuaternion(n.quaternion);n.zoom=w,this._set(n.position.clone().add(S),this.target.clone().add(S));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new R),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Uh,Math.max(Wf,r)),h=oe.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let u=n.position.clone().addScaledVector(a,l),d=this._wheelPick.point,f=d&&d.clone().sub(n.position).dot(a)>=c?d:u,g=zf(n.position,u,f,h);this._set(g.position,g.target)}};function nt(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=nt("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 ye=i=>``,Yf='',re={model:ye(''),views:ye(''),sections:ye(''),clashes:ye(''),bcf:ye(''),timeliner:ye(''),links:ye(''),orbit:ye(''),pan:ye(''),fit:ye(''),projection:ye(Yf),mode2d:ye(''),plane:ye(''),box:ye(`${Yf}`),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 Wr=new R(0,0,1),un={right:new R(1,0,0),left:new R(-1,0,0),back:new R(0,1,0),front:new R(0,-1,0),top:new R(0,0,1),bottom:new R(0,0,-1)},_y={right:Wr,left:Wr,back:Wr,front:Wr,top:un.back,bottom:un.front},Zi=.7,xy=oe.degToRad(1),$f=.01,Zf=96,fl=1.75;function Kf(i){let t=i.split("-"),e=new R;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 vy(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=xy){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 R(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($f)).addScaledVector(un[i],Math.cos($f))}function yy(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):Kf(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 My(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=pe,r}var pl=class{constructor(t,e,n){this.controls=n,this.home={position:e.position.clone(),target:n.target.clone()},this.element=nt("div","ioviewer-viewcube"),this.canvas=nt("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}`),u=new me(new cn(2,2),new Je({map:My(h,s)})),d=_y[l];u.quaternion.setFromRotationMatrix(new Yt().makeBasis(d.clone().cross(c),d,c)),u.position.copy(c),u.name=l,u.userData.label=h,this.faces.add(u)}let r=new ln(new Hi(new gn(2,2,2)),new sn({color:"#5b6575"}));this.highlight=new me(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)):Kf(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=tn("ioviewer-viewcube-arrow",re.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",re.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(Zf,Zf),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?vy(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 R),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=yy(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 by=` #include #ifdef IO_PICK_POINTS uniform uint pointIndex; uniform float pointSize; flat varying uint vPoint; flat varying uint vVertex; +#elif defined( IO_PICK_LINES ) +attribute float lineSlot; +uniform sampler2D lineState; +varying float vLine; #else -${Ur} +${Br} varying vec2 vSlot; #endif #include @@ -4275,8 +4313,13 @@ void main() { gl_PointSize = pointSize; vPoint = pointIndex; vVertex = uint( gl_VertexID ); + #elif defined( IO_PICK_LINES ) + int lSlot = int( lineSlot + 0.5 ); + vec4 lState = texelFetch( lineState, ivec2( lSlot & 2047, lSlot >> 11 ), 0 ); + vec3 transformed = position; + vLine = float( lSlot ); #else - ${Fr} + ${Or} vec3 transformed = slotPosition; #endif #include @@ -4292,11 +4335,13 @@ void main() { vPos = ( modelMatrix * wp ).xyz; #ifdef IO_PICK_POINTS if ( pointSize <= 0.0 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); + #elif defined( IO_PICK_LINES ) + if ( lState.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); #else 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 -}`,dy=` +}`,Sy=` #include #include #include @@ -4304,18 +4349,28 @@ varying vec3 vPos; #ifdef IO_PICK_POINTS flat varying uint vPoint; flat varying uint vVertex; +#elif defined( IO_PICK_LINES ) +uniform float pointCount; +varying float vLine; #else varying vec2 vSlot; #ifdef IO_PICK_DEPTH varying float vViewDepth; #endif #endif +#if defined( IO_PICK_LINES ) && defined( IO_PICK_DEPTH ) +varying float vViewDepth; +#endif void main() { #include #include #ifdef IO_PICK_POINTS uint id = 0x80000000u | vPoint; float sampleId = -float( vPoint + 1u ); + #elif defined( IO_PICK_LINES ) + uint lineIdx = uint( vLine + 0.5 ); + uint id = 0x40000000u | lineIdx; + float sampleId = -( pointCount + float( lineIdx ) + 1.0 ); #else float sampleId = floor( vSlot.x + 0.5 ) * 4096.0 + floor( vSlot.y + 0.5 ) + 1.0; uint id = uint( sampleId ); @@ -4335,31 +4390,32 @@ void main() { uvec4 bytes = ( uvec4( bits ) >> uvec4( 0u, 8u, 16u, 24u ) ) & 255u; gl_FragColor = vec4( bytes ) / 255.0; #endif -}`,Wf=i=>i&&{element:i.element,point:i.point.clone()};function zs(i,t,e=!1){let n=new Ue({vertexShader:uy,fragmentShader:dy,uniforms:i,defines:t?{[t]:""}:{},side:Oe,clipping:!0});return e?n.defines.IO_PICK_POINTS="":n.index0AttributeName="q",n}var ul=class{constructor(t,e,n,s={}){this.renderer=t,this.scene=e,this.points=s.points?.count?s.points: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",l=>{l.detail.kind!=="appearance"&&(this._last=this._lastTile=null)});let r=e.slotUniforms,o={pointIndex:{value:0},pointSize:{value:0}};this._float=s.pickFloat!==!1&&t.extensions.has("EXT_color_buffer_float");let a=this.points?3:1;this._float?(this._material=zs(r,null),this._target=new Ne(a,a,{type:Ye}),this._pixel=new Float32Array(a*a*4),this.points&&(this._pointMaterial=zs(o,null,!0))):(this._material=zs(r,"IO_PICK_RGBA8"),this._depthMaterial=zs(r,"IO_PICK_DEPTH"),this._target=new Ne(a,a),this._pixel=new Uint8Array(a*a*4),this.points&&(this._pointMaterial=zs(o,"IO_PICK_RGBA8",!0),this._pointDepthMaterial=zs(o,"IO_PICK_DEPTH",!0)))}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 Wf(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},Wf(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&&rx===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 Ne(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=(x,w)=>{let R=Math.floor(x)-m,D=Math.floor(w)-_;return R>=0&&R=0&&Dthis._slotAt(p,x),T=g(r,o),S=M(T),v=T;if(S<0&&this.points){let x=(n-1)**2;for(let w=0;wx||(x=R,v=w)}}let b=null,A=M(v);if(A>=0){f&&this._render(this._depthMaterial,m,_,s,d,f);let x=f&&new DataView(f.buffer),w=l.matrixWorldInverse.elements.slice(),R=new P,D=V=>{let O=this._vertexAt(M(V),u,x,V,R);return O?-(w[2]*O.x+w[6]*O.y+w[10]*O.z+w[14]):x.getFloat32(V*4,!0)},N=this._vertexAt(A,u,x,v)??this._depthPoint(r,o,s,D(v)),B=this._isPoint(A),L=this._elementAt(A),U=new Set([A]);if(!B&&L>=0)for(let V=0;V=0&&!this._isPoint(O)&&!U.has(O)&&this.scene.slotElement(O)===L&&U.add(O)}let W=l.isPerspectiveCamera;b={rect:s,point:N,element:L,slots:U,pointSample:B,depthAt(V,O,F){let G=g(V,O),Y=G<0?-1:M(G);if(Y<0)return 1/0;if(Y!==F)return D(G);let z=at=>W?1/D(at):D(at),$=z(G);function nt(at,X,tt){let ht=Math.sign(tt),Rt=g(V+ht*at,O+ht*X);if(Rt>=0&&M(Rt)===Y)return(z(Rt)-$)*Math.abs(tt);let ft=g(V-ht*at,O-ht*X);return ft>=0&&M(ft)===Y?($-z(ft))*Math.abs(tt):0}let lt=$+nt(1,0,V-Math.floor(V)-.5)+nt(0,1,O-Math.floor(O)-.5);return lt>0?W?1/lt:lt:D(G)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:b},this._last={camera:l,key:this._lastTile.key,hit:S>=0?b:null},b}_pick(t,e,n){let s=(this._target.width-1)/2,r=(this._target.width**2-1)/2,o=this._render(this._material,t-s,e-s,n),a=this._slotAt(this._float?o:new Uint32Array(o.buffer),r);if(a<0)return null;let l=this._elementAt(a),c=this._float?null:this._render(this._depthMaterial,t-s,e-s,n),h=c&&new DataView(c.buffer),d=this._vertexAt(a,o,h,r)??this._depthPoint(t,e,n,h.getFloat32(r*4,!0));return{element:l,point:d}}_slotAt(t,e){let n=this._float?Math.round(t[e*4+3]):t[e];return n<0?this.scene.slotCount-n-1:n>=2147483648?this.scene.slotCount+n-2147483648:n-1}_isPoint(t){return t>=this.scene.slotCount}_elementAt(t){return this._isPoint(t)?this.scene.instance(this.scene.instanceCount-this.points.count+t-this.scene.slotCount).element:this.scene.slotElement(t)}_vertexAt(t,e,n,s,r=new P){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 P((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 Ht),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))}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 dl=33.333333333333336,fy=200,Xf=1e6,py=20,fl=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,fy)))}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>dl*1.1?(this._refine=!1,this._fastFrames=0):this._refine||(this._fastFrames=this.minPixels>0&&t=py),this._cost>dl*1.1?this.budget=Math.max(this.budget*.9,Xf):this._cost0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),Xf))}_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 Cn,ks,pl,ml=class extends EventTarget{constructor(){super(...arguments);Dl(this,ks);Dl(this,Cn,new Set)}get size(){return ui(this,Cn).size}has(e){return ui(this,Cn).has(e)}values(){return ui(this,Cn).values()}set(e){eu(this,Cn,new Set(e)),Jr(this,ks,pl).call(this)}toggle(e){ui(this,Cn).delete(e)||ui(this,Cn).add(e),Jr(this,ks,pl).call(this)}clear(){ui(this,Cn).size!==0&&(ui(this,Cn).clear(),Jr(this,ks,pl).call(this))}};Cn=new WeakMap,ks=new WeakSet,pl=function(){this.dispatchEvent(new Event("change"))};function qf(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 Yf(i,t,e){let n=new Zt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse).elements,{left:s,top:r,width:o,height:a}=e,l=new ae,c=[];for(let h=0;hn===l?r(l):o(l));let g=[...t.children].find(v=>$f.indexOf(v.dataset.panel)>m);t.insertBefore(_,g??null);let p=et("section","ioviewer-side-panel ioviewer-floating");p.dataset.panel=l,p.hidden=!0,p.setAttribute("aria-label",h);let M=Qe("ioviewer-panel-close",re.close,Z("close"));M.addEventListener("click",()=>r(l));let T=et("header","ioviewer-panel-header");T.append(et("h2","",h),M);let S=et("div","ioviewer-panel-body");p.append(T,S),i.append(p),e.set(l,{button:_,panel:p,onClose:f}),d(S)}return{rail:t,openPanel:o,closePanel:r,registerPanel:a}}var Jf=[{id:"navigation",items:["orbit","pan","fit","projection"]},{id:"sections",items:["plane","box","resetSections"]},{id:"measure",items:["distance"]},{id:"display",items:["displayMode","grids","opacity"]},{id:"view",items:["fullscreen"]}];function Kf(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",Z(`group.${a.id}`));let c=et("div","ioviewer-toolbar-row");for(let h of a.items){let d=Qe("ioviewer-tool",re[h],Z(`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",Z(`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 my="input, textarea, select, [contenteditable]";function Ch(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function jf(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(my))return null;if(Ch(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 Qf(i,t,e,n,s){let r=et("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=et("summary","",Z("filters.title")),a=et("div","ioviewer-filter-fields"),l=new Map(t.map(({id:v,name:b})=>[v,b||`#${v}`])),c=v=>v.modelId??t[0]?.id??null,h=v=>v.levelId??(v.level||null),d=v=>v.category??"",u=[{name:Z("filters.model"),key:c,labels:new Map},{name:Z("level"),key:h,labels:new Map},{name:Z("category"),key:d,labels:new Map}],[f,m,_]=u,g=et("div","ioviewer-filter-actions"),p=et("button","ioviewer-text-button",Z("filters.clear"));p.type="button",p.addEventListener("click",()=>{for(let v of u)v.select&&(v.select.selectedIndex=0);e.value="",n(),e.focus()});let M=et("button","ioviewer-text-button",Z("filters.isolate"));M.type="button",M.addEventListener("click",s),g.append(p,M),r.append(o,a,g);function T(){if(r.open){r.removeEventListener("toggle",T);for(let v of i){let b=c(v),A=l.get(b)??(b==null?"":`#${b}`);b!=null&&f.labels.set(b,A);let x=h(v);if(!m.labels.has(x)){let R=v.level||(x==null?Z("filters.noLevel"):`#${x}`);m.labels.set(x,x!=null&&t.length>1&&A?`${R} \xB7 ${A}`:R)}let w=d(v);_.labels.set(w,w||Z("noCategory"))}for(let v of u){if(!v.labels.size)continue;let b=new Map;for(let R of v.labels.values())b.set(R,(b.get(R)??0)+1);let A=[...v.labels].map(([R,D])=>[R,b.get(D)>1?`${D} (#${R})`:D]);A.sort((R,D)=>R[1].localeCompare(D[1])),v.keys=A.map(([R])=>R);let x=v.select=et("select");x.append(new Option(Z("filters.all"),""));for(let[R,[,D]]of A.entries())x.append(new Option(D,String(R+1)));x.addEventListener("change",n);let w=et("label","ioviewer-filter-field");w.append(et("span","",v.name),x),a.append(w)}}}r.addEventListener("toggle",T);function S(){return u.filter(v=>v.select?.selectedIndex>0)}return{element:r,predicate(){let v=S().map(({select:b,keys:A,key:x})=>({key:x,value:A[b.selectedIndex-1]}));return v.length?b=>v.every(({key:A,value:x})=>A(b)===x):null},update(v,b){let A=S().length;o.textContent=A?`${Z("filters.title")} (${A})`:Z("filters.title"),p.disabled=!A&&!v,M.disabled=!b}}}var Ri=24,gy=8;function Ih(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 _y(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} +}`,jf=i=>i&&{element:i.element,point:i.point.clone()};function li(i,t,e=null){let n=new Ie({vertexShader:by,fragmentShader:Sy,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[u]))return jf(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},jf(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&&rx===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:u,ids:d,depths:f}=this._measure,g=r-n,_=o-n;this._render(this._material,g,_,s,u,d);let p=(x,E)=>{let I=Math.floor(x)-g,D=Math.floor(E)-_;return I>=0&&I=0&&Dthis._slotAt(m,x),w=p(r,o),S=b(w),v=w;if(S<0&&(this.points||this.lines)){let x=(n+1)**2;for(let E=0;Ex||(x=D,v=E)}}let y=null,A=b(v);if(A>=0){f&&this._render(this._depthMaterial,g,_,s,u,f);let x=f&&new DataView(f.buffer),E=l.matrixWorldInverse.elements.slice(),I=new R,D=U=>{let z=this._vertexAt(b(U),d,x,U,I);return z?-(E[2]*z.x+E[6]*z.y+E[10]*z.z+E[14]):x.getFloat32(U*4,!0)},N=this._vertexAt(A,d,x,v)??this._depthPoint(r,o,s,D(v)),B=this._isPoint(A),L=this._isLine(A)?A-this.scene.slotCount-(this.points?.count??0):-1,F=new Set,k=this._elementAt(A),W=new Set(B||L>=0?[]:[A]);if(L>=0&&F.add(L),!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&&!W.has(z)&&this.scene.slotElement(z)===k&&W.add(z))}let O=l.isPerspectiveCamera;y={rect:s,point:N,element:k,slots:W,lineInstances:F,pointSample:B,depthAt(U,z,q){let V=p(U,z),Z=V<0?-1:b(V);if(Z<0)return 1/0;if(Z!==q)return D(V);let K=Q=>O?1/D(Q):D(Q),lt=K(V);function rt(Q,ut,It){let ft=Math.sign(It),Ut=p(U+ft*Q,z+ft*ut);if(Ut>=0&&b(Ut)===Z)return(K(Ut)-lt)*Math.abs(It);let ae=p(U-ft*Q,z-ft*ut);return ae>=0&&b(ae)===Z?(lt-K(ae))*Math.abs(It):0}let H=lt+rt(1,0,U-Math.floor(U)-.5)+rt(0,1,z-Math.floor(z)-.5);return H>0?O?1/H:H:D(V)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:y},this._last={camera:l,key:this._lastTile.key,hit:S>=0?y:null},y}_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 m=1/0;for(let b=0;b=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 R){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 R((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 u=t===this._depthMaterial?this._pointDepthMaterial:this._pointMaterial;this.points.withPickMaterial(u,()=>a.render(this.points.root,l))}if(this.lines){a.autoClear=!1;let u=t===this._depthMaterial?this._lineDepthMaterial:this._lineMaterial;this.lines.withPickMaterial(u,()=>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,wy=200,Qf=1e6,Ey=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,wy)))}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=Ey),this._cost>gl*1.1?this.budget=Math.max(this.budget*.9,Qf):this._cost0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),Qf))}_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){cu(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 tp(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 ep(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 p=[...t.children].find(v=>np.indexOf(v.dataset.panel)>g);t.insertBefore(_,p??null);let m=nt("section","ioviewer-side-panel ioviewer-floating");m.dataset.panel=l,m.hidden=!0,m.setAttribute("aria-label",h);let b=tn("ioviewer-panel-close",re.close,$("close"));b.addEventListener("click",()=>r(l));let w=nt("header","ioviewer-panel-header");w.append(nt("h2","",h),b);let S=nt("div","ioviewer-panel-body");m.append(w,S),i.append(m),e.set(l,{button:_,panel:m,onClose:f}),u(S)}return{rail:t,openPanel:o,closePanel:r,registerPanel:a}}var sp=[{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 rp(i,t){let e=nt("div","ioviewer-toolbar ioviewer-floating");e.setAttribute("role","toolbar");let n=new Map;for(let a of t){let l=nt("div","ioviewer-toolbar-group");l.setAttribute("role","group"),l.setAttribute("aria-label",$(`group.${a.id}`));let c=nt("div","ioviewer-toolbar-row");for(let h of a.items){let u=tn("ioviewer-tool",re[h],$(`tool.${h}`));u.dataset.tool=h,u.setAttribute("aria-disabled","true");let d={button:u,handler:null};u.addEventListener("click",()=>{u.getAttribute("aria-disabled")!=="true"&&d.handler?.()}),n.set(h,d),c.append(u)}l.append(c,nt("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 Ty="input, textarea, select, [contenteditable]";function Oh(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function op(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(Ty))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 ap(i,t,e,n,s){let r=nt("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=nt("summary","",$("filters.title")),a=nt("div","ioviewer-filter-fields"),l=new Map(t.map(({id:v,name:y})=>[v,y||`#${v}`])),c=v=>v.modelId??t[0]?.id??null,h=v=>v.levelId??(v.level||null),u=v=>v.category??"",d=[{name:$("filters.model"),key:c,labels:new Map},{name:$("level"),key:h,labels:new Map},{name:$("category"),key:u,labels:new Map}],[f,g,_]=d,p=nt("div","ioviewer-filter-actions"),m=nt("button","ioviewer-text-button",$("filters.clear"));m.type="button",m.addEventListener("click",()=>{for(let v of d)v.select&&(v.select.selectedIndex=0);e.value="",n(),e.focus()});let b=nt("button","ioviewer-text-button",$("filters.isolate"));b.type="button",b.addEventListener("click",s),p.append(m,b),r.append(o,a,p);function w(){if(r.open){r.removeEventListener("toggle",w);for(let v of i){let y=c(v),A=l.get(y)??(y==null?"":`#${y}`);y!=null&&f.labels.set(y,A);let x=h(v);if(!g.labels.has(x)){let I=v.level||(x==null?$("filters.noLevel"):`#${x}`);g.labels.set(x,x!=null&&t.length>1&&A?`${I} \xB7 ${A}`:I)}let E=u(v);_.labels.set(E,E||$("noCategory"))}for(let v of d){if(!v.labels.size)continue;let y=new Map;for(let I of v.labels.values())y.set(I,(y.get(I)??0)+1);let A=[...v.labels].map(([I,D])=>[I,y.get(D)>1?`${D} (#${I})`:D]);A.sort((I,D)=>I[1].localeCompare(D[1])),v.keys=A.map(([I])=>I);let x=v.select=nt("select");x.append(new Option($("filters.all"),""));for(let[I,[,D]]of A.entries())x.append(new Option(D,String(I+1)));x.addEventListener("change",n);let E=nt("label","ioviewer-filter-field");E.append(nt("span","",v.name),x),a.append(E)}}}r.addEventListener("toggle",w);function S(){return d.filter(v=>v.select?.selectedIndex>0)}return{element:r,predicate(){let v=S().map(({select:y,keys:A,key:x})=>({key:x,value:A[y.selectedIndex-1]}));return v.length?y=>v.every(({key:A,value:x})=>A(y)===x):null},update(v,y){let A=S().length;o.textContent=A?`${$("filters.title")} (${A})`:$("filters.title"),m.disabled=!A&&!v,b.disabled=!y}}}var Ci=24,Ay=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 Ry(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 tp(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=xy(t),l=new Int32Array(t.length);a.forEach((z,$)=>z.indices.forEach(nt=>l[nt]=$));let c=new Uint8Array(a.length),h=new Int32Array(a.length),d=new Uint32Array(a.length),u=_y(t),f="",m=!1,_=new Int32Array(0),g=0,p=-1,M=null,T=!1,S=et("input","ioviewer-tree-search");S.type="search",S.placeholder=Z("searchPlaceholder"),S.setAttribute("aria-label",Z("searchPlaceholder"));let v=et("div","ioviewer-tree");v.setAttribute("role","tree"),v.setAttribute("aria-label",Z("panel.model")),v.setAttribute("aria-multiselectable","true"),v.tabIndex=-1;let b=et("div","ioviewer-tree-spacer");b.setAttribute("role","presentation"),v.append(b);let A=et("div","ioviewer-tree-empty",Z("noMatches")),x=Qf(t,e,S,F,()=>s.isolate(_));i.append(x.element,S,v,A);function w(){let z=_[g],$=x.predicate();if(m=!!(f||$),m){let lt=f?u(f):t.keys();if($){let at=[];for(let X of lt)$(t[X])&&at.push(X);_=Int32Array.from(at)}else _=Int32Array.from(lt)}else{let lt=a.length;a.forEach((X,tt)=>c[tt]&&(lt+=X.indices.length)),_=new Int32Array(lt);let at=0;a.forEach((X,tt)=>{if(h[tt]=at,_[at++]=-(tt+1),c[tt])for(let ht of X.indices)_[at++]=ht})}let nt=_.indexOf(z);g=nt>=0?nt:0,b.style.height=`${_.length*Ri}px`,A.hidden=_.length>0||!m,x.update(f,!!s.isolate&&m&&_.some(lt=>s.instancesOf(lt).length>0)),R()}function R(z=v.contains(document.activeElement)){let $=v.clientHeight;if($===0||_.length===0){b.replaceChildren();return}let nt=v.scrollTop,{start:lt,end:at}=Ih(nt,Ri,$,_.length,gy);!z&&(g=at)&&(g=Math.min(_.length-1,Math.floor(nt/Ri)));let X=[];g=at&&X.push(D(g)),b.replaceChildren(...X),z&&b.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function D(z){let $=_[z],nt=$<0?-$-1:l[$],lt=$<0?d[nt]===a[nt].indices.length:n.has($),at=et("div","tree-row");if(at.style.top=`${z*Ri}px`,at.style.height=`${Ri}px`,at.dataset.row=z,at.tabIndex=z===g?0:-1,at.setAttribute("role","treeitem"),at.classList.toggle("selected",lt),at.setAttribute("aria-selected",String(lt)),$<0){at.classList.add("tree-category"),at.setAttribute("aria-level","1"),at.setAttribute("aria-posinset",String(nt+1)),at.setAttribute("aria-setsize",String(a.length)),at.setAttribute("aria-expanded",String(!!c[nt]));let X=et("span","tree-chevron");X.innerHTML=re.chevron;let{name:tt,indices:ht}=a[nt];at.append(X,et("span","tree-name",tt||Z("noCategory")),et("span","tree-count",kr(ht.length)))}else{let X=t[$];at.classList.add("tree-element"),at.setAttribute("aria-level",m?"1":"2"),at.setAttribute("aria-posinset",String(m?z+1:z-h[nt])),at.setAttribute("aria-setsize",String(m?_.length:a[nt].indices.length)),at.classList.toggle("tree-child",!m),at.classList.toggle("tree-hidden",s.isVisible?.($)===!1),at.append(et("span","tree-name",X.name||`#${X.id}`),et("span","tree-type",X.type??""))}return at}function N(z){let $=v.clientHeight;if($===0){p=z;return}let nt=z*Ri;ntv.scrollTop+$&&(v.scrollTop=nt+Ri-$)}function B(z){g=z,N(z),R(!0)}function L(z){let $=l[z];!m&&!c[$]&&(c[$]=1,w());let nt=_.indexOf(z);nt>=0&&(v.contains(document.activeElement)||(g=nt),N(nt)),R()}function U(z){T=!0;try{n.set(z)}finally{T=!1}}function W(z,$){let nt=_.indexOf(M);nt<0&&(nt=z,M=_[z]);let lt=_.subarray(Math.min(nt,z),Math.max(nt,z)+1).filter(at=>at>=0);lt.length>0&&U($?[...n.values(),...lt]:lt)}function V(z){M=z;let $=-z-1,nt=z<0?a[$].indices:[z],lt=z<0?d[$]===nt.length:n.has(z),at=new Set(n.values());for(let X of nt)lt?at.delete(X):at.add(X);U(at)}function O(z,$,nt){z>=0&&!n.has(z)&&(M=z,U([z]));let lt=z>=0?z:n.values().next().value??null;o($,nt,lt,()=>{let at=_.indexOf(z);at>=0?B(at):S.focus()})}S.addEventListener("focus",()=>{b.firstElementChild||Y()});function F(){f=S.value.trim(),v.scrollTop=0,p=-1,g=-1,w()}S.addEventListener("input",F),v.addEventListener("scroll",()=>R()),v.addEventListener("focusin",z=>{let $=z.target.closest(".tree-row");!$||$.tabIndex===0||(b.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),g=Number($.dataset.row),$.tabIndex=0)}),v.addEventListener("keydown",z=>{let $=z.target.closest(".tree-row");if(!$||z.ctrlKey||z.altKey||z.metaKey)return;let nt=Number($.dataset.row),lt=_[nt];if(Ch(z)){if(z.preventDefault(),!z.repeat){let{left:X,bottom:tt}=$.getBoundingClientRect();O(lt,X,tt)}return}if(z.key===" "){z.preventDefault(),z.repeat||(z.shiftKey?W(nt,!1):V(lt));return}if(z.shiftKey)return;let at=nt;switch(z.key){case"ArrowUp":at=Math.max(0,nt-1);break;case"ArrowDown":at=Math.min(_.length-1,nt+1);break;case"Home":at=0;break;case"End":at=_.length-1;break;case"ArrowRight":lt<0&&(c[-lt-1]?at=nt+1:(c[-lt-1]=1,w()));break;case"ArrowLeft":lt>=0&&!m?at=h[l[lt]]:lt<0&&c[-lt-1]&&(c[-lt-1]=0,w());break;case"Enter":z.repeat||G(lt);break;default:return}z.preventDefault(),at!==nt&&B(at)});function G(z){if(z>=0){M=z,U([z]),r(z);return}c[-z-1]^=1,w()}v.addEventListener("click",z=>{let $=z.target.closest(".tree-row");if(!$)return;let nt=Number($.dataset.row),lt=z.ctrlKey||z.metaKey;z.shiftKey?W(nt,lt):lt?V(_[nt]):G(_[nt])}),v.addEventListener("contextmenu",z=>{let $=z.target.closest(".tree-row");$&&(z.preventDefault(),O(_[Number($.dataset.row)],z.clientX,z.clientY))});function Y(){p>=0&&v.clientHeight>0&&(N(p),p=-1),R()}new ResizeObserver(Y).observe(v),n.addEventListener("change",()=>{let z=-1;d.fill(0);for(let $ of n.values())d[l[$]]++,z=$;if(T){R();return}M=null,z>=0?L(z):R()}),s.root?.addEventListener("change",z=>z.detail.kind==="visibility"&&R()),w()}var ep={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},vy={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},gl=4;function np(i){let t=et("div","ioviewer-context-menu");t.setAttribute("role","menu"),t.setAttribute("aria-label",Z("contextMenu")),t.hidden=!0,i.append(t);let e=new Map(Object.values(ep).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(),ll(c))}function a(c,h,d,u,f=null){let m=ep[c];if(!m)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let p of m){if(p==="-"){let S=et("div","ioviewer-menu-separator");S.setAttribute("role","separator"),t.append(S);continue}let M=e.get(p),T=et("button","ioviewer-menu-item");T.type="button",T.tabIndex=-1,T.dataset.item=p,T.setAttribute("role","menuitem"),T.setAttribute("aria-disabled",String(!M.enabled)),M.enabled||(T.title=Z("menu.unavailable")),T.append(et("span","",Z(`menu.${p}`)),et("kbd","",vy[p]??"")),T.addEventListener("click",()=>{M.enabled&&(s(),M.handler(u))}),t.append(T)}t.hidden=!1;let{width:_,height:g}=t.getBoundingClientRect();t.style.left=`${Math.max(gl,Math.min(h,innerWidth-_-gl))}px`,t.style.top=`${Math.max(gl,Math.min(d,innerHeight-g-gl))}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 yy=1600;function ip(i,t,e){let n=()=>i.textContent=`${Z("selected")}: ${kr(t.size)} \xB7 ${Z("elements")}: ${kr(e)}`;t.addEventListener("change",n),n()}function sp(i,t){if(!t)return;let e=et("div","ioviewer-banner ioviewer-floating");e.setAttribute("role","status");let n=Z("truncated").replace("{meshes}",t.meshes).replace("{total}",t.totalMeshes),s=Qe("ioviewer-panel-close",re.close,Z("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 Hs(i,t){let e=et("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),yy)}function rp(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 op(i,t,e){let n=et("h2","ioviewer-properties-title"),s=et("button","ioviewer-properties-close","\xD7");s.type="button",s.title=Z("close"),s.setAttribute("aria-label",Z("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=[[Z("id"),h.id],[Z("category"),h.category],[Z("type"),h.type],[Z("level"),h.level]];return h.sourceId&&d.push([Z("sourceId"),h.sourceId]),h.link&&d.push([Z("link"),h.link]),rp(Z("elementGroup"),d)},l=h=>{for(let[d,u]of Object.entries(h??{}))o.append(rp(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=`${Z("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","",Z("badData")))}).finally(()=>{c===u&&o.removeAttribute("aria-busy")})})}async function My(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 ap({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[M,...T]=r.values(),S=e.elementBox(M);for(let v of T)S.union(e.elementBox(v));n.zoomToBox(S)},fitAll:l},h=Zf(i);h.registerPanel("model",{icon:re.model,title:Z("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:M=>tp(M,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:_,zoomToElement:T=>n.zoomToBox(e.elementBox(T))})});let d=document.createElement("aside");d.id="ioviewer-properties",d.className="ioviewer-floating",i.append(d),op(d,r,t);let u=Kf(i,Jf),f=M=>{n.setLeftButtonMode(M),u.setActive("orbit",M==="orbit"),u.setActive("pan",M==="pan")};u.setHandler("orbit",()=>f("orbit")),u.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),u.setHandler("fit",l),u.setHandler("projection",()=>{let M=!n.camera.isOrthographicCamera;n.setProjection(M?"orthographic":"perspective"),u.setActive("projection",M)}),u.setActive("projection",!1),document.fullscreenEnabled&&(u.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{u.setActive("fullscreen",!!document.fullscreenElement),Hs(i,Z("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>u.setActive("fullscreen",!!document.fullscreenElement)));let m=np(i);function _(M,T,S,v){m.open(S===null?"empty":"element",M,T,S,v)}function g(M){if(m.isOpen)return;let T=M===document.body,S=(T?n.dom:M).getBoundingClientRect(),v=T?S.left+S.width/2:S.left,b=T?S.top+S.height/2:S.bottom;_(v,b,r.values().next().value??null,()=>M.focus({preventScroll:!0}))}m.setItem("properties",{handler:M=>r.set([M])});for(let M of["hide","isolate","showAll","zoomTo","fitAll"])m.setItem(M,{handler:c[M]});m.setItem("copyId",{handler:M=>My(String(a.elements[M].id)).then(T=>Hs(i,Z(T?"idCopied":"copyFailed")),()=>Hs(i,Z("copyFailed")))}),n.addEventListener("contextmenu",async M=>{let{x:T,y:S}=M.detail;if(o?.active)return _(T,S,r.values().next().value??null);let v=s.pick(T,S),b=v?.then?await v:v;if(b!==void 0){if(!b||b.element<0)return _(T,S,null);r.has(b.element)||r.set([b.element]),_(T,S,b.element)}});let p=[];return window.addEventListener("keydown",M=>{if(M.defaultPrevented)return;let T=jf(M);if(T){if(M.preventDefault(),T==="contextMenu")return g(document.activeElement??document.body);if(T==="escape"&&!m.isOpen){p.some(S=>S())||r.clear();return}m.close(),T!=="escape"&&c[T]?.()}}),ip(document.getElementById("ioviewer-status"),r,e.elementCount),sp(i,a.truncated),{shell:h,toolbar:u,contextMenu:m,onEscape:M=>p.push(M)}}var Ph={x:new P(1,0,0),y:new P(0,1,0),z:new P(0,0,1)};function Lh(i){let t=Ph[i];if(!t)throw new RangeError(`Unknown axis: ${i}`);return t.clone()}function lp(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 cp(i,t,e,n){let s=i.clone().normalize(),r=s.dot(t)+e;return n?new Te(s,-r):new Te(s.negate(),r)}function hp(i,t,e=0){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);let{min:n,max:s}=i,r=[new Te(new P(1,0,0),-n.x),new Te(new P(-1,0,0),s.x),new Te(new P(0,1,0),-n.y),new Te(new P(0,-1,0),s.y),new Te(new P(0,0,1),-n.z),new Te(new P(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new P);for(let a of r){let l=a.distanceToPoint(o);a.normal.applyAxisAngle(Ph.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 up(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 P).sub(i.getCenter(new P));o.translate(a.clone().applyAxisAngle(Ph.z,t).sub(a))}return o}function dp(i){let{min:t,max:e}=i;return Array.from({length:8},(n,s)=>new P(s&1?e.x:t.x,s&2?e.y:t.y,s&4?e.z:t.z))}function fp(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=dp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function _l(i,t){let e=i.getSize(new P).multiplyScalar(.5);return Math.abs(t.x)*e.x+Math.abs(t.y)*e.y+Math.abs(t.z)*e.z}function Gr(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 xl(i,t,e){let n=new P(1,0,0).applyQuaternion(t),s=new P(0,1,0).applyQuaternion(t),[r,o,a,l]=[1/0,-1/0,1/0,-1/0];for(let h of dp(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 Wr=6,by=["off","planes","box"],Sy=.05,Dh=new P(0,0,1),vl=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new P),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 P().fromArray(r),c=new De().setFromUnitVectors(Dh,l);return{axis:s,quaternion:c,offset:o-l.dot(this.center),flipped:a,enabled:!0,rotated:!1}}),this.active=this.planes.length?0:-1,this.box=e?new ae(new P().fromArray(e.min),new P().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(!by.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=Lh(t);if(this.planes.length>=Wr||this.modelBox.isEmpty())return null;let n=new De().setFromUnitVectors(Dh,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(Lh(o.axis))>1e-6),this._changed(!0)}setActivePlane(t){this._plane(t),this.active=t,this._changed(!1)}normal(t){return Dh.clone().applyQuaternion(this._plane(t).quaternion)}extent(t){return _l(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 cp(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=pp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=pp(t),this._changed(this.mode==="box"))}setBoxMode(t){if(t!=="keepInside"&&t!=="cutInside")throw new RangeError(`Unknown box mode: ${t}`);this.boxMode=t,this._changed(!0)}fitBoxToElements(t){let e=new ae;for(let s of t)e.union(this.scene.elementBox(s));if(e.isEmpty())return!1;let n=e.getSize(new P);return this.setBox(e.expandByScalar(Sy*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 P);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=hp(this.box,this.boxMode,this.boxYaw);if(!t.intersection&&this.boxYaw!==0){let e=this.box.getCenter(new P),n=this.box.getSize(new P).multiplyScalar(.5),s=Math.abs(Math.cos(this.boxYaw)),r=Math.abs(Math.sin(this.boxYaw));n.set(s*n.x+r*n.y,r*n.x+s*n.y,n.z),t.bounds=new ae(e.clone().sub(n),e.add(n))}return t}return{planes:[],intersection:!1}}isCut(t,{planes:e,intersection:n,bounds:s}=this.clipping()){return s&&!t.isEmpty()&&!s.intersectsBox(t)||fp(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 pp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:le.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Nh=80,wy=8,Bh=.8,Ey=Math.sin(le.degToRad(12)),Ci={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Uh=["x","y","z"],Ty=Math.cos(le.degToRad(12)),yl=new P(0,0,1),Ay=i=>new Ke({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),Ry=new Ke({visible:!1});function Ml(i,t,e,n){let s=new Re,r=Ay(t);for(let a of e)s.add(new pe(a,r));let o=new pe(n,Ry);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 Fh(i,t,e=n=>n){let n=Ml("rotate",Ci[t],[e(new Ss(Bh,.018,8,64))],e(new Ss(Bh,.09,8,48)));return n.name=i,n.userData.axis=t,n}var bl=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 Gn,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)*Nh),this.arrow.visible=this._across(yl.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)*wy)}let n=this.boxRing;n.visible&&n.scale.setScalar(this._worldPerPixel(n.position)*Nh)}_across(t,e){let n=this.camera,s=n.isOrthographicCamera?n.getWorldDirection(new P):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new P(r/2,o/2,0))),n=new Ke({color:Ci.fill,transparent:!0,opacity:.12,side:Oe,depthWrite:!1}),s=new an({color:Ci.frame});this.planeVisuals=Array.from({length:Wr},()=>{let r=new Re;return r.add(new pe(t,n),new sr(e,s)),this.group.add(r),r})}_buildPlaneGizmo(){let t=(n,s)=>n.rotateX(Math.PI/2).translate(0,0,s),e=Ml("move",Ci.z,[t(new Oi(.025,.025,1),.5),t(new lr(.08,.25),1.125)],t(new Oi(.12,.12,1.25),.625));e.name="arrow",this.arrow=e,this.planeGizmo=new Re,this.planeGizmo.add(e,Fh("ringX","x",n=>n.rotateY(Math.PI/2)),Fh("ringY","y",n=>n.rotateX(Math.PI/2))),this.group.add(this.planeGizmo)}_buildBox(){this.boxWire=new bn(new zi(new pn(1,1,1)),new an({color:Ci.frame})),this.group.add(this.boxWire);let t=new Hn(1,16,12),e=new Hn(1.6,8,6);this.boxHandles=[];for(let s of Uh)for(let r of[-1,1]){let o=Ml("face",Ci[s],[t],e);o.name=`face${r>0?"+":"-"}${s}`,Object.assign(o.userData,{axis:s,sign:r,normal:new P}),this.boxHandles.push(o)}let n=Ml("centre",Ci.centre,[new pn(1.4,1.4,1.4)],e);n.name="centre",this.boxHandles.push(n),this.boxRing=Fh("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=xl(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 P),o=s.getSize(new P);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new P(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(Uh.indexOf(l),c).applyAxisAngle(yl,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 P));return 2*Math.max(s,e.near)*Math.tan(le.degToRad(e.fov/2))/n}_ray(t){let e=this.dom.getBoundingClientRect(),n=new Gt((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),_=Gr(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?yl:new P().setComponent(Uh.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 Ly(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 lp(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=Cy(t),l=new Int32Array(t.length);a.forEach((V,Z)=>V.indices.forEach(K=>l[K]=Z));let c=new Uint8Array(a.length),h=new Int32Array(a.length),u=new Uint32Array(a.length),d=Ry(t),f="",g=!1,_=new Int32Array(0),p=0,m=-1,b=null,w=!1,S=nt("input","ioviewer-tree-search");S.type="search",S.placeholder=$("searchPlaceholder"),S.setAttribute("aria-label",$("searchPlaceholder"));let v=nt("div","ioviewer-tree");v.setAttribute("role","tree"),v.setAttribute("aria-label",$("panel.model")),v.setAttribute("aria-multiselectable","true"),v.tabIndex=-1;let y=nt("div","ioviewer-tree-spacer");y.setAttribute("role","presentation"),v.append(y);let A=nt("div","ioviewer-tree-empty",$("noMatches")),x=ap(t,e,S,U,()=>s.isolate(_));i.append(x.element,S,v,A);function E(){let V=_[p],Z=x.predicate();if(g=!!(f||Z),g){let lt=f?d(f):t.keys();if(Z){let rt=[];for(let H of lt)Z(t[H])&&rt.push(H);_=Int32Array.from(rt)}else _=Int32Array.from(lt)}else{let lt=a.length;a.forEach((H,Q)=>c[Q]&&(lt+=H.indices.length)),_=new Int32Array(lt);let rt=0;a.forEach((H,Q)=>{if(h[Q]=rt,_[rt++]=-(Q+1),c[Q])for(let ut of H.indices)_[rt++]=ut})}let K=_.indexOf(V);p=K>=0?K:0,y.style.height=`${_.length*Ci}px`,A.hidden=_.length>0||!g,x.update(f,!!s.isolate&&g&&_.some(lt=>s.instancesOf(lt).length>0)),I()}function I(V=v.contains(document.activeElement)){let Z=v.clientHeight;if(Z===0||_.length===0){y.replaceChildren();return}let K=v.scrollTop,{start:lt,end:rt}=zh(K,Ci,Z,_.length,Ay);!V&&(p=rt)&&(p=Math.min(_.length-1,Math.floor(K/Ci)));let H=[];p=rt&&H.push(D(p)),y.replaceChildren(...H),V&&y.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function D(V){let Z=_[V],K=Z<0?-Z-1:l[Z],lt=Z<0?u[K]===a[K].indices.length:n.has(Z),rt=nt("div","tree-row");if(rt.style.top=`${V*Ci}px`,rt.style.height=`${Ci}px`,rt.dataset.row=V,rt.tabIndex=V===p?0:-1,rt.setAttribute("role","treeitem"),rt.classList.toggle("selected",lt),rt.setAttribute("aria-selected",String(lt)),Z<0){rt.classList.add("tree-category"),rt.setAttribute("aria-level","1"),rt.setAttribute("aria-posinset",String(K+1)),rt.setAttribute("aria-setsize",String(a.length)),rt.setAttribute("aria-expanded",String(!!c[K]));let H=nt("span","tree-chevron");H.innerHTML=re.chevron;let{name:Q,indices:ut}=a[K];rt.append(H,nt("span","tree-name",Q||$("noCategory")),nt("span","tree-count",Vr(ut.length)))}else{let H=t[Z];rt.classList.add("tree-element"),rt.setAttribute("aria-level",g?"1":"2"),rt.setAttribute("aria-posinset",String(g?V+1:V-h[K])),rt.setAttribute("aria-setsize",String(g?_.length:a[K].indices.length)),rt.classList.toggle("tree-child",!g),rt.classList.toggle("tree-hidden",s.isVisible?.(Z)===!1),rt.append(nt("span","tree-name",H.name||`#${H.id}`),nt("span","tree-type",H.type??""))}return rt}function N(V){let Z=v.clientHeight;if(Z===0){m=V;return}let K=V*Ci;Kv.scrollTop+Z&&(v.scrollTop=K+Ci-Z)}function B(V){p=V,N(V),I(!0)}function L(V){let Z=l[V];!g&&!c[Z]&&(c[Z]=1,E());let K=_.indexOf(V);K>=0&&(v.contains(document.activeElement)||(p=K),N(K)),I()}function F(V){w=!0;try{n.set(V)}finally{w=!1}}function k(V,Z){let K=_.indexOf(b);K<0&&(K=V,b=_[V]);let lt=_.subarray(Math.min(K,V),Math.max(K,V)+1).filter(rt=>rt>=0);lt.length>0&&F(Z?[...n.values(),...lt]:lt)}function W(V){b=V;let Z=-V-1,K=V<0?a[Z].indices:[V],lt=V<0?u[Z]===K.length:n.has(V),rt=new Set(n.values());for(let H of K)lt?rt.delete(H):rt.add(H);F(rt)}function O(V,Z,K){V>=0&&!n.has(V)&&(b=V,F([V]));let lt=V>=0?V:n.values().next().value??null;o(Z,K,lt,()=>{let rt=_.indexOf(V);rt>=0?B(rt):S.focus()})}S.addEventListener("focus",()=>{y.firstElementChild||q()});function U(){f=S.value.trim(),v.scrollTop=0,m=-1,p=-1,E()}S.addEventListener("input",U),v.addEventListener("scroll",()=>I()),v.addEventListener("focusin",V=>{let Z=V.target.closest(".tree-row");!Z||Z.tabIndex===0||(y.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),p=Number(Z.dataset.row),Z.tabIndex=0)}),v.addEventListener("keydown",V=>{let Z=V.target.closest(".tree-row");if(!Z||V.ctrlKey||V.altKey||V.metaKey)return;let K=Number(Z.dataset.row),lt=_[K];if(Oh(V)){if(V.preventDefault(),!V.repeat){let{left:H,bottom:Q}=Z.getBoundingClientRect();O(lt,H,Q)}return}if(V.key===" "){V.preventDefault(),V.repeat||(V.shiftKey?k(K,!1):W(lt));return}if(V.shiftKey)return;let rt=K;switch(V.key){case"ArrowUp":rt=Math.max(0,K-1);break;case"ArrowDown":rt=Math.min(_.length-1,K+1);break;case"Home":rt=0;break;case"End":rt=_.length-1;break;case"ArrowRight":lt<0&&(c[-lt-1]?rt=K+1:(c[-lt-1]=1,E()));break;case"ArrowLeft":lt>=0&&!g?rt=h[l[lt]]:lt<0&&c[-lt-1]&&(c[-lt-1]=0,E());break;case"Enter":V.repeat||z(lt);break;default:return}V.preventDefault(),rt!==K&&B(rt)});function z(V){if(V>=0){b=V,F([V]),r(V);return}c[-V-1]^=1,E()}v.addEventListener("click",V=>{let Z=V.target.closest(".tree-row");if(!Z)return;let K=Number(Z.dataset.row),lt=V.ctrlKey||V.metaKey;V.shiftKey?k(K,lt):lt?W(_[K]):z(_[K])}),v.addEventListener("contextmenu",V=>{let Z=V.target.closest(".tree-row");Z&&(V.preventDefault(),O(_[Number(Z.dataset.row)],V.clientX,V.clientY))});function q(){m>=0&&v.clientHeight>0&&(N(m),m=-1),I()}new ResizeObserver(q).observe(v),n.addEventListener("change",()=>{let V=-1;u.fill(0);for(let Z of n.values())u[l[Z]]++,V=Z;if(w){I();return}b=null,V>=0?L(V):I()}),s.root?.addEventListener("change",V=>V.detail.kind==="visibility"&&I()),E()}var cp={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},Iy={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},yl=4;function hp(i){let t=nt("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(cp).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,u,d,f=null){let g=cp[c];if(!g)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let m of g){if(m==="-"){let S=nt("div","ioviewer-menu-separator");S.setAttribute("role","separator"),t.append(S);continue}let b=e.get(m),w=nt("button","ioviewer-menu-item");w.type="button",w.tabIndex=-1,w.dataset.item=m,w.setAttribute("role","menuitem"),w.setAttribute("aria-disabled",String(!b.enabled)),b.enabled||(w.title=$("menu.unavailable")),w.append(nt("span","",$(`menu.${m}`)),nt("kbd","",Iy[m]??"")),w.addEventListener("click",()=>{b.enabled&&(s(),b.handler(d))}),t.append(w)}t.hidden=!1;let{width:_,height:p}=t.getBoundingClientRect();t.style.left=`${Math.max(yl,Math.min(h,innerWidth-_-yl))}px`,t.style.top=`${Math.max(yl,Math.min(u,innerHeight-p-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")],u=h.indexOf(document.activeElement),d;switch(c.key){case"ArrowDown":d=(u+1)%h.length;break;case"ArrowUp":d=(u+h.length-1)%h.length;break;case"Home":d=0;break;case"End":d=h.length-1;break;default:return}c.preventDefault(),h[d]?.focus({preventScroll:!0})});function l(c,{enabled:h=!0,handler:u}){let d=e.get(c);if(!d)throw new RangeError(`Unknown menu item: ${c}`);u&&(d.handler=u),d.enabled=h&&!!d.handler}return{element:t,open:a,close:s,setItem:l,get isOpen(){return!t.hidden}}}var Py=1600;function up(i,t,e){let n=()=>i.textContent=`${$("selected")}: ${Vr(t.size)} \xB7 ${$("elements")}: ${Vr(e)}`;t.addEventListener("change",n),n()}function dp(i,t){if(!t)return;let e=nt("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",re.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(nt("span","",n),s),i.append(e),r.observe(e)}function Gs(i,t){let e=nt("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),Py)}function fp(i,t){let e=nt("table");for(let[s,r]of t)e.insertRow().append(nt("th","",s),nt("td","",String(r??"")));let n=nt("section");return n.append(nt("h3","",i),e),n}function pp(i,t,e){let n=nt("h2","ioviewer-properties-title"),s=nt("button","ioviewer-properties-close","\xD7");s.type="button",s.title=$("close"),s.setAttribute("aria-label",$("close")),s.addEventListener("click",()=>t.clear());let r=nt("header");r.append(n,s);let o=nt("div","ioviewer-properties-body");i.replaceChildren(r,o),i.hidden=!0;let a=h=>{let u=[[$("id"),h.id],[$("category"),h.category],[$("type"),h.type],[$("level"),h.level]];return h.sourceId&&u.push([$("sourceId"),h.sourceId]),h.link&&u.push([$("link"),h.link]),fp($("elementGroup"),u)},l=h=>{for(let[u,d]of Object.entries(h??{}))o.append(fp(u,Object.entries(d)))},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(),u=e.meta.elements[h];if(n.textContent=u.name||`#${u.id}`,o.append(a(u)),!e.loadProperties){l(e.props(u.id));return}let d=new AbortController;c=d,o.setAttribute("aria-busy","true"),e.loadProperties(h,d.signal).then(f=>{d.signal.aborted||!f||(n.textContent=f.name||u.name||`#${u.id}`,o.replaceChildren(a({...u,...f})),l(f.properties))}).catch(()=>{d.signal.aborted||o.append(nt("p","",$("badData")))}).finally(()=>{c===d&&o.removeAttribute("aria-busy")})})}async function Ly(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 mp({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,...S]=r.values(),v=e.elementBox(w);for(let y of S)v.union(e.elementBox(y));n.zoomToBox(v)},fitAll:l},h=ip(i);h.registerPanel("model",{icon:re.model,title:$("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:w=>lp(w,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:p,zoomToElement:S=>n.zoomToBox(e.elementBox(S))})});let u=document.createElement("aside");u.id="ioviewer-properties",u.className="ioviewer-floating",i.append(u),pp(u,r,t);let d=rp(i,sp),f=w=>{n.is2D&&w==="orbit"||(n.setLeftButtonMode(w),d.setActive("orbit",w==="orbit"),d.setActive("pan",w==="pan"))};d.setHandler("orbit",()=>f("orbit")),d.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),d.setHandler("fit",l),d.setHandler("projection",()=>{if(n.is2D)return;let w=!n.camera.isOrthographicCamera;n.setProjection(w?"orthographic":"perspective"),d.setActive("projection",w)}),d.setActive("projection",!1);let g=()=>{let w=!!n.is2D;d.setActive("mode2d",w),d.setEnabled("orbit",!w),d.setEnabled("projection",!w),d.setActive("projection",w||n.camera.isOrthographicCamera),d.setActive("orbit",!w&&n.leftButtonMode==="orbit"),d.setActive("pan",w||n.leftButtonMode==="pan")};d.setHandler("mode2d",()=>{n.set2DMode(!n.is2D,e.visibleBox(),!1),g()}),g(),document.fullscreenEnabled&&(d.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{d.setActive("fullscreen",!!document.fullscreenElement),Gs(i,$("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>d.setActive("fullscreen",!!document.fullscreenElement)));let _=hp(i);function p(w,S,v,y){_.open(v===null?"empty":"element",w,S,v,y)}function m(w){if(_.isOpen)return;let S=w===document.body,v=(S?n.dom:w).getBoundingClientRect(),y=S?v.left+v.width/2:v.left,A=S?v.top+v.height/2:v.bottom;p(y,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=>Ly(String(a.elements[w].id)).then(S=>Gs(i,$(S?"idCopied":"copyFailed")),()=>Gs(i,$("copyFailed")))}),n.addEventListener("contextmenu",async w=>{let{x:S,y:v}=w.detail;if(o?.active)return p(S,v,r.values().next().value??null);let y=s.pick(S,v),A=y?.then?await y:y;if(A!==void 0){if(!A||A.element<0)return p(S,v,null);r.has(A.element)||r.set([A.element]),p(S,v,A.element)}});let b=[];return window.addEventListener("keydown",w=>{if(w.defaultPrevented)return;let S=op(w);if(S){if(w.preventDefault(),S==="contextMenu")return m(document.activeElement??document.body);if(S==="escape"&&!_.isOpen){b.some(v=>v())||r.clear();return}_.close(),S!=="escape"&&c[S]?.()}}),up(document.getElementById("ioviewer-status"),r,e.elementCount),dp(i,a.truncated),{shell:h,toolbar:d,contextMenu:_,sync2DState:g,onEscape:w=>b.push(w)}}var kh={x:new R(1,0,0),y:new R(0,1,0),z:new R(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 gp(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 _p(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 R(1,0,0),-n.x),new Ae(new R(-1,0,0),s.x),new Ae(new R(0,1,0),-n.y),new Ae(new R(0,-1,0),s.y),new Ae(new R(0,0,1),-n.z),new Ae(new R(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new R);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 xp(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 R).sub(i.getCenter(new R));o.translate(a.clone().applyAxisAngle(kh.z,t).sub(a))}return o}function vp(i){let{min:t,max:e}=i;return Array.from({length:8},(n,s)=>new R(s&1?e.x:t.x,s&2?e.y:t.y,s&4?e.z:t.z))}function yp(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=vp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function bl(i,t){let e=i.getSize(new R).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 R(1,0,0).applyQuaternion(t),s=new R(0,1,0).applyQuaternion(t),[r,o,a,l]=[1/0,-1/0,1/0,-1/0];for(let h of vp(i)){h.sub(e);let u=h.dot(n),d=h.dot(s);[r,o,a,l]=[Math.min(r,u),Math.max(o,u),Math.min(a,d),Math.max(l,d)]}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,Dy=["off","planes","box"],Ny=.05,Vh=new R(0,0,1),wl=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new R),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 R().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 R().fromArray(e.min),new R().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(!Dy.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 gp(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=Mp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=Mp(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 R);return this.setBox(e.expandByScalar(Ny*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 R);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=_p(this.box,this.boxMode,this.boxYaw);if(!t.intersection&&this.boxYaw!==0){let e=this.box.getCenter(new R),n=this.box.getSize(new R).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)||yp(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 Mp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:oe.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Gh=80,Uy=8,qh=.8,Fy=Math.sin(oe.degToRad(12)),Ii={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Wh=["x","y","z"],By=Math.cos(oe.degToRad(12)),El=new R(0,0,1),Oy=i=>new Je({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),zy=new Je({visible:!1});function Tl(i,t,e,n){let s=new Re,r=Oy(t);for(let a of e)s.add(new me(a,r));let o=new me(n,zy);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)*Uy)}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 R):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new R(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 me(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 R}),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 R),o=s.getSize(new R);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new R(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 R));return 2*Math.max(s,e.near)*Math.tan(oe.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 d=r.active,f=r.origin(d),g=r.normal(d),_=Xr(e,f,g);return _===null?null:{index:d,origin:f,normal:g,offset:r.planes[d].offset,s0:_}}if(o==="rotate"){let d=r.active,f=t===this.boxRing,g=f?t.position.clone():r.origin(d),_=f?null:r.planes[d].quaternion.clone(),p=f?El:new R().setComponent(Wh.indexOf(t.userData.axis),1).applyQuaternion(_),m={index:d,origin:g,quaternion:_,axis:p,yaw:f?r.boxYaw:null};if(Math.abs(p.dot(e.direction))0&&r===0}function Gy(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 -${Ur} +${Br} #include uniform highp sampler2D closedSlots; void main() { - ${Fr} + ${Or} vec3 transformed = slotPosition; #include #include - ${xh} + ${wh} 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 Sl=class{constructor(t,e,n,s){this.model=t,this.sections=e,this.data=n,this.drawStencils=s,this._farSide=new Te,this._surface=new pe(new ln(1,1),new Ke({color:Iy,side:Oe,forceSinglePass:!0,stencilWrite:!0,stencilFunc:Nc,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))<_l(s.modelBox,u.normal);if(r.opacity===0||!l.some(c))return t.render(e,n);if(!this.drawStencils&&!this._stencils){let u={...r.slotUniforms,closedSlots:{value:Ly(r,this.data)}};this._stencils=[mp(u,this._farSide,Be,Lc),mp(u,this._farSide,Wn,Dc)]}let h=this._surface.material;h.opacity=r.opacity,h.transparent!==r.opacity<1&&(h.transparent=r.opacity<1,h.depthWrite=!h.transparent,h.needsUpdate=!0);let d=t.autoClear;t.autoClear=!1;try{t.clear();let u=n.isOrthographicCamera?n.getWorldDirection(new P):null;l.forEach((f,m)=>{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(Cy,f.normal);let g=xl(s.modelBox,this._surface.quaternion,f.coplanarPoint(new P));this._surface.position.copy(g.center),this._surface.scale.set(g.width,g.height,1),h.clippingPlanes=l.filter((p,M)=>M!==m),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=d}}};function Xr(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 Oh(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 Dy(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=Qe("ioviewer-icon-button",re.flip,Z("sections.flip"));s.addEventListener("click",()=>i.updatePlane(t,{flipped:!i.planes[t].flipped}));let r=Oh(Z("sections.enabled"),h=>i.updatePlane(t,{enabled:h})),o=Qe("ioviewer-icon-button",re.remove,Z("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",Z("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?` (${Z("sections.rotated")})`:"",u=h.axis==="custom"?Z("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 gp({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"),Hs(i,Z("sections.maxPlanes")))},h=()=>[...r.values()],d=()=>s.fitBoxToElements(h()),u=Xr(Z("sections.mode"),[["planes",Z("sections.planes")],["box",Z("sections.box")],["off",Z("sections.off")]],U=>s.setMode(U)),f=Xr(Z("sections.axis"),["x","y","z"].map(U=>[U,U.toUpperCase()]),U=>f.update(l=U));f.update(l);let m=et("button","ioviewer-text-button",Z("sections.addPlane"));m.type="button",m.addEventListener("click",c);let _=et("ul","ioviewer-section-list"),g=et("div","ioviewer-section-empty",Z("sections.noPlanes")),p=et("div","ioviewer-section-block"),M=et("div","ioviewer-section-row");M.append(et("span","",Z("sections.axis")),f.element,m),p.append(M,_,g);let T=Xr(Z("sections.box"),[["keepInside",Z("sections.keepInside")],["cutInside",Z("sections.cutInside")]],U=>s.setBoxMode(U)),S=et("button","ioviewer-text-button",Z("sections.fitSelection"));S.type="button",S.addEventListener("click",d);let v=et("input","ioviewer-section-slider");Object.assign(v,{type:"range",min:"-180",max:"180",step:"1"}),v.addEventListener("input",()=>s.setBoxYaw(Number(v.value)*Math.PI/180));let b=et("span");b.setAttribute("aria-hidden","true");let A=et("label","ioviewer-section-row");A.append(et("span","",Z("sections.boxYaw")),v,b);let x=et("div","ioviewer-section-block");x.append(T.element,A,S);let w=Oh(Z("sections.showGizmo"),U=>s.setGizmoVisible(U)),R=Oh(Z("sections.fill"),U=>s.setFill(U));o||(R.element.title=Z(a?"sections.fillUnavailable":"sections.fillNeedsMeshes"));let D=[],N=()=>{u.update(s.mode),p.hidden=s.mode!=="planes",x.hidden=s.mode!=="box",m.disabled=s.planes.length>=Wr,D.length!==s.planes.length&&(D=s.planes.map((W,V)=>Dy(s,V)),_.replaceChildren(...D.map(W=>W.element))),D.forEach(W=>W.update()),g.hidden=D.length>0,T.update(s.boxMode),v.value=String(Math.round(s.boxYaw*180/Math.PI)),b.textContent=`${v.value}\xB0`,v.setAttribute("aria-valuetext",b.textContent),w.input.checked=s.gizmoVisible,R.input.checked=s.fill;let U=s.mode==="box"||s.mode==="planes"&&s.planes.some(W=>W.enabled);R.input.disabled=!o||!U,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},B=()=>S.disabled=r.size===0;if(t.registerPanel("sections",{icon:re.sections,title:Z("panel.sections"),visible:!s.modelBox.isEmpty(),render:U=>U.append(u.element,p,x,R.element,w.element)}),s.addEventListener("change",N),r.addEventListener("change",B),N(),B(),s.modelBox.isEmpty())return;let L=()=>t.openPanel("sections");e.setHandler("plane",()=>{c(),L()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&d()||s.fitBoxToShown())&&L()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:U=>{s.fitBoxToElements(r.has(U)?h():[U]),L()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var Ny="#facc15",Uy=9;function zh(i,t=ai){return`${new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}).format(i)} ${Z("unit.m",t)}`}var wl=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 fe;e.setAttribute("position",new Ae(new Float32Array(6),3));let n={color:Ny,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Bi(e,new an(n)),this._markers=new Sn(e,new zn({...n,size:Uy,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 ae().setFromPoints(this.points)}setActive(t){this.active=!!t,this.active||(this.points=[],this.setPreview(null)),this._sync()}add(t){this.active&&(this.points=this.points.length===1?[this.points[0],t.clone()]:[t.clone()],this._sync())}clear(){return this.points.length===0?!1:(this.points=[],this._sync(),!0)}setPreview(t){!this.preview&&!t||(this.preview=t,this._previewMarker.hidden=!t,t&&(this._previewMarker.dataset.kind=t.kind),this.dispatchEvent(new Event("previewchange")))}update(t,e){this.preview&&Hr(this._previewMarker,this.preview.point,t,e),this.distance!==null&&Hr(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=zh(this.distance)),this.dispatchEvent(new Event("change"))}};var _p=8,Fy=1-1e-6,By=8,xp={vertex:0,midpoint:1,edge:2},Oy=2e4;function zy(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 El(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 ky(i,t,e,n,s,r){let o=[0,1];if(!El(o,e.w+e.z,n.w+n.z)||!El(o,e.w-e.z,n.w-n.z))return[];if(!r||!s.length)return s.every(c=>El(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)&&El(a,-h,-d)}))return[o];let l=[];return o[0]0))return null;let g=le.clamp(((r-c)*f+(o-h)*m)/_,0,1);return e+(n-e)*(g*a.w/((1-g)*l.w+g*a.w))}var Tl=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=tl({view:this.data.readView},n);e={positions:s,...zy(s,this.data.readView(n.indices))}}return this.cache.set(t,e),this.cache.size>By&&this.cache.delete(this.cache.keys().next().value),e}target(t,e){let n=this.picker.measureTile(t,e,_p+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(v,b,A,x){if(f&&xp[v]>xp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[w,R]=kh(A,s);if(!(w>=0&&R>=0&&w_p**2||f?.kind===v&&D>=f.distance||v!=="edge"&&lp(b,c,h))return;let N=-(u[2]*b.x+u[6]*b.y+u[10]*b.z+u[14]);N-n.depthAt(w,R,x)>2*An+Math.abs(N)*2**-21||(f={kind:v,distance:D,point:b.clone()})}let _=Oy*3,g=new Zt,p=new P,M=new xe,{geometry:T,matrix:S}=this.data.meta.instances;for(let v of n.slots){let b=l.slotInstance(v),[A]=this.data.readView({t:"u32",o:T.o+b*4,n:1}),x=this.data.meta.geometries[A],w=Math.max(x.indices.n,x.positions.n/3);if(w>_)continue;_-=w;let{positions:R,vertices:D,edges:N}=this._geometry(A),B=this.data.readView({t:"f32",o:S.o+b*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 L=new Map;for(let U of D){let W=new P().fromArray(R,U*3).applyMatrix4(g),V=new xe(W.x,W.y,W.z,1).applyMatrix4(d);L.set(U,[W,V]),m("vertex",W,V,v)}if(f?.kind!=="vertex")for(let U=0;Ur.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)Hr(n,s,t,e)}};var Vy=8,vp=4;function Hh(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(),ll(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(vp,Math.min(l.left+l.width/2-c/2,innerWidth-c-vp))}px`,s.style.bottom=`${innerHeight-l.top+Vy}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 Gy(i){return i?.initialWireframe?"wireframe":i?.initialWhiteMode?"white":"materials"}function yp({root:i,toolbar:t,scene:e,meta:n,grids:s,initialBackground:r,setBackground:o,hasMeshes:a=!0}){let l=R=>t.element.querySelector(`[data-tool="${R}"]`),c=l("displayMode"),h=Hh(i,c,Z("group.display"));h.element.classList.add("ioviewer-display-modes");let d=et("div");d.setAttribute("role","menu"),d.setAttribute("aria-label",Z("tool.displayMode")),h.element.append(d);let u=(n.textures??[]).length>0,f=Sh.map(R=>{let D=et("button","ioviewer-menu-item",Z(`display.${R}`));return D.type="button",D.dataset.mode=R,D.setAttribute("role","menuitemradio"),D.disabled=R==="textures"&&!u||R==="wireframe"&&!a,D.addEventListener("click",()=>{m(R),h.close(),c.focus()}),d.append(D),D}),m=R=>{e.setDisplayMode(R);for(let D of f)D.setAttribute("aria-checked",String(D.dataset.mode===R))},_=Gy(n.options);m(_==="wireframe"&&!a?"materials":_),t.setHandler("displayMode",()=>{h.toggle(),h.isOpen&&d.querySelector('[aria-checked="true"]')?.focus()});let g=et("div","ioviewer-background-setting"),p=et("label","",Z("display.background")),M=et("input");Object.assign(M,{type:"color",value:r}),p.append(M);let T=et("button","ioviewer-text-button",Z("display.backgroundReset"));T.type="button",T.disabled=!0;let S=()=>{o(M.value),T.disabled=M.value===r};M.addEventListener("input",S),T.addEventListener("click",()=>{M.value=r,M.focus(),S()}),g.append(p,T),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 v=Hh(i,l("opacity"),Z("tool.opacity"));v.element.classList.add("ioviewer-opacity");let b=et("input","ioviewer-opacity-slider");Object.assign(b,{type:"range",min:"10",max:"100",step:"1",value:"100"}),b.setAttribute("aria-label",Z("opacity.label"));let A=et("output","ioviewer-opacity-value"),x=()=>A.textContent=Z("opacity.value").replace("{value}",b.value);b.addEventListener("input",()=>{e.setOpacity(Number(b.value)/100),x()}),x();let w=et("div","ioviewer-opacity-head");return w.append(et("span","",Z("opacity.label")),A),v.element.append(w,b),t.setHandler("opacity",v.toggle),[h,v]}var Wy=3e3;function Rl(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 Mp({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(T){T.sections!=null&&s.restore(T.sections),T.hiddenElements!=null&&n.setHiddenElements(T.hiddenElements),T.visibleElements!=null&&n.isolate(T.visibleElements),T.hiddenModelKeys!=null&&o(T.hiddenModelKeys),T.selectedElements!=null&&r.set(T.selectedElements);let S=T.camera.projection==="orthographic";e.setProjection(S?"orthographic":"perspective"),t.setActive("projection",S),e.restoreViewCamera(T.camera)}function u(){d(a[c.next]),c.next=(c.next+1)%a.length;let T=()=>{e.animating?c.frame=requestAnimationFrame(T):c.timer=setTimeout(u,Wy)};c.frame=requestAnimationFrame(T)}let f=T=>h.contains(T.target),m=T=>!f(T)&&g(),_=T=>{f(T)&&(T.key==="Enter"||T.key===" ")||(T.key==="Escape"&&(T.preventDefault(),T.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),M())}function p(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",m,!0),window.addEventListener("wheel",g,!0),window.addEventListener("keydown",_,!0),M(),u()}function M(){let T=Z(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?re.pause:re.play),h.append(et("span","",T)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?g():p()),M(),i.registerPanel("views",{icon:re.views,title:Z("panel.views"),visible:a.length>0,render:T=>{let S=et("div","ioviewer-row-list");for(let v of a){let b=Rl("ioviewer-row ioviewer-view",String(v.name??""));b.addEventListener("click",()=>d(v)),S.append(b)}T.append(h,S)}}),i.registerPanel("bcf",{icon:re.bcf,title:Z("panel.bcf"),visible:l.length>0,render:T=>{let S=et("div","ioviewer-row-list");for(let v of l){let b=et("details","ioviewer-bcf-topic");b.append(et("summary","",v.title)),v.status&&b.append(et("p","ioviewer-bcf-status",v.status)),v.description&&b.append(et("p","ioviewer-bcf-description",v.description)),v.viewpoints.length||b.append(et("p","ioviewer-bcf-status",Z("bcf.noView"))),v.viewpoints.forEach((A,x)=>{let w=Z("bcf.viewpoint").replace("{index}",String(x+1)),R=Rl("ioviewer-row ioviewer-view",w);if(R.addEventListener("click",()=>d(A)),b.append(R),A.missingComponents||A.ambiguousComponents){let D=Z("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));b.append(et("p","ioviewer-bcf-status",D))}}),S.append(b)}T.append(S)}})}function bp(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):Xy(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function Xy(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 qy=["New","Active","Reviewed","Approved","Resolved"],Vh=27,Yy=8,$y=14,Zy=2,Jy=new P(1,-1,.8).normalize();function Sp({shell:i,tests:t,elements:e,scene:n,controls:s,selection:r}){let o=new Re;o.name="clash-marker";let a=new fe;a.setAttribute("position",new Ae(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new Sn(a,new zn({...l,size:$y,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(M,T){let S=bp(M,e);S.length?r.set(S):r.clear();let v=new P(...M.point),b=0;for(let w of S){let R=n.elementBox(w);R.isEmpty()||(b=Math.max(b,...R.getSize(new P).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(Jy);let x=Math.max(3*b,Zy);s.animateTo({position:A.normalize().multiplyScalar(x).add(v),target:v}),a.attributes.position.setXYZ(0,v.x,v.y,v.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=T,d=M,T.setAttribute("aria-current","true"),s.setExtraBounds("clash",new ae(v.clone(),v.clone()))}function m(M){let T=Rl("ioviewer-row ioviewer-clash",String(M.name??""));T.setAttribute("title",`${M.name??""}: ${M.element1Name??""} \u2014 ${M.element2Name??""}`);let S=qy.includes(M.status),v=et("span","ioviewer-clash-status",S?Z(`clash.${M.status}`):String(M.status??""));S&&(v.dataset.status=M.status);let b=typeof M.distance=="number"?zh(M.distance):"";return T.append(v,et("span","ioviewer-clash-distance",b)),M===d&&(h=T,T.setAttribute("aria-current","true")),T.addEventListener("click",()=>f(M,T)),T}function _(M,T){let S=et("div","ioviewer-clash-test"),v=et("button","ioviewer-row ioviewer-clash-header");v.type="button",v.setAttribute("aria-expanded","true");let b=`${M.name??""} (${M.clashes.length})`;v.setAttribute("title",b),v.insertAdjacentHTML("afterbegin",re.chevron),v.append(et("span","ioviewer-row-name",b));let A=et("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,M.clashes.length*Vh-1)}px`,v.addEventListener("click",()=>{A.hidden=!A.hidden,v.setAttribute("aria-expanded",String(!A.hidden)),T()}),S.append(v,A),{box:S,list:A,clashes:M.clashes,rows:new Map}}function g({list:M,clashes:T,rows:S},{start:v,end:b}){for(let[x,w]of S)(x=b)&&(w.remove(),S.delete(x));let A=null;for(let x=b-1;x>=v;x--){let w=S.get(x);w||(w=m(T[x]),w.style.top=`${x*Vh}px`,M.insertBefore(w,A),S.set(x,w)),A=w}}function p(M){if(!t.length)return;M.classList.add("ioviewer-clashes-body");let T=t.map(v=>_(v,S));for(let v of T)M.append(v.box);function S(){let v=M.scrollTop,b=M.clientHeight,A=T.map(({list:x,clashes:w})=>b&&!x.hidden?Ih(v-x.offsetTop,Vh,b,w.length,Yy):{start:0,end:0});T.forEach((x,w)=>g(x,A[w]))}M.addEventListener("scroll",S),M.addEventListener("focusin",S),new ResizeObserver(S).observe(M)}return i.registerPanel("clashes",{icon:re.clashes,title:Z("panel.clashes"),visible:t.length>0,render:p,onClose:()=>o.visible&&u()}),{group:o}}var Ky=["construct","demolish","temporary"],jy=Date.parse("0002-01-01T00:00:00Z");function wp(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=jy?t:NaN}function Ep(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=wp(o?.start),l=wp(o?.end);if(!(a<=l))continue;let c=Ky.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 Tp(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 Qy=864e5,tM=["1","5","15"],eM={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function Ap({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=Ep(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:re.timeliner,title:Z("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,_=et("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",Z("player.title")),_.hidden=!0;let g=Qe("ioviewer-icon-button ioviewer-player-play",re.play,Z("player.play"));g.addEventListener("click",()=>h?N():D());let p=et("output","ioviewer-player-date"),M=et("input","ioviewer-player-slider");Object.assign(M,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),M.setAttribute("aria-label",Z("player.date")),M.addEventListener("input",()=>A(Number(M.value)));let T=Xr(Z("player.speed"),tM.map(L=>[L,`${L}\xD7`]),L=>{c=Number(L),T.update(L)});T.update(String(c));let S=Qe("ioviewer-panel-close",re.close,Z("close"));S.addEventListener("click",w),_.append(g,p,M,T.element,S),i.append(_),new ResizeObserver(()=>{let L=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${L}px`)}).observe(_);function b(){let L=Tp(r.tasks,l),U=[...f].filter(F=>!L.hidden.has(F)),W=[...L.hidden].filter(F=>!f.has(F));f=L.hidden;let V=[...m.keys()].filter(F=>L.active.get(F)!==m.get(F)),O=new Map;for(let[F,G]of L.active)m.get(F)!==G&&(O.has(G)||O.set(G,[]),O.get(G).push(F));m=L.active,U.length&&s.setLayerHidden("schedule",U,!1),W.length&&s.setLayerHidden("schedule",W,!0),V.length&&s.setTint(V,null);for(let[F,G]of O)s.setTint(G,eM[F])}function A(L){l=Math.min(Math.max(L,r.start),r.end),M.value=String(l),p.textContent=a.format(l),u&&b()}function x(){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(L){A(l+Math.max(L-d,0)/1e3*c*Qy),d=L,l>=r.end?N():h=requestAnimationFrame(R)}function D(){x(),!h&&(l>=r.end&&A(r.start),d=performance.now(),h=requestAnimationFrame(R),B())}function N(){cancelAnimationFrame(h),h=0,B()}function B(){let L=Z(h?"player.pause":"player.play");g.innerHTML=h?re.pause:re.play,g.title=L,g.setAttribute("aria-label",L)}return t.registerPanel("timeliner",{icon:re.timeliner,title:Z("panel.timeliner"),render:L=>{let U=et("button","ioviewer-text-button ioviewer-player-open");U.type="button",U.insertAdjacentHTML("afterbegin",re.play),U.append(et("span","",Z("player.play"))),U.addEventListener("click",D);let W=et("div","ioviewer-row-list");for(let V of r.tasks){let O=String(V.name??""),F=et("div","ioviewer-row ioviewer-task");F.dataset.type=V.type,F.setAttribute("title",`${O} \xB7 ${Z(`task.${V.type}`)}`);let G=`${o.format(V.start)} \u2013 ${o.format(V.end)}`;F.append(et("span","ioviewer-row-name",O),et("span","ioviewer-task-dates",G)),W.append(F)}L.append(U,W)}}),{open:x,close:w,play:D,pause:N,setDate:A,get date(){return l},get isOpen(){return u}}}function Rp({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:re.links,title:Z("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 Cp(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 Ip(i,t){return!i||t>=i.min&&t<=i.max}function Pp(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 Lp(){let i=new fn,t=new Le(72,1,.15,20);t.up.set(0,0,1);let e=new P,n=new Ue({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 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 me(new cn(1,1),new Je({color:Hy,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(d=>d.clone().negate()):o,c=d=>Math.abs(d.distanceToPoint(s.center)){if(!c(f))return;let _=d?-f.normal.dot(d):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 m of this._stencils)r.withMaterial(m,()=>t.render(r.root,n),{section:!0});this._surface.quaternion.setFromUnitVectors(ky,f.normal);let p=Sl(s.modelBox,this._surface.quaternion,f.coplanarPoint(new R));this._surface.position.copy(p.center),this._surface.scale.set(p.width,p.height,1),h.clippingPlanes=l.filter((m,b)=>b!==g),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=u}}};function Yr(i,t,e){let n=nt("div","ioviewer-segmented");n.setAttribute("role","group"),n.setAttribute("aria-label",i);let s=t.map(([o,a])=>{let l=nt("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=nt("label","ioviewer-check"),n=nt("input");return n.type="checkbox",n.addEventListener("change",()=>t(n.checked)),e.append(n,nt("span","",i)),{element:e,input:n}}function Wy(i,t){let e=nt("li","ioviewer-section-plane");e.addEventListener("pointerdown",()=>i.active!==t&&i.setActivePlane(t));let n=nt("span","ioviewer-section-name"),s=tn("ioviewer-icon-button",re.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",re.remove,$("sections.delete"));o.addEventListener("click",()=>i.removePlane(t));let a=nt("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=nt("div","ioviewer-section-head");return l.append(n,s,r.element,o),e.append(l,a),{element:e,update:()=>{let h=i.planes[t],u=h.rotated?` (${$("sections.rotated")})`:"",d=h.axis==="custom"?$("sections.custom"):h.axis.toUpperCase();n.textContent=`${t+1}. ${d}${u}`,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 Sp({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()],u=()=>s.fitBoxToElements(h()),d=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=nt("button","ioviewer-text-button",$("sections.addPlane"));g.type="button",g.addEventListener("click",c);let _=nt("ul","ioviewer-section-list"),p=nt("div","ioviewer-section-empty",$("sections.noPlanes")),m=nt("div","ioviewer-section-block"),b=nt("div","ioviewer-section-row");b.append(nt("span","",$("sections.axis")),f.element,g),m.append(b,_,p);let w=Yr($("sections.box"),[["keepInside",$("sections.keepInside")],["cutInside",$("sections.cutInside")]],F=>s.setBoxMode(F)),S=nt("button","ioviewer-text-button",$("sections.fitSelection"));S.type="button",S.addEventListener("click",u);let v=nt("input","ioviewer-section-slider");Object.assign(v,{type:"range",min:"-180",max:"180",step:"1"}),v.addEventListener("input",()=>s.setBoxYaw(Number(v.value)*Math.PI/180));let y=nt("span");y.setAttribute("aria-hidden","true");let A=nt("label","ioviewer-section-row");A.append(nt("span","",$("sections.boxYaw")),v,y);let x=nt("div","ioviewer-section-block");x.append(w.element,A,S);let E=Yh($("sections.showGizmo"),F=>s.setGizmoVisible(F)),I=Yh($("sections.fill"),F=>s.setFill(F));o||(I.element.title=$(a?"sections.fillUnavailable":"sections.fillNeedsMeshes"));let D=[],N=()=>{d.update(s.mode),m.hidden=s.mode!=="planes",x.hidden=s.mode!=="box",g.disabled=s.planes.length>=qr,D.length!==s.planes.length&&(D=s.planes.map((k,W)=>Wy(s,W)),_.replaceChildren(...D.map(k=>k.element))),D.forEach(k=>k.update()),p.hidden=D.length>0,w.update(s.boxMode),v.value=String(Math.round(s.boxYaw*180/Math.PI)),y.textContent=`${v.value}\xB0`,v.setAttribute("aria-valuetext",y.textContent),E.input.checked=s.gizmoVisible,I.input.checked=s.fill;let F=s.mode==="box"||s.mode==="planes"&&s.planes.some(k=>k.enabled);I.input.disabled=!o||!F,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},B=()=>S.disabled=r.size===0;if(t.registerPanel("sections",{icon:re.sections,title:$("panel.sections"),visible:!s.modelBox.isEmpty(),render:F=>F.append(d.element,m,x,I.element,E.element)}),s.addEventListener("change",N),r.addEventListener("change",B),N(),B(),s.modelBox.isEmpty())return;let L=()=>t.openPanel("sections");e.setHandler("plane",()=>{c(),L()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&u()||s.fitBoxToShown())&&L()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:F=>{s.fitBoxToElements(r.has(F)?h():[F]),L()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var Xy="#facc15",qy=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 _e(new Float32Array(6),3));let n={color:Xy,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Oi(e,new sn(n)),this._markers=new wn(e,new Hn({...n,size:qy,sizeAttenuation:!1}));for(let s of[this._line,this._markers])s.frustumCulled=!1,s.renderOrder=1001,this.group.add(s);this.label=nt("div","ioviewer-measure-label"),this.label.hidden=!0,this._previewMarker=nt("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,Yy=1-1e-6,$y=8,wp={vertex:0,midpoint:1,edge:2},Zy=2e4;function Ky(i,t){let e=new Map,n=new Uint32Array(i.length/3);for(let u=0;u0&&(_.normalize(),l(d,f,_),l(f,g,_),l(g,d,_))}let c=[],h=new Set;for(let{lo:u,hi:d,count:f,crease:g}of s.values())f!==1&&!g||(c.push(u,d),h.add(u),h.add(d));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 Ep(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),u=c.distanceToPoint(t);return(h<0||u<0)&&Il(a,-h,-u)}))return[o];let l=[];return o[0]0))return null;let p=oe.clamp(((r-c)*f+(o-h)*g)/_,0,1);return e+(n-e)*(p*a.w/((1-p)*l.w+p*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;c$y&&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(),u=new Yt().multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),d=a.matrixWorldInverse.elements,f=null;function g(v,y,A,x){if(f&&wp[v]>wp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[E,I]=Ws(A,s);if(!(E>=0&&I>=0&&E$r**2||f?.kind===v&&D>=f.distance||v!=="edge"&&Ml(y,c,h))return;let N=-(d[2]*y.x+d[6]*y.y+d[10]*y.z+d[14]);N-n.depthAt(E,I,x)>2*Cn+Math.abs(N)*2**-21||(f={kind:v,distance:D,point:y.clone()})}let _=Zy*3,p=new Yt,m=new R,b=new xe,{geometry:w,matrix:S}=this.data.meta.instances;for(let v of n.slots){let y=l.slotInstance(v),[A]=this.data.readView({t:"u32",o:w.o+y*4,n:1}),x=this.data.meta.geometries[A],E=Math.max(x.indices.n,x.positions.n/3);if(E>_)continue;_-=E;let{positions:I,vertices:D,edges:N}=this._geometry(A),B=this.data.readView({t:"f32",o:S.o+y*48,n:12});p.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 L=new Map;for(let F of D){let k=new R().fromArray(I,F*3).applyMatrix4(p),W=new xe(k.x,k.y,k.z,1).applyMatrix4(u);L.set(F,[k,W]),g("vertex",k,W,v)}if(f?.kind!=="vertex")for(let F=0;F_)continue;_-=I;let{positions:D,vertices:N,edges:B}=this._geometry(x),L=this.data.readView({t:"f32",o:y.o+A*48,n:12});p.set(L[0],L[3],L[6],L[9],L[1],L[4],L[7],L[10],L[2],L[5],L[8],L[11],0,0,0,1);let F=new Map;for(let k of N){let W=new R().fromArray(D,k*3).applyMatrix4(p),O=new xe(W.x,W.y,W.z,1).applyMatrix4(u);if(F.set(k,[W,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&&V.z>=-V.w&&V.z<=V.w){let[Z,K]=Ws(V,s),lt=(Z-r)**2+(K-o)**2;lt<=$r**2&&(!f||f.kind!=="midpoint"||ltr.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 Jy=8,Ap=4;function Zh(i,t,e,n="dialog"){let s=nt("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(Ap,Math.min(l.left+l.width/2-c/2,innerWidth-c-Ap))}px`,s.style.bottom=`${innerHeight-l.top+Jy}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 jy(i){return i?.initialWireframe?"wireframe":i?.initialWhiteMode?"white":"materials"}function Rp({root:i,toolbar:t,scene:e,meta:n,grids:s,initialBackground:r,setBackground:o,hasMeshes:a=!0}){let l=D=>t.element.querySelector(`[data-tool="${D}"]`),c=l("displayMode"),h=Zh(i,c,$("group.display"));h.element.classList.add("ioviewer-display-modes");let u=nt("div");u.setAttribute("role","menu"),u.setAttribute("aria-label",$("tool.displayMode")),h.element.append(u);let d=(n.textures??[]).length>0,f=Ih.map(D=>{let N=nt("button","ioviewer-menu-item",$(`display.${D}`));return N.type="button",N.dataset.mode=D,N.setAttribute("role","menuitemradio"),N.disabled=D==="textures"&&!d||D==="wireframe"&&!a,N.addEventListener("click",()=>{g(D),h.close(),c.focus()}),u.append(N),N}),g=D=>{e.setDisplayMode(D);for(let N of f)N.setAttribute("aria-checked",String(N.dataset.mode===D))},_=jy(n.options);g(_==="wireframe"&&!a?"materials":_),t.setHandler("displayMode",()=>{h.toggle(),h.isOpen&&u.querySelector('[aria-checked="true"]')?.focus()});let p=nt("div","ioviewer-background-setting"),m=nt("label","",$("display.background")),b=nt("input");Object.assign(b,{type:"color",value:r}),m.append(b);let w=nt("button","ioviewer-text-button",$("display.backgroundReset"));w.type="button",w.disabled=!0;let S=()=>{o(b.value),w.disabled=b.value===r};b.addEventListener("input",S),w.addEventListener("click",()=>{b.value=r,b.focus(),S()});let v=nt("div","ioviewer-bg-presets");for(let[D,N]of[["#14171c","display.bgCadDark"],["#ffffff","display.bgPaper"]]){let B=nt("button","ioviewer-text-button",$(N));B.type="button",B.addEventListener("click",()=>{b.value=D,S()}),v.append(B)}p.append(m,v,w),h.element.append(p),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let y=Zh(i,l("opacity"),$("tool.opacity"));y.element.classList.add("ioviewer-opacity");let A=nt("input","ioviewer-opacity-slider");Object.assign(A,{type:"range",min:"10",max:"100",step:"1",value:"100"}),A.setAttribute("aria-label",$("opacity.label"));let x=nt("output","ioviewer-opacity-value"),E=()=>x.textContent=$("opacity.value").replace("{value}",A.value);A.addEventListener("input",()=>{e.setOpacity(Number(A.value)/100),E()}),E();let I=nt("div","ioviewer-opacity-head");return I.append(nt("span","",$("opacity.label")),x),y.element.append(I,A),t.setHandler("opacity",y.toggle),[h,y]}var Qy=3e3;function Dl(i,t){let e=nt("button",i);return e.type="button",e.setAttribute("title",t),e.append(nt("span","ioviewer-row-name",t)),e}function Cp({shell:i,toolbar:t,controls:e,scene:n,sections:s,selection:r,restoreLinkedModels:o,views:a,bcfTopics:l}){let c=null,h=nt("button","ioviewer-text-button ioviewer-tour");h.type="button";function u(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 S=w.camera.projection==="orthographic";e.setProjection(S?"orthographic":"perspective"),t.setActive("projection",S),e.restoreViewCamera(w.camera)}function d(){u(a[c.next]),c.next=(c.next+1)%a.length;let w=()=>{e.animating?c.frame=requestAnimationFrame(w):c.timer=setTimeout(d,Qy)};c.frame=requestAnimationFrame(w)}let f=w=>h.contains(w.target),g=w=>!f(w)&&p(),_=w=>{f(w)&&(w.key==="Enter"||w.key===" ")||(w.key==="Escape"&&(w.preventDefault(),w.stopPropagation()),p())};function p(){c&&(cancelAnimationFrame(c.frame),clearTimeout(c.timer),c=null,window.removeEventListener("pointerdown",g,!0),window.removeEventListener("wheel",p,!0),window.removeEventListener("keydown",_,!0),b())}function m(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",g,!0),window.addEventListener("wheel",p,!0),window.addEventListener("keydown",_,!0),b(),d()}function b(){let w=$(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?re.pause:re.play),h.append(nt("span","",w)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?p():m()),b(),i.registerPanel("views",{icon:re.views,title:$("panel.views"),visible:a.length>0,render:w=>{let S=nt("div","ioviewer-row-list");for(let v of a){let y=Dl("ioviewer-row ioviewer-view",String(v.name??""));y.addEventListener("click",()=>u(v)),S.append(y)}w.append(h,S)}}),i.registerPanel("bcf",{icon:re.bcf,title:$("panel.bcf"),visible:l.length>0,render:w=>{let S=nt("div","ioviewer-row-list");for(let v of l){let y=nt("details","ioviewer-bcf-topic");y.append(nt("summary","",v.title)),v.status&&y.append(nt("p","ioviewer-bcf-status",v.status)),v.description&&y.append(nt("p","ioviewer-bcf-description",v.description)),v.viewpoints.length||y.append(nt("p","ioviewer-bcf-status",$("bcf.noView"))),v.viewpoints.forEach((A,x)=>{let E=$("bcf.viewpoint").replace("{index}",String(x+1)),I=Dl("ioviewer-row ioviewer-view",E);if(I.addEventListener("click",()=>u(A)),y.append(I),A.missingComponents||A.ambiguousComponents){let D=$("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));y.append(nt("p","ioviewer-bcf-status",D))}}),S.append(y)}w.append(S)}})}function Ip(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):tM(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function tM(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 eM=["New","Active","Reviewed","Approved","Resolved"],Kh=27,nM=8,iM=14,sM=2,rM=new R(1,-1,.8).normalize();function Pp({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 _e(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new wn(a,new Hn({...l,size:iM,sizeAttenuation:!1}));c.frustumCulled=!1,c.renderOrder=1002,o.add(c),o.visible=!1;let h=null,u=null;function d(){o.visible=!1,h?.removeAttribute("aria-current"),h=null,u=null,s.setExtraBounds("clash",null)}function f(b,w){let S=Ip(b,e);S.length?r.set(S):r.clear();let v=new R(...b.point),y=0;for(let E of S){let I=n.elementBox(E);I.isEmpty()||(y=Math.max(y,...I.getSize(new R).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(rM);let x=Math.max(3*y,sM);s.animateTo({position:A.normalize().multiplyScalar(x).add(v),target:v}),a.attributes.position.setXYZ(0,v.x,v.y,v.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=w,u=b,w.setAttribute("aria-current","true"),s.setExtraBounds("clash",new se(v.clone(),v.clone()))}function g(b){let w=Dl("ioviewer-row ioviewer-clash",String(b.name??""));w.setAttribute("title",`${b.name??""}: ${b.element1Name??""} \u2014 ${b.element2Name??""}`);let S=eM.includes(b.status),v=nt("span","ioviewer-clash-status",S?$(`clash.${b.status}`):String(b.status??""));S&&(v.dataset.status=b.status);let y=typeof b.distance=="number"?$h(b.distance):"";return w.append(v,nt("span","ioviewer-clash-distance",y)),b===u&&(h=w,w.setAttribute("aria-current","true")),w.addEventListener("click",()=>f(b,w)),w}function _(b,w){let S=nt("div","ioviewer-clash-test"),v=nt("button","ioviewer-row ioviewer-clash-header");v.type="button",v.setAttribute("aria-expanded","true");let y=`${b.name??""} (${b.clashes.length})`;v.setAttribute("title",y),v.insertAdjacentHTML("afterbegin",re.chevron),v.append(nt("span","ioviewer-row-name",y));let A=nt("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,b.clashes.length*Kh-1)}px`,v.addEventListener("click",()=>{A.hidden=!A.hidden,v.setAttribute("aria-expanded",String(!A.hidden)),w()}),S.append(v,A),{box:S,list:A,clashes:b.clashes,rows:new Map}}function p({list:b,clashes:w,rows:S},{start:v,end:y}){for(let[x,E]of S)(x=y)&&(E.remove(),S.delete(x));let A=null;for(let x=y-1;x>=v;x--){let E=S.get(x);E||(E=g(w[x]),E.style.top=`${x*Kh}px`,b.insertBefore(E,A),S.set(x,E)),A=E}}function m(b){if(!t.length)return;b.classList.add("ioviewer-clashes-body");let w=t.map(v=>_(v,S));for(let v of w)b.append(v.box);function S(){let v=b.scrollTop,y=b.clientHeight,A=w.map(({list:x,clashes:E})=>y&&!x.hidden?zh(v-x.offsetTop,Kh,y,E.length,nM):{start:0,end:0});w.forEach((x,E)=>p(x,A[E]))}b.addEventListener("scroll",S),b.addEventListener("focusin",S),new ResizeObserver(S).observe(b)}return i.registerPanel("clashes",{icon:re.clashes,title:$("panel.clashes"),visible:t.length>0,render:m,onClose:()=>o.visible&&d()}),{group:o}}var oM=["construct","demolish","temporary"],aM=Date.parse("0002-01-01T00:00:00Z");function Lp(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=aM?t:NaN}function Dp(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=Lp(o?.start),l=Lp(o?.end);if(!(a<=l))continue;let c=oM.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(u=>e.get(String(u))).filter(u=>u!==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 Np(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 lM=864e5,cM=["1","5","15"],hM={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function Up({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=Dp(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:re.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,u=0,d=!1,f=new Set,g=new Map,_=nt("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",$("player.title")),_.hidden=!0;let p=tn("ioviewer-icon-button ioviewer-player-play",re.play,$("player.play"));p.addEventListener("click",()=>h?N():D());let m=nt("output","ioviewer-player-date"),b=nt("input","ioviewer-player-slider");Object.assign(b,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),b.setAttribute("aria-label",$("player.date")),b.addEventListener("input",()=>A(Number(b.value)));let w=Yr($("player.speed"),cM.map(L=>[L,`${L}\xD7`]),L=>{c=Number(L),w.update(L)});w.update(String(c));let S=tn("ioviewer-panel-close",re.close,$("close"));S.addEventListener("click",E),_.append(p,m,b,w.element,S),i.append(_),new ResizeObserver(()=>{let L=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${L}px`)}).observe(_);function y(){let L=Np(r.tasks,l),F=[...f].filter(U=>!L.hidden.has(U)),k=[...L.hidden].filter(U=>!f.has(U));f=L.hidden;let W=[...g.keys()].filter(U=>L.active.get(U)!==g.get(U)),O=new Map;for(let[U,z]of L.active)g.get(U)!==z&&(O.has(z)||O.set(z,[]),O.get(z).push(U));g=L.active,F.length&&s.setLayerHidden("schedule",F,!1),k.length&&s.setLayerHidden("schedule",k,!0),W.length&&s.setTint(W,null);for(let[U,z]of O)s.setTint(z,hM[U])}function A(L){l=Math.min(Math.max(L,r.start),r.end),b.value=String(l),m.textContent=a.format(l),d&&y()}function x(){d||(d=!0,_.hidden=!1,A(r.start))}function E(){d&&(N(),d=!1,s.setTint([...g.keys()],null),g=new Map,f=new Set,s.clearLayer("schedule"),_.hidden=!0)}function I(L){A(l+Math.max(L-u,0)/1e3*c*lM),u=L,l>=r.end?N():h=requestAnimationFrame(I)}function D(){x(),!h&&(l>=r.end&&A(r.start),u=performance.now(),h=requestAnimationFrame(I),B())}function N(){cancelAnimationFrame(h),h=0,B()}function B(){let L=$(h?"player.pause":"player.play");p.innerHTML=h?re.pause:re.play,p.title=L,p.setAttribute("aria-label",L)}return t.registerPanel("timeliner",{icon:re.timeliner,title:$("panel.timeliner"),render:L=>{let F=nt("button","ioviewer-text-button ioviewer-player-open");F.type="button",F.insertAdjacentHTML("afterbegin",re.play),F.append(nt("span","",$("player.play"))),F.addEventListener("click",D);let k=nt("div","ioviewer-row-list");for(let W of r.tasks){let O=String(W.name??""),U=nt("div","ioviewer-row ioviewer-task");U.dataset.type=W.type,U.setAttribute("title",`${O} \xB7 ${$(`task.${W.type}`)}`);let z=`${o.format(W.start)} \u2013 ${o.format(W.end)}`;U.append(nt("span","ioviewer-row-name",O),nt("span","ioviewer-task-dates",z)),k.append(U)}L.append(F,k)}}),{open:x,close:E,play:D,pause:N,setDate:A,get date(){return l},get isOpen(){return d}}}function Fp({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:nt("input")})),r=()=>n.replaceLayerHidden("links",s.flatMap(({input:o,members:a})=>o.checked?[]:a));return i.registerPanel("links",{icon:re.links,title:$("panel.links"),visible:s.length>0,render:o=>{let a=nt("div","ioviewer-row-list");for(let l of s){let c=String(l.file.name??""),h=nt("label","ioviewer-row ioviewer-check ioviewer-link");h.setAttribute("title",`${c} (${l.file.path??""})`);let{input:u}=l;u.type="checkbox",u.checked=l.members.length===0||l.file.visible!==!1,u.disabled=l.members.length===0,u.addEventListener("change",r),h.append(u,nt("span","ioviewer-row-name",c),nt("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 Bp(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 Op(i,t){return!i||t>=i.min&&t<=i.max}function zp(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 kp(){let i=new pn,t=new Ue(72,1,.15,20);t.up.set(0,0,1);let e=new R,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 Ne(1,1,{depthTexture:new kn(1,1)}),r=new Gt,o=new fn,a=new ki,l=new Ue({depthTest:!1,depthWrite:!1,uniforms:{levels:{value:s.texture},depth:{value:s.depthTexture},sampleStep:{value:new Gt},range:{value:new Gt}},vertexShader:["varying vec2 uvScreen;","void main() { uvScreen = uv; gl_Position = vec4(position, 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(` `),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 pe(new ln(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 Sn(m.geometry,n);_.matrixAutoUpdate=!1,_.matrix.copy(m.matrixWorld),i.add(_)}t.position.copy(d);let u=new ae().setFromObject(i),f=u.getSize(e).length();t.far=Math.max(20,f+d.distanceTo(u.getCenter(e)))},draw(h,d,u){t.aspect=d.aspect,t.fov=d.fov,t.updateProjectionMatrix(),t.lookAt(e.copy(t.position).add(u));let f=h.getPixelRatio();n.uniforms.size.value=5.5*f,h.getDrawingBufferSize(r),s.setSize(r.x,r.y),l.uniforms.sampleStep.value.set(2*f/r.x,2*f/r.y),l.uniforms.range.value.set(t.near,t.far),h.setRenderTarget(s),h.render(i,t),h.setRenderTarget(null),h.render(o,a)}}}var nM=new Intl.NumberFormat(ai,{maximumFractionDigits:2,minimumFractionDigits:2}),Cl=i=>`${nM.format(i)} ${Z("scanMap.metres")}`;function $n(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 iM(i,t){return[i*.005,t*.005]}function sM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function rM(i,t,e,n,s,r,o){let a=new Gn;a.setFromCamera(new Gt(n,s),i),a.ray.origin.copy(t),a.near=.05,a.params.Points.threshold=.12;let l=new P,c=new P;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 Dp(i,t,e,n,s,r){if(!e.count)return;let o=new ae().setFromObject(e.root);if(o.isEmpty())return;let a=o.getSize(new P),l=o.getCenter(new P),c={x:l.x,y:l.y,side:Math.max(a.x,a.y,.01)*1.12,zoom:1},h={...c},d=I=>50+100*(I-h.x)*h.zoom/h.side,u=I=>50-100*(I-h.y)*h.zoom/h.side,f=I=>Math.min(96,Math.max(4,I)),m=(I,ut,Et=!1)=>{let C=d(ut.x),y=u(ut.y);return I.style.left=`${Et?f(C):C}%`,I.style.top=`${Et?f(y):y}%`,C>=0&&C<=100&&y>=0&&y<=100},_=t.meta.rtcOffset?.[2]??0,g=t.meta.panoramas??[],p=g.map(I=>new P(...I.position)),M=`ioviewer.scan-levels.v1:${location.pathname}`,T=()=>Cp(p.map(I=>I.z+_),o.min.z+_,o.max.z+_),S=null;try{let I=JSON.parse(localStorage.getItem(M));Array.isArray(I)&&(S=I.filter(ut=>Number.isFinite(ut?.min)&&Number.isFinite(ut.max)&&ut.max>ut.min))}catch{S=null}let v=S??T(),b=-1,A=!0,x=I=>Ip(v[b],I+_),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=Z("scanMap.title");let D=document.createElement("div");D.className="scan-map-plot";let N=document.createElement("canvas");N.width=N.height=300,N.setAttribute("role","img"),N.setAttribute("aria-label",Z("scanMap.plan")),N.tabIndex=0;let B=document.createElement("span");B.className="scan-map-camera",B.setAttribute("aria-hidden","true");let L=document.createElement("span");L.className="scan-map-axes",L.textContent="Y \u2191";let U=document.createElement("span");U.className="scan-map-scale",D.append(N,B,L,U),w.append(R,D),i.append(w);let W=e.root.children.reduce((I,ut)=>I+ut.geometry.attributes.position.count,0),V=Math.max(1,Math.ceil(W/6e4)),O=e.root.children.map(I=>{let ut=I.geometry.attributes.position,Et=new Float32Array(Math.ceil(ut.count/V)*3),C=new P;for(let y=0,q=0;y{if(F=0,!w.open)return;let I=N.getContext("2d");if(!I)return;I.clearRect(0,0,300,300),I.fillStyle="rgba(160, 185, 201, .33)";for(let[C,y]of O.entries())if(e.root.children[C].visible)for(let q=0;q{F||(F=requestAnimationFrame(G))},z=new P,$=null,nt=()=>{if($){B.hidden=!x($.position.z),m(B,$.position,!0),B.style.rotate=`${Math.PI/2-$.yaw}rad`;return}B.hidden=!1,m(B,s.camera.position,!0),s.camera.getWorldDirection(z),B.style.rotate=`${Math.atan2(z.x,z.y)}rad`};w.addEventListener("toggle",Y),n.root.addEventListener("change",I=>{I.detail.kind==="visibility"&&Y()}),s.addEventListener("change",nt);let lt=document.createElement("div");lt.className="scan-map-controls";let at=document.createElement("select");at.setAttribute("aria-label",Z("scanMap.size"));for(let I of["small","medium","large"])at.add(new Option(Z(`scanMap.${I}`),I));at.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=at.value,at.addEventListener("change",()=>{i.dataset.scanMapSize=at.value});let X=(I,ut=0,Et=0)=>{h=Pp(h,I,ut,Et),Y()},tt=()=>{h={...c},Y()};lt.append(at,$n(Z("scanMap.zoomOut"),"\u2212",()=>X(.8)),$n(Z("scanMap.zoomIn"),"+",()=>X(1.25)),$n(Z("scanMap.reset"),"\u21BA",tt)),w.insertBefore(lt,D),N.addEventListener("wheel",I=>{I.preventDefault();let ut=N.getBoundingClientRect();X(I.deltaY<0?1.15:1/1.15,(I.clientX-ut.left)/ut.width-.5,(I.clientY-ut.top)/ut.height-.5)},{passive:!1});let ht;N.addEventListener("pointerdown",I=>{I.button!==0||ht||(N.setPointerCapture(I.pointerId),ht={id:I.pointerId,x:I.clientX,y:I.clientY})}),N.addEventListener("pointermove",I=>{if(ht?.id!==I.pointerId)return;let ut=h.side/(h.zoom*Math.max(1,N.clientWidth));h.x-=(I.clientX-ht.x)*ut,h.y+=(I.clientY-ht.y)*ut,ht.x=I.clientX,ht.y=I.clientY,Y()}),N.addEventListener("lostpointercapture",I=>{I.pointerId===ht?.id&&(ht=void 0)}),N.addEventListener("keydown",I=>{let ut={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[I.key];if(ut){let Et=h.side/h.zoom/10;h.x+=ut[0]*Et,h.y+=ut[1]*Et,Y()}else if(I.key==="+"||I.key==="="||I.key==="-")X(I.key==="-"?.8:1.25);else if(I.key==="0")tt();else return;I.preventDefault(),I.stopPropagation()});let Rt=document.createElement("div");Rt.className="scan-map-controls";let ft=document.createElement("select");ft.setAttribute("aria-label",Z("scanMap.levels"));let Ot=document.createElement("p");Ot.className="scan-map-feedback",Ot.setAttribute("role","status");function Ct(){try{localStorage.setItem(M,JSON.stringify(v))}catch{Ot.textContent=Z("scanMap.levelTemporary")}}function It(){ft.replaceChildren(new Option(Z("scanMap.allLevels"),"-1")),v.forEach((I,ut)=>ft.add(new Option(`${Z("scanMap.level").replace("{n}",ut+1)} \xB7 ${Cl(I.min)} \u2013 ${Cl(I.max)}`,String(ut)))),ft.value=String(b),qt.disabled=b<0;for(let[I,ut]of p.entries())ie.options[I+1].hidden=!x(ut.z);Y(),r()}ft.addEventListener("change",()=>{b=Number(ft.value),Ot.textContent="",It()});let Xt=$n(Z("scanMap.addLevel"),"+",()=>{if(Qt.isClosed()){let I=p.findIndex(ut=>x(ut.z));zt(Math.max(0,I))}Qt.pickLevel()});Xt.disabled=!g.length;let $t=$n(Z("scanMap.autoLevels"),Z("scanMap.autoButton"),()=>{let I=T(),ut=I.filter(Et=>!v.some(C=>C.min{b<0||(v.splice(b,1),b=-1,Ot.textContent="",Ct(),It())});if(Rt.append(ft,Xt,$t,qt),g.length){let I=$n(Z("scanMap.spheres"),"\u25C9",()=>{A=!A,I.setAttribute("aria-pressed",String(A)),r()});I.setAttribute("aria-pressed","true"),Rt.append(I)}w.append(Rt,Ot);let Qt=g.length?oM(i,t,e,zt,I=>{$=I,I||dt.forEach(ut=>ut.classList.remove("current")),nt()},I=>{b=v.push(I)-1,Ot.textContent=Z("scanMap.levelAdded"),Ct(),It()}):null,ie=document.createElement("select");ie.setAttribute("aria-label",Z("scanMap.choosePhoto"));let ge=new Option(Z("scanMap.choosePhoto"),"");ge.disabled=!0,ie.add(ge);let dt=[];for(let[I,ut]of g.entries()){let Et=ut.name||t.meta.elements[ut.element].name||String(I+1);ie.add(new Option(Et,String(I)));let C=document.createElement("button");C.type="button",C.className="scan-map-station",C.title=Et,C.setAttribute("aria-label",`${Z("scanMap.photo")} \xB7 ${Et}`),C.addEventListener("click",()=>zt(I)),dt.push(C),D.append(C)}ie.value="",ie.addEventListener("change",()=>zt(Number(ie.value))),ie.hidden=!g.length,w.append(ie),It(),!S&&v.length&&Ct();function zt(I,ut=!1){w.open=!0,ie.value=String(I),dt.forEach((Et,C)=>Et.classList.toggle("current",I===C)),Qt.open(I,ut),ie.value=""}return{open:zt,showSphere:(I,ut)=>A&&x(ut)&&n.isVisible(I)}}function oM(i,t,e,n,s,r){let o=document.createElement("section");o.className="ioviewer-floating scan-photo",o.setAttribute("aria-label",Z("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=$n(Z("scanMap.enlargePhoto"),Z("scanMap.enlargePhoto"),()=>{let dt=o.classList.toggle("is-expanded"),zt=Z(dt?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=zt,h.setAttribute("aria-label",zt),h.setAttribute("aria-pressed",String(dt))});h.setAttribute("aria-pressed","false");let d=document.createElement("button");d.type="button",d.textContent=Z("close"),d.addEventListener("click",It);let u=!1,f=$n(Z("scanMap.intensity"),Z("scanMap.intensity"),()=>{u=!u,ge(!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",Z("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 M=document.createElement("div");M.className="scan-photo-level",M.hidden=!0;let T=document.createElement("span");T.setAttribute("role","status"),M.append(T,$n(Z("scanMap.cancel"),Z("scanMap.cancel"),$t)),g.append(m,p,_),o.append(a,M,g),i.append(o);let S=t.meta.panoramas.map((dt,zt)=>{let I=dt.name||t.meta.elements[dt.element].name||String(zt+1),ut=document.createElement("button");return ut.className="scan-photo-link",ut.type="button",ut.title=I,ut.setAttribute("aria-label",Z("scanMap.goToStation").replace("{name}",I)),ut.hidden=!0,ut.addEventListener("click",()=>n(zt,!0)),g.append(ut),{photo:dt,name:I,button:ut,position:new P(...dt.position)}}),v=t.readView(t.meta.points.element),b=new Gn;b.params.Points.threshold=.12,b.near=.25;let A=new P,x=new P,w=new P,R=[],D=[],N=!1,B,L=t.meta.rtcOffset?.[2]??0,U,W,V,O=0,F=!1,G=!1,Y=0,z=0,$=null,nt,lt,at=new fn,X=new Le(72,1,.1,20);X.up.set(0,0,1);let tt=new Hn(10,56,28);tt.rotateX(Math.PI/2);let ht=new Ke({side:Be}),Rt=new pe(tt,ht);at.add(Rt);let ft=()=>{if(!(o.hidden||!W&&!G)){U.setSize(m.clientWidth,m.clientHeight,!1),X.aspect=m.clientWidth/Math.max(1,m.clientHeight),X.updateProjectionMatrix(),X.lookAt(sM(A,Y,z)),G?V.draw(U,X,A):U.render(at,X),X.getWorldDirection(A);for(let dt of R){if(N){dt.button.hidden=!0;continue}w.copy(dt.position).sub(nt.position).normalize(),x.copy(w).project(X);let zt=w.dot(A)>0&&Math.abs(x.x)<.92&&Math.abs(x.y)<.88;dt.button.hidden=!zt,zt&&(dt.button.style.left=`${(1+x.x)*50}%`,dt.button.style.top=`${(1-x.y)*50}%`)}s({position:nt.position,yaw:Y})}},Ot=(dt,zt)=>{Y+=dt,z=le.clamp(z+zt,-1.55,1.55),ft()};new ResizeObserver(ft).observe(m),m.addEventListener("pointerdown",dt=>{dt.button!==0||$||(m.setPointerCapture(dt.pointerId),$={id:dt.pointerId,x:dt.clientX,y:dt.clientY,moved:!1})}),m.addEventListener("pointermove",dt=>{$?.id===dt.pointerId&&(N&&!$.moved&&Math.hypot(dt.clientX-$.x,dt.clientY-$.y)<5||($.moved=!0,Ot(...iM(dt.clientX-$.x,dt.clientY-$.y)),$.x=dt.clientX,$.y=dt.clientY))}),m.addEventListener("pointerup",dt=>{if($?.id!==dt.pointerId||$.moved||!N)return;let zt=m.getBoundingClientRect();Qt((dt.clientX-zt.left)*2/zt.width-1,1-(dt.clientY-zt.top)*2/zt.height)}),m.addEventListener("lostpointercapture",dt=>{$?.id===dt.pointerId&&($=null)}),m.addEventListener("keydown",dt=>{if(N&&dt.key==="Enter"){dt.preventDefault(),Qt(0,0);return}let zt={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[dt.key];zt&&(dt.preventDefault(),dt.stopPropagation(),Ot(...zt))}),m.addEventListener("wheel",dt=>{dt.preventDefault(),X.fov=le.clamp(X.fov+Math.sign(dt.deltaY)*5,32,95),ft()},{passive:!1}),o.addEventListener("keydown",dt=>{dt.key==="Escape"&&(N?$t():It()),dt.stopPropagation()});function It(){o.hidden=!0,$t(),O++,$=null,Xt(),s(null),lt?.focus()}function Xt(){G=!1,W?.dispose(),W=void 0,ht.map=null;for(let dt of R)dt.button.hidden=!0;R=[]}function $t(){N=!1,B=void 0,o.classList.remove("is-picking"),M.hidden=!0,ft()}function qt(){N=!0,B=void 0,o.classList.add("is-picking"),T.textContent=Z("scanMap.pickLower"),M.hidden=!1,ft(),(W||G)&&m.focus()}function Qt(dt,zt){if(!W&&!G)return;let I=rM(X,nt.position,D,dt,zt,m.clientWidth,m.clientHeight);if(I===void 0){T.textContent=Z(B===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let ut=I+L;B===void 0?(B=ut,T.textContent=Z("scanMap.pickUpper").replace("{z}",Cl(ut))):ut<=B?T.textContent=Z("scanMap.upperAboveLower").replace("{z}",Cl(B)):(r({min:B,max:ut}),$t())}function ie(dt,zt){let I=o.hidden;if(I&&(lt=document.activeElement),Xt(),nt=S[dt],o.hidden=!1,l.textContent=nt.name,Rt.rotation.z=le.degToRad(nt.photo.yaw),D=e.root.children.filter((ut,Et)=>v[Et]===nt.photo.element),F=D.some(ut=>ut.geometry.getAttribute("intensity")),f.hidden=!F&&!nt.photo.intensity,R=S.filter(ut=>{if(ut===nt)return!1;let Et=w.copy(ut.position).sub(nt.position).length();return Et<=.25?!1:(b.set(nt.position,w.multiplyScalar(1/Et)),b.far=Et-.25,!b.intersectObjects(D,!1).length)}),I||!zt){let ut=R.reduce((Et,C)=>!Et||C.position.distanceToSquared(nt.position){zt===O&&(_.textContent=Z("scanMap.photoError"))},Et;try{if(U??(U=new Ei({canvas:m,antialias:!0})),U.setPixelRatio(Math.min(devicePixelRatio,2)),I&&F){V??(V=Lp()),V.setScan(D,nt.position),G=!0,_.textContent="",m.style.visibility="visible",ft(),dt&&m.focus();return}let C=I?nt.photo.intensity:nt.photo.image;Et=URL.createObjectURL(new Blob([t.readView(C)],{type:"image/jpeg"}))}catch{ut();return}new ur().load(Et,C=>{if(URL.revokeObjectURL(Et),zt!==O||C.image.width!==2*C.image.height){C.dispose(),ut();return}W?.dispose(),W=C,W.colorSpace=Me,ht.map=W,ht.needsUpdate=!0,_.textContent="",m.style.visibility="visible",ft(),dt&&m.focus()},void 0,()=>{URL.revokeObjectURL(Et),ut()})}return{open:ie,pickLevel:qt,isClosed:()=>o.hidden}}var Vs=7;function Np(i){if(!i?.length)return null;let t=i.map(({position:l})=>new P(...l)),e=new cr({color:"#72bfff",depthTest:!1,depthWrite:!1}),n=new _i(new Hn(1,12,8),e,i.length);n.count=0,n.frustumCulled=!1,n.renderOrder=10,n.instanceMatrix.setUsage(Ar);let s=[],r=new Zt,o=new P,a=new Gt;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<-Vs||m>c.width+Vs||_<-Vs||_>c.height+Vs)continue;let g=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,p=Vs*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.depthh.visibleBox(),_=new vl(h,m(),i.meta.sections);d.syncVisibility(h),d.syncAppearance(h);let g=()=>{let{planes:Ct,intersection:It}=_.clipping();d.setClipping(Ct,It)};g();let p=h.slotCount>0,M=p&&t.getContextAttributes()?.stencil===!0,T,S=new bl(_,Zn);n.add(S.group);let v=document.getElementById("ioviewer-ui"),b=new wl(v),A=new Al(v,i.meta.grids??[]);n.add(b.group,A.group);function x(){try{return new zr(i,{...Gh,maxTextureSize:e.capabilities.maxTextureSize})}catch(Ct){if(!(Ct instanceof Or))throw Ct;c=!0,Yr(Z("tooLarge").replace("{count}",Ct.count).replace("{limit}",Ct.limit));let It=$t=>({o:0,n:0,t:$t}),Xt={count:0,geometry:It("u32"),material:It("u32"),element:It("i32"),matrix:It("f32")};return new zr({...i,meta:{...i.meta,instances:Xt}})}}let w=!1;Zn.addEventListener("webglcontextlost",()=>{w=!0,Yr(Z("contextLost"))});let R,D=new Promise(Ct=>R=Ct),N=qr,B=!1;function L(){B||w||(B=!0,u.requested(performance.now()),requestAnimationFrame(()=>{if(B=!1,w)return;let Ct=Zn.getBoundingClientRect();z.camera.updateMatrixWorld(),ft&&f?.update(z.camera,Ct,ft.showSphere),S.update(z.camera),b.update(z.camera,Ct),A.update(z.camera,Ct),u.begin(z.camera,Ct.height,performance.now()),N?.("renderStart"),_.fill&&M?(T??(T=new Sl(h,_,i)),T.render(e,n,z.camera)):e.render(n,z.camera),N&&(N("renderEnd"),N=void 0),u.end(performance.now()),Ot.update(),R()}))}h.root.addEventListener("change",L),_.addEventListener("change",()=>{g(),L()}),S.addEventListener("change",L),b.addEventListener("change",L),b.addEventListener("previewchange",L),A.addEventListener("change",L);let U=new ul(e,h,a,{points:d,pickFloat:Gh.pickFloat}),W=new Tl(U,_,i),V=0,O=null;function F(){cancelAnimationFrame(V),V=0,O=null,b.setPreview(null)}function G(){V=0,O&&b.setPreview(W.target(...O))}function Y(){O&&(b.setPreview(null),cancelAnimationFrame(V),V=requestAnimationFrame(()=>{V=requestAnimationFrame(G)}))}Zn.addEventListener("pointermove",Ct=>{if(!b.active||Ct.buttons)return F();O=[Ct.clientX,Ct.clientY],V||(V=requestAnimationFrame(G))});for(let Ct of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Zn.addEventListener(Ct,F);h.root.addEventListener("change",Ct=>{Ct.detail.kind!=="appearance"&&Y()});let z=new al(a,Zn,{pick:(Ct,It)=>U.pick(Ct,It)?.point??null,visibleBox:m});z.addEventListener("change",()=>{U.camera=z.camera,Y(),L()}),h.root.addEventListener("change",Ct=>{Ct.detail.kind==="appearance"&&d.syncAppearance(h),Ct.detail.kind==="visibility"&&(d.syncVisibility(h),z.invalidateBounds(),z.resize())});let $=new ml;$.addEventListener("change",()=>h.setHighlighted([...$.values()]));let nt=ap({root:v,data:i,scene:h,controls:z,picker:U,selection:$,measure:b});gp({root:v,...nt,sections:_,selection:$,canFill:M,hasMeshes:p});let{meta:lt}=i,at=Rp({...nt,files:lt.linkedFiles??[],elements:lt.elements,scene:h});Mp({...nt,controls:z,scene:h,sections:_,selection:$,restoreLinkedModels:at,views:lt.viewpoints??[],bcfTopics:lt.bcfTopics??[]});let X=Sp({...nt,tests:lt.clashTests??[],elements:lt.elements,scene:h,controls:z,selection:$});n.add(X.group);let tt=Ap({root:v,...nt,timeliner:lt.timeliner,elements:lt.elements,scene:h}),ht=Ct=>{e.setClearColor(r.set(Ct),1);let{r:It,g:Xt,b:$t}=r,Qt=.2126*It+.7152*Xt+.0722*$t>Math.sqrt(.0525)-.05?"#000":"#fff";v.style.setProperty("--viewport-text",Ct===s?"":Qt),L()};for(let Ct of yp({root:v,toolbar:nt.toolbar,scene:h,meta:lt,grids:A,initialBackground:s,setBackground:ht,hasMeshes:p}))nt.onEscape(Ct.close);nt.toolbar.setHandler("distance",()=>{F(),b.setActive(!b.active),b.active||W.release(),nt.toolbar.setActive("distance",b.active)}),nt.toolbar.setActive("distance",!1),nt.onEscape(()=>(F(),b.clear()));let Rt=()=>{z.setExtraBounds("grids",A.visible?A.box:null),z.setExtraBounds("measure",b.box)};A.addEventListener("change",Rt),b.addEventListener("change",Rt),Rt(),z.addEventListener("click",Ct=>{let{x:It,y:Xt,ctrl:$t,shift:qt}=Ct.detail;if(b.active){let dt=W.target(It,Xt);dt&&b.add(dt.point);return}let Qt=!$t&&!qt?f?.pick(It,Xt):void 0;if(Qt!==void 0){ft.open(Qt);return}let ge=U.pick(It,Xt)?.element??-1;$t?ge>=0&&$.toggle(ge):ge>=0?$.set([ge]):qt||$.clear()}),z.addEventListener("boxselect",Ct=>{if(b.active)return;let{rect:It,mode:Xt,ctrl:$t,shift:qt}=Ct.detail;if(It.width<4||It.height<4){!$t&&!qt&&$.clear();return}let Qt=new ae,ie=qf(It,Xt,Yf(h,z.camera,Zn.getBoundingClientRect())),ge=_.clipping(),dt=ie.filter(zt=>!_.isCut(h.elementBox(zt,Qt),ge));$.set($t?[...$.values(),...dt]:dt)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),z.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),z.resize(),z.fitBox(m(),!1);let ft=Dp(v,i,d,h,z,L),Ot=new hl(document.getElementById("ioviewer-ui"),a,z);window.addEventListener("pointerdown",Ct=>{(Ct.target===Zn||Ot.element.contains(Ct.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:h,points:d,motionDetail:u,controls:z,picker:U,selection:$,ui:nt,viewCube:Ot,sections:_,sectionGizmo:S,measure:b,measureSnap:W,grids:A,clashes:X,timeliner:tt,ready:D,get camera(){return z.camera}}}})(); +`)}),c=new me(new cn(2,2),l);return c.frustumCulled=!1,o.add(c),{setScan(h,u){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(u);let d=new se().setFromObject(i),f=d.getSize(e).length();t.far=Math.max(20,f+u.distanceTo(d.getCenter(e)))},draw(h,u,d){t.aspect=u.aspect,t.fov=u.fov,t.updateProjectionMatrix(),t.lookAt(e.copy(t.position).add(d));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 uM=new Intl.NumberFormat(ai,{maximumFractionDigits:2,minimumFractionDigits:2}),Nl=i=>`${uM.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 dM(i,t){return[i*.005,t*.005]}function fM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function pM(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 R,c=new R;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 Hp(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 R),l=o.getCenter(new R),c={x:l.x,y:l.y,side:Math.max(a.x,a.y,.01)*1.12,zoom:1},h={...c},u=C=>50+100*(C-h.x)*h.zoom/h.side,d=C=>50-100*(C-h.y)*h.zoom/h.side,f=C=>Math.min(96,Math.max(4,C)),g=(C,ht,Tt=!1)=>{let P=u(ht.x),M=d(ht.y);return C.style.left=`${Tt?f(P):P}%`,C.style.top=`${Tt?f(M):M}%`,P>=0&&P<=100&&M>=0&&M<=100},_=t.meta.rtcOffset?.[2]??0,p=t.meta.panoramas??[],m=p.map(C=>new R(...C.position)),b=`ioviewer.scan-levels.v1:${location.pathname}`,w=()=>Bp(m.map(C=>C.z+_),o.min.z+_,o.max.z+_),S=null;try{let C=JSON.parse(localStorage.getItem(b));Array.isArray(C)&&(S=C.filter(ht=>Number.isFinite(ht?.min)&&Number.isFinite(ht.max)&&ht.max>ht.min))}catch{S=null}let v=S??w(),y=-1,A=!0,x=C=>Op(v[y],C+_),E=document.createElement("details");E.className="ioviewer-floating ioviewer-scan-map",E.open=!matchMedia("(max-width: 600px)").matches;let I=document.createElement("summary");I.textContent=$("scanMap.title");let D=document.createElement("div");D.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 L=document.createElement("span");L.className="scan-map-axes",L.textContent="Y \u2191";let F=document.createElement("span");F.className="scan-map-scale",D.append(N,B,L,F),E.append(I,D),i.append(E);let k=e.root.children.reduce((C,ht)=>C+ht.geometry.attributes.position.count,0),W=Math.max(1,Math.ceil(k/6e4)),O=e.root.children.map(C=>{let ht=C.geometry.attributes.position,Tt=new Float32Array(Math.ceil(ht.count/W)*3),P=new R;for(let M=0,Y=0;M{if(U=0,!E.open)return;let C=N.getContext("2d");if(!C)return;C.clearRect(0,0,300,300),C.fillStyle="rgba(160, 185, 201, .33)";for(let[P,M]of O.entries())if(e.root.children[P].visible)for(let Y=0;Y{U||(U=requestAnimationFrame(z))},V=new R,Z=null,K=()=>{if(Z){B.hidden=!x(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(V),B.style.rotate=`${Math.atan2(V.x,V.y)}rad`};E.addEventListener("toggle",q),n.root.addEventListener("change",C=>{C.detail.kind==="visibility"&&q()}),s.addEventListener("change",K);let lt=document.createElement("div");lt.className="scan-map-controls";let rt=document.createElement("select");rt.setAttribute("aria-label",$("scanMap.size"));for(let C of["small","medium","large"])rt.add(new Option($(`scanMap.${C}`),C));rt.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=rt.value,rt.addEventListener("change",()=>{i.dataset.scanMapSize=rt.value});let H=(C,ht=0,Tt=0)=>{h=zp(h,C,ht,Tt),q()},Q=()=>{h={...c},q()};lt.append(rt,Kn($("scanMap.zoomOut"),"\u2212",()=>H(.8)),Kn($("scanMap.zoomIn"),"+",()=>H(1.25)),Kn($("scanMap.reset"),"\u21BA",Q)),E.insertBefore(lt,D),N.addEventListener("wheel",C=>{C.preventDefault();let ht=N.getBoundingClientRect();H(C.deltaY<0?1.15:1/1.15,(C.clientX-ht.left)/ht.width-.5,(C.clientY-ht.top)/ht.height-.5)},{passive:!1});let ut;N.addEventListener("pointerdown",C=>{C.button!==0||ut||(N.setPointerCapture(C.pointerId),ut={id:C.pointerId,x:C.clientX,y:C.clientY})}),N.addEventListener("pointermove",C=>{if(ut?.id!==C.pointerId)return;let ht=h.side/(h.zoom*Math.max(1,N.clientWidth));h.x-=(C.clientX-ut.x)*ht,h.y+=(C.clientY-ut.y)*ht,ut.x=C.clientX,ut.y=C.clientY,q()}),N.addEventListener("lostpointercapture",C=>{C.pointerId===ut?.id&&(ut=void 0)}),N.addEventListener("keydown",C=>{let ht={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[C.key];if(ht){let Tt=h.side/h.zoom/10;h.x+=ht[0]*Tt,h.y+=ht[1]*Tt,q()}else if(C.key==="+"||C.key==="="||C.key==="-")H(C.key==="-"?.8:1.25);else if(C.key==="0")Q();else return;C.preventDefault(),C.stopPropagation()});let It=document.createElement("div");It.className="scan-map-controls";let ft=document.createElement("select");ft.setAttribute("aria-label",$("scanMap.levels"));let Ut=document.createElement("p");Ut.className="scan-map-feedback",Ut.setAttribute("role","status");function ae(){try{localStorage.setItem(b,JSON.stringify(v))}catch{Ut.textContent=$("scanMap.levelTemporary")}}function Gt(){ft.replaceChildren(new Option($("scanMap.allLevels"),"-1")),v.forEach((C,ht)=>ft.add(new Option(`${$("scanMap.level").replace("{n}",ht+1)} \xB7 ${Nl(C.min)} \u2013 ${Nl(C.max)}`,String(ht)))),ft.value=String(y),Ct.disabled=y<0;for(let[C,ht]of m.entries())qt.options[C+1].hidden=!x(ht.z);q(),r()}ft.addEventListener("change",()=>{y=Number(ft.value),Ut.textContent="",Gt()});let Jt=Kn($("scanMap.addLevel"),"+",()=>{if($t.isClosed()){let C=m.findIndex(ht=>x(ht.z));Ft(Math.max(0,C))}$t.pickLevel()});Jt.disabled=!p.length;let mt=Kn($("scanMap.autoLevels"),$("scanMap.autoButton"),()=>{let C=w(),ht=C.filter(Tt=>!v.some(P=>P.min{y<0||(v.splice(y,1),y=-1,Ut.textContent="",ae(),Gt())});if(It.append(ft,Jt,mt,Ct),p.length){let C=Kn($("scanMap.spheres"),"\u25C9",()=>{A=!A,C.setAttribute("aria-pressed",String(A)),r()});C.setAttribute("aria-pressed","true"),It.append(C)}E.append(It,Ut);let $t=p.length?mM(i,t,e,Ft,C=>{Z=C,C||dt.forEach(ht=>ht.classList.remove("current")),K()},C=>{y=v.push(C)-1,Ut.textContent=$("scanMap.levelAdded"),ae(),Gt()}):null,qt=document.createElement("select");qt.setAttribute("aria-label",$("scanMap.choosePhoto"));let Me=new Option($("scanMap.choosePhoto"),"");Me.disabled=!0,qt.add(Me);let dt=[];for(let[C,ht]of p.entries()){let Tt=ht.name||t.meta.elements[ht.element].name||String(C+1);qt.add(new Option(Tt,String(C)));let P=document.createElement("button");P.type="button",P.className="scan-map-station",P.title=Tt,P.setAttribute("aria-label",`${$("scanMap.photo")} \xB7 ${Tt}`),P.addEventListener("click",()=>Ft(C)),dt.push(P),D.append(P)}qt.value="",qt.addEventListener("change",()=>Ft(Number(qt.value))),qt.hidden=!p.length,E.append(qt),Gt(),!S&&v.length&&ae();function Ft(C,ht=!1){E.open=!0,qt.value=String(C),dt.forEach((Tt,P)=>Tt.classList.toggle("current",C===P)),$t.open(C,ht),qt.value=""}return{open:Ft,showSphere:(C,ht)=>A&&x(ht)&&n.isVisible(C)}}function mM(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"),Ft=$(dt?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Ft,h.setAttribute("aria-label",Ft),h.setAttribute("aria-pressed",String(dt))});h.setAttribute("aria-pressed","false");let u=document.createElement("button");u.type="button",u.textContent=$("close"),u.addEventListener("click",Gt);let d=!1,f=Kn($("scanMap.intensity"),$("scanMap.intensity"),()=>{d=!d,Me(!1)});f.className="scan-photo-intensity",f.hidden=!0,c.append(f,h,u),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 p=document.createElement("div");p.className="scan-photo-view";let m=document.createElement("span");m.className="scan-photo-crosshair",m.setAttribute("aria-hidden","true");let b=document.createElement("div");b.className="scan-photo-level",b.hidden=!0;let w=document.createElement("span");w.setAttribute("role","status"),b.append(w,Kn($("scanMap.cancel"),$("scanMap.cancel"),mt)),p.append(g,m,_),o.append(a,b,p),i.append(o);let S=t.meta.panoramas.map((dt,Ft)=>{let C=dt.name||t.meta.elements[dt.element].name||String(Ft+1),ht=document.createElement("button");return ht.className="scan-photo-link",ht.type="button",ht.title=C,ht.setAttribute("aria-label",$("scanMap.goToStation").replace("{name}",C)),ht.hidden=!0,ht.addEventListener("click",()=>n(Ft,!0)),p.append(ht),{photo:dt,name:C,button:ht,position:new R(...dt.position)}}),v=t.readView(t.meta.points.element),y=new Xn;y.params.Points.threshold=.12,y.near=.25;let A=new R,x=new R,E=new R,I=[],D=[],N=!1,B,L=t.meta.rtcOffset?.[2]??0,F,k,W,O=0,U=!1,z=!1,q=0,V=0,Z=null,K,lt,rt=new pn,H=new Ue(72,1,.1,20);H.up.set(0,0,1);let Q=new Gn(10,56,28);Q.rotateX(Math.PI/2);let ut=new Je({side:ze}),It=new me(Q,ut);rt.add(It);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(fM(A,q,V)),z?W.draw(F,H,A):F.render(rt,H),H.getWorldDirection(A);for(let dt of I){if(N){dt.button.hidden=!0;continue}E.copy(dt.position).sub(K.position).normalize(),x.copy(E).project(H);let Ft=E.dot(A)>0&&Math.abs(x.x)<.92&&Math.abs(x.y)<.88;dt.button.hidden=!Ft,Ft&&(dt.button.style.left=`${(1+x.x)*50}%`,dt.button.style.top=`${(1-x.y)*50}%`)}s({position:K.position,yaw:q})}},Ut=(dt,Ft)=>{q+=dt,V=oe.clamp(V+Ft,-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,Ut(...dM(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 Ft=g.getBoundingClientRect();$t((dt.clientX-Ft.left)*2/Ft.width-1,1-(dt.clientY-Ft.top)*2/Ft.height)}),g.addEventListener("lostpointercapture",dt=>{Z?.id===dt.pointerId&&(Z=null)}),g.addEventListener("keydown",dt=>{if(N&&dt.key==="Enter"){dt.preventDefault(),$t(0,0);return}let Ft={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[dt.key];Ft&&(dt.preventDefault(),dt.stopPropagation(),Ut(...Ft))}),g.addEventListener("wheel",dt=>{dt.preventDefault(),H.fov=oe.clamp(H.fov+Math.sign(dt.deltaY)*5,32,95),ft()},{passive:!1}),o.addEventListener("keydown",dt=>{dt.key==="Escape"&&(N?mt():Gt()),dt.stopPropagation()});function Gt(){o.hidden=!0,mt(),O++,Z=null,Jt(),s(null),lt?.focus()}function Jt(){z=!1,k?.dispose(),k=void 0,ut.map=null;for(let dt of I)dt.button.hidden=!0;I=[]}function mt(){N=!1,B=void 0,o.classList.remove("is-picking"),b.hidden=!0,ft()}function Ct(){N=!0,B=void 0,o.classList.add("is-picking"),w.textContent=$("scanMap.pickLower"),b.hidden=!1,ft(),(k||z)&&g.focus()}function $t(dt,Ft){if(!k&&!z)return;let C=pM(H,K.position,D,dt,Ft,g.clientWidth,g.clientHeight);if(C===void 0){w.textContent=$(B===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let ht=C+L;B===void 0?(B=ht,w.textContent=$("scanMap.pickUpper").replace("{z}",Nl(ht))):ht<=B?w.textContent=$("scanMap.upperAboveLower").replace("{z}",Nl(B)):(r({min:B,max:ht}),mt())}function qt(dt,Ft){let C=o.hidden;if(C&&(lt=document.activeElement),Jt(),K=S[dt],o.hidden=!1,l.textContent=K.name,It.rotation.z=oe.degToRad(K.photo.yaw),D=e.root.children.filter((ht,Tt)=>v[Tt]===K.photo.element),U=D.some(ht=>ht.geometry.getAttribute("intensity")),f.hidden=!U&&!K.photo.intensity,I=S.filter(ht=>{if(ht===K)return!1;let Tt=E.copy(ht.position).sub(K.position).length();return Tt<=.25?!1:(y.set(K.position,E.multiplyScalar(1/Tt)),y.far=Tt-.25,!y.intersectObjects(D,!1).length)}),C||!Ft){let ht=I.reduce((Tt,P)=>!Tt||P.position.distanceToSquared(K.position){Ft===O&&(_.textContent=$("scanMap.photoError"))},Tt;try{if(F??(F=new Ti({canvas:g,antialias:!0})),F.setPixelRatio(Math.min(devicePixelRatio,2)),C&&U){W??(W=kp()),W.setScan(D,K.position),z=!0,_.textContent="",g.style.visibility="visible",ft(),dt&&g.focus();return}let P=C?K.photo.intensity:K.photo.image;Tt=URL.createObjectURL(new Blob([t.readView(P)],{type:"image/jpeg"}))}catch{ht();return}new fr().load(Tt,P=>{if(URL.revokeObjectURL(Tt),Ft!==O||P.image.width!==2*P.image.height){P.dispose(),ht();return}k?.dispose(),k=P,k.colorSpace=pe,ut.map=k,ut.needsUpdate=!0,_.textContent="",g.style.visibility="visible",ft(),dt&&g.focus()},void 0,()=>{URL.revokeObjectURL(Tt),ht()})}return{open:qt,pickLevel:Ct,isClosed:()=>o.hidden}}var Xs=7;function Vp(i){if(!i?.length)return null;let t=i.map(({position:l})=>new R(...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 R,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[u,d]of t.entries()){if(!h(i[u].element,d.z))continue;let f=-o.copy(d).applyMatrix4(l.matrixWorldInverse).z;if(f<=l.near||f>=l.far||(o.copy(d).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 p=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,m=Xs*p/c.height;n.setMatrixAt(n.count++,r.makeScale(m,m,m).setPosition(d)),s.push({index:u,depth:f,x:g+c.left,y:_+c.top})}n.instanceMatrix.needsUpdate=n.count>0}},pick(l,c){let h;for(let u of s)(!h||u.depth=0&&this.scene.instancesOf(u.element).length>0&&!this.scene.isVisible(u.element))continue;this._p.set(u.position[0],u.position[1],u.position[2]);let d=this._p.clone().applyMatrix4(l);if(t.isPerspectiveCamera&&d.z>=-t.near)continue;let f=c||e.height/(2*Math.max(-d.z,1e-6)*h),g=u.height*f;if(!Number.isFinite(g)||g<1.5||g>800)continue;let _=this._p.clone().applyMatrix4(a);if(_.z<-1||_.z>1)continue;let p=(_.x*.5+.5)*e.width,m=(-_.y*.5+.5)*e.height;if(p<-400||p>e.width+400||m<-400||m>e.height+400)continue;this._x.set(u.position[0]+Math.cos(u.rotation),u.position[1]+Math.sin(u.rotation),u.position[2]).applyMatrix4(a);let b=(this._x.x*.5+.5)*e.width,w=(-this._x.y*.5+.5)*e.height,S=Math.atan2(w-m,b-p),[v,y,A]=u.color?[Math.round(u.color[0]*255),Math.round(u.color[1]*255),Math.round(u.color[2]*255)]:this.lightBackground?[17,24,39]:[229,231,235];this.lightBackground&&v>230&&y>230&&A>230?[v,y,A]=[17,24,39]:!this.lightBackground&&v<20&&y<20&&A<20&&([v,y,A]=[241,245,249]),o.save(),o.translate(p,m),Math.abs(S)>1e-4&&o.rotate(S),o.font=`${g.toFixed(2)}px system-ui, -apple-system, "Segoe UI", Arial, sans-serif`,o.fillStyle=`rgb(${v},${y},${A})`;let x=u.attachment||1,E=(x-1)%3,I=Math.floor((x-1)/3);o.textAlign=E===1?"center":E===2?"right":"left",o.textBaseline=I===1?"middle":I>=2?"bottom":"top";let D=u.text.split(` +`),N=g*1.25,B=I===1?-((D.length-1)*N)/2:I>=2?-(D.length-1)*N:0;for(let L=0;L{}};let c=new Set(l.flatMap(p=>p.elements)),h=nt("div","ioviewer-sheets ioviewer-floating");h.setAttribute("role","tablist"),h.setAttribute("aria-label",$("sheets.label"));let u=new zi(new ce,new sn({color:"#94a3b8",transparent:!0,opacity:.55}));u.visible=!1,t.add(u);let d=null,f=new Map;function g(p,m=!1){let b=l.find(y=>y.key===p)??l[0];if(!b)return;d=b;for(let[y,A]of f){let x=y===b.key;A.classList.toggle("active",x),A.setAttribute("aria-selected",String(x))}let w=new Set(b.elements),S=[];for(let y of c)w.has(y)||S.push(y);if(n.replaceLayerHidden("sheet",S),s?.setSheet(b.key),!b.isModel&&b.paperBounds){let{min:y,max:A}=b.paperBounds,x=y[2];u.geometry.setFromPoints([new R(y[0],y[1],x),new R(A[0],y[1],x),new R(A[0],A[1],x),new R(y[0],A[1],x)]),u.visible=!0}else u.visible=!1;b.background&&o(b.background,!m);let v=b.paperBounds?new se(new R(...b.paperBounds.min),new R(...b.paperBounds.max)):n.visibleBox();r(!!b.is2D,v,!1),a()}for(let p of l){let m=nt("button","ioviewer-sheet-tab",p.name);m.type="button",m.setAttribute("role","tab"),m.dataset.sheet=p.key,m.addEventListener("click",()=>g(p.key,!1)),f.set(p.key,m),h.append(m)}l.length>1&&i.append(h);let _=e.options?.initialSheet??l[0].key;return g(_,!0),{get active(){return d},setSheet:p=>g(p,!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?gM(uf(document,Zr,i),t):Kr($("noWebGL"))}catch(i){if(!(i instanceof te))throw i;Kr($("badData"))}function gM(i,t){let e=new Ti({canvas:Ln,context:t,antialias:!0,stencil:!0,logarithmicDepthBuffer:qf(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;Zr?.("sceneStart");let h=I(),u=new al(i),d=new ll(i);Zr?.("sceneEnd"),i.releaseBinary(),!c&&h.totalCost===0&&u.count===0&&d.count===0&&Kr($("noGeometry"));let f=new _l(h,k,Math.min(h.totalCost,2e7));n.add(h.root),n.add(u.root),n.add(d.root);let g=u.count?Vp(i.meta.panoramas):null;g&&n.add(g.mesh);let _=()=>h.visibleBox(),p=new wl(h,_(),i.meta.sections);u.syncVisibility(h),u.syncAppearance(h),d.syncVisibility(h),d.syncAppearance(h);let m=()=>{let{planes:mt,intersection:Ct}=p.clipping();u.setClipping(mt,Ct),d.setClipping(mt,Ct)};m();let b=h.slotCount>0,w=b&&t.getContextAttributes()?.stencil===!0,S,v=new Al(p,Ln);n.add(v.group);let y=document.getElementById("ioviewer-ui"),A=new Ul(y,i,h),x=new Cl(y),E=new Ll(y,i.meta.grids??[]);n.add(x.group,E.group);function I(){try{return new Hr(i,{...Jh,maxTextureSize:e.capabilities.maxTextureSize})}catch(mt){if(!(mt instanceof kr))throw mt;c=!0,Kr($("tooLarge").replace("{count}",mt.count).replace("{limit}",mt.limit));let Ct=qt=>({o:0,n:0,t:qt}),$t={count:0,geometry:Ct("u32"),material:Ct("u32"),element:Ct("i32"),matrix:Ct("f32")};return new Hr({...i,meta:{...i.meta,instances:$t}})}}let D=!1;Ln.addEventListener("webglcontextlost",()=>{D=!0,Kr($("contextLost"))});let N,B=new Promise(mt=>N=mt),L=Zr,F=!1;function k(){F||D||(F=!0,f.requested(performance.now()),requestAnimationFrame(()=>{if(F=!1,D)return;let mt=Ln.getBoundingClientRect();K.camera.updateMatrixWorld(),Gt&&g?.update(K.camera,mt,Gt.showSphere),v.update(K.camera),x.update(K.camera,mt),E.update(K.camera,mt),A.update(K.camera,mt),f.begin(K.camera,mt.height,performance.now()),L?.("renderStart"),p.fill&&w?(S??(S=new Rl(h,p,i)),S.render(e,n,K.camera)):e.render(n,K.camera),L&&(L("renderEnd"),L=void 0),f.end(performance.now()),lt.update(),N()}))}h.root.addEventListener("change",k),p.addEventListener("change",()=>{m(),k()}),v.addEventListener("change",k),x.addEventListener("change",k),x.addEventListener("previewchange",k),E.addEventListener("change",k);let W=new ml(e,h,a,{points:u,lines:d,pickFloat:Jh.pickFloat}),O=new Pl(W,p,i),U=0,z=null;function q(){cancelAnimationFrame(U),U=0,z=null,x.setPreview(null)}function V(){U=0,z&&x.setPreview(O.target(...z))}function Z(){z&&(x.setPreview(null),cancelAnimationFrame(U),U=requestAnimationFrame(()=>{U=requestAnimationFrame(V)}))}Ln.addEventListener("pointermove",mt=>{if(!x.active||mt.buttons)return q();z=[mt.clientX,mt.clientY],U||(U=requestAnimationFrame(V))});for(let mt of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Ln.addEventListener(mt,q);h.root.addEventListener("change",mt=>{mt.detail.kind!=="appearance"&&Z()});let K=new ul(a,Ln,{pick:(mt,Ct)=>W.pick(mt,Ct)?.point??null,visibleBox:_});K.addEventListener("change",()=>{W.camera=K.camera,Z(),k()}),h.root.addEventListener("change",mt=>{mt.detail.kind==="appearance"&&(u.syncAppearance(h),d.syncAppearance(h)),(mt.detail.kind==="appearance"||mt.detail.kind==="visibility")&&A.update(K.camera,Ln.getBoundingClientRect()),mt.detail.kind==="visibility"&&(u.syncVisibility(h),d.syncVisibility(h),K.invalidateBounds(),K.resize())});let lt,rt=new vl;rt.addEventListener("change",()=>h.setHighlighted([...rt.values()]));let H=mp({root:y,data:i,scene:h,controls:K,picker:W,selection:rt,measure:x});K.addEventListener("mode2d",()=>{H.sync2DState(),lt?.set2D(K.is2D)}),Sp({root:y,...H,sections:p,selection:rt,canFill:w,hasMeshes:b});let{meta:Q}=i,ut=Fp({...H,files:Q.linkedFiles??[],elements:Q.elements,scene:h});Cp({...H,controls:K,scene:h,sections:p,selection:rt,restoreLinkedModels:ut,views:Q.viewpoints??[],bcfTopics:Q.bcfTopics??[]});let It=Pp({...H,tests:Q.clashTests??[],elements:Q.elements,scene:h,controls:K,selection:rt});n.add(It.group);let ft=Up({root:y,...H,timeliner:Q.timeliner,elements:Q.elements,scene:h}),Ut=mt=>{e.setClearColor(r.set(mt),1);let{r:Ct,g:$t,b:qt}=r,dt=.2126*Ct+.7152*$t+.0722*qt>Math.sqrt(.0525)-.05,Ft=dt?"#000":"#fff";y.style.setProperty("--viewport-text",mt===s?"":Ft),d.setLightBackground(dt),A.setLightBackground(dt),k()};{let{r:mt,g:Ct,b:$t}=r,qt=.2126*mt+.7152*Ct+.0722*$t>Math.sqrt(.0525)-.05;d.setLightBackground(qt),A.setLightBackground(qt),qt&&y.style.setProperty("--viewport-text","#000")}for(let mt of Rp({root:y,toolbar:H.toolbar,scene:h,meta:Q,grids:E,initialBackground:s,setBackground:Ut,hasMeshes:b}))H.onEscape(mt.close);H.toolbar.setHandler("distance",()=>{q(),x.setActive(!x.active),x.active||O.release(),H.toolbar.setActive("distance",x.active)}),H.toolbar.setActive("distance",!1),H.onEscape(()=>(q(),x.clear()));let ae=()=>{K.setExtraBounds("grids",E.visible?E.box:null),K.setExtraBounds("measure",x.box)};E.addEventListener("change",ae),x.addEventListener("change",ae),ae(),K.addEventListener("click",mt=>{let{x:Ct,y:$t,ctrl:qt,shift:Me}=mt.detail;if(x.active){let ht=O.target(Ct,$t);ht&&x.add(ht.point);return}let dt=!qt&&!Me?g?.pick(Ct,$t):void 0;if(dt!==void 0){Gt.open(dt);return}let C=W.pick(Ct,$t)?.element??-1;qt?C>=0&&rt.toggle(C):C>=0?rt.set([C]):Me||rt.clear()}),K.addEventListener("boxselect",mt=>{if(x.active)return;let{rect:Ct,mode:$t,ctrl:qt,shift:Me}=mt.detail;if(Ct.width<4||Ct.height<4){!qt&&!Me&&rt.clear();return}let dt=new se,Ft=tp(Ct,$t,ep(h,K.camera,Ln.getBoundingClientRect())),C=p.clipping(),ht=Ft.filter(Tt=>!p.isCut(h.elementBox(Tt,dt),C));rt.set(qt?[...rt.values(),...ht]:ht)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),K.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),K.resize(),K.fitBox(_(),!1);let Gt=Hp(y,i,u,h,K,k);lt=new pl(document.getElementById("ioviewer-ui"),a,K);let Jt=Gp({root:y,world:n,meta:Q,scene:h,annotationsOverlay:A,apply2DMode:(mt,Ct,$t)=>{K.set2DMode(mt,Ct,$t),H.sync2DState(),lt.set2D(K.is2D)},setBackground:Ut,requestRender:k});!Q.sheets?.length&&Q.options?.initial2DMode&&(K.set2DMode(!0,_(),!1),H.sync2DState(),lt.set2D(!0)),window.addEventListener("pointerdown",mt=>{(mt.target===Ln||lt.element.contains(mt.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:h,points:u,lines:d,annotationsOverlay:A,sheetsBar:Jt,motionDetail:f,controls:K,picker:W,selection:rt,ui:H,viewCube:lt,sections:p,sectionGizmo:v,measure:x,measureSnap:O,grids:E,clashes:It,timeliner:ft,ready:B,get camera(){return K.camera}}}})(); /*! Bundled license information: three/build/three.core.js: diff --git a/src/IOViewer/Viewer/src/data.js b/src/IOViewer/Viewer/src/data.js index cd38f28..df9d036 100644 --- a/src/IOViewer/Viewer/src/data.js +++ b/src/IOViewer/Viewer/src/data.js @@ -109,22 +109,26 @@ function validateMeta(meta) { || (q && (!vector(q.o) || typeof q.s !== 'number')) || (g.normals != null && !['f32', 'i16'].includes(g.normals.t)) || (g.uvs != null && g.uvs.t !== 'f32') - || (g.kind != null && g.kind !== 'points') + || (g.kind != null && g.kind !== 'points' && g.kind !== 'lines') || (g.colors != null && (g.kind !== 'points' || g.colors.t !== 'u8' || g.colors.n !== g.positions.n)) || (g.intensities != null && (g.kind !== 'points' || g.intensities.t !== 'u8' || 3 * g.intensities.n !== g.positions.n))) { throw new ModelDataError('Invalid META geometry.'); } } - if (meta.points != null) { - const p = meta.points; - if (!object(p) || !Number.isSafeInteger(p.count) || p.count < 0) throw new ModelDataError('Invalid META point count.'); - for (const [name, type, length] of [ - ['geometry', 'u32', p.count], ['material', 'u32', p.count], - ['element', 'i32', p.count], ['matrix', 'f32', p.count * 12], - ]) { - if (p[name]?.t !== type || p[name].n !== length) throw new ModelDataError(`Invalid META point ${name} view.`); + for (const kind of ['points', 'lines']) { + if (meta[kind] != null) { + const p = meta[kind]; + if (!object(p) || !Number.isSafeInteger(p.count) || p.count < 0) throw new ModelDataError(`Invalid META ${kind} count.`); + for (const [name, type, length] of [ + ['geometry', 'u32', p.count], ['material', 'u32', p.count], + ['element', 'i32', p.count], ['matrix', 'f32', p.count * 12], + ]) { + if (p[name]?.t !== type || p[name].n !== length) throw new ModelDataError(`Invalid META ${kind} ${name} view.`); + } } } + if (meta.annotations != null && !records(meta.annotations)) throw new ModelDataError('Invalid META annotations.'); + if (meta.sheets != null && !records(meta.sheets)) throw new ModelDataError('Invalid META sheets.'); if (meta.panoramas != null && (!records(meta.panoramas) || meta.panoramas.some((p) => !Number.isInteger(p.element) || p.element < 0 || p.element >= meta.elements.length || (p.name != null && typeof p.name !== 'string') || !vector(p.position) || !p.position.every(Number.isFinite) || !Number.isFinite(p.yaw) || diff --git a/src/IOViewer/Viewer/src/engine/lineScene.js b/src/IOViewer/Viewer/src/engine/lineScene.js new file mode 100644 index 0000000..72e08e7 --- /dev/null +++ b/src/IOViewer/Viewer/src/engine/lineScene.js @@ -0,0 +1,224 @@ +import * as THREE from 'three'; +import { ModelDataError } from '../data.js'; +import { geometryPositions } from './quantize.js'; + +const ROW = 2048; +const CHUNK_LINE_VERTICES = 524288; // 262,144 segments per draw call (must be even) +const HIGHLIGHT = [245, 158, 11]; +const WHITE = [235, 235, 237]; + +const LINE_VERTEX = /* glsl */ ` +#include +attribute float lineSlot; +uniform sampler2D lineState; +varying vec3 vColor; +#include +#include +void main() { + int slot = int(lineSlot + 0.5); + vec4 state = texelFetch(lineState, ivec2(slot & 2047, slot >> 11), 0); + vColor = state.rgb; + vec3 transformed = position; + #include + #include + #include + if (state.a < 0.5) gl_Position = vec4(0.0, 0.0, 2.0, 1.0); +}`; + +const LINE_FRAGMENT = /* glsl */ ` +#include +#include +#include +uniform float opacity; +uniform float lightBg; +varying vec3 vColor; +void main() { + #include + #include + vec3 c = vColor; + // AutoCAD-style ACI 7 adaptive contrast when switching between dark CAD and light paper backgrounds. + if (lightBg > 0.5 && c.r > 0.90 && c.g > 0.90 && c.b > 0.90) { + c = vec3(0.07, 0.09, 0.14); + } else if (lightBg < 0.5 && c.r < 0.08 && c.g < 0.08 && c.b < 0.08) { + c = vec3(0.95, 0.96, 0.98); + } + gl_FragColor = vec4(c, opacity); +}`; + +/** + * Vector line-segment batcher (META `lines`) drawn natively beside triangle chunks and point clouds. + * Merges line segments into large `THREE.LineSegments` chunks with GPU per-instance slot visibility, highlight, + * white mode, opacity, clipping planes and AutoCAD-style light/dark contrast adaptation. + */ +export class LineScene { + constructor(data) { + this.root = new THREE.Group(); + const lines = data.meta.lines; + this.count = lines?.count ?? 0; + this.clippingPlanes = null; + this.clipIntersection = false; + this._lightBg = false; + if (!this.count) return; + + const geometryOf = data.view(lines.geometry); + const materialOf = data.view(lines.material); + const matrices = data.view(lines.matrix); + const height = Math.ceil(this.count / ROW); + this._stateData = new Uint8Array(ROW * height * 4); + this._state = new THREE.DataTexture(this._stateData, ROW, height, THREE.RGBAFormat); + this._state.colorSpace = THREE.SRGBColorSpace; + this._state.minFilter = THREE.NearestFilter; + this._state.magFilter = THREE.NearestFilter; + this._state.generateMipmaps = false; + + this._baseColors = new Array(this.count); + for (let i = 0; i < this.count; i++) { + const m = data.meta.materials[materialOf[i]]; + const c = m?.color ?? [0.85, 0.85, 0.85]; + this._baseColors[i] = [Math.round(c[0] * 255), Math.round(c[1] * 255), Math.round(c[2] * 255)]; + const o = i * 4; + this._stateData[o] = this._baseColors[i][0]; + this._stateData[o + 1] = this._baseColors[i][1]; + this._stateData[o + 2] = this._baseColors[i][2]; + this._stateData[o + 3] = 255; + } + this._state.needsUpdate = true; + + this._uniforms = { + lineState: { value: this._state }, + opacity: { value: 1 }, + lightBg: { value: 0 }, + }; + this._material = new THREE.ShaderMaterial({ + vertexShader: LINE_VERTEX, + fragmentShader: LINE_FRAGMENT, + uniforms: this._uniforms, + transparent: false, + clipping: true, + }); + + // Decode each referenced line geometry once and bake chunks with slot IDs. + const cachedPos = new Map(); + const cachedIdx = new Map(); + const getGeo = (gi) => { + if (!cachedPos.has(gi)) { + const g = data.meta.geometries[gi]; + if (!g || g.kind !== 'lines') throw new ModelDataError(`Line instance references a geometry (${gi}) that is not lines.`); + cachedPos.set(gi, geometryPositions(data, g)); + cachedIdx.set(gi, data.view(g.indices)); + } + return { positions: cachedPos.get(gi), indices: cachedIdx.get(gi) }; + }; + + let chunkVerts = []; + let chunkSlots = []; + const flush = () => { + if (chunkVerts.length === 0) return; + const geo = new THREE.BufferGeometry(); + geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(chunkVerts), 3)); + geo.setAttribute('lineSlot', new THREE.BufferAttribute(new Float32Array(chunkSlots), 1)); + geo.computeBoundingSphere(); + const segs = new THREE.LineSegments(geo, this._material); + segs.frustumCulled = false; + this.root.add(segs); + chunkVerts = []; + chunkSlots = []; + }; + + for (let i = 0; i < this.count; i++) { + const { positions, indices } = getGeo(geometryOf[i]); + const o = i * 12; + const m0 = matrices[o], m1 = matrices[o + 1], m2 = matrices[o + 2]; + const m3 = matrices[o + 3], m4 = matrices[o + 4], m5 = matrices[o + 5]; + const m6 = matrices[o + 6], m7 = matrices[o + 7], m8 = matrices[o + 8]; + const tx = matrices[o + 9], ty = matrices[o + 10], tz = matrices[o + 11]; + const segCount = indices.length - (indices.length % 2); + if (chunkSlots.length + segCount > CHUNK_LINE_VERTICES && chunkSlots.length > 0) flush(); + + for (let k = 0; k < segCount; k++) { + const vi = indices[k] * 3; + const x = positions[vi], y = positions[vi + 1], z = positions[vi + 2]; + chunkVerts.push( + m0 * x + m3 * y + m6 * z + tx, + m1 * x + m4 * y + m7 * z + ty, + m2 * x + m5 * y + m8 * z + tz, + ); + chunkSlots.push(i); + } + } + flush(); + } + + setLightBackground(light) { + this._lightBg = !!light; + if (this._uniforms) this._uniforms.lightBg.value = this._lightBg ? 1 : 0; + } + + syncVisibility(scene) { + if (!this.count) return; + const first = scene.lineOffset ?? (scene.instanceCount - this.count); + for (let i = 0; i < this.count; i++) { + this._stateData[i * 4 + 3] = scene.isInstanceVisible(first + i) ? 255 : 0; + } + this._state.needsUpdate = true; + } + + syncAppearance(scene) { + if (!this.count) return; + const first = scene.lineOffset ?? (scene.instanceCount - this.count); + const whiteMode = scene._mode === 'white'; + const overrideColor = new THREE.Color(); + for (let i = 0; i < this.count; i++) { + const o = i * 4; + const inst = first + i; + if (scene._highlight[inst]) { + this._stateData[o] = HIGHLIGHT[0]; + this._stateData[o + 1] = HIGHLIGHT[1]; + this._stateData[o + 2] = HIGHLIGHT[2]; + } else if (scene.instanceColorOverride(inst, overrideColor)) { + const hex = overrideColor.getHex(THREE.SRGBColorSpace); + this._stateData[o] = (hex >> 16) & 255; + this._stateData[o + 1] = (hex >> 8) & 255; + this._stateData[o + 2] = hex & 255; + } else if (whiteMode) { + this._stateData[o] = WHITE[0]; + this._stateData[o + 1] = WHITE[1]; + this._stateData[o + 2] = WHITE[2]; + } else { + const base = this._baseColors[i]; + this._stateData[o] = base[0]; + this._stateData[o + 1] = base[1]; + this._stateData[o + 2] = base[2]; + } + } + this._state.needsUpdate = true; + const opacity = scene._opacity ?? 1; + this._uniforms.opacity.value = opacity; + const transparent = opacity < 1; + if (this._material.transparent !== transparent) { + this._material.transparent = transparent; + this._material.needsUpdate = true; + } + } + + setClipping(planes, intersection = false) { + this.clippingPlanes = planes.length > 0 ? planes : null; + this.clipIntersection = intersection; + if (this._material) { + this._material.clippingPlanes = this.clippingPlanes; + this._material.clipIntersection = intersection; + } + } + + withPickMaterial(material, draw) { + material.clippingPlanes = this.clippingPlanes; + material.clipIntersection = this.clipIntersection; + if (material.uniforms?.lineState) material.uniforms.lineState.value = this._state; + for (const object of this.root.children) object.material = material; + try { + draw(); + } finally { + for (const object of this.root.children) object.material = this._material; + } + } +} diff --git a/src/IOViewer/Viewer/src/engine/modelScene.js b/src/IOViewer/Viewer/src/engine/modelScene.js index d9ee324..4eb7716 100644 --- a/src/IOViewer/Viewer/src/engine/modelScene.js +++ b/src/IOViewer/Viewer/src/engine/modelScene.js @@ -124,10 +124,14 @@ export class ModelScene { const matrices = data.view(instances.matrix); const points = meta.points; const pointCount = points?.count ?? 0; - const instanceCount = count + pointCount; + const lines = meta.lines; + const lineCount = lines?.count ?? 0; + const instanceCount = count + pointCount + lineCount; this.root = new THREE.Group(); this.elementCount = meta.elements.length; + this.pointOffset = count; + this.lineOffset = count + pointCount; this._elements = meta.elements; this._meta = meta; this._mode = 'materials'; @@ -137,7 +141,7 @@ export class ModelScene { this._instanceDetail = true; this._pickFrustum = null; this._textures = new Map(); - // Points share the element visibility and bounds, with no triangle draw slots. + // Points and lines share the element visibility and bounds, with no triangle draw slots. this._elementOf = new Int32Array(instanceCount); this._elementOf.set(data.view(instances.element)); this._bucketOf = new Uint32Array(count); @@ -164,6 +168,16 @@ export class ModelScene { writeInstanceBox(pointMatrices, i, meta.geometries[pointGeometry[i]].bbox, boxes); } } + if (lineCount) { + this._elementOf.set(data.view(lines.element), count + pointCount); + this._lineMaterials = data.view(lines.material).slice(); + const lineGeometry = data.view(lines.geometry); + const lineMatrices = data.view(lines.matrix); + const boxes = this._boxes.subarray((count + pointCount) * 6); + for (let i = 0; i < lineCount; i++) { + writeInstanceBox(lineMatrices, i, meta.geometries[lineGeometry[i]].bbox, boxes); + } + } this._indexElements(); for (let i = 0; i < count; i++) { diff --git a/src/IOViewer/Viewer/src/engine/picking.js b/src/IOViewer/Viewer/src/engine/picking.js index 9b993a4..586afab 100644 --- a/src/IOViewer/Viewer/src/engine/picking.js +++ b/src/IOViewer/Viewer/src/engine/picking.js @@ -11,6 +11,10 @@ uniform uint pointIndex; uniform float pointSize; flat varying uint vPoint; flat varying uint vVertex; +#elif defined( IO_PICK_LINES ) +attribute float lineSlot; +uniform sampler2D lineState; +varying float vLine; #else ${SLOT_PARS} varying vec2 vSlot; @@ -27,6 +31,11 @@ void main() { gl_PointSize = pointSize; vPoint = pointIndex; vVertex = uint( gl_VertexID ); + #elif defined( IO_PICK_LINES ) + int lSlot = int( lineSlot + 0.5 ); + vec4 lState = texelFetch( lineState, ivec2( lSlot & 2047, lSlot >> 11 ), 0 ); + vec3 transformed = position; + vLine = float( lSlot ); #else ${SLOT_DECODE} vec3 transformed = slotPosition; @@ -44,14 +53,16 @@ void main() { vPos = ( modelMatrix * wp ).xyz; #ifdef IO_PICK_POINTS if ( pointSize <= 0.0 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); + #elif defined( IO_PICK_LINES ) + if ( lState.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); #else 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 }`; -// Point IDs are negative in float samples and tagged with the high bit in RGBA8. -// The second RGBA8 pass returns view-space depth for triangles and the exact vertex index for points. +// Point IDs use high bit 0x80000000 in RGBA8, Line IDs use 0x40000000 in RGBA8; +// in float targets, points use -1..-N and lines use -(N + 1)..-(N + M). const FRAGMENT = /* glsl */ ` #include #include @@ -60,18 +71,28 @@ varying vec3 vPos; #ifdef IO_PICK_POINTS flat varying uint vPoint; flat varying uint vVertex; +#elif defined( IO_PICK_LINES ) +uniform float pointCount; +varying float vLine; #else varying vec2 vSlot; #ifdef IO_PICK_DEPTH varying float vViewDepth; #endif #endif +#if defined( IO_PICK_LINES ) && defined( IO_PICK_DEPTH ) +varying float vViewDepth; +#endif void main() { #include #include #ifdef IO_PICK_POINTS uint id = 0x80000000u | vPoint; float sampleId = -float( vPoint + 1u ); + #elif defined( IO_PICK_LINES ) + uint lineIdx = uint( vLine + 0.5 ); + uint id = 0x40000000u | lineIdx; + float sampleId = -( pointCount + float( lineIdx ) + 1.0 ); #else float sampleId = floor( vSlot.x + 0.5 ) * 4096.0 + floor( vSlot.y + 0.5 ) + 1.0; uint id = uint( sampleId ); @@ -95,7 +116,7 @@ void main() { const copy = (hit) => hit && { element: hit.element, point: hit.point.clone() }; -function pickMaterial(uniforms, define, points = false) { +function pickMaterial(uniforms, define, mode = null) { const material = new THREE.ShaderMaterial({ vertexShader: VERTEX, fragmentShader: FRAGMENT, @@ -104,7 +125,8 @@ function pickMaterial(uniforms, define, points = false) { side: THREE.DoubleSide, clipping: true, }); - if (points) material.defines.IO_PICK_POINTS = ''; + if (mode === 'points') material.defines.IO_PICK_POINTS = ''; + else if (mode === 'lines') material.defines.IO_PICK_LINES = ''; else material.index0AttributeName = 'q'; return material; } @@ -119,6 +141,7 @@ export class Picker { this.renderer = renderer; this.scene = modelScene; this.points = options.points?.count ? options.points : null; + this.lines = options.lines?.count ? options.lines : null; this.camera = camera; // The model's buffers are not restored with a restored context: after a loss nothing is picked any more. this._lost = false; @@ -133,22 +156,28 @@ export class Picker { }); const uniforms = modelScene.slotUniforms; const pointUniforms = { pointIndex: { value: 0 }, pointSize: { value: 0 } }; + const lineUniforms = { lineState: { value: null }, pointCount: { value: this.points?.count ?? 0 } }; this._float = options.pickFloat !== false && renderer.extensions.has('EXT_color_buffer_float'); - // A point sprite whose centre falls just outside a 1 px tile can still cover the cursor. - const side = this.points ? 3 : 1; + // Hairline segments and point sprites use a small neighborhood so clicks do not miss by 1-2 px. + const side = this.lines ? 5 : this.points ? 3 : 1; if (this._float) { this._material = pickMaterial(uniforms, null); this._target = new THREE.WebGLRenderTarget(side, side, { type: THREE.FloatType }); this._pixel = new Float32Array(side * side * 4); - if (this.points) this._pointMaterial = pickMaterial(pointUniforms, null, true); + if (this.points) this._pointMaterial = pickMaterial(pointUniforms, null, 'points'); + if (this.lines) this._lineMaterial = pickMaterial(lineUniforms, null, 'lines'); } else { this._material = pickMaterial(uniforms, 'IO_PICK_RGBA8'); this._depthMaterial = pickMaterial(uniforms, 'IO_PICK_DEPTH'); this._target = new THREE.WebGLRenderTarget(side, side); this._pixel = new Uint8Array(side * side * 4); if (this.points) { - this._pointMaterial = pickMaterial(pointUniforms, 'IO_PICK_RGBA8', true); - this._pointDepthMaterial = pickMaterial(pointUniforms, 'IO_PICK_DEPTH', true); + this._pointMaterial = pickMaterial(pointUniforms, 'IO_PICK_RGBA8', 'points'); + this._pointDepthMaterial = pickMaterial(pointUniforms, 'IO_PICK_DEPTH', 'points'); + } + if (this.lines) { + this._lineMaterial = pickMaterial(lineUniforms, 'IO_PICK_RGBA8', 'lines'); + this._lineDepthMaterial = pickMaterial(lineUniforms, 'IO_PICK_DEPTH', 'lines'); } } } @@ -213,11 +242,12 @@ export class Picker { const center = index(x, y); const slot = slotAtIndex(center); let sample = center; - if (slot < 0 && this.points) { - // Snap through the sparse gaps between measured points, using only visible depth-tested samples. - let nearest = (radius - 1) ** 2; + if (slot < 0 && (this.points || this.lines)) { + // Snap through the sparse gaps between measured points or hairline segments, using only depth-tested samples. + let nearest = (radius + 1) ** 2; for (let j = 0; j < side * side; j++) { - if (!this._isPoint(slotAtIndex(j))) continue; + const s = slotAtIndex(j); + if (!this._isPoint(s) && !this._isLine(s)) continue; const distance = (j % side - radius) ** 2 + (Math.floor(j / side) - radius) ** 2; if (distance > nearest) continue; nearest = distance; @@ -238,16 +268,22 @@ export class Picker { }; const point = this._vertexAt(sampleSlot, ids, encodedDepth, sample) ?? this._depthPoint(x, y, rect, depth(sample)); const pointSample = this._isPoint(sampleSlot); + const lineSample = this._isLine(sampleSlot) ? sampleSlot - this.scene.slotCount - (this.points?.count ?? 0) : -1; + const lineInstances = new Set(); const element = this._elementAt(sampleSlot); - const slots = new Set([sampleSlot]); - if (!pointSample && element >= 0) { + const slots = new Set(pointSample || lineSample >= 0 ? [] : [sampleSlot]); + if (lineSample >= 0) lineInstances.add(lineSample); + if (!pointSample) { for (let j = 0; j < side * side; j++) { const nearby = slotAtIndex(j); - if (nearby >= 0 && !this._isPoint(nearby) && !slots.has(nearby) && this.scene.slotElement(nearby) === element) slots.add(nearby); + if (nearby >= 0 && !this._isPoint(nearby)) { + if (this._isLine(nearby)) lineInstances.add(nearby - this.scene.slotCount - (this.points?.count ?? 0)); + else if (element >= 0 && !slots.has(nearby) && this.scene.slotElement(nearby) === element) slots.add(nearby); + } } } const perspective = camera.isPerspectiveCamera; - tile = { rect, point, element, slots, pointSample, depthAt(px, py, candidateSlot) { + tile = { rect, point, element, slots, lineInstances, pointSample, depthAt(px, py, candidateSlot) { const j = index(px, py); const front = j < 0 ? -1 : slotAtIndex(j); if (front < 0) return Infinity; @@ -274,32 +310,62 @@ export class Picker { } _pick(x, y, rect) { - const radius = (this._target.width - 1) / 2; - const center = (this._target.width ** 2 - 1) / 2; + const side = this._target.width; + const radius = (side - 1) / 2; + const center = (side ** 2 - 1) / 2; const pixel = this._render(this._material, x - radius, y - radius, rect); - const slot = this._slotAt(this._float ? pixel : new Uint32Array(pixel.buffer), center); + const slotIds = this._float ? pixel : new Uint32Array(pixel.buffer); + let pickCell = center; + let slot = this._slotAt(slotIds, center); + if (slot < 0 && side > 1) { + let bestDist = Infinity; + for (let j = 0; j < side * side; j++) { + const s = this._slotAt(slotIds, j); + if (s < 0) continue; + const d = (j % side - radius) ** 2 + (Math.floor(j / side) - radius) ** 2; + if (d < bestDist) { + bestDist = d; + slot = s; + pickCell = j; + } + } + } if (slot < 0) return null; const element = this._elementAt(slot); const bytes = this._float ? null : this._render(this._depthMaterial, x - radius, y - radius, rect); const encoded = bytes && new DataView(bytes.buffer); - const point = this._vertexAt(slot, pixel, encoded, center) ?? this._depthPoint(x, y, rect, encoded.getFloat32(center * 4, true)); + const px = x - radius + (pickCell % side); + const py = y - radius + (side - 1 - Math.floor(pickCell / side)); + const point = this._vertexAt(slot, pixel, encoded, pickCell) ?? this._depthPoint(px, py, rect, encoded.getFloat32(pickCell * 4, true)); return { element, point }; } _slotAt(pixels, i) { const id = this._float ? Math.round(pixels[i * 4 + 3]) : pixels[i]; if (id < 0) return this.scene.slotCount - id - 1; - if (id >= 0x80000000) return this.scene.slotCount + id - 0x80000000; + if (!this._float && (id & 0x80000000) !== 0) return this.scene.slotCount + (id & 0x3fffffff); + if (!this._float && (id & 0x40000000) !== 0) return this.scene.slotCount + (this.points?.count ?? 0) + (id & 0x3fffffff); return id - 1; } _isPoint(slot) { - return slot >= this.scene.slotCount; + return slot >= this.scene.slotCount && slot < this.scene.slotCount + (this.points?.count ?? 0); + } + + _isLine(slot) { + return slot >= this.scene.slotCount + (this.points?.count ?? 0); } _elementAt(slot) { - return this._isPoint(slot) ? this.scene.instance(this.scene.instanceCount - this.points.count + slot - this.scene.slotCount).element - : this.scene.slotElement(slot); + if (this._isPoint(slot)) { + const pointOffset = this.scene.pointOffset ?? (this.scene.instanceCount - this.points.count - (this.lines?.count ?? 0)); + return this.scene.instance(pointOffset + slot - this.scene.slotCount).element; + } + if (this._isLine(slot)) { + const lineOffset = this.scene.lineOffset ?? (this.scene.instanceCount - this.lines.count); + return this.scene.instance(lineOffset + slot - this.scene.slotCount - (this.points?.count ?? 0)).element; + } + return this.scene.slotElement(slot); } _vertexAt(slot, ids, depths, i, target = new THREE.Vector3()) { @@ -337,6 +403,11 @@ export class Picker { const pointMaterial = material === this._depthMaterial ? this._pointDepthMaterial : this._pointMaterial; this.points.withPickMaterial(pointMaterial, () => renderer.render(this.points.root, camera)); } + if (this.lines) { + renderer.autoClear = false; // keep triangles/points depth for the line pass + const lineMaterial = material === this._depthMaterial ? this._lineDepthMaterial : this._lineMaterial; + this.lines.withPickMaterial(lineMaterial, () => renderer.render(this.lines.root, camera)); + } renderer.readRenderTargetPixels(target, 0, 0, target.width, target.height, pixels); } finally { renderer.setRenderTarget(previous.target); diff --git a/src/IOViewer/Viewer/src/engine/pointScene.js b/src/IOViewer/Viewer/src/engine/pointScene.js index 3c79a57..cb42c08 100644 --- a/src/IOViewer/Viewer/src/engine/pointScene.js +++ b/src/IOViewer/Viewer/src/engine/pointScene.js @@ -71,14 +71,14 @@ export class PointScene { // ModelScene appends point instances after meshes in its visibility state. syncVisibility(scene) { - const first = scene.instanceCount - this.count; + const first = scene.pointOffset ?? (scene.instanceCount - this.count); for (const [i, object] of this.root.children.entries()) { object.visible = scene.isInstanceVisible(first + i); } } syncAppearance(scene) { - const first = scene.instanceCount - this.count; + const first = scene.pointOffset ?? (scene.instanceCount - this.count); for (const [i, source] of this._materials.entries()) { const { material } = source; const override = scene.instanceColorOverride(first + i, material.color); diff --git a/src/IOViewer/Viewer/src/i18n.js b/src/IOViewer/Viewer/src/i18n.js index c5a4404..b5496ca 100644 --- a/src/IOViewer/Viewer/src/i18n.js +++ b/src/IOViewer/Viewer/src/i18n.js @@ -73,6 +73,8 @@ const dictionaries = { 'tool.pan': 'Панорама', 'tool.fit': 'Вписать всё', 'tool.projection': 'Перспектива / ортография', + 'tool.mode2d': 'Режим 2D / 3D', + 'sheets.label': 'Листы и пространство модели', 'tool.plane': 'Плоскость сечения', 'tool.box': 'Бокс сечения', 'tool.resetSections': 'Сбросить сечения', @@ -145,6 +147,8 @@ const dictionaries = { 'display.wireframe': 'Каркас', 'display.background': 'Цвет фона', 'display.backgroundReset': 'Фон по умолчанию', + 'display.bgCadDark': 'CAD тёмный', + 'display.bgPaper': 'Лист белый', 'opacity.label': 'Непрозрачность', 'opacity.value': '{value} %', 'views.tour': 'Тур по видам', @@ -238,6 +242,8 @@ const dictionaries = { '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', @@ -310,6 +316,8 @@ const dictionaries = { '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', diff --git a/src/IOViewer/Viewer/src/main.js b/src/IOViewer/Viewer/src/main.js index eebcc3b..f39f509 100644 --- a/src/IOViewer/Viewer/src/main.js +++ b/src/IOViewer/Viewer/src/main.js @@ -2,6 +2,7 @@ import * as THREE from 'three'; import { loadModelData, ModelDataError, readModelMeta } from './data.js'; import { ModelScene, ModelTooLargeError } from './engine/modelScene.js'; import { PointScene } from './engine/pointScene.js'; +import { LineScene } from './engine/lineScene.js'; import { lang, t } from './i18n.js'; import { NavigationControls, needsLogarithmicDepth } from './nav/controls.js'; import { ViewCube } from './nav/viewCube.js'; @@ -24,6 +25,8 @@ import { mountTimeliner } from './ui/timeliner.js'; import { mountLinks } from './ui/linksPanel.js'; import { mountScanMap } from './ui/scanMap.js'; import { createPanoramaSpheres } from './ui/panoramaSpheres.js'; +import { AnnotationsOverlay } from './ui/annotationsOverlay.js'; +import { mountSheetsBar } from './ui/sheetsBar.js'; document.documentElement.lang = lang; const canvas = document.getElementById('ioviewer-canvas'); @@ -58,7 +61,7 @@ function start(data, context) { renderer.localClippingEnabled = true; const world = new THREE.Scene(); - const initialBackground = '#1f2228'; + const initialBackground = data.meta.options?.initialBackground || '#1f2228'; const background = new THREE.Color(initialBackground); renderer.setClearColor(background, 1); const sky = new THREE.HemisphereLight('#ffffff', '#8a8f99', 1.6); @@ -81,15 +84,17 @@ function start(data, context) { startup?.('sceneStart'); const scene = createScene(); const points = new PointScene(data); + const lines = new LineScene(data); startup?.('sceneEnd'); data.releaseBinary(); // the scene has copied what it needs - if (!tooLarge && scene.totalCost === 0 && points.count === 0) showMessage(t('noGeometry')); + if (!tooLarge && scene.totalCost === 0 && points.count === 0 && lines.count === 0) showMessage(t('noGeometry')); // Starting at the whole model's cost, a GPU that draws it in time orbits at full detail; a slower one shrinks it. // Larger models start at about what an integrated GPU draws at 30 fps (a 200k-element model, 19.2e6): from a 1M one's // 134e6 the first gesture would take some 20 frames of 200 ms to shrink. A faster GPU grows the budget. const motionDetail = new MotionDetail(scene, requestRender, Math.min(scene.totalCost, 20e6)); world.add(scene.root); world.add(points.root); + world.add(lines.root); const panoramaSpheres = points.count ? createPanoramaSpheres(data.meta.panoramas) : null; if (panoramaSpheres) world.add(panoramaSpheres.mesh); const visibleBox = () => scene.visibleBox(); @@ -97,9 +102,12 @@ function start(data, context) { const sections = new Sections(scene, visibleBox(), data.meta.sections); points.syncVisibility(scene); points.syncAppearance(scene); + lines.syncVisibility(scene); + lines.syncAppearance(scene); const syncPointClipping = () => { const { planes, intersection } = sections.clipping(); points.setClipping(planes, intersection); + lines.setClipping(planes, intersection); }; syncPointClipping(); const hasMeshes = scene.slotCount > 0; @@ -108,6 +116,7 @@ function start(data, context) { const sectionGizmo = new SectionGizmo(sections, canvas); world.add(sectionGizmo.group); // outside scene.root: the picking id pass renders only the model const uiRoot = document.getElementById('ioviewer-ui'); + const annotationsOverlay = new AnnotationsOverlay(uiRoot, data, scene); const measure = new Measure(uiRoot); const grids = new GridAxes(uiRoot, data.meta.grids ?? []); world.add(measure.group, grids.group); // overlays too @@ -151,6 +160,7 @@ function start(data, context) { sectionGizmo.update(controls.camera); measure.update(controls.camera, rect); grids.update(controls.camera, rect); + annotationsOverlay.update(controls.camera, rect); motionDetail.begin(controls.camera, rect.height, performance.now()); firstRender?.('renderStart'); if (sections.fill && canFillSections) { @@ -176,7 +186,7 @@ function start(data, context) { measure.addEventListener('previewchange', requestRender); grids.addEventListener('change', requestRender); - const picker = new Picker(renderer, scene, camera, { points, pickFloat: testOptions.pickFloat }); + const picker = new Picker(renderer, scene, camera, { points, lines, pickFloat: testOptions.pickFloat }); const measureSnap = new MeasureSnap(picker, sections, data); let measureFrame = 0, measureHover = null; function clearMeasurePreview() { @@ -218,16 +228,28 @@ function start(data, context) { requestRender(); }); scene.root.addEventListener('change', (e) => { - if (e.detail.kind === 'appearance') points.syncAppearance(scene); + if (e.detail.kind === 'appearance') { + points.syncAppearance(scene); + lines.syncAppearance(scene); + } + if (e.detail.kind === 'appearance' || e.detail.kind === 'visibility') { + annotationsOverlay.update(controls.camera, canvas.getBoundingClientRect()); + } if (e.detail.kind !== 'visibility') return; // a highlight must not walk every instance for the bounds points.syncVisibility(scene); + lines.syncVisibility(scene); controls.invalidateBounds(); controls.resize(); }); + let viewCube; const selection = new Selection(); selection.addEventListener('change', () => scene.setHighlighted([...selection.values()])); const ui = mountUI({ root: uiRoot, data, scene, controls, picker, selection, measure }); + controls.addEventListener('mode2d', () => { + ui.sync2DState(); + viewCube?.set2D(controls.is2D); + }); mountSections({ root: uiRoot, ...ui, sections, selection, canFill: canFillSections, hasMeshes }); const { meta } = data; const restoreLinkedModels = mountLinks({ ...ui, files: meta.linkedFiles ?? [], elements: meta.elements, scene }); @@ -241,10 +263,20 @@ function start(data, context) { const { r, g, b } = background; // The equality point of the white and black contrast ratios against a linear sRGB background. const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b; - const text = luminance > Math.sqrt(0.0525) - 0.05 ? '#000' : '#fff'; + const isLight = luminance > Math.sqrt(0.0525) - 0.05; + const text = isLight ? '#000' : '#fff'; uiRoot.style.setProperty('--viewport-text', color === initialBackground ? '' : text); + lines.setLightBackground(isLight); + annotationsOverlay.setLightBackground(isLight); requestRender(); }; + { + const { r, g, b } = background; + const isLight = (0.2126 * r + 0.7152 * g + 0.0722 * b) > Math.sqrt(0.0525) - 0.05; + lines.setLightBackground(isLight); + annotationsOverlay.setLightBackground(isLight); + if (isLight) uiRoot.style.setProperty('--viewport-text', '#000'); + } for (const popover of mountDisplay({ root: uiRoot, toolbar: ui.toolbar, scene, meta, grids, initialBackground, setBackground, hasMeshes })) ui.onEscape(popover.close); ui.toolbar.setHandler('distance', () => { @@ -312,7 +344,26 @@ function start(data, context) { controls.resize(); // also schedules the first frame for an empty model controls.fitBox(visibleBox(), false); const scanMap = mountScanMap(uiRoot, data, points, scene, controls, requestRender); - const viewCube = new ViewCube(document.getElementById('ioviewer-ui'), camera, controls); // home = this load view + viewCube = new ViewCube(document.getElementById('ioviewer-ui'), camera, controls); // home = this load view + const sheetsBar = mountSheetsBar({ + root: uiRoot, + world, + meta, + scene, + annotationsOverlay, + apply2DMode: (enabled, box, animate) => { + controls.set2DMode(enabled, box, animate); + ui.sync2DState(); + viewCube.set2D(controls.is2D); + }, + setBackground, + requestRender, + }); + if (!meta.sheets?.length && meta.options?.initial2DMode) { + controls.set2DMode(true, visibleBox(), false); + ui.sync2DState(); + viewCube.set2D(true); + } // The canvas and the view cube take no focus, so a press on them takes it from a panel field or a toolbar button: // the hotkeys work again and Space or Enter does not repeat the last tool. @@ -320,6 +371,6 @@ function start(data, context) { if (e.target === canvas || viewCube.element.contains(e.target)) document.activeElement?.blur(); }, true); - window.__ioviewer = { scene, points, motionDetail, controls, picker, selection, ui, viewCube, sections, sectionGizmo, + window.__ioviewer = { scene, points, lines, annotationsOverlay, sheetsBar, motionDetail, controls, picker, selection, ui, viewCube, sections, sectionGizmo, measure, measureSnap, grids, clashes, timeliner, ready, get camera() { return controls.camera; } }; } diff --git a/src/IOViewer/Viewer/src/nav/controls.js b/src/IOViewer/Viewer/src/nav/controls.js index 3d269a9..b0f1f42 100644 --- a/src/IOViewer/Viewer/src/nav/controls.js +++ b/src/IOViewer/Viewer/src/nav/controls.js @@ -40,6 +40,8 @@ export class NavigationControls extends EventTarget { this.visibleBox = visibleBox; this.target = new THREE.Vector3(); this.leftButtonMode = 'orbit'; + this.is2D = false; + this._saved3D = null; this._perspective = camera; this._defaultFov = camera.fov; this._orthographic = new THREE.OrthographicCamera(-1, 1, 1, -1); @@ -143,6 +145,21 @@ export class NavigationControls extends EventTarget { fitBox(box, animate = true) { if (box.isEmpty()) return; const sphere = box.getBoundingSphere(new THREE.Sphere()); + if (this.is2D) { + this.setProjection('orthographic'); + this.camera.up.set(0, 1, 0); + const size = box.getSize(new THREE.Vector3()); + const span = Math.max(size.x, size.y, sphere.radius * 2, 1e-2); + const center = box.getCenter(new THREE.Vector3()); + const position = new THREE.Vector3(center.x, center.y, box.max.z + span * 2); + this._set(position, center); + const aspect = Math.max(this.dom.clientWidth / Math.max(this.dom.clientHeight, 1), 1e-3); + const camHalf = Math.max(this.camera.top, 1e-6); + const needHalf = Math.max(size.y / 2, size.x / (2 * aspect), 1e-4) * 1.06; + this.camera.zoom = camHalf / needHalf; + this.resize(); + return; + } const radius = Math.max(sphere.radius, 1e-3); const halfFov = THREE.MathUtils.degToRad(this._perspective.fov / 2); const aspect = this.dom.clientWidth / Math.max(this.dom.clientHeight, 1); @@ -157,6 +174,51 @@ export class NavigationControls extends EventTarget { } } + set2DMode(enabled, box = null, animate = false) { + const next = !!enabled; + if (next === this.is2D) { + if (next && box && !box.isEmpty()) this.fitBox(box, animate); + return; + } + this._stopAnimation(); + if (next) { + 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 = true; + this.setProjection('orthographic'); + this.leftButtonMode = 'pan'; + const targetBox = box && !box.isEmpty() ? box : this.visibleBox(); + this.fitBox(targetBox, false); + } else { + this.is2D = false; + this.camera.up.set(0, 0, 1); + const saved = this._saved3D; + this._saved3D = null; + if (saved) { + this.setProjection(saved.projection); + this.leftButtonMode = saved.leftButtonMode; + this.camera.zoom = saved.zoom; + this._set(saved.position, saved.target); + } else { + this.setProjection('perspective'); + this.leftButtonMode = 'orbit'; + const targetBox = box && !box.isEmpty() ? box : this.visibleBox(); + if (!targetBox.isEmpty()) { + const center = targetBox.getCenter(new THREE.Vector3()); + const radius = Math.max(targetBox.getBoundingSphere(new THREE.Sphere()).radius, 1); + this._set(center.clone().addScaledVector(DEFAULT_DIRECTION, radius * 2.5), center); + this.fitBox(targetBox, false); + } + } + } + this.dispatchEvent(detail('mode2d', { enabled: this.is2D })); + } + zoomToBox(box) { this.fitBox(box, true); } @@ -231,7 +293,8 @@ export class NavigationControls extends EventTarget { this._stopAnimation(); this.dom.setPointerCapture(e.pointerId); e.preventDefault(); // middle button autoscroll - const mode = e.button === 0 && e.shiftKey ? 'box' : e.button === 0 && this.leftButtonMode === 'orbit' ? 'orbit' : 'pan'; + const mode = e.button === 0 && e.shiftKey ? 'box' + : e.button === 0 && !this.is2D && this.leftButtonMode === 'orbit' ? 'orbit' : 'pan'; const point = { x: e.clientX, y: e.clientY }; let pivot = null; if (mode === 'orbit') { diff --git a/src/IOViewer/Viewer/src/nav/viewCube.js b/src/IOViewer/Viewer/src/nav/viewCube.js index 3978bc8..ab61942 100644 --- a/src/IOViewer/Viewer/src/nav/viewCube.js +++ b/src/IOViewer/Viewer/src/nav/viewCube.js @@ -228,6 +228,10 @@ export class ViewCube { } } + set2D(enabled) { + this.element.classList.toggle('ioviewer-viewcube-2d', !!enabled); + } + update() { if (!this.renderer) return; const main = this.controls.camera; diff --git a/src/IOViewer/Viewer/src/tools/display.js b/src/IOViewer/Viewer/src/tools/display.js index 9d46985..8573745 100644 --- a/src/IOViewer/Viewer/src/tools/display.js +++ b/src/IOViewer/Viewer/src/tools/display.js @@ -67,7 +67,17 @@ export function mountDisplay({ root, toolbar, scene, meta, grids, initialBackgro color.focus(); applyBackground(); }); - background.append(label, reset); + const presets = el('div', 'ioviewer-bg-presets'); + for (const [hex, key] of [['#14171c', 'display.bgCadDark'], ['#ffffff', 'display.bgPaper']]) { + const preset = el('button', 'ioviewer-text-button', t(key)); + preset.type = 'button'; + preset.addEventListener('click', () => { + color.value = hex; + applyBackground(); + }); + presets.append(preset); + } + background.append(label, presets, reset); modes.element.append(background); toolbar.setActive('grids', grids.visible); diff --git a/src/IOViewer/Viewer/src/tools/measureSnap.js b/src/IOViewer/Viewer/src/tools/measureSnap.js index 5225772..8f8d24a 100644 --- a/src/IOViewer/Viewer/src/tools/measureSnap.js +++ b/src/IOViewer/Viewer/src/tools/measureSnap.js @@ -114,7 +114,19 @@ export class MeasureSnap { else { const meta = this.data.meta.geometries[index]; const positions = geometryPositions({ view: this.data.readView }, meta); - geometry = { positions, ...featureEdges(positions, this.data.readView(meta.indices)) }; + const rawIndices = this.data.readView(meta.indices); + if (meta.kind === 'lines') { + const edges = []; + const vertices = new Set(); + const segLen = rawIndices.length - (rawIndices.length % 2); + for (let k = 0; k < segLen; k++) { + edges.push(rawIndices[k]); + vertices.add(rawIndices[k]); + } + geometry = { positions, edges, vertices }; + } else { + geometry = { positions, ...featureEdges(positions, rawIndices) }; + } } this.cache.set(index, geometry); if (this.cache.size > CACHE_SIZE) this.cache.delete(this.cache.keys().next().value); @@ -178,6 +190,55 @@ export class MeasureSnap { } } } + if (tile.lineInstances?.size && this.data.meta.lines) { + const { geometry: lGeo, matrix: lTrans } = this.data.meta.lines; + for (const lineIdx of tile.lineInstances) { + const [index] = this.data.readView({ t: 'u32', o: lGeo.o + lineIdx * 4, n: 1 }); + const meta = this.data.meta.geometries[index]; + const cost = Math.max(meta.indices.n, meta.positions.n / 3); + if (cost > budget) continue; + budget -= cost; + const { positions, vertices, edges } = this._geometry(index); + const m = this.data.readView({ t: 'f32', o: lTrans.o + lineIdx * 48, n: 12 }); + matrix.set(m[0], m[3], m[6], m[9], m[1], m[4], m[7], m[10], m[2], m[5], m[8], m[11], 0, 0, 0, 1); + const points = new Map(); + for (const v of vertices) { + const point = new THREE.Vector3().fromArray(positions, v * 3).applyMatrix4(matrix); + const p = new THREE.Vector4(point.x, point.y, point.z, 1).applyMatrix4(projection); + points.set(v, [point, p]); + if (p.w > 0 && p.z >= -p.w && p.z <= p.w) { + const [sx, sy] = screen(p, rect); + const dist = (sx - x) ** 2 + (sy - y) ** 2; + if (dist <= SNAP_RADIUS ** 2 && (!best || best.kind !== 'vertex' || dist < best.distance)) { + if (!isClipped(point, planes, intersection)) best = { kind: 'vertex', distance: dist, point: point.clone() }; + } + } + } + if (best?.kind === 'vertex') continue; + for (let k = 0; k < edges.length; k += 2) { + const [a, pa] = points.get(edges[k]), [b, pb] = points.get(edges[k + 1]); + const mp = middle.copy(a).lerp(b, 0.5), mpp = projected.copy(pa).lerp(pb, 0.5); + if (mpp.w > 0 && mpp.z >= -mpp.w && mpp.z <= mpp.w) { + const [sx, sy] = screen(mpp, rect); + const dist = (sx - x) ** 2 + (sy - y) ** 2; + if (dist <= SNAP_RADIUS ** 2 && (!best || best.kind !== 'midpoint' || dist < best.distance)) { + if (!isClipped(mp, planes, intersection)) best = { kind: 'midpoint', distance: dist, point: mp.clone() }; + } + } + if (best?.kind === 'midpoint') continue; + for (const range of visibleEdgeRanges(a, b, pa, pb, planes, intersection)) { + const t = edgeParameter(pa, pb, range, rect, x, y); + if (t === null) continue; + const ep = middle.copy(a).lerp(b, t), epp = projected.copy(pa).lerp(pb, t); + const [sx, sy] = screen(epp, rect); + const dist = (sx - x) ** 2 + (sy - y) ** 2; + if (dist <= SNAP_RADIUS ** 2 && (!best || dist < best.distance)) { + best = { kind: 'edge', distance: dist, point: ep.clone() }; + } + } + } + } + } return best ? { kind: best.kind, point: best.point } : { kind: 'surface', point: tile.point.clone() }; } } diff --git a/src/IOViewer/Viewer/src/ui/annotationsOverlay.js b/src/IOViewer/Viewer/src/ui/annotationsOverlay.js new file mode 100644 index 0000000..cc15932 --- /dev/null +++ b/src/IOViewer/Viewer/src/ui/annotationsOverlay.js @@ -0,0 +1,107 @@ +import * as THREE from 'three'; + +/** + * HiDPI Canvas2D overlay drawing crisp CAD text annotations (`META.annotations`) synchronized with the camera. + * Respects element visibility, active sheet filtering, rotation, attachment and adaptive light/dark contrast. + */ +export class AnnotationsOverlay { + constructor(container, data, scene) { + this.annotations = data.meta.annotations ?? []; + this.scene = scene; + this.activeSheet = null; + this.lightBackground = false; + this.canvas = document.createElement('canvas'); + this.canvas.className = 'ioviewer-annotations'; + this.canvas.setAttribute('aria-hidden', 'true'); + if (this.annotations.length === 0) this.canvas.hidden = true; + container.append(this.canvas); + this._ctx = this.canvas.getContext('2d'); + this._p = new THREE.Vector3(); + this._x = new THREE.Vector3(); + } + + setSheet(sheetKey) { + this.activeSheet = sheetKey ?? null; + } + + setLightBackground(light) { + this.lightBackground = !!light; + } + + update(camera, rect) { + if (!this.annotations.length || !this._ctx || rect.width < 1 || rect.height < 1) return; + const dpr = window.devicePixelRatio || 1; + const targetW = Math.round(rect.width * dpr); + const targetH = Math.round(rect.height * dpr); + if (this.canvas.width !== targetW || this.canvas.height !== targetH) { + this.canvas.width = targetW; + this.canvas.height = targetH; + } + const ctx = this._ctx; + ctx.setTransform(dpr, 0, 0, dpr, 0, 0); + ctx.clearRect(0, 0, rect.width, rect.height); + + const viewProj = new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse); + const viewInv = camera.matrixWorldInverse; + const orthoPxPerUnit = camera.isOrthographicCamera + ? rect.height * camera.zoom / Math.max(camera.top - camera.bottom, 1e-9) + : 0; + const tanHalfFov = camera.isPerspectiveCamera ? Math.tan(THREE.MathUtils.degToRad(camera.fov / 2)) : 0; + + for (const a of this.annotations) { + if (this.activeSheet != null && a.sheet != null && a.sheet !== this.activeSheet) continue; + if (a.element >= 0 && this.scene.instancesOf(a.element).length > 0 && !this.scene.isVisible(a.element)) continue; + + this._p.set(a.position[0], a.position[1], a.position[2]); + const viewPos = this._p.clone().applyMatrix4(viewInv); + if (camera.isPerspectiveCamera && viewPos.z >= -camera.near) continue; + + const pxPerUnit = orthoPxPerUnit || (rect.height / (2 * Math.max(-viewPos.z, 1e-6) * tanHalfFov)); + const fontPx = a.height * pxPerUnit; + if (!Number.isFinite(fontPx) || fontPx < 1.5 || fontPx > 800) continue; + + const ndc = this._p.clone().applyMatrix4(viewProj); + if (ndc.z < -1 || ndc.z > 1) continue; + const sx = (ndc.x * 0.5 + 0.5) * rect.width; + const sy = (-ndc.y * 0.5 + 0.5) * rect.height; + if (sx < -400 || sx > rect.width + 400 || sy < -400 || sy > rect.height + 400) continue; + + // Project direction vector to follow view rotation smoothly. + this._x.set( + a.position[0] + Math.cos(a.rotation), + a.position[1] + Math.sin(a.rotation), + a.position[2], + ).applyMatrix4(viewProj); + const sx2 = (this._x.x * 0.5 + 0.5) * rect.width; + const sy2 = (-this._x.y * 0.5 + 0.5) * rect.height; + const angle = Math.atan2(sy2 - sy, sx2 - sx); + + let [r, g, b] = a.color + ? [Math.round(a.color[0] * 255), Math.round(a.color[1] * 255), Math.round(a.color[2] * 255)] + : this.lightBackground ? [17, 24, 39] : [229, 231, 235]; + if (this.lightBackground && r > 230 && g > 230 && b > 230) [r, g, b] = [17, 24, 39]; + else if (!this.lightBackground && r < 20 && g < 20 && b < 20) [r, g, b] = [241, 245, 249]; + + ctx.save(); + ctx.translate(sx, sy); + if (Math.abs(angle) > 1e-4) ctx.rotate(angle); + ctx.font = `${fontPx.toFixed(2)}px system-ui, -apple-system, "Segoe UI", Arial, sans-serif`; + ctx.fillStyle = `rgb(${r},${g},${b})`; + + const att = a.attachment || 1; + const hMod = (att - 1) % 3; // 0=left, 1=center, 2=right + const vRow = Math.floor((att - 1) / 3); // 0=top, 1=middle, 2=bottom + ctx.textAlign = hMod === 1 ? 'center' : hMod === 2 ? 'right' : 'left'; + ctx.textBaseline = vRow === 1 ? 'middle' : vRow >= 2 ? 'bottom' : 'top'; + + const lines = a.text.split('\n'); + const lineStep = fontPx * 1.25; + const yOffset = vRow === 1 ? -((lines.length - 1) * lineStep) / 2 + : vRow >= 2 ? -(lines.length - 1) * lineStep : 0; + for (let i = 0; i < lines.length; i++) { + ctx.fillText(lines[i], 0, yOffset + i * lineStep); + } + ctx.restore(); + } + } +} diff --git a/src/IOViewer/Viewer/src/ui/app.js b/src/IOViewer/Viewer/src/ui/app.js index a0a7c2d..10e4427 100644 --- a/src/IOViewer/Viewer/src/ui/app.js +++ b/src/IOViewer/Viewer/src/ui/app.js @@ -71,6 +71,7 @@ export function mountUI({ root, data, scene, controls, picker, selection, measur const toolbar = createToolbar(root, toolbarGroups); const setLeftMode = (mode) => { + if (controls.is2D && mode === 'orbit') return; controls.setLeftButtonMode(mode); toolbar.setActive('orbit', mode === 'orbit'); toolbar.setActive('pan', mode === 'pan'); @@ -80,11 +81,26 @@ export function mountUI({ root, data, scene, controls, picker, selection, measur setLeftMode(controls.leftButtonMode); toolbar.setHandler('fit', fitAll); toolbar.setHandler('projection', () => { + if (controls.is2D) return; const orthographic = !controls.camera.isOrthographicCamera; controls.setProjection(orthographic ? 'orthographic' : 'perspective'); toolbar.setActive('projection', orthographic); }); toolbar.setActive('projection', false); + const sync2DState = () => { + const is2D = !!controls.is2D; + toolbar.setActive('mode2d', is2D); + toolbar.setEnabled('orbit', !is2D); + toolbar.setEnabled('projection', !is2D); + toolbar.setActive('projection', is2D || controls.camera.isOrthographicCamera); + toolbar.setActive('orbit', !is2D && controls.leftButtonMode === 'orbit'); + toolbar.setActive('pan', is2D || controls.leftButtonMode === 'pan'); + }; + toolbar.setHandler('mode2d', () => { + controls.set2DMode(!controls.is2D, scene.visibleBox(), false); + sync2DState(); + }); + sync2DState(); if (document.fullscreenEnabled) { toolbar.setHandler('fullscreen', () => { const request = document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen(); @@ -149,5 +165,5 @@ export function mountUI({ root, data, scene, controls, picker, selection, measur mountStatusBar(document.getElementById('ioviewer-status'), selection, scene.elementCount); mountTruncationBanner(root, meta.truncated); - return { shell, toolbar, contextMenu, onEscape: (handler) => escapeHandlers.push(handler) }; + return { shell, toolbar, contextMenu, sync2DState, onEscape: (handler) => escapeHandlers.push(handler) }; } diff --git a/src/IOViewer/Viewer/src/ui/icons.js b/src/IOViewer/Viewer/src/ui/icons.js index 728b365..777e3c0 100644 --- a/src/IOViewer/Viewer/src/ui/icons.js +++ b/src/IOViewer/Viewer/src/ui/icons.js @@ -21,6 +21,7 @@ export const icons = { pan: svg(''), fit: svg(''), projection: svg(cube), + mode2d: svg(''), plane: svg(''), box: svg(`${cube}`), resetSections: svg(''), diff --git a/src/IOViewer/Viewer/src/ui/sheetsBar.js b/src/IOViewer/Viewer/src/ui/sheetsBar.js new file mode 100644 index 0000000..16bc958 --- /dev/null +++ b/src/IOViewer/Viewer/src/ui/sheetsBar.js @@ -0,0 +1,91 @@ +import * as THREE from 'three'; +import { el } from './dom.js'; +import { t } from '../i18n.js'; + +/** + * Sheet / Model Space switcher rendered at the bottom-left when `META.sheets` defines multiple layouts. + * Isolates elements & annotations of the active space, draws paper extents when given, and syncs 2D mode/background. + */ +export function mountSheetsBar({ + root, + world, + meta, + scene, + annotationsOverlay, + apply2DMode, + setBackground, + requestRender, +}) { + const sheets = meta.sheets ?? []; + if (!sheets.length) return { active: null, setSheet: () => {} }; + + const allIndices = new Set(sheets.flatMap((s) => s.elements)); + const bar = el('div', 'ioviewer-sheets ioviewer-floating'); + bar.setAttribute('role', 'tablist'); + bar.setAttribute('aria-label', t('sheets.label')); + + const paperFrame = new THREE.LineLoop( + new THREE.BufferGeometry(), + new THREE.LineBasicMaterial({ color: '#94a3b8', transparent: true, opacity: 0.55 }), + ); + paperFrame.visible = false; + world.add(paperFrame); + + let current = null; + const buttons = new Map(); + + function selectSheet(key, initial = false) { + const sheet = sheets.find((s) => s.key === key) ?? sheets[0]; + if (!sheet) return; + current = sheet; + for (const [k, btn] of buttons) { + const selected = k === sheet.key; + btn.classList.toggle('active', selected); + btn.setAttribute('aria-selected', String(selected)); + } + + const keep = new Set(sheet.elements); + const hide = []; + for (const i of allIndices) { + if (!keep.has(i)) hide.push(i); + } + scene.replaceLayerHidden('sheet', hide); + annotationsOverlay?.setSheet(sheet.key); + + if (!sheet.isModel && sheet.paperBounds) { + const { min, max } = sheet.paperBounds; + const z = min[2]; + paperFrame.geometry.setFromPoints([ + new THREE.Vector3(min[0], min[1], z), + new THREE.Vector3(max[0], min[1], z), + new THREE.Vector3(max[0], max[1], z), + new THREE.Vector3(min[0], max[1], z), + ]); + paperFrame.visible = true; + } else { + paperFrame.visible = false; + } + + if (sheet.background) setBackground(sheet.background, !initial); + const box = sheet.paperBounds + ? new THREE.Box3(new THREE.Vector3(...sheet.paperBounds.min), new THREE.Vector3(...sheet.paperBounds.max)) + : scene.visibleBox(); + apply2DMode(!!sheet.is2D, box, false); + requestRender(); + } + + for (const sheet of sheets) { + const btn = el('button', 'ioviewer-sheet-tab', sheet.name); + btn.type = 'button'; + btn.setAttribute('role', 'tab'); + btn.dataset.sheet = sheet.key; + btn.addEventListener('click', () => selectSheet(sheet.key, false)); + buttons.set(sheet.key, btn); + bar.append(btn); + } + if (sheets.length > 1) root.append(bar); + + const initialKey = meta.options?.initialSheet ?? sheets[0].key; + selectSheet(initialKey, true); + return { get active() { return current; }, setSheet: (k) => selectSheet(k, false) }; +} diff --git a/src/IOViewer/Viewer/src/ui/toolbar.js b/src/IOViewer/Viewer/src/ui/toolbar.js index 6c4f79e..f93da8b 100644 --- a/src/IOViewer/Viewer/src/ui/toolbar.js +++ b/src/IOViewer/Viewer/src/ui/toolbar.js @@ -4,7 +4,7 @@ import { el, iconButton } from './dom.js'; // Groups and their order; labels come from t('group.'), tooltips from t('tool.'), icons from icons[]. export const toolbarGroups = [ - { id: 'navigation', items: ['orbit', 'pan', 'fit', 'projection'] }, + { id: 'navigation', items: ['orbit', 'pan', 'fit', 'projection', 'mode2d'] }, { id: 'sections', items: ['plane', 'box', 'resetSections'] }, { id: 'measure', items: ['distance'] }, { id: 'display', items: ['displayMode', 'grids', 'opacity'] }, diff --git a/src/IOViewer/Viewer/styles/viewer.css b/src/IOViewer/Viewer/styles/viewer.css index 35731d4..4d9f309 100644 --- a/src/IOViewer/Viewer/styles/viewer.css +++ b/src/IOViewer/Viewer/styles/viewer.css @@ -1420,3 +1420,56 @@ label.ioviewer-row:hover { .ioviewer-player .ioviewer-segmented { flex: none; } + +/* CAD 2D overlays, sheet tabs and background presets */ +.ioviewer-annotations { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + pointer-events: none; + z-index: 1; +} + +.ioviewer-sheets { + left: 60px; + bottom: 12px; + display: flex; + align-items: center; + gap: 4px; + padding: 4px; + max-width: min(460px, calc(100% - 140px)); + overflow-x: auto; + z-index: 4; +} + +.ioviewer-sheet-tab { + border: none; + border-radius: 6px; + background: transparent; + color: var(--text); + font: 500 12px/1.4 inherit; + padding: 5px 10px; + cursor: pointer; + white-space: nowrap; +} + +.ioviewer-sheet-tab:hover { + background: rgba(255, 255, 255, 0.08); +} + +.ioviewer-sheet-tab.active { + background: var(--accent, #2563eb); + color: #fff; +} + +.ioviewer-viewcube-2d { + opacity: 0.25; + pointer-events: none; +} + +.ioviewer-bg-presets { + display: flex; + gap: 6px; + margin: 4px 0; +} diff --git a/tests/IOViewer.Tests/HtmlViewerExporterTests.cs b/tests/IOViewer.Tests/HtmlViewerExporterTests.cs index 748d55e..cb41cff 100644 --- a/tests/IOViewer.Tests/HtmlViewerExporterTests.cs +++ b/tests/IOViewer.Tests/HtmlViewerExporterTests.cs @@ -786,7 +786,7 @@ public void Elements_ListEveryElementWithLevelAndModelIdentity() } [Fact] - public void LinesAndUnknown_AreSkipped_PointsAreDrawn() + public void Unknown_IsSkipped_LinesAndPointsAreDrawn() { var scene = TestScenes.Empty(); Cube(scene, Vector3d.Zero); @@ -797,9 +797,10 @@ public void LinesAndUnknown_AreSkipped_PointsAreDrawn() var view = ViewerHtml.Export(new ViewerDocument(scene), new HtmlViewerOptions { MaxMeshVertices = CubeVertices.Length }); - Assert.Equal(2, ViewerPayloadWriter.UndrawnInstances(scene)); - Assert.Equal(2, view.Meta.GetProperty("skipped").GetProperty("instances").GetInt32()); + Assert.Equal(1, ViewerPayloadWriter.UndrawnInstances(scene)); + Assert.Equal(1, view.Meta.GetProperty("skipped").GetProperty("instances").GetInt32()); Assert.Equal(1, view.Meta.GetProperty("points").GetProperty("count").GetInt32()); + Assert.Equal(1, view.Meta.GetProperty("lines").GetProperty("count").GetInt32()); Assert.Equal(1, view.InstanceCount); Assert.Equal(2, view.Meta.GetProperty("truncated").GetProperty("totalMeshes").GetInt32()); Assert.Equal(5, view.Meta.GetProperty("elements").GetArrayLength()); diff --git a/tests/IOViewer.Tests/LinePayloadTests.cs b/tests/IOViewer.Tests/LinePayloadTests.cs new file mode 100644 index 0000000..66c9b55 --- /dev/null +++ b/tests/IOViewer.Tests/LinePayloadTests.cs @@ -0,0 +1,151 @@ +using IOScene; +using IOViewer.Exporters; +using IOViewer.Model; +using Xunit; + +namespace IOViewer.Tests; + +public class LinePayloadTests +{ + private static SceneDocument CadDrawing() + { + var scene = new SceneDocument(); + scene.Models.Add(new SceneModel { Id = 1, Key = "plan", Name = "plan.dwg" }); + scene.Materials.Add(new SceneMaterial + { + Id = 1, + Name = "Walls", + Color = new RgbaColor(255, 255, 255, 255), + }); + scene.Elements.Add(new SceneElement { Id = 1, ModelId = 1, Name = "WallLine", Category = "WALL" }); + scene.Elements.Add(new SceneElement { Id = 2, ModelId = 1, Name = "SheetBorder", Category = "STAMP" }); + scene.Geometries.Add(new SceneGeometry + { + Id = 1, + Topology = SceneTopology.Lines, + Vertices = + [ + new Vector3d(0, 0, 0), + new Vector3d(4, 0, 0), + new Vector3d(4, 0, 0), + new Vector3d(4, 2, 0), + ], + }); + scene.Geometries.Add(new SceneGeometry + { + Id = 2, + Topology = SceneTopology.Lines, + Vertices = + [ + new Vector3d(-1, -1, 0), + new Vector3d(5, -1, 0), + ], + }); + scene.Instances.Add(new SceneInstance { ElementId = 1, GeometryId = 1, MaterialId = 1 }); + scene.Instances.Add(new SceneInstance { ElementId = 2, GeometryId = 2, MaterialId = 1 }); + return scene; + } + + [Fact] + public void Lines_Are_Written_As_Format3_LineSegments_And_Not_Skipped() + { + var scene = CadDrawing(); + var view = ViewerHtml.Export(new ViewerDocument(scene)); + + Assert.Equal(3, view.Meta.GetProperty("format").GetInt32()); + Assert.Equal(0, ViewerPayloadWriter.UndrawnInstances(scene)); + Assert.Equal("lines", view.Geometries[0].GetProperty("kind").GetString()); + Assert.Equal("lines", view.Geometries[1].GetProperty("kind").GetString()); + Assert.Equal(2, view.Meta.GetProperty("lines").GetProperty("count").GetInt32()); + } + + [Fact] + public void Annotations_And_Sheets_Are_Serialized_With_Centered_Coordinates() + { + var doc = new ViewerDocument(CadDrawing()) + { + Annotations = + [ + new ViewerAnnotation + { + Text = "ROOM 101", + Position = new Vector3d(2, 1, 0), + Height = 0.25, + ElementId = 1, + SheetKey = "model", + }, + ], + Sheets = + [ + new ViewerSheet + { + Key = "sheet:A102", + Name = "A102 - Plans", + IsModelSpace = false, + Is2D = true, + BackgroundColor = "#ffffff", + PaperBounds = new BoundingBox3d(new Vector3d(-1, -1, 0), new Vector3d(5, 3, 0)), + ElementIds = [2], + }, + new ViewerSheet + { + Key = "model", + Name = "Model", + IsModelSpace = true, + Is2D = true, + BackgroundColor = "#14171c", + ElementIds = [1], + }, + ], + }; + + var view = ViewerHtml.Export(doc, new HtmlViewerOptions + { + Initial2DMode = true, + InitialBackground = "#ffffff", + }); + + Assert.True(view.Meta.GetProperty("options").GetProperty("initial2DMode").GetBoolean()); + Assert.Equal("#ffffff", view.Meta.GetProperty("options").GetProperty("initialBackground").GetString()); + + var annotations = view.Meta.GetProperty("annotations"); + Assert.Equal(1, annotations.GetArrayLength()); + Assert.Equal("ROOM 101", annotations[0].GetProperty("text").GetString()); + Assert.Equal(0, annotations[0].GetProperty("element").GetInt32()); + Assert.Equal("model", annotations[0].GetProperty("sheet").GetString()); + + var sheets = view.Meta.GetProperty("sheets"); + Assert.Equal(2, sheets.GetArrayLength()); + Assert.Equal("sheet:A102", sheets[0].GetProperty("key").GetString()); + Assert.False(sheets[0].GetProperty("isModel").GetBoolean()); + Assert.True(sheets[0].GetProperty("is2D").GetBoolean()); + Assert.Equal("#ffffff", sheets[0].GetProperty("background").GetString()); + Assert.Equal([1], sheets[0].GetProperty("elements").EnumerateArray().Select(x => x.GetInt32())); + Assert.True(sheets[0].TryGetProperty("paperBounds", out _)); + + Assert.Equal("model", sheets[1].GetProperty("key").GetString()); + Assert.True(sheets[1].GetProperty("isModel").GetBoolean()); + Assert.Equal("#14171c", sheets[1].GetProperty("background").GetString()); + } + + [Fact] + public void Lines_Preserve_SubMillimetre_PaperSheet_Precision() + { + var scene = new SceneDocument(); + scene.Models.Add(new SceneModel { Id = 1, Key = "sheet", Name = "sheet" }); + scene.Elements.Add(new SceneElement { Id = 1, ModelId = 1, Name = "ChairArc", Category = "FURN" }); + scene.Geometries.Add(new SceneGeometry + { + Id = 1, + Topology = SceneTopology.Lines, + Vertices = [new Vector3d(0, 0, 0), new Vector3d(0.00035, 0.00025, 0)], + }); + scene.Instances.Add(new SceneInstance { ElementId = 1, GeometryId = 1 }); + + var view = ViewerHtml.Export(new ViewerDocument(scene)); + Assert.False(view.Geometries[0].TryGetProperty("q", out _)); + double[] pos = view.Positions(view.Geometries[0]); + Assert.Equal(0.00035, pos[3], 1e-6); + Assert.Equal(0.00025, pos[4], 1e-6); + } +} diff --git a/tests/IOViewer.Tests/ModelAndCliIntegrationTests.cs b/tests/IOViewer.Tests/ModelAndCliIntegrationTests.cs index 2afe96b..e2b5dce 100644 --- a/tests/IOViewer.Tests/ModelAndCliIntegrationTests.cs +++ b/tests/IOViewer.Tests/ModelAndCliIntegrationTests.cs @@ -313,7 +313,7 @@ public void Cli_ConvertsEveryJsonKindToHtml(string kind) { var scene = TestScenes.Empty("Json kinds"); scene.Mesh([new(0, 0, 0), new(1, 0, 0), new(0, 1, 0)], [0, 1, 2]); - scene.Place(scene.Geometry([new(0, 0, 0), new(0, 0, 1)], [], topology: SceneTopology.Lines)); + scene.Place(scene.Geometry([new(0, 0, 0), new(0, 0, 1)], [], topology: (SceneTopology)7)); var tempJson = Path.Combine(Path.GetTempPath(), $"test_model_{Guid.NewGuid():N}.json"); var tempHtml = Path.Combine(Path.GetTempPath(), $"test_viewer_{Guid.NewGuid():N}.html"); @@ -334,7 +334,7 @@ public void Cli_ConvertsEveryJsonKindToHtml(string kind) Assert.Equal(0, code); var view = ViewerHtml.Parse(File.ReadAllText(tempHtml)); Assert.Equal(kind == "legacy" ? 3 : 1, view.InstanceCount); - Assert.Equal(kind == "legacy" ? "" : "Warning: 1 meshes of lines or an unknown kind are not shown; the viewer draws triangles and point clouds.", + Assert.Equal(kind == "legacy" ? "" : "Warning: 1 meshes of an unknown kind are not shown; the viewer draws triangles, lines and point clouds.", errors.ToString().Trim()); } finally From 90672e304b4889f4f7f9c95059efd9abe409a38d Mon Sep 17 00:00:00 2001 From: mahach666 <79989386+mahach666@users.noreply.github.com> Date: Wed, 2 Dec 2026 15:31:16 +0300 Subject: [PATCH 2/3] Fix CAD text framing, visibility and sheet persistence --- docs/getting-started.md | 3 + src/IOViewer/Exporters/JsonViewerExporter.cs | 12 + src/IOViewer/Viewer/dist/viewer.js | 368 +++++++++--------- src/IOViewer/Viewer/src/engine/modelScene.js | 40 +- src/IOViewer/Viewer/src/main.js | 19 +- .../Viewer/src/ui/annotationsOverlay.js | 97 +++-- src/IOViewer/Viewer/src/ui/sheetsBar.js | 11 +- src/IOViewer/Viewer/test/e2e/cad.spec.js | 47 +++ src/IOViewer/Viewer/test/e2e/tools.spec.js | 2 +- tests/IOViewer.Tests/JsonAndImportTests.cs | 38 ++ tests/fixtures/viewer/cad-annotations.json | 23 ++ 11 files changed, 433 insertions(+), 227 deletions(-) create mode 100644 src/IOViewer/Viewer/test/e2e/cad.spec.js create mode 100644 tests/fixtures/viewer/cad-annotations.json diff --git a/docs/getting-started.md b/docs/getting-started.md index 3c7435d..0d75fbd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -146,6 +146,9 @@ what breaks the scene contract, such as an instance that names a missing element The model's up axis is +Z. The interface is in Russian when the browser language is Russian and in English otherwise. +Viewer JSON can store drawing labels in `Annotations` and layouts in `Sheets`. Set `InitialSheetKey` to choose the first layout shown. +A label can reference an `ElementId` so it follows that element's visibility. Its optional `Width` sets the wrap width in scene metres. + Point clouds have a collapsible minimap showing their XY footprint and the camera heading. Colored point cloud inputs keep their source RGB. A viewer snapshot can also contain `PointColors`, a dictionary using scene geometry IDs and base64 RGB triplets in vertex order, and `Panoramas`, a list with `ElementId`, XYZ `Position` in scene metres, and a base64 `Jpeg`. Use a 2:1 equirectangular JPEG with its diff --git a/src/IOViewer/Exporters/JsonViewerExporter.cs b/src/IOViewer/Exporters/JsonViewerExporter.cs index 5c7b9c4..a32ad4b 100644 --- a/src/IOViewer/Exporters/JsonViewerExporter.cs +++ b/src/IOViewer/Exporters/JsonViewerExporter.cs @@ -78,6 +78,12 @@ internal sealed class ViewerJsonFile public Dictionary? PointIntensities { get; set; } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public List? Panoramas { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public List? Annotations { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public List? Sheets { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? InitialSheetKey { get; set; } public static ViewerJsonFile From(ViewerDocument doc) => new() { @@ -91,6 +97,9 @@ internal sealed class ViewerJsonFile PointColors = doc.PointColors is { Count: > 0 } ? doc.PointColors : null, PointIntensities = doc.PointIntensities is { Count: > 0 } ? doc.PointIntensities : null, Panoramas = doc.Panoramas is { Count: > 0 } ? doc.Panoramas : null, + Annotations = doc.Annotations is { Count: > 0 } ? doc.Annotations : null, + Sheets = doc.Sheets is { Count: > 0 } ? doc.Sheets : null, + InitialSheetKey = doc.InitialSheetKey, }; public ViewerDocument ToDocument() => new(Scene) @@ -104,5 +113,8 @@ internal sealed class ViewerJsonFile PointColors = PointColors ?? [], PointIntensities = PointIntensities ?? [], Panoramas = Panoramas ?? [], + Annotations = Annotations ?? [], + Sheets = Sheets ?? [], + InitialSheetKey = InitialSheetKey, }; } diff --git a/src/IOViewer/Viewer/dist/viewer.js b/src/IOViewer/Viewer/dist/viewer.js index 8a42e4e..e4fb3db 100644 --- a/src/IOViewer/Viewer/dist/viewer.js +++ b/src/IOViewer/Viewer/dist/viewer.js @@ -1,10 +1,10 @@ -(()=>{var lu=i=>{throw TypeError(i)};var Ol=(i,t,e)=>t.has(i)||lu("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)?lu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),cu=(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 Gu=0,xc=1,Wu=2;var xr=1,Xu=2,Cs=3,qn=0,ze=1,ke=2,Yn=0,Is=1,vc=2,yc=3,Mc=4,qu=5;var Gi=100,Yu=101,$u=102,Zu=103,Ku=104,Ju=200,ju=201,Qu=202,td=203,bc=204,Sc=205,ed=206,nd=207,id=208,sd=209,rd=210,od=211,ad=212,ld=213,cd=214,Po=0,Lo=1,Do=2,ms=3,No=4,Uo=5,Fo=6,Bo=7,vr=0,hd=1,ud=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,dd=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 fd=3200;var Rr=0,pd=1,oi="",pe="srgb",er="srgb-linear",nr="linear",de="srgb";var Co=7680;var Oc=34055,zc=34056;var kc=517;var md=519,gd=512,_d=513,xd=514,Za=515,vd=516,yd=517,Ka=518,Md=519,Hc=35044,Cr=35048;var Vc="300 es",bn=2e3,_s=2001;function Jp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function jp(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function xs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function bd(){let i=xs("canvas");return i.style.display="block",i}var hu={},vs=null;function ir(...i){let t="THREE."+i.shift();vs?vs("log",t,...i):console.log(t,...i)}function Sd(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=Sd(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=Sd(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 hu||(hu[t]=!0,Ht(...i))}function wd(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 Ed={[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 Qp(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function tm(i,t,e){return i!==t?(e-i)/(t-i):0}function Qs(i,t,e){return(1-e)*i+e*t}function em(i,t,e,n){return Qs(i,t,1-Math.exp(-e*n))}function nm(i,t=1){return t-Math.abs(Gc(i,t*2)-t)}function im(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function sm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function rm(i,t){return i+Math.floor(Math.random()*(t-i+1))}function om(i,t){return i+Math.random()*(t-i)}function am(i){return i*(.5-Math.random())}function lm(i){i!==void 0&&(uu=i);let t=uu+=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 cm(i){return i*fs}function hm(i){return i*ys}function um(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function dm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function fm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function pm(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),u=r((t-n)/2),d=o((t-n)/2),f=r((n-t)/2),g=o((n-t)/2);switch(s){case"XYX":i.set(a*h,l*u,l*d,a*c);break;case"YZY":i.set(l*d,a*h,l*u,a*c);break;case"ZXZ":i.set(l*u,l*d,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 fe(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 oe={DEG2RAD:fs,RAD2DEG:ys,generateUUID:ii,clamp:ie,euclideanModulo:Gc,mapLinear:Qp,inverseLerp:tm,lerp:Qs,damp:em,pingpong:nm,smoothstep:im,smootherstep:sm,randInt:rm,randFloat:om,randFloatSpread:am,seededRandom:lm,degToRad:cm,radToDeg:hm,isPowerOfTwo:um,ceilPowerOfTwo:dm,floorPowerOfTwo:fm,setQuaternionFromProperEuler:pm,normalize:fe,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],u=n[s+3],d=r[o+0],f=r[o+1],g=r[o+2],_=r[o+3];if(u!==_||l!==d||c!==f||h!==g){let p=l*d+c*f+h*g+u*_;p<0&&(d=-d,f=-f,g=-g,_=-_,p=-p);let m=1-a;if(p<.9995){let b=Math.acos(p),w=Math.sin(b);m=Math.sin(m*b)/w,a=Math.sin(a*b)/w,l=l*m+d*a,c=c*m+f*a,h=h*m+g*a,u=u*m+_*a}else{l=l*m+d*a,c=c*m+f*a,h=h*m+g*a,u=u*m+_*a;let b=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=b,c*=b,h*=b,u*=b}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[o],d=r[o+1],f=r[o+2],g=r[o+3];return t[e]=a*g+h*u+l*f-c*d,t[e+1]=l*g+h*d+c*u-a*f,t[e+2]=c*g+h*f+a*d-l*u,t[e+3]=h*g-a*u-l*d-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),u=a(r/2),d=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*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],u=e[10],d=n+a+u;if(d>0){let f=.5/Math.sqrt(d+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>u){let f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);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+u-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(du.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(du.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),u=2*(r*n-o*e);return this.x=e+l*c+o*u-a*h,this.y=n+l*h+a*c-r*u,this.z=s+l*u+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 R=Zc,kl=new R,du=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],u=n[7],d=n[2],f=n[5],g=n[8],_=s[0],p=s[3],m=s[6],b=s[1],w=s[4],S=s[7],v=s[2],y=s[5],A=s[8];return r[0]=o*_+a*b+l*v,r[3]=o*p+a*w+l*y,r[6]=o*m+a*S+l*A,r[1]=c*_+h*b+u*v,r[4]=c*p+h*w+u*y,r[7]=c*m+h*S+u*A,r[2]=d*_+f*b+g*v,r[5]=d*p+f*w+g*y,r[8]=d*m+f*S+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],u=h*o-a*c,d=a*l-h*r,f=c*r-o*l,g=e*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;return t[0]=u*_,t[1]=(s*c-h*n)*_,t[2]=(a*n-s*o)*_,t[3]=d*_,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 Zt=Kc,Hl=new Zt,fu=new Zt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),pu=new Zt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function mm(){let i={enabled:!0,workingColorSpace:er,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===de&&(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===de&&(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:fu,fromXYZ:pu,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:pe},outputColorSpaceConfig:{drawingBufferColorSpace:pe}},[pe]:{primaries:t,whitePoint:n,transfer:de,toXYZ:fu,fromXYZ:pu,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:pe}}}),i}var ne=mm();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],u=l[8],d=l[1],f=l[5],g=l[9],_=l[2],p=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+p)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let w=(c+1)/2,S=(f+1)/2,v=(m+1)/2,y=(h+d)/4,A=(u+_)/4,x=(g+p)/4;return w>S&&w>v?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=y/n,r=A/n):S>v?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=y/s,r=x/s):v<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(v),n=A/r,s=x/r),this.set(n,s,r,e),this}let b=Math.sqrt((p-g)*(p-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(p-g)/b,this.y=(u-_)/b,this.z=(d-h)/b,this.w=Math.acos((c+f+m-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 xe=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 xe(0,0,t,e),this.scissorTest=!1,this.viewport=new xe(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),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),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&&d<=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(wm)))}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]}},Td={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=pe){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=pe){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=pe){let n=Td[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=pe){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=pe){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 u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(s-r)/u+(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),u=o*c-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(c*l-a*h)*d,g=(o*h-a*l)*d;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),u=is.dot($l);if(h>=0&&u<=h)return e.copy(s);let d=l*u-h*c;if(d<=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 p=h*g-f*u;if(p<=0&&u-h>=0&&f-g>=0)return bu.subVectors(r,s),a=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector(bu,a);let m=1/(p+_+d);return o=_*m,a=d*m,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 R(1/0,1/0,1/0),e=new R(-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 R,new R,new R,new R,new R,new R,new R,new R],yn=new R,io=new se,ss=new R,rs=new R,os=new R,mi=new R,gi=new R,Li=new R,Ys=new R,so=new R,ro=new R,Di=new R;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 R,oo=new Wt,Em=0,_e=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:Em++}),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}},Am=0,fn=new Yt,ec=new Xe,as=new R,an=new se,Zs=new se,Ge=new R,ce=class i extends On{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Am++}),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(Jp(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 Zt().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 R(-1/0,-1/0,-1/0),new R(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 u=0,d=c.length;u0&&(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=[],u=r[c];for(let d=0,f=u.length;d1)?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||Cm.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}},Im=0,Sn=class extends On{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Im++}),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=md,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 R,ic=new R,ao=new R,lo=new R,Bi=class{constructor(t=new R,e=new R(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),u,d,f,g;if(h>0)if(u=o*l-a,d=o*a-l,g=r*h,u>=0)if(d>=-g)if(d<=g){let _=1/h;u*=_,d*=_,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-o*r+a)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(o*r+a)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=o>0?-r:r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(ic).addScaledVector(ao,d),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,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,o=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,o=(t.min.y-d.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),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,u=t.x-o.x,d=t.y-o.y,f=t.z-o.z,g=e.x-o.x,_=e.y-o.y,p=e.z-o.z,m=n.x-o.x,b=n.y-o.y,w=n.z-o.z,S=Math.abs(l),v=Math.abs(c),y=Math.abs(h),A,x,E,I,D,N,B,L,F,k,W,O;if(S>=v&&S>=y?(E=l,N=u,F=g,O=m,l>=0?(A=c,x=h,I=d,D=f,B=_,L=p,k=b,W=w):(A=h,x=c,I=f,D=d,B=p,L=_,k=w,W=b)):v>=y?(E=c,N=d,F=_,O=b,c>=0?(A=h,x=l,I=f,D=u,B=p,L=g,k=w,W=m):(A=l,x=h,I=u,D=f,B=g,L=p,k=m,W=w)):(E=h,N=f,F=p,O=w,h>=0?(A=l,x=c,I=u,D=d,B=g,L=_,k=m,W=b):(A=c,x=l,I=d,D=u,B=_,L=g,k=b,W=m)),E===0)return null;let U=A/E,z=x/E,q=1/E,V=I-U*N,Z=D-z*N,K=B-U*F,lt=L-z*F,rt=k-U*O,H=W-z*O,Q=rt*lt-H*K,ut=V*H-Z*rt,It=K*Z-lt*V;if(s){if(Q<0||ut<0||It<0)return null}else if((Q<0||ut<0||It<0)&&(Q>0||ut>0||It>0))return null;let ft=Q+ut+It;if(ft===0)return null;let Ut=q*(Q*N+ut*F+It*O);return(ft>0?Ut<0:Ut>0)?null:this.at(Ut/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}},Su=new Yt,Ni=new Bi,co=new Oe,wu=new R,ho=new R,uo=new R,fo=new R,sc=new R,po=new R,Eu=new R,mo=new R,me=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))&&(Su.copy(r).invert(),Ni.copy(t.ray).applyMatrix4(Su),!(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,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,_=d.length;g<_;g++){let p=d[g],m=o[p.materialIndex],b=Math.max(p.start,f.start),w=Math.min(a.count,Math.min(p.start+p.count,f.start+f.count));for(let S=b,v=w;Se.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=Pm(i,t,e,n,ho,uo,fo,Eu);if(h){let u=new R;ni.getBarycoord(Eu,ho,uo,fo,u),s&&(h.uv=ni.getInterpolatedAttribute(s,a,l,c,u,new Wt)),r&&(h.uv1=ni.getInterpolatedAttribute(r,a,l,c,u,new Wt)),o&&(h.normal=ni.getInterpolatedAttribute(o,a,l,c,u,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:l,c,normal:new R,materialIndex:0};ni.getNormal(ho,uo,fo,d.normal),h.face=d,h.barycoord=u}return h}var mn=class extends We{constructor(t=null,e=1,n=1,s,r,o,a,l,c=Le,h=Le,u,d){super(null,o,a,l,c,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var ri=class extends _e{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,Tu=new Yt,_o=[],Au=new se,Lm=new Yt,Ks=new me,Js=new Oe,xi=class extends me{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 R,Xo=new R,Ru=new Yt,js=new Bi,vo=new Oe,rc=new R,Cu=new R,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:Cu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Iu=new R,Pu=new R,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,u=1){if(h!==Bn&&h!==wi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:t,height:e,depth:u};super(d,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},u=[h,h,h,h,h,h];super(t,t,e,n,s,r,o,a,l,c),this.image=u,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=[],u=[],d=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(u,2));function g(_,p,m,b,w,S,v,y,A,x,E){let I=S/A,D=v/x,N=S/2,B=v/2,L=y/2,F=A+1,k=x+1,W=0,O=0,U=new R;for(let z=0;z0?1:-1,h.push(U.x,U.y,U.z),u.push(V/A),u.push(1-z/x),W+=1}}for(let z=0;z0&&w(!0),e>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new we(u,3)),this.setAttribute("normal",new we(d,3)),this.setAttribute("uv",new we(f,2));function b(){let S=new R,v=new R,y=0,A=(e-t)/n;for(let x=0;x<=r;x++){let E=[],I=x/r,D=I*(e-t)+t;for(let N=0;N<=s;N++){let B=N/s,L=B*l+a,F=Math.sin(L),k=Math.cos(L);v.x=D*F,v.y=-I*n+p,v.z=D*k,u.push(v.x,v.y,v.z),S.set(F,A,k).normalize(),d.push(S.x,S.y,S.z),f.push(B,1-I),E.push(g++)}_.push(E)}for(let x=0;x0||E!==0)&&(h.push(I,D,B),y+=3),(e>0||E!==r-1)&&(h.push(D,N,B),y+=3)}c.addGroup(m,y,0),m+=y}function w(S){let v=g,y=new Wt,A=new R,x=0,E=S===!0?t:e,I=S===!0?1:-1;for(let N=1;N<=s;N++)u.push(0,p*I,0),d.push(0,I,0),f.push(.5,.5),g++;let D=g;for(let N=0;N<=s;N++){let L=N/s*l+a,F=Math.cos(L),k=Math.sin(L);A.x=E*k,A.y=p*I,A.z=E*F,u.push(A.x,A.y,A.z),d.push(0,I,0),y.x=F*.5+.5,y.y=k*.5*I+.5,f.push(y.x,y.y),g++}for(let N=0;N0)&&f.push(w,S,y),(m!==n-1||l{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||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 R().fromArray(s.value);break;case"v4":this.uniforms[n].value=new xe().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Zt().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=fd,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&&jp(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 Uu(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&&(Fu(i)||(this.files[i]=t))},get:function(i){if(this.enabled!==!1&&!Fu(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function Fu(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,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;uf.start-g.start);let d=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 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;f 0 +#endif`,pg=`#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`,dg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,fg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,pg=`#if NUM_CLIPPING_PLANES > 0 +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,mg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; -#endif`,gg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; -#endif`,_g=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; -#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,Mg=`#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`,vg=`#define PI 3.141592653589793 +#endif`,bg=`#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`,yg=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,Sg=`#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`,Mg=`vec3 transformedNormal = objectNormal; +#endif`,wg=`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`,bg=`#ifdef USE_DISPLACEMENTMAP +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,Sg=`#ifdef USE_DISPLACEMENTMAP +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,wg=`#ifdef USE_EMISSIVEMAP +#endif`,Ag=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,Eg=`#ifdef USE_EMISSIVEMAP +#endif`,Rg=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,Tg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ag=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,Cg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ig=`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 ); -}`,Rg=`#ifdef USE_ENVMAP +}`,Pg=`#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`,Cg=`#ifdef USE_ENVMAP +#endif`,Lg=`#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`,Ig=`#ifdef USE_ENVMAP +#endif`,Dg=`#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`,Pg=`#ifdef USE_ENVMAP +#endif`,Ng=`#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`,Lg=`#ifdef USE_ENVMAP +#endif`,Ug=`#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`,Dg=`#ifdef USE_FOG +#endif`,Fg=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,Ng=`#ifdef USE_FOG +#endif`,Bg=`#ifdef USE_FOG varying float vFogDepth; -#endif`,Ug=`#ifdef USE_FOG +#endif`,Og=`#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`,Fg=`#ifdef USE_FOG +#endif`,zg=`#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`,Bg=`#ifdef USE_GRADIENTMAP +#endif`,kg=`#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 -}`,Og=`#ifdef USE_LIGHTMAP +}`,Hg=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,zg=`LambertMaterial material; +#endif`,Vg=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,kg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Gg=`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`,Hg=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`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 `,Vg=`#ifdef USE_ENVMAP +#include `,Xg=`#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`,Gg=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Wg=`varying vec3 vViewPosition; +#endif`,qg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Yg=`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`,Xg=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$g=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,qg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Zg=`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`,Yg=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Kg=`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`,$g=`uniform sampler2D dfgLUT; +#endif`,Jg=`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 ); -}`,Zg=` +}`,jg=` 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`,Kg=`#if defined( RE_IndirectDiffuse ) +#endif`,Qg=`#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`,Jg=`#if defined( RE_IndirectDiffuse ) +#endif`,t_=`#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`,jg=`#ifdef USE_LIGHT_PROBES_GRID +#endif`,e_=`#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`,Qg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,t0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,e0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,n0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,i0=`#ifdef USE_MAP +#endif`,o_=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,s0=`#ifdef USE_MAP +#endif`,a_=`#ifdef USE_MAP uniform sampler2D map; -#endif`,r0=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,l_=`#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`,o0=`#if defined( USE_POINTS_UV ) +#endif`,c_=`#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`,a0=`float metalnessFactor = metalness; +#endif`,h_=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,l0=`#ifdef USE_METALNESSMAP +#endif`,u_=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,c0=`#ifdef USE_INSTANCING_MORPH +#endif`,d_=`#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`,h0=`#if defined( USE_MORPHCOLORS ) +#endif`,f_=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) @@ -1593,12 +1593,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,u0=`#ifdef USE_MORPHNORMALS +#endif`,p_=`#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`,d0=`#ifdef USE_MORPHTARGETS +#endif`,m_=`#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`,f0=`#ifdef USE_MORPHTARGETS +#endif`,g_=`#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`,p0=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,__=`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;`,m0=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,x_=`#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;`,m0=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,g0=`#ifndef FLAT_SHADED +#endif`,v_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,_0=`#ifndef FLAT_SHADED +#endif`,y_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,x0=`#ifndef FLAT_SHADED +#endif`,M_=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,m0=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,v0=`#ifdef USE_NORMALMAP +#endif`,b_=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,m0=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,y0=`#ifdef USE_CLEARCOAT +#endif`,S_=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,M0=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,w_=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,b0=`#ifdef USE_CLEARCOATMAP +#endif`,E_=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,m0=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,S0=`#ifdef USE_IRIDESCENCEMAP +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,w0=`#ifdef OPAQUE +#endif`,A_=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,E0=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,R_=`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 -}`,T0=`#ifdef PREMULTIPLIED_ALPHA +}`,C_=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,A0=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,I_=`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;`,R0=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,P_=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,C0=`#ifdef DITHERING +#endif`,L_=`#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`,I0=`float roughnessFactor = roughness; +#endif`,D_=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,P0=`#ifdef USE_ROUGHNESSMAP +#endif`,N_=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,L0=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,U_=`#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;`,R0=`#ifdef DITHERING } #endif #endif -#endif`,D0=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,F_=`#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;`,R0=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,N0=`#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`,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 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else @@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,R0=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,U0=`float getShadowMask() { +#endif`,O_=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,R0=`#ifdef DITHERING #endif #endif return shadow; -}`,F0=`#ifdef USE_SKINNING +}`,z_=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,B0=`#ifdef USE_SKINNING +#endif`,k_=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,R0=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,O0=`#ifdef USE_SKINNING +#endif`,H_=`#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;`,R0=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,z0=`#ifdef USE_SKINNING +#endif`,V_=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,R0=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,k0=`float specularStrength; +#endif`,G_=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,H0=`#ifdef USE_SPECULARMAP +#endif`,W_=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,V0=`#if defined( TONE_MAPPING ) +#endif`,X_=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,G0=`#ifndef saturate +#endif`,q_=`#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; }`,W0=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,Y_=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,W0=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,X0=`#ifdef USE_TRANSMISSION +#endif`,$_=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,W0=`#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`,q0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,W0=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,Y0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,K_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,W0=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,$0=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,J_=`#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; }`,W0=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,Z0=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,j_=`#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; }`,W0=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,K0=`varying vec2 vUv; +#endif`,Q_=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,J0=`uniform sampler2D t2D; +}`,t0=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2780,14 +2780,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,j0=`varying vec3 vWorldDirection; +}`,e0=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,Q0=`#ifdef ENVMAP_TYPE_CUBE +}`,n0=`#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 -}`,t_=`varying vec3 vWorldDirection; +}`,i0=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,e_=`uniform samplerCube tCube; +}`,s0=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2826,7 +2826,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,n_=`#include +}`,r0=`#include #include #include #include @@ -2853,7 +2853,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,i_=`#if DEPTH_PACKING == 3200 +}`,o0=`#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 -}`,s_=`#define DISTANCE +}`,a0=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2918,7 +2918,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,r_=`#define DISTANCE +}`,l0=`#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 ); -}`,o_=`varying vec3 vWorldDirection; +}`,c0=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,a_=`uniform sampler2D tEquirect; +}`,h0=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2956,7 +2956,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,l_=`uniform float scale; +}`,u0=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2978,7 +2978,7 @@ void main() { #include #include #include -}`,c_=`uniform vec3 diffuse; +}`,d0=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3006,7 +3006,7 @@ void main() { #include #include #include -}`,h_=`#include +}`,f0=`#include #include #include #include @@ -3038,7 +3038,7 @@ void main() { #include #include #include -}`,u_=`uniform vec3 diffuse; +}`,p0=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -3086,7 +3086,7 @@ void main() { #include #include #include -}`,d_=`#define LAMBERT +}`,m0=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3125,7 +3125,7 @@ void main() { #include #include #include -}`,f_=`#define LAMBERT +}`,g0=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3183,7 +3183,7 @@ void main() { #include #include #include -}`,p_=`#define MATCAP +}`,_0=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3217,7 +3217,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,m_=`#define MATCAP +}`,x0=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3263,7 +3263,7 @@ void main() { #include #include #include -}`,g_=`#define NORMAL +}`,v0=`#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 -}`,__=`#define NORMAL +}`,y0=`#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 -}`,x_=`#define PHONG +}`,M0=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3356,7 +3356,7 @@ void main() { #include #include #include -}`,v_=`#define PHONG +}`,b0=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3416,7 +3416,7 @@ void main() { #include #include #include -}`,y_=`#define STANDARD +}`,S0=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3459,7 +3459,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,M_=`#define STANDARD +}`,w0=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3587,7 +3587,7 @@ void main() { #include #include #include -}`,b_=`#define TOON +}`,E0=`#define TOON varying vec3 vViewPosition; #include #include @@ -3624,7 +3624,7 @@ void main() { #include #include #include -}`,S_=`#define TOON +}`,T0=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3676,7 +3676,7 @@ void main() { #include #include #include -}`,w_=`uniform float size; +}`,A0=`uniform float size; uniform float scale; #include #include @@ -3707,7 +3707,7 @@ void main() { #include #include #include -}`,E_=`uniform vec3 diffuse; +}`,R0=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3732,7 +3732,7 @@ void main() { #include #include #include -}`,T_=`#include +}`,C0=`#include #include #include #include @@ -3755,7 +3755,7 @@ void main() { #include #include #include -}`,A_=`uniform vec3 color; +}`,I0=`uniform vec3 color; uniform float opacity; #include #include @@ -3771,7 +3771,7 @@ void main() { #include #include #include -}`,R_=`uniform float rotation; +}`,P0=`uniform float rotation; uniform vec2 center; #include #include @@ -3795,7 +3795,7 @@ void main() { #include #include #include -}`,C_=`uniform vec3 diffuse; +}`,L0=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3820,7 +3820,7 @@ void main() { #include #include #include -}`,Qt={alphahash_fragment:Km,alphahash_pars_fragment:Jm,alphamap_fragment:jm,alphamap_pars_fragment:Qm,alphatest_fragment:tg,alphatest_pars_fragment:eg,aomap_fragment:ng,aomap_pars_fragment:ig,batching_pars_vertex:sg,batching_vertex:rg,begin_vertex:og,beginnormal_vertex:ag,bsdfs:lg,iridescence_fragment:cg,bumpmap_pars_fragment:hg,clipping_planes_fragment:ug,clipping_planes_pars_fragment:dg,clipping_planes_pars_vertex:fg,clipping_planes_vertex:pg,color_fragment:mg,color_pars_fragment:gg,color_pars_vertex:_g,color_vertex:xg,common:vg,cube_uv_reflection_fragment:yg,defaultnormal_vertex:Mg,displacementmap_pars_vertex:bg,displacementmap_vertex:Sg,emissivemap_fragment:wg,emissivemap_pars_fragment:Eg,colorspace_fragment:Tg,colorspace_pars_fragment:Ag,envmap_fragment:Rg,envmap_common_pars_fragment:Cg,envmap_pars_fragment:Ig,envmap_pars_vertex:Pg,envmap_physical_pars_fragment:Vg,envmap_vertex:Lg,fog_vertex:Dg,fog_pars_vertex:Ng,fog_fragment:Ug,fog_pars_fragment:Fg,gradientmap_pars_fragment:Bg,lightmap_pars_fragment:Og,lights_lambert_fragment:zg,lights_lambert_pars_fragment:kg,lights_pars_begin:Hg,lights_toon_fragment:Gg,lights_toon_pars_fragment:Wg,lights_phong_fragment:Xg,lights_phong_pars_fragment:qg,lights_physical_fragment:Yg,lights_physical_pars_fragment:$g,lights_fragment_begin:Zg,lights_fragment_maps:Kg,lights_fragment_end:Jg,lightprobes_pars_fragment:jg,logdepthbuf_fragment:Qg,logdepthbuf_pars_fragment:t0,logdepthbuf_pars_vertex:e0,logdepthbuf_vertex:n0,map_fragment:i0,map_pars_fragment:s0,map_particle_fragment:r0,map_particle_pars_fragment:o0,metalnessmap_fragment:a0,metalnessmap_pars_fragment:l0,morphinstance_vertex:c0,morphcolor_vertex:h0,morphnormal_vertex:u0,morphtarget_pars_vertex:d0,morphtarget_vertex:f0,normal_fragment_begin:p0,normal_fragment_maps:m0,normal_pars_fragment:g0,normal_pars_vertex:_0,normal_vertex:x0,normalmap_pars_fragment:v0,clearcoat_normal_fragment_begin:y0,clearcoat_normal_fragment_maps:M0,clearcoat_pars_fragment:b0,iridescence_pars_fragment:S0,opaque_fragment:w0,packing:E0,premultiplied_alpha_fragment:T0,project_vertex:A0,dithering_fragment:R0,dithering_pars_fragment:C0,roughnessmap_fragment:I0,roughnessmap_pars_fragment:P0,shadowmap_pars_fragment:L0,shadowmap_pars_vertex:D0,shadowmap_vertex:N0,shadowmask_pars_fragment:U0,skinbase_vertex:F0,skinning_pars_vertex:B0,skinning_vertex:O0,skinnormal_vertex:z0,specularmap_fragment:k0,specularmap_pars_fragment:H0,tonemapping_fragment:V0,tonemapping_pars_fragment:G0,transmission_fragment:W0,transmission_pars_fragment:X0,uv_pars_fragment:q0,uv_pars_vertex:Y0,uv_vertex:$0,worldpos_vertex:Z0,background_vert:K0,background_frag:J0,backgroundCube_vert:j0,backgroundCube_frag:Q0,cube_vert:t_,cube_frag:e_,depth_vert:n_,depth_frag:i_,distance_vert:s_,distance_frag:r_,equirect_vert:o_,equirect_frag:a_,linedashed_vert:l_,linedashed_frag:c_,meshbasic_vert:h_,meshbasic_frag:u_,meshlambert_vert:d_,meshlambert_frag:f_,meshmatcap_vert:p_,meshmatcap_frag:m_,meshnormal_vert:g_,meshnormal_frag:__,meshphong_vert:x_,meshphong_frag:v_,meshphysical_vert:y_,meshphysical_frag:M_,meshtoon_vert:b_,meshtoon_frag:S_,points_vert:w_,points_frag:E_,shadow_vert:T_,shadow_frag:A_,sprite_vert:R_,sprite_frag:C_},bt={common:{diffuse:{value:new kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Zt},alphaMap:{value:null},alphaMapTransform:{value:new Zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Zt}},envmap:{envMap:{value:null},envMapRotation:{value:new Zt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Zt},normalScale:{value:new Wt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Zt}},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 R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Zt},alphaTest:{value:0},uvTransform:{value:new Zt}},sprite:{diffuse:{value:new kt(16777215)},opacity:{value:1},center:{value:new Wt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Zt},alphaMap:{value:null},alphaMapTransform:{value:new Zt},alphaTest:{value:0}}},Zn={basic:{uniforms:Qe([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:Qt.meshbasic_vert,fragmentShader:Qt.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:Qt.meshlambert_vert,fragmentShader:Qt.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:Qt.meshphong_vert,fragmentShader:Qt.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:Qt.meshphysical_vert,fragmentShader:Qt.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:Qt.meshtoon_vert,fragmentShader:Qt.meshtoon_frag},matcap:{uniforms:Qe([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:Qt.meshmatcap_vert,fragmentShader:Qt.meshmatcap_frag},points:{uniforms:Qe([bt.points,bt.fog]),vertexShader:Qt.points_vert,fragmentShader:Qt.points_frag},dashed:{uniforms:Qe([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qt.linedashed_vert,fragmentShader:Qt.linedashed_frag},depth:{uniforms:Qe([bt.common,bt.displacementmap]),vertexShader:Qt.depth_vert,fragmentShader:Qt.depth_frag},normal:{uniforms:Qe([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:Qt.meshnormal_vert,fragmentShader:Qt.meshnormal_frag},sprite:{uniforms:Qe([bt.sprite,bt.fog]),vertexShader:Qt.sprite_vert,fragmentShader:Qt.sprite_frag},background:{uniforms:{uvTransform:{value:new Zt},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 Zt}},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([bt.common,bt.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qt.distance_vert,fragmentShader:Qt.distance_frag},shadow:{uniforms:Qe([bt.lights,bt.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:Qt.shadow_vert,fragmentShader:Qt.shadow_frag}};Zn.physical={uniforms:Qe([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Zt},clearcoatNormalScale:{value:new Wt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Zt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Zt},sheen:{value:0},sheenColor:{value:new kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Zt},transmissionSamplerSize:{value:new Wt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Zt},attenuationDistance:{value:0},attenuationColor:{value:new kt(0)},specularColor:{value:new kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Zt},anisotropyVector:{value:new Wt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Zt}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag};var Ja={r:0,b:0,g:0},I_=new Yt,jd=new Zt;jd.set(-1,0,0,0,1,0,0,0,1);function P_(i,t,e,n,s,r){let o=new kt(0),a=s===!0?0:1,l,c,h=null,u=0,d=null;function f(b){let w=b.isScene===!0?b.background:null;if(w&&w.isTexture){let S=b.backgroundBlurriness>0;w=t.get(w,S)}return w}function g(b){let w=!1,S=f(b);S===null?p(o,a):S&&S.isColor&&(p(S,1),w=!0);let v=i.xr.getEnvironmentBlendMode();v==="additive"?e.buffers.color.setClear(0,0,0,1,r):v==="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 _(b,w){let S=f(w);S&&(S.isCubeTexture||S.mapping===yr)?(c===void 0&&(c=new me(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(v,y,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=S,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(I_.makeRotationFromEuler(w.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(jd),c.material.toneMapped=ne.getTransfer(S.colorSpace)!==de,(h!==S||u!==S.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):S&&S.isTexture&&(l===void 0&&(l=new me(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=S,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=ne.getTransfer(S.colorSpace)!==de,S.matrixAutoUpdate===!0&&S.updateMatrix(),l.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||u!==S.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function p(b,w){b.getRGB(Ja,Wc(i)),e.buffers.color.setClear(Ja.r,Ja.g,Ja.b,w,r)}function m(){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(b,w=1){o.set(b),a=w,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(b){a=b,p(o,a)},render:g,addToRenderList:_,dispose:m}}function L_(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null),r=s,o=!1;function a(D,N,B,L,F){let k=!1,W=u(D,L,B,N);r!==W&&(r=W,c(r.object)),k=f(D,L,B,F),k&&g(D,L,B,F),F!==null&&t.update(F,i.ELEMENT_ARRAY_BUFFER),(k||o)&&(o=!1,S(D,N,B,L),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(F).buffer))}function l(){return i.createVertexArray()}function c(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function u(D,N,B,L){let F=L.wireframe===!0,k=n[N.id];k===void 0&&(k={},n[N.id]=k);let W=D.isInstancedMesh===!0?D.id:0,O=k[W];O===void 0&&(O={},k[W]=O);let U=O[B.id];U===void 0&&(U={},O[B.id]=U);let z=U[F];return z===void 0&&(z=d(l()),U[F]=z),z}function d(D){let N=[],B=[],L=[];for(let F=0;F=0){let q=F[U],V=k[U];if(V===void 0&&(U==="instanceMatrix"&&D.instanceMatrix&&(V=D.instanceMatrix),U==="instanceColor"&&D.instanceColor&&(V=D.instanceColor)),q===void 0||q.attribute!==V||V&&q.data!==V.data)return!0;W++}return r.attributesNum!==W||r.index!==L}function g(D,N,B,L){let F={},k=N.attributes,W=0,O=B.getAttributes();for(let U in O)if(O[U].location>=0){let q=k[U];q===void 0&&(U==="instanceMatrix"&&D.instanceMatrix&&(q=D.instanceMatrix),U==="instanceColor"&&D.instanceColor&&(q=D.instanceColor));let V={};V.attribute=q,q&&q.data&&(V.data=q.data),F[U]=V,W++}r.attributes=F,r.attributesNum=W,r.index=L}function _(){let D=r.newAttributes;for(let N=0,B=D.length;N=0){let z=F[O];if(z===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(z=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(z=D.instanceColor)),z!==void 0){let q=z.normalized,V=z.itemSize,Z=t.get(z);if(Z===void 0)continue;let K=Z.buffer,lt=Z.type,rt=Z.bytesPerElement,H=lt===i.INT||lt===i.UNSIGNED_INT||z.gpuType===fa;if(z.isInterleavedBufferAttribute){let Q=z.data,ut=Q.stride,It=z.offset;if(Q.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 u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!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),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),m=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),v=i.getParameter(i.MAX_SAMPLES),y=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:b,maxVaryings:w,maxFragmentUniforms:S,maxSamples:v,samples:y}}function U_(i){let t=this,e=null,n=0,s=!1,r=!1,o=new Ae,a=new Zt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){let g=u.clippingPlanes,_=u.clipIntersection,p=u.clipShadows,m=i.get(u);if(!s||g===null||g.length===0||r&&!p)r?h(null):c();else{let b=r?0:n,w=b*4,S=m.clippingState||null;l.value=S,S=h(g,d,w,f);for(let v=0;v!==w;++v)S[v]=e[v];m.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){let _=u!==null?u.length:0,p=null;if(_!==0){if(p=l.value,g!==!0||p===null){let m=f+_*4,b=d.matrixWorldInverse;a.getNormalMatrix(b),(p===null||p.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=Dd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ld(),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?v:0,v,v),u.setRenderTarget(s),m&&u.render(_,l),u.render(t,l)}u.toneMapping=f,u.autoClear=d,t.background=b}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===bi||t.mapping===Wi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Dd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ld());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),m=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=g-e,Ns(r,p,m,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,p,m,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],u=3*h*(s>this._lodMax-Us?s-this._lodMax+Us:0),d=4*(this._cubeSize-h);Ns(e,u,d,3*h,2*h),o.setRenderTarget(e),o.render(l,Ir)}};function k_(i){let t=[],e=[],n=i,s=i-Us+1+F_;for(let r=0;r2?0:-1,S=[b,w,0,b+2/3,w,0,b+2/3,w+1,0,b,w,0,b+2/3,w+1,0,b,w+1,0];g.set(S,f*d*m);for(let v=0;vUs&&n--}return{lodMeshes:e,sizeLods:t}}function Pd(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 H_(i,t,e){return new Ie({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:O_,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:` +}`,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:` 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 V_(i,t,e){return new Ie({name:"SphericalGaussianBlur",defines:{SAMPLES:B_,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: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:` 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 Ld(){return new Ie({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:el(),fragmentShader:` + `,blending:Yn,depthTest:!1,depthWrite:!1})}function Dd(){return new Ie({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:el(),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 Dd(){return new Ie({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:el(),fragmentShader:` + `,blending:Yn,depthTest:!1,depthWrite:!1})}function Nd(){return new Ie({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:el(),fragmentShader:` precision mediump float; precision mediump int; @@ -4069,7 +4069,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},s=new gn(5,5,5),r=new Ie({name:"CubemapFromEquirect",uniforms:Xi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ze,blending:Yn});r.uniforms.tEquirect.value=e;let o=new me(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 G_(i){let t=new WeakMap,e=new WeakMap,n=null;function s(d,f=!1){return d==null?null:f?o(d):r(d)}function r(d){if(d&&d.isTexture){let f=d.mapping;if(f===ha||f===ua)if(t.has(d)){let g=t.get(d).texture;return a(g,d.mapping)}else{let g=d.image;if(g&&g.height>0){let _=new tl(g.height);return _.fromEquirectangularTexture(i,d),t.set(d,_),d.addEventListener("dispose",c),a(_.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture){let f=d.mapping,g=f===ha||f===ua,_=f===bi||f===Wi;if(g||_){let p=e.get(d),m=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==m)return n===null&&(n=new Qa(i)),p=g?n.fromEquirectangular(d,p):n.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,e.set(d,p),p.texture;if(p!==void 0)return p.texture;{let b=d.image;return g&&b&&b.height>0||_&&b&&l(b)?(n===null&&(n=new Qa(i)),p=g?n.fromEquirectangular(d):n.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,e.set(d,p),d.addEventListener("dispose",h),p.texture):null}}}return d}function a(d,f){return f===ha?d.mapping=bi:f===ua&&(d.mapping=Wi),d}function l(d){let f=0,g=6;for(let _=0;_=65535?or:rr)(d,1);p.version=_;let m=r.get(u);m&&t.remove(m),r.set(u,p)}function h(u){let d=r.get(u);if(d){let f=u.index;f!==null&&d.versiont.maxTextureSize&&(v=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize);let y=new Float32Array(S*v*4*u),A=new sr(y,S,v,u);A.type=Ye,A.needsUpdate=!0;let x=w*4;for(let I=0;I0){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&&b[0].isRenderPass===!0;let v=o.width,y=o.height;b.length>0&&a===null&&(a=new Be(v,y,{type:An,depthBuffer:!1,stencilBuffer:!1}),l=new Be(v,y,{type:An,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=Nd[s];if(r===void 0&&(r=new Float32Array(s),Nd[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 kd(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var zx=37297,kx=0;function Hx(i,t){let e=i.split(` + }`,depthTest:!1,depthWrite:!1}),d=new ge(c,h),u=new Wn(-1,1,1,-1,0,1),f=null,g=null,_=!1,m,p=null,y=[],w=!1;this.setSize=function(M,x){o.setSize(M,x),a!==null&&a.setSize(M,x),l!==null&&l.setSize(M,x);for(let S=0;S0&&y[0].isRenderPass===!0;let x=o.width,S=o.height;y.length>0&&a===null&&(a=new Be(x,S,{type:An,depthBuffer:!1,stencilBuffer:!1}),l=new Be(x,S,{type:An,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=t*e,r=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(` `),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 Hd=new Zt;function Vx(i){ne._getMatrix(Hd,ne.workingColorSpace,i);let t=`mat3( ${Hd.elements.map(e=>e.toFixed(4))} )`;switch(ne.getTransfer(i)){case nr:return[t,"LinearTransferOETF"];case de:return[t,"sRGBTransferOETF"];default:return Ht("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Vd(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 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()+` `+r+` -`+Hx(i.getShaderSource(t),a)}else return r}function Gx(i,t){let e=Vx(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` -`)}var Wx={[wc]:"Linear",[Ec]:"Reinhard",[Tc]:"Cineon",[Ac]:"ACESFilmic",[Cc]:"AgX",[Ic]:"Neutral",[Rc]:"Custom"};function Xx(i,t){let e=Wx[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 R;function qx(){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 Yx(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Lr).join(` -`)}function $x(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` -`)}function Zx(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function ch(i){return i.replace(Kx,jx)}var Jx=new Map;function jx(i,t){let e=Qt[t];if(e===void 0){let n=Jx.get(t);if(n!==void 0)e=Qt[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 Qx=/#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 Xd(i){return i.replace(Qx,tv)}function tv(i,t,e,n){let s="";for(let r=parseInt(t);r/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);r0&&(p+=` -`),m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Lr).join(` +#define LOW_PRECISION`),t}var sv={[xr]:"SHADOWMAP_TYPE_PCF",[Cs]:"SHADOWMAP_TYPE_VSM"};function rv(i){return sv[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var ov={[bi]:"ENVMAP_TYPE_CUBE",[Wi]:"ENVMAP_TYPE_CUBE",[yr]:"ENVMAP_TYPE_CUBE_UV"};function av(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":ov[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var lv={[Wi]:"ENVMAP_MODE_REFRACTION"};function cv(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":lv[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var hv={[vr]:"ENVMAP_BLENDING_MULTIPLY",[ud]:"ENVMAP_BLENDING_MIX",[dd]:"ENVMAP_BLENDING_ADD"};function uv(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":hv[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 fv(i,t,e,n){let s=i.getContext(),r=e.defines,o=e.vertexShader,a=e.fragmentShader,l=rv(e),c=av(e),h=cv(e),d=uv(e),u=dv(e),f=Kx(e),g=Jx(r),_=s.createProgram(),m,p,y=e.glslVersion?"#version "+e.glslVersion+` +`:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Lr).join(` `),m.length>0&&(m+=` -`)):(p=[qd(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",` +`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Lr).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(` -`),m=[qd(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 "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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?Xx("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Qt.colorspace_pars_fragment,Gx("linearToOutputTexel",e.outputColorSpace),qx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`),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=Gd(o,e),o=Wd(o,e),a=ch(a),a=Gd(a,e),a=Wd(a,e),o=Xd(o),a=Xd(a),e.isRawShaderMaterial!==!0&&(b=`#version 300 es -`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].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(` `)+` -`+p,m=["#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(` +`+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(` `)+` -`+m);let w=b+p+o,S=b+m+a,v=kd(s,s.VERTEX_SHADER,w),y=kd(s,s.FRAGMENT_SHADER,S);s.attachShader(_,v),s.attachShader(_,y),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function A(D){if(i.debug.checkShaderErrors){let N=s.getProgramInfoLog(_)||"",B=s.getShaderInfoLog(v)||"",L=s.getShaderInfoLog(y)||"",F=N.trim(),k=B.trim(),W=L.trim(),O=!0,U=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(O=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,v,y);else{let z=Vd(s,v,"vertex"),q=Vd(s,y,"fragment");Xt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` +`+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)+` -Material Name: `+D.name+` -Material Type: `+D.type+` +Material Name: `+L.name+` +Material Type: `+L.type+` Program Info Log: `+F+` `+z+` -`+q)}else F!==""?Ht("WebGLProgram: Program Info Log:",F):(k===""||W==="")&&(U=!1);U&&(D.diagnostics={runnable:O,programLog:F,vertexShader:{log:k,prefix:p},fragmentShader:{log:W,prefix:m}})}s.deleteShader(v),s.deleteShader(y),x=new Fs(s,_),E=Zx(s,_)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let E;this.getAttributes=function(){return E===void 0&&A(this),E};let I=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,zx)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=kx++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=v,this.fragmentShader=y,this}var uv=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=uv++,this.code=t,this.usedTimes=0}};function dv(i){return i===Ei||i===Tr||i===Ar}function fv(i,t,e,n,s,r){let o=new bs,a=new hh,l=new Set,c=[],h=new Map,u=n.logarithmicDepthBuffer,d=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(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,E,I,D,N,B){let L=D.fog,F=N.geometry,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=t.get(x.envMap||k,W),U=O&&O.mapping===yr?O.image.height:null,z=f[x.type];x.precision!==null&&(d=n.getMaxPrecision(x.precision),d!==x.precision&&Ht("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));let q=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,V=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 K,lt,rt,H;if(z){let be=Zn[z];K=be.vertexShader,lt=be.fragmentShader}else{K=x.vertexShader,lt=x.fragmentShader;let be=a.getVertexShaderStage(x),he=a.getFragmentShaderStage(x);a.update(x,be,he),rt=be.id,H=he.id}let Q=i.getRenderTarget(),ut=i.state.buffers.depth.getReversed(),It=N.isInstancedMesh===!0,ft=N.isBatchedMesh===!0,Ut=!!x.map,ae=!!x.matcap,Gt=!!O,Jt=!!x.aoMap,mt=!!x.lightMap,Ct=!!x.bumpMap&&x.wireframe===!1,$t=!!x.normalMap,qt=!!x.displacementMap,Me=!!x.emissiveMap,dt=!!x.metalnessMap,Ft=!!x.roughnessMap,C=x.anisotropy>0,ht=x.clearcoat>0,Tt=x.dispersion>0,P=x.retroreflectivity>0,M=x.iridescence>0,Y=x.sheen>0,tt=x.transmission>0,it=C&&!!x.anisotropyMap,pt=ht&&!!x.clearcoatMap,gt=ht&&!!x.clearcoatNormalMap,st=ht&&!!x.clearcoatRoughnessMap,at=M&&!!x.iridescenceMap,_t=M&&!!x.iridescenceThicknessMap,Bt=Y&&!!x.sheenColorMap,Mt=Y&&!!x.sheenRoughnessMap,xt=!!x.specularMap,Ot=!!x.specularColorMap,Vt=!!x.specularIntensityMap,Kt=tt&&!!x.transmissionMap,X=tt&&!!x.thicknessMap,vt=!!x.gradientMap,ot=!!x.alphaMap,yt=x.alphaTest>0,Et=!!x.alphaHash,ct=!!x.extensions,zt=En;x.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(zt=i.toneMapping);let Dt={shaderID:z,shaderType:x.type,shaderName:x.name,vertexShader:K,fragmentShader:lt,defines:x.defines,customVertexShaderID:rt,customFragmentShaderID:H,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:ft,batchingColor:ft&&N._colorsTexture!==null,instancing:It,instancingColor:It&&N.instanceColor!==null,instancingMorph:It&&N.morphTexture!==null,outputColorSpace:Q===null?i.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:ne.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ut,matcap:ae,envMap:Gt,envMapMode:Gt&&O.mapping,envMapCubeUVHeight:U,aoMap:Jt,lightMap:mt,bumpMap:Ct,normalMap:$t,displacementMap:qt,emissiveMap:Me,normalMapObjectSpace:$t&&x.normalMapType===pd,normalMapTangentSpace:$t&&x.normalMapType===Rr,packedNormalMap:$t&&x.normalMapType===Rr&&dv(x.normalMap.format),metalnessMap:dt,roughnessMap:Ft,anisotropy:C,anisotropyMap:it,clearcoat:ht,clearcoatMap:pt,clearcoatNormalMap:gt,clearcoatRoughnessMap:st,dispersion:Tt,retroreflection:P,iridescence:M,iridescenceMap:at,iridescenceThicknessMap:_t,sheen:Y,sheenColorMap:Bt,sheenRoughnessMap:Mt,specularMap:xt,specularColorMap:Ot,specularIntensityMap:Vt,transmission:tt,transmissionMap:Kt,thicknessMap:X,gradientMap:vt,opaque:x.transparent===!1&&x.blending===Is&&x.alphaToCoverage===!1,alphaMap:ot,alphaTest:yt,alphaHash:Et,combine:x.combine,mapUv:Ut&&g(x.map.channel),aoMapUv:Jt&&g(x.aoMap.channel),lightMapUv:mt&&g(x.lightMap.channel),bumpMapUv:Ct&&g(x.bumpMap.channel),normalMapUv:$t&&g(x.normalMap.channel),displacementMapUv:qt&&g(x.displacementMap.channel),emissiveMapUv:Me&&g(x.emissiveMap.channel),metalnessMapUv:dt&&g(x.metalnessMap.channel),roughnessMapUv:Ft&&g(x.roughnessMap.channel),anisotropyMapUv:it&&g(x.anisotropyMap.channel),clearcoatMapUv:pt&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:gt&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:st&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:at&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:_t&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:Bt&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&g(x.sheenRoughnessMap.channel),specularMapUv:xt&&g(x.specularMap.channel),specularColorMapUv:Ot&&g(x.specularColorMap.channel),specularIntensityMapUv:Vt&&g(x.specularIntensityMap.channel),transmissionMapUv:Kt&&g(x.transmissionMap.channel),thicknessMapUv:X&&g(x.thicknessMap.channel),alphaMapUv:ot&&g(x.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&($t||C),vertexNormals:!!F.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!F.attributes.uv&&(Ut||ot),fog:!!L,useFog:x.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||F.attributes.normal===void 0&&$t===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:ut,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:V,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:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:zt,decodeVideoTexture:Ut&&x.map.isVideoTexture===!0&&ne.getTransfer(x.map.colorSpace)===de,decodeVideoTextureEmissive:Me&&x.emissiveMap.isVideoTexture===!0&&ne.getTransfer(x.emissiveMap.colorSpace)===de,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===ke,flipSided:x.side===ze,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ct&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ct&&x.extensions.multiDraw===!0||ft)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Dt.vertexUv1s=l.has(1),Dt.vertexUv2s=l.has(2),Dt.vertexUv3s=l.has(3),l.clear(),Dt}function p(x){let E=[];if(x.shaderID?E.push(x.shaderID):(E.push(x.customVertexShaderID),E.push(x.customFragmentShaderID)),x.defines!==void 0)for(let I in x.defines)E.push(I),E.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(m(E,x),b(E,x),E.push(i.outputColorSpace)),E.push(x.customProgramCacheKey),E.join()}function m(x,E){x.push(E.precision),x.push(E.outputColorSpace),x.push(E.envMapMode),x.push(E.envMapCubeUVHeight),x.push(E.mapUv),x.push(E.alphaMapUv),x.push(E.lightMapUv),x.push(E.aoMapUv),x.push(E.bumpMapUv),x.push(E.normalMapUv),x.push(E.displacementMapUv),x.push(E.emissiveMapUv),x.push(E.metalnessMapUv),x.push(E.roughnessMapUv),x.push(E.anisotropyMapUv),x.push(E.clearcoatMapUv),x.push(E.clearcoatNormalMapUv),x.push(E.clearcoatRoughnessMapUv),x.push(E.iridescenceMapUv),x.push(E.iridescenceThicknessMapUv),x.push(E.sheenColorMapUv),x.push(E.sheenRoughnessMapUv),x.push(E.specularMapUv),x.push(E.specularColorMapUv),x.push(E.specularIntensityMapUv),x.push(E.transmissionMapUv),x.push(E.thicknessMapUv),x.push(E.combine),x.push(E.fogExp2),x.push(E.sizeAttenuation),x.push(E.morphTargetsCount),x.push(E.morphAttributeCount),x.push(E.numSunLights),x.push(E.numDirLights),x.push(E.numPointLights),x.push(E.numSpotLights),x.push(E.numSpotLightMaps),x.push(E.numHemiLights),x.push(E.numRectAreaLights),x.push(E.numSunLightShadows),x.push(E.numDirLightShadows),x.push(E.numPointLightShadows),x.push(E.numSpotLightShadows),x.push(E.numSpotLightShadowsWithMaps),x.push(E.numLightProbes),x.push(E.shadowMapType),x.push(E.toneMapping),x.push(E.numClippingPlanes),x.push(E.numClipIntersection),x.push(E.depthPacking)}function b(x,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),x.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),x.push(o.mask)}function w(x){let E=f[x.type],I;if(E){let D=Zn[E];I=Ad.clone(D.uniforms)}else I=x.uniforms;return I}function S(x,E){let I=h.get(E);return I!==void 0?++I.usedTimes:(I=new hv(i,E,x,s),c.push(I),h.set(E,I)),I}function v(x){if(--x.usedTimes===0){let E=c.indexOf(x);c[E]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function y(x){a.remove(x)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:w,acquireProgram:S,releaseProgram:v,releaseShaderCache:y,programs:c,dispose:A}}function pv(){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 mv(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 Yd(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 $d(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function o(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function a(d,f,g,_,p,m){let b=i[t];return b===void 0?(b={id:d.id,object:d,geometry:f,material:g,materialVariant:o(d),groupOrder:_,renderOrder:d.renderOrder,z:p,group:m},i[t]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=g,b.materialVariant=o(d),b.groupOrder=_,b.renderOrder=d.renderOrder,b.z=p,b.group=m),t++,b}function l(d,f,g,_,p,m,b){b.reversedDepth===!0&&(p=-p);let w=a(d,f,g,_,p,m);g.transmission>0?n.push(w):g.transparent===!0?s.push(w):e.push(w)}function c(d,f,g,_,p,m){let b=a(d,f,g,_,p,m);g.transmission>0?n.unshift(b):g.transparent===!0?s.unshift(b):e.unshift(b)}function h(d,f){e.length>1&&e.sort(d||mv),n.length>1&&n.sort(f||Yd),s.length>1&&s.sort(f||Yd)}function u(){for(let d=t,f=i.length;d=r.length?(o=new $d,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function _v(){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 R,color:new kt};break;case"SpotLight":e={position:new R,direction:new R,color:new kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new R,color:new kt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new R,skyColor:new kt,groundColor:new kt};break;case"RectAreaLight":e={color:new kt,position:new R,halfWidth:new R,halfHeight:new R};break}return i[t.id]=e,e}}}function xv(){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 vv=0;function yv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Mv(i){let t=new _v,e=xv(),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 R);let s=new R,r=new Yt,o=new Yt;function a(c){let h=0,u=0,d=0;for(let N=0;N<9;N++)n.probe[N].set(0,0,0);let f=0,g=0,_=0,p=0,m=0,b=0,w=0,S=0,v=0,y=0,A=0,x=0,E=0,I=0;c.sort(yv);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]=u,n.ambient[2]=d;let D=n.hash;(D.sunLength!==f||D.directionalLength!==p||D.pointLength!==m||D.spotLength!==b||D.rectAreaLength!==w||D.hemiLength!==S||D.numSunShadows!==g||D.numDirectionalShadows!==v||D.numPointShadows!==y||D.numSpotShadows!==A||D.numSpotMaps!==x||D.numLightProbes!==I)&&(n.sun.length=f,n.directional.length=p,n.spot.length=b,n.rectArea.length=w,n.point.length=m,n.hemi.length=S,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.directionalShadowMatrix.length=v,n.pointShadow.length=y,n.pointShadowMap.length=y,n.pointShadowMatrix.length=y,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-E,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=I,D.sunLength=f,D.directionalLength=p,D.pointLength=m,D.spotLength=b,D.rectAreaLength=w,D.hemiLength=S,D.numSunShadows=g,D.numDirectionalShadows=v,D.numPointShadows=y,D.numSpotShadows=A,D.numSpotMaps=x,D.numLightProbes=I,n.version=vv++)}function l(c,h){let u=0,d=0,f=0,g=0,_=0,p=0,m=h.matrixWorldInverse;for(let b=0,w=c.length;b=o.length?(a=new Zd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var Sv=`void main() { +`+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() { gl_Position = vec4( position, 1.0 ); -}`,wv=`uniform sampler2D shadow_pass; +}`,Av=`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 ); -}`,Ev=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],Tv=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],Kd=new Yt,Pr=new R,sh=new R;function Av(i,t,e){let n=new kn,s=new Wt,r=new Wt,o=new xe,a=new $o,l=new Zo,c={},h=e.maxTextureSize,u={[qn]:ze,[ze]:qn,[ke]:ke},d=new Ie({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Wt},radius:{value:4}},vertexShader:Sv,fragmentShader:wv}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let g=new ce;g.setAttribute("position",new _e(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new me(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xr;let m=this.type;this.render=function(y,A,x){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||y.length===0)return;this.type===Xu&&(Ht("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=xr);let E=i.getRenderTarget(),I=i.getActiveCubeFace(),D=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=m!==this.type;B&&A.traverse(function(L){L.material&&(Array.isArray(L.material)?L.material.forEach(F=>F.needsUpdate=!0):L.material.needsUpdate=!0)});for(let L=0,F=y.length;Lh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/O.x),s.x=r.x*O.x,W.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/O.y),s.y=r.y*O.y,W.mapSize.y=r.y));let U=i.state.buffers.depth.getReversed();if(W.camera._reversedDepth=U,W.map===null||B===!0){if(W.map!==null&&(W.map.depthTexture!==null&&(W.map.depthTexture.dispose(),W.map.depthTexture=null),W.map.dispose()),this.type===Cs){if(k.isPointLight){Ht("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}W.map=new Be(s.x,s.y,{format:Ei,type:An,minFilter:qe,magFilter:qe,generateMipmaps:!1}),W.map.texture.name=k.name+".shadowMap",W.map.depthTexture=new Vn(s.x,s.y,Ye),W.map.depthTexture.name=k.name+".shadowMapDepth",W.map.depthTexture.format=Bn,W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Le,W.map.depthTexture.magFilter=Le}else k.isPointLight?(W.map=new tl(s.x),W.map.depthTexture=new qo(s.x,Tn)):(W.map=new Be(s.x,s.y),W.map.depthTexture=new Vn(s.x,s.y,Tn)),W.map.depthTexture.name=k.name+".shadowMap",W.map.depthTexture.format=Bn,this.type===xr?(W.map.depthTexture.compareFunction=U?Ka:Za,W.map.depthTexture.minFilter=qe,W.map.depthTexture.magFilter=qe):(W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Le,W.map.depthTexture.magFilter=Le);W.camera.updateProjectionMatrix()}W.map.isWebGLCubeRenderTarget!==!0&&(W.map.width!==s.x||W.map.height!==s.y)&&W.map.setSize(s.x,s.y);let z=W.map.isWebGLCubeRenderTarget?6:W.getViewportCount();k.isPointLight!==!0&&W.updateMatrices(k,x);for(let q=0;q0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let N=I.uuid,B=A.uuid,L=c[N];L===void 0&&(L={},c[N]=L);let F=L[B];F===void 0&&(F=I.clone(),L[B]=F,A.addEventListener("dispose",v)),I=F}if(I.visible=A.visible,I.wireframe=A.wireframe,E===Cs?I.side=A.shadowSide!==null?A.shadowSide:A.side:I.side=A.shadowSide!==null?A.shadowSide:u[A.side],I.alphaMap=A.alphaMap,I.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,I.map=A.map,I.clipShadows=A.clipShadows,I.clippingPlanes=A.clippingPlanes,I.clipIntersection=A.clipIntersection,I.displacementMap=A.displacementMap,I.displacementScale=A.displacementScale,I.displacementBias=A.displacementBias,I.wireframeLinewidth=A.wireframeLinewidth,I.linewidth=A.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){let N=i.properties.get(I);N.light=x}return I}function S(y,A,x,E,I){if(y.visible===!1)return;if(y.layers.test(A.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&I===Cs)&&(!y.frustumCulled||y.intersectsFrustum(n))){y.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,y.matrixWorld);let B=t.update(y),L=y.material;if(Array.isArray(L)){let F=B.groups;for(let k=0,W=F.length;k=1):U.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),W=O>=2);let z=null,q={},V=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),K=new xe().fromArray(V),lt=new xe().fromArray(Z);function rt(X,vt,ot,yt){let Et=new Uint8Array(4),ct=i.createTexture();i.bindTexture(X,ct),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,u=new Set,d,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(P,M){return g?new OffscreenCanvas(P,M):xs("canvas")}function p(P,M,Y){let tt=1,it=Tt(P);if((it.width>Y||it.height>Y)&&(tt=Y/Math.max(it.width,it.height)),tt<1)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap||typeof VideoFrame<"u"&&P instanceof VideoFrame){let pt=Math.floor(tt*it.width),gt=Math.floor(tt*it.height);d===void 0&&(d=_(pt,gt));let st=M?_(pt,gt):d;return st.width=pt,st.height=gt,st.getContext("2d").drawImage(P,0,0,pt,gt),Ht("WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+pt+"x"+gt+")."),st}else return"data"in P&&Ht("WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+")."),P;return P}function m(P){return P.generateMipmaps}function b(P){i.generateMipmap(P)}function w(P){return P.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:P.isWebGL3DRenderTarget?i.TEXTURE_3D:P.isWebGLArrayRenderTarget||P.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(P,M,Y,tt,it,pt=!1){if(P!==null){if(i[P]!==void 0)return i[P];Ht("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let gt;tt&&(gt=t.get("EXT_texture_norm16"),gt||Ht("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let st=M;if(M===i.RED&&(Y===i.FLOAT&&(st=i.R32F),Y===i.HALF_FLOAT&&(st=i.R16F),Y===i.UNSIGNED_BYTE&&(st=i.R8),Y===i.UNSIGNED_SHORT&>&&(st=gt.R16_EXT),Y===i.SHORT&>&&(st=gt.R16_SNORM_EXT)),M===i.RED_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.R8UI),Y===i.UNSIGNED_SHORT&&(st=i.R16UI),Y===i.UNSIGNED_INT&&(st=i.R32UI),Y===i.BYTE&&(st=i.R8I),Y===i.SHORT&&(st=i.R16I),Y===i.INT&&(st=i.R32I)),M===i.RG&&(Y===i.FLOAT&&(st=i.RG32F),Y===i.HALF_FLOAT&&(st=i.RG16F),Y===i.UNSIGNED_BYTE&&(st=i.RG8),Y===i.UNSIGNED_SHORT&>&&(st=gt.RG16_EXT),Y===i.SHORT&>&&(st=gt.RG16_SNORM_EXT)),M===i.RG_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.RG8UI),Y===i.UNSIGNED_SHORT&&(st=i.RG16UI),Y===i.UNSIGNED_INT&&(st=i.RG32UI),Y===i.BYTE&&(st=i.RG8I),Y===i.SHORT&&(st=i.RG16I),Y===i.INT&&(st=i.RG32I)),M===i.RGB_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.RGB8UI),Y===i.UNSIGNED_SHORT&&(st=i.RGB16UI),Y===i.UNSIGNED_INT&&(st=i.RGB32UI),Y===i.BYTE&&(st=i.RGB8I),Y===i.SHORT&&(st=i.RGB16I),Y===i.INT&&(st=i.RGB32I)),M===i.RGBA_INTEGER&&(Y===i.UNSIGNED_BYTE&&(st=i.RGBA8UI),Y===i.UNSIGNED_SHORT&&(st=i.RGBA16UI),Y===i.UNSIGNED_INT&&(st=i.RGBA32UI),Y===i.BYTE&&(st=i.RGBA8I),Y===i.SHORT&&(st=i.RGBA16I),Y===i.INT&&(st=i.RGBA32I)),M===i.RGB&&(Y===i.UNSIGNED_SHORT&>&&(st=gt.RGB16_EXT),Y===i.SHORT&>&&(st=gt.RGB16_SNORM_EXT),Y===i.UNSIGNED_INT_5_9_9_9_REV&&(st=i.RGB9_E5),Y===i.UNSIGNED_INT_10F_11F_11F_REV&&(st=i.R11F_G11F_B10F)),M===i.RGBA){let at=pt?nr:ne.getTransfer(it);Y===i.FLOAT&&(st=i.RGBA32F),Y===i.HALF_FLOAT&&(st=i.RGBA16F),Y===i.UNSIGNED_BYTE&&(st=at===de?i.SRGB8_ALPHA8:i.RGBA8),Y===i.UNSIGNED_SHORT&>&&(st=gt.RGBA16_EXT),Y===i.SHORT&>&&(st=gt.RGBA16_SNORM_EXT),Y===i.UNSIGNED_SHORT_4_4_4_4&&(st=i.RGBA4),Y===i.UNSIGNED_SHORT_5_5_5_1&&(st=i.RGB5_A1)}return(st===i.R16F||st===i.R32F||st===i.RG16F||st===i.RG32F||st===i.RGBA16F||st===i.RGBA32F)&&t.get("EXT_color_buffer_float"),st}function v(P,M){let Y;return P?M===null||M===Tn||M===Ls?Y=i.DEPTH24_STENCIL8:M===Ye?Y=i.DEPTH32F_STENCIL8:M===Ps&&(Y=i.DEPTH24_STENCIL8,Ht("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Tn||M===Ls?Y=i.DEPTH_COMPONENT24:M===Ye?Y=i.DEPTH_COMPONENT32F:M===Ps&&(Y=i.DEPTH_COMPONENT16),Y}function y(P,M){return m(P)===!0||P.isFramebufferTexture&&P.minFilter!==Le&&P.minFilter!==qe?Math.log2(Math.max(M.width,M.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?M.mipmaps.length:1}function A(P){let M=P.target;M.removeEventListener("dispose",A),E(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&u.delete(M)}function x(P){let M=P.target;M.removeEventListener("dispose",x),D(M)}function E(P){let M=n.get(P);if(M.__webglInit===void 0)return;let Y=P.source,tt=f.get(Y);if(tt){let it=tt[M.__cacheKey];it.usedTimes--,it.usedTimes===0&&I(P),Object.keys(tt).length===0&&f.delete(Y)}n.remove(P)}function I(P){let M=n.get(P);i.deleteTexture(M.__webglTexture);let Y=P.source,tt=f.get(Y);delete tt[M.__cacheKey],o.memory.textures--}function D(P){let M=n.get(P);if(P.depthTexture&&(P.depthTexture.dispose(),n.remove(P.depthTexture)),P.isWebGLCubeRenderTarget)for(let tt=0;tt<6;tt++){if(Array.isArray(M.__webglFramebuffer[tt]))for(let it=0;it=s.maxTextures&&Ht("WebGLTextures: Trying to use "+(P+1)+" texture units while this GPU supports only "+s.maxTextures),N+=1,P}function W(P){let M=[];return M.push(P.wrapS),M.push(P.wrapT),M.push(P.wrapR||0),M.push(P.magFilter),M.push(P.minFilter),M.push(P.anisotropy),M.push(P.internalFormat),M.push(P.format),M.push(P.type),M.push(P.generateMipmaps),M.push(P.premultiplyAlpha),M.push(P.flipY),M.push(P.unpackAlignment),M.push(P.colorSpace),M.join()}function O(P,M){let Y=n.get(P);if(P.isVideoTexture&&C(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&Y.__version!==P.version){let tt=P.image;if(tt===null)Ht("WebGLRenderer: Texture marked for update but no image data found.");else if(tt.complete===!1)Ht("WebGLRenderer: Texture marked for update but image is incomplete");else{ut(Y,P,M);return}}else P.isExternalTexture&&(Y.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,Y.__webglTexture,i.TEXTURE0+M)}function U(P,M){let Y=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&Y.__version!==P.version){ut(Y,P,M);return}else P.isExternalTexture&&(Y.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,Y.__webglTexture,i.TEXTURE0+M)}function z(P,M){let Y=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&Y.__version!==P.version){ut(Y,P,M);return}e.bindTexture(i.TEXTURE_3D,Y.__webglTexture,i.TEXTURE0+M)}function q(P,M){let Y=n.get(P);if(P.isCubeDepthTexture!==!0&&P.version>0&&Y.__version!==P.version){It(Y,P,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture,i.TEXTURE0+M)}let V={[gs]:i.REPEAT,[Fn]:i.CLAMP_TO_EDGE,[Oo]:i.MIRRORED_REPEAT},Z={[Le]:i.NEAREST,[dd]:i.NEAREST_MIPMAP_NEAREST,[Mr]:i.NEAREST_MIPMAP_LINEAR,[qe]:i.LINEAR,[da]:i.LINEAR_MIPMAP_NEAREST,[Si]:i.LINEAR_MIPMAP_LINEAR},K={[gd]:i.NEVER,[Md]:i.ALWAYS,[_d]:i.LESS,[Za]:i.LEQUAL,[xd]:i.EQUAL,[Ka]:i.GEQUAL,[vd]:i.GREATER,[yd]:i.NOTEQUAL};function lt(P,M){if(M.type===Ye&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===qe||M.magFilter===da||M.magFilter===Mr||M.magFilter===Si||M.minFilter===qe||M.minFilter===da||M.minFilter===Mr||M.minFilter===Si)&&Ht("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(P,i.TEXTURE_WRAP_S,V[M.wrapS]),i.texParameteri(P,i.TEXTURE_WRAP_T,V[M.wrapT]),(P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY)&&i.texParameteri(P,i.TEXTURE_WRAP_R,V[M.wrapR]),i.texParameteri(P,i.TEXTURE_MAG_FILTER,Z[M.magFilter]),i.texParameteri(P,i.TEXTURE_MIN_FILTER,Z[M.minFilter]),M.compareFunction&&(i.texParameteri(P,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(P,i.TEXTURE_COMPARE_FUNC,K[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Le||M.minFilter!==Mr&&M.minFilter!==Si||M.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){let Y=t.get("EXT_texture_filter_anisotropic");i.texParameterf(P,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function rt(P,M){let Y=!1;P.__webglInit===void 0&&(P.__webglInit=!0,M.addEventListener("dispose",A));let tt=M.source,it=f.get(tt);it===void 0&&(it={},f.set(tt,it));let pt=W(M);if(pt!==P.__cacheKey){it[pt]===void 0&&(it[pt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),it[pt].usedTimes++;let gt=it[P.__cacheKey];gt!==void 0&&(it[P.__cacheKey].usedTimes--,gt.usedTimes===0&&I(M)),P.__cacheKey=pt,P.__webglTexture=it[pt].texture}return Y}function H(P,M,Y){return Math.floor(Math.floor(P/Y)/M)}function Q(P,M,Y,tt){let pt=P.updateRanges;if(pt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,M.width,M.height,Y,tt,M.data);else{pt.sort((Bt,Mt)=>Bt.start-Mt.start);let gt=0;for(let Bt=1;Bt0){Vt&&Kt&&e.texStorage2D(i.TEXTURE_2D,vt,Mt,Ot[0].width,Ot[0].height);for(let ot=0,yt=Ot.length;ot0){let Et=Yc(xt.width,xt.height,M.format,M.type);for(let ct of M.layerUpdates){let zt=xt.data.subarray(ct*Et/xt.data.BYTES_PER_ELEMENT,(ct+1)*Et/xt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,ct,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,Bt,xt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,ot,Mt,xt.width,xt.height,at.depth,0,_t,Bt,xt.data);M.layerUpdates.size>0&&M.clearLayerUpdates()}else{Vt&&Kt&&e.texStorage2D(i.TEXTURE_2D,vt,Mt,Ot[0].width,Ot[0].height);for(let ot=0,yt=Ot.length;ot0){let ot=Yc(at.width,at.height,M.format,M.type);for(let yt of M.layerUpdates){let Et=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,Bt,Et)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,at.width,at.height,at.depth,_t,Bt,at.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Mt,at.width,at.height,at.depth,0,_t,Bt,at.data);else if(M.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,Bt,at.data)):e.texImage3D(i.TEXTURE_3D,0,Mt,at.width,at.height,at.depth,0,_t,Bt,at.data);else if(M.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 Et=0;Et>=1,yt>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in i){let ot=i.canvas;if(ot.hasAttribute("layoutsubtree")||ot.setAttribute("layoutsubtree","true"),at.parentNode!==ot){ot.appendChild(at),u.add(M),ot.onpaint=yt=>{let Et=yt.changedElements;for(let ct of u)Et.includes(ct.image)&&(ct.needsUpdate=!0)},ot.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,at);else{let Et=i.RGBA,ct=i.RGBA,zt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Et,ct,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(Ot.length>0){if(Vt&&Kt){let ot=Tt(Ot[0]);e.texStorage2D(i.TEXTURE_2D,vt,Mt,ot.width,ot.height)}for(let ot=0,yt=Ot.length;ot0&&yt++;let ct=Tt(Mt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,yt,Kt,ct.width,ct.height)}for(let ct=0;ct<6;ct++)if(Bt){X?ot&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,0,0,Mt[ct].width,Mt[ct].height,Ot,Vt,Mt[ct].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,Kt,Mt[ct].width,Mt[ct].height,0,Ot,Vt,Mt[ct].data);for(let zt=0;zt>pt),xt=Math.max(1,M.height>>pt);it===i.TEXTURE_3D||it===i.TEXTURE_2D_ARRAY?e.texImage3D(it,pt,at,Mt,xt,M.depth,0,gt,st,null):e.texImage2D(it,pt,at,Mt,xt,0,gt,st,null)}e.bindFramebuffer(i.FRAMEBUFFER,P),Ft(M)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,tt,it,Bt.__webglTexture,0,dt(M)):(it===i.TEXTURE_2D||it>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,tt,it,Bt.__webglTexture,pt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ut(P,M,Y){if(i.bindRenderbuffer(i.RENDERBUFFER,P),M.depthBuffer){let tt=M.depthTexture,it=tt&&tt.isDepthTexture?tt.type:null,pt=v(M.stencilBuffer,it),gt=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Ft(M)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,dt(M),pt,M.width,M.height):Y?i.renderbufferStorageMultisample(i.RENDERBUFFER,dt(M),pt,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,pt,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,gt,i.RENDERBUFFER,P)}else{let tt=M.textures;for(let it=0;it{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,tt.removeEventListener("dispose",it)};tt.addEventListener("dispose",it),M.__depthDisposeCallback=it}M.__boundDepthTexture=tt}if(P.depthTexture&&!M.__autoAllocateDepthBuffer)if(Y)for(let tt=0;tt<6;tt++)ae(M.__webglFramebuffer[tt],P,tt);else{let tt=P.texture.mipmaps;tt&&tt.length>0?ae(M.__webglFramebuffer[0],P,0):ae(M.__webglFramebuffer,P,0)}else if(Y){M.__webglDepthbuffer=[];for(let tt=0;tt<6;tt++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[tt]),M.__webglDepthbuffer[tt]===void 0)M.__webglDepthbuffer[tt]=i.createRenderbuffer(),Ut(M.__webglDepthbuffer[tt],P,!1);else{let it=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=M.__webglDepthbuffer[tt];i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,pt)}}else{let tt=P.texture.mipmaps;if(tt&&tt.length>0?e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Ut(M.__webglDepthbuffer,P,!1);else{let it=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,pt),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,pt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Jt(P,M,Y){let tt=n.get(P);M!==void 0&&ft(tt.__webglFramebuffer,P,P.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Y!==void 0&&Gt(P)}function mt(P){let M=P.texture,Y=n.get(P),tt=n.get(M);P.addEventListener("dispose",x);let it=P.textures,pt=P.isWebGLCubeRenderTarget===!0,gt=it.length>1;if(gt||(tt.__webglTexture===void 0&&(tt.__webglTexture=i.createTexture()),tt.__version=M.version,o.memory.textures++),pt){Y.__webglFramebuffer=[];for(let st=0;st<6;st++)if(M.mipmaps&&M.mipmaps.length>0){Y.__webglFramebuffer[st]=[];for(let at=0;at0){Y.__webglFramebuffer=[];for(let st=0;st0&&Ft(P)===!1){Y.__webglMultisampledFramebuffer=i.createFramebuffer(),Y.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let st=0;st0)for(let at=0;at0)for(let at=0;at0){if(Ft(P)===!1){let M=P.textures,Y=P.width,tt=P.height,it=i.COLOR_BUFFER_BIT,pt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,gt=n.get(P),st=M.length>1;if(st)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&&M.__useRenderToTexture!==!1}function C(P){let M=o.render.frame;h.get(P)!==M&&(h.set(P,M),P.update())}function ht(P,M){let Y=P.colorSpace,tt=P.format,it=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||Y!==er&&Y!==oi&&(ne.getTransfer(Y)===de?(tt!==je||it!==rn)&&Ht("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xt("WebGLTextures: Unsupported texture color space:",Y)),M}function Tt(P){return typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement?(c.width=P.naturalWidth||P.width,c.height=P.naturalHeight||P.height):typeof VideoFrame<"u"&&P instanceof VideoFrame?(c.width=P.displayWidth,c.height=P.displayHeight):(c.width=P.width,c.height=P.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=B,this.getTextureUnits=L,this.setTextureUnits=F,this.setTexture2D=O,this.setTexture2DArray=U,this.setTexture3D=z,this.setTextureCube=q,this.rebindTextures=Jt,this.setupRenderTarget=mt,this.updateRenderTargetMipmap=Ct,this.updateMultisampleRenderTarget=Me,this.setupDepthRenderbuffer=Gt,this.setupFrameBufferTexture=ft,this.useMultisampledRTT=Ft,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function Iv(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===de)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===de?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ea)return o===de?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===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ia)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Pa)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===La)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Da)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Na)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ua)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Fa)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ba)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Oa)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===za)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ka)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ha)return o===de?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Va)return o===de?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===de?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 Pv=` +}`,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=` void main() { gl_Position = vec4( position, 1.0 ); -}`,Lv=` +}`,Uv=` 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:Pv,fragmentShader:Lv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new me(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,u=null,d=null,f=null,g=null,_=typeof XRWebGLBinding<"u",p=new dh,m={},b=e.getContextAttributes(),w=null,S=null,v=[],y=[],A=new Wt,x=null,E=null,I=new Ue;I.viewport=new xe;let D=new Ue;D.viewport=new xe;let N=[I,D],B=new la,L=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(H){let Q=v[H];return Q===void 0&&(Q=new Ss,v[H]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(H){let Q=v[H];return Q===void 0&&(Q=new Ss,v[H]=Q),Q.getGripSpace()},this.getHand=function(H){let Q=v[H];return Q===void 0&&(Q=new Ss,v[H]=Q),Q.getHandSpace()};function k(H){let Q=y.indexOf(H.inputSource);if(Q===-1)return;let ut=v[Q];ut!==void 0&&(ut.update(H.inputSource,H.frame,c||o),ut.dispatchEvent({type:H.type,data:H.inputSource}))}function W(){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",W),s.removeEventListener("inputsourceschange",O);for(let H=0;H=0&&(y[It]=null,v[It].disconnect(ut))}for(let Q=0;Q=y.length){y.push(ut),It=Ut;break}else if(y[Ut]===null){y[Ut]=ut,It=Ut;break}if(It===-1)break}let ft=v[It];ft&&ft.connect(ut)}}let U=new R,z=new R;function q(H,Q,ut){U.setFromMatrixPosition(Q.matrixWorld),z.setFromMatrixPosition(ut.matrixWorld);let It=U.distanceTo(z),ft=Q.projectionMatrix.elements,Ut=ut.projectionMatrix.elements,ae=ft[14]/(ft[10]-1),Gt=ft[14]/(ft[10]+1),Jt=(ft[9]+1)/ft[5],mt=(ft[9]-1)/ft[5],Ct=(ft[8]-1)/ft[0],$t=(Ut[8]+1)/Ut[0],qt=ae*Ct,Me=ae*$t,dt=It/(-Ct+$t),Ft=dt*-Ct;if(Q.matrixWorld.decompose(H.position,H.quaternion,H.scale),H.translateX(Ft),H.translateZ(dt),H.matrixWorld.compose(H.position,H.quaternion,H.scale),H.matrixWorldInverse.copy(H.matrixWorld).invert(),ft[10]===-1)H.projectionMatrix.copy(Q.projectionMatrix),H.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{let C=ae+dt,ht=Gt+dt,Tt=qt-Ft,P=Me+(It-Ft),M=Jt*Gt/ht*C,Y=mt*Gt/ht*C;H.projectionMatrix.makePerspective(Tt,P,M,Y,C,ht),H.projectionMatrixInverse.copy(H.projectionMatrix).invert()}}function V(H,Q){Q===null?H.matrixWorld.copy(H.matrix):H.matrixWorld.multiplyMatrices(Q.matrixWorld,H.matrix),H.matrixWorldInverse.copy(H.matrixWorld).invert()}this.updateCamera=function(H){if(s===null)return;let Q=H.near,ut=H.far;p.texture!==null&&(p.depthNear>0&&(Q=p.depthNear),p.depthFar>0&&(ut=p.depthFar)),B.near=D.near=I.near=Q,B.far=D.far=I.far=ut,(L!==B.near||F!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),L=B.near,F=B.far),B.layers.mask=H.layers.mask|6,I.layers.mask=B.layers.mask&-5,D.layers.mask=B.layers.mask&-3;let It=H.parent,ft=B.cameras;V(B,It);for(let Ut=0;Ut0&&(p.alphaTest.value=m.alphaTest);let b=t.get(m),w=b.envMap,S=b.envMapRotation;w&&(p.envMap.value=w,p.envMapRotation.value.setFromMatrix4(Dv.makeRotationFromEuler(S)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(sf),p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,p.aoMapTransform))}function o(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform))}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,b,w){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*b,p.scale.value=w*.5,m.map&&(p.map.value=m.map,e(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,b){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===ze&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.retroreflectivity>0&&(p.retroreflectivity.value=m.retroreflectivity),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=b.texture,p.transmissionSamplerSize.value.set(b.width,b.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function _(p,m){let b=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(b.matrixWorld),p.nearDistance.value=b.shadow.camera.near,p.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Uv(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,v){let y=v.program;n.uniformBlockBinding(S,y)}function c(S,v){let y=s[S.id];y===void 0&&(p(S),y=h(S),s[S.id]=y,S.addEventListener("dispose",b));let A=v.program;n.updateUBOMapping(S,A);let x=t.render.frame;r[S.id]!==x&&(d(S),r[S.id]=x)}function h(S){let v=u();S.__bindingPointIndex=v;let y=i.createBuffer(),A=S.__size,x=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,y),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,v,y),y}function u(){for(let S=0;S0&&(y+=A-x),S.__size=y,S.__cache={},this}function m(S){let v={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(v.boundary=4,v.storage=4):S.isVector2?(v.boundary=8,v.storage=8):S.isVector3||S.isColor?(v.boundary=16,v.storage=12):S.isVector4?(v.boundary=16,v.storage=16):S.isMatrix3?(v.boundary=48,v.storage=48):S.isMatrix4?(v.boundary=64,v.storage=64):S.isTexture?Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(v.boundary=16,v.storage=S.byteLength):Ht("WebGLRenderer: Unsupported uniform value type.",S),v}function b(S){let v=S.target;v.removeEventListener("dispose",b);let y=o.indexOf(v.__bindingPointIndex);o.splice(y,1),i.deleteBuffer(s[v.id]),delete s[v.id],delete r[v.id]}function w(){for(let S in s)i.deleteBuffer(s[S]);o=[],s={},r={}}return{bind:l,update:c,dispose:w}}var Fv=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 Bv(){return $n===null&&($n=new mn(Fv,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=bd(),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:u=!1,reversedDepthBuffer:d=!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,p=new Set([xa,_a,ga]),m=new Set([rn,Tn,Ps,Ls,pa,ma]),b=new Uint32Array(4),w=new Int32Array(4),S=new R,v=null,y=null,A=[],x=[],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 I=this,D=!1,N=null,B=null,L=null,F=null;this._outputColorSpace=pe;let k=0,W=0,O=null,U=-1,z=null,q=new xe,V=new xe,Z=null,K=new kt(0),lt=0,rt=e.width,H=e.height,Q=1,ut=null,It=null,ft=new xe(0,0,rt,H),Ut=new xe(0,0,rt,H),ae=!1,Gt=new kn,Jt=!1,mt=!1,Ct=new Yt,$t=new R,qt=new xe,Me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},dt=!1;function Ft(){return O===null?Q:1}let C=n;function ht(T,G){return e.getContext(T,G)}let Tt,P,M,Y,tt,it,pt,gt,st,at,_t,Bt,Mt,xt,Ot,Vt,Kt,X,vt,ot,yt,Et,ct;try{let T={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",be,!1),e.addEventListener("webglcontextrestored",he,!1),e.addEventListener("webglcontextcreationerror",_n,!1),C===null){let G="webgl2";if(C=ht(G,T),C===null)throw ht(G)?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",he,!1),e.removeEventListener("webglcontextcreationerror",_n,!1),Xt("WebGLRenderer: "+T.message),T}function zt(){Tt=new W_(C),Tt.init(),yt=new Iv(C,Tt),P=new N_(C,Tt,t,yt),M=new Rv(C,Tt),P.reversedDepthBuffer&&d&&M.buffers.depth.setReversed(!0),B=C.createFramebuffer(),L=C.createFramebuffer(),F=C.createFramebuffer(),Y=new Y_(C),tt=new pv,it=new Cv(C,Tt,M,tt,P,yt,Y),pt=new G_(I),gt=new Zm(C),Et=new L_(C,gt),st=new X_(C,gt,Y,Et),at=new Z_(C,st,gt,Et,Y),X=new $_(C,P,it),Ot=new U_(tt),_t=new fv(I,pt,Tt,P,Et,Ot),Bt=new Nv(I,tt),Mt=new gv,xt=new bv(Tt),Kt=new P_(I,pt,M,at,g,l),Vt=new Av(I,at,P),ct=new Uv(C,Y,P,M),vt=new D_(C,Tt,Y),ot=new q_(C,Tt,Y),Y.programs=_t.programs,I.capabilities=P,I.extensions=Tt,I.properties=tt,I.renderLists=Mt,I.shadowMap=Vt,I.state=M,I.info=Y}_!==rn&&(E=new J_(_,e.width,e.height,a,s,r));let Dt=new fh(I,C);this.xr=Dt,this.getContext=function(){return C},this.getContextAttributes=function(){return C.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 Q},this.setPixelRatio=function(T){T!==void 0&&(Q=T,this.setSize(rt,H,!1))},this.getSize=function(T){return T.set(rt,H)},this.setSize=function(T,G,et=!0){if(Dt.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}rt=T,H=G,e.width=Math.floor(T*Q),e.height=Math.floor(G*Q),et===!0&&(e.style.width=T+"px",e.style.height=G+"px"),E!==null&&E.setSize(e.width,e.height),this.setViewport(0,0,T,G)},this.getDrawingBufferSize=function(T){return T.set(rt*Q,H*Q).floor()},this.setDrawingBufferSize=function(T,G,et){rt=T,H=G,Q=et,e.width=Math.floor(T*et),e.height=Math.floor(G*et),this.setViewport(0,0,T,G)},this.setEffects=function(T){if(_===rn){Xt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(T){for(let G=0;G{function wt(){if(J.forEach(function(Rt){let Pt=tt.get(Rt).currentProgram;(Pt===void 0||Pt.isReady())&&J.delete(Rt)}),J.size===0){j(T);return}setTimeout(wt,10)}Tt.get("KHR_parallel_shader_compile")!==null?wt():setTimeout(wt,10)})};let Fl=null;function qp(T){Fl&&Fl(T)}function Qh(){Pi.stop()}function tu(){Pi.start()}let Pi=new Jd;Pi.setAnimationLoop(qp),typeof self<"u"&&Pi.setContext(self),this.setAnimationLoop=function(T){Fl=T,Dt.setAnimationLoop(T),T===null?Pi.stop():Pi.start()},Dt.addEventListener("sessionstart",Qh),Dt.addEventListener("sessionend",tu),this.render=function(T,G){if(G!==void 0&&G.isCamera!==!0){Xt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;N!==null&&N.renderStart(T,G);let et=Dt.enabled===!0&&Dt.isPresenting===!0,J=E!==null&&(O===null||et)&&E.begin(I,O);if(T.matrixWorldAutoUpdate===!0&&T.updateMatrixWorld(),G.parent===null&&G.matrixWorldAutoUpdate===!0&&G.updateMatrixWorld(),Dt.enabled===!0&&Dt.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Dt.cameraAutoUpdate===!0&&Dt.updateCamera(G),G=Dt.getCamera()),T.isScene===!0&&T.onBeforeRender(I,T,G,O),y=xt.get(T,x.length),y.init(G),y.state.textureUnits=it.getTextureUnits(),x.push(y),Ct.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse),Gt.setFromProjectionMatrix(Ct,bn,G.reversedDepth),mt=this.localClippingEnabled,Jt=Ot.init(this.clippingPlanes,mt),v=Mt.get(T,A.length),v.init(),A.push(v),Dt.enabled===!0&&Dt.isPresenting===!0){let Rt=I.xr.getDepthSensingMesh();Rt!==null&&Bl(Rt,G,-1/0,I.sortObjects)}Bl(T,G,0,I.sortObjects),v.finish(),N!==null&&N.updateLights(y.state.lightsArray),I.sortObjects===!0&&v.sort(ut,It),dt=Dt.enabled===!1||Dt.isPresenting===!1||Dt.hasDepthSensing()===!1,dt&&Kt.addToRenderList(v,T),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Jt===!0&&Ot.beginShadows();let j=y.state.shadowsArray;if(Vt.render(j,T,G),Jt===!0&&Ot.endShadows(),(J&&E.hasRenderPass())===!1){let Rt=v.opaque,St=v.transmissive;if(y.setupLights(),G.isArrayCamera){let Pt=G.cameras;if(St.length>0)for(let Nt=0,jt=Pt.length;Nt0&&nu(Rt,St,T,G),dt&&Kt.render(T),eu(v,T,G)}O!==null&&W===0&&(it.updateMultisampleRenderTarget(O),it.updateRenderTargetMipmap(O)),J&&E.end(I),T.isScene===!0&&T.onAfterRender(I,T,G),Et.resetDefaultState(),U=-1,z=null,x.pop(),x.length>0?(y=x[x.length-1],it.setTextureUnits(y.state.textureUnits),Jt===!0&&Ot.setGlobalState(I.clippingPlanes,y.state.camera)):y=null,A.pop(),A.length>0?v=A[A.length-1]:v=null,N!==null&&N.renderEnd()};function Bl(T,G,et,J){if(T.visible===!1)return;if(T.layers.test(G.layers)){if(T.isGroup)et=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(G);else if(T.isLightProbeGrid)y.pushLightProbeGrid(T);else if(T.isLight)y.pushLight(T),T.castShadow&&y.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||T.intersectsFrustum(Gt)){J&&qt.setFromMatrixPosition(T.matrixWorld).applyMatrix4(Ct);let Rt=at.update(T),St=T.material;St.visible&&v.push(T,Rt,St,et,qt.z,null,G)}}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(Ct)),Array.isArray(St)){let Pt=Rt.groups;for(let Nt=0,jt=Pt.length;Nt0&&Jr(j,G,et),wt.length>0&&Jr(wt,G,et),Rt.length>0&&Jr(Rt,G,et),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function nu(T,G,et,J){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;if(y.state.transmissionRenderTarget[J.id]===void 0){let Lt=Tt.has("EXT_color_buffer_half_float")||Tt.has("EXT_color_buffer_float");y.state.transmissionRenderTarget[J.id]=new Be(1,1,{generateMipmaps:!0,type:Lt?An:rn,minFilter:Si,samples:Math.max(4,P.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ne.workingColorSpace})}let wt=y.state.transmissionRenderTarget[J.id],Rt=J.viewport||q;wt.setSize(Rt.z*I.transmissionResolutionScale,Rt.w*I.transmissionResolutionScale);let St=I.getRenderTarget(),Pt=I.getActiveCubeFace(),Nt=I.getActiveMipmapLevel();I.setRenderTarget(wt),I.getClearColor(K),lt=I.getClearAlpha(),lt<1&&I.setClearColor(16777215,.5),I.clear(),dt&&Kt.render(et);let jt=I.toneMapping;I.toneMapping=En;let ee=J.viewport;if(J.viewport!==void 0&&(J.viewport=void 0),y.setupLightsView(J),Jt===!0&&Ot.setGlobalState(I.clippingPlanes,J),Jr(T,et,J),it.updateMultisampleRenderTarget(wt),it.updateRenderTargetMipmap(wt),Tt.has("WEBGL_multisampled_render_to_texture")===!1){let Lt=!1;for(let ue=0,De=G.length;ue0,J.currentProgram=ee,J.uniformsList=null,ee}function su(T){if(T.uniformsList===null){let G=T.currentProgram.getUniforms();T.uniformsList=Fs.seqWithValue(G.seq,T.uniforms)}return T.uniformsList}function ru(T,G){let et=tt.get(T);et.outputColorSpace=G.outputColorSpace,et.batching=G.batching,et.batchingColor=G.batchingColor,et.instancing=G.instancing,et.instancingColor=G.instancingColor,et.instancingMorph=G.instancingMorph,et.skinning=G.skinning,et.morphTargets=G.morphTargets,et.morphNormals=G.morphNormals,et.morphColors=G.morphColors,et.morphTargetsCount=G.morphTargetsCount,et.numClippingPlanes=G.numClippingPlanes,et.numIntersection=G.numClipIntersection,et.vertexAlphas=G.vertexAlphas,et.vertexTangents=G.vertexTangents,et.toneMapping=G.toneMapping}function Yp(T,G){if(T.length===0)return null;if(T.length===1)return T[0].texture!==null?T[0]:null;S.setFromMatrixPosition(G.matrixWorld);for(let et=0,J=T.length;et0),Lt=!!et.morphAttributes.position,ue=!!et.morphAttributes.normal,De=!!et.morphAttributes.color,Ee=En;J.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(Ee=I.toneMapping);let ve=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,$e=ve!==void 0?ve.length:0,At=tt.get(J),en=y.state.lights;if(Jt===!0&&(mt===!0||T!==z)){let Se=T===z&&J.id===U;Ot.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!==wt||At.numClippingPlanes!==void 0&&(At.numClippingPlanes!==Ot.numPlanes||At.numIntersection!==Ot.numIntersection)||At.vertexAlphas!==jt||At.vertexTangents!==ee||At.morphTargets!==Lt||At.morphNormals!==ue||At.morphColors!==De||At.toneMapping!==Ee||At.morphTargetsCount!==$e||!!At.lightProbeGrid!=y.state.lightProbeGridArray.length>0)&&(le=!0):(le=!0,At.__version=J.version);let dn=At.currentProgram;le===!0&&(dn=jr(J,G,j),N&&J.isNodeMaterial&&N.onUpdateProgram(J,dn,At));let Nn=!1,ci=!1,Ki=!1,ge=dn.getUniforms(),Pe=At.uniforms;if(M.useProgram(dn.program)&&(Nn=!0,ci=!0,Ki=!0),J.id!==U&&(U=J.id,ci=!0),At.needsLights){let Se=Yp(y.state.lightProbeGridArray,j);At.lightProbeGrid!==Se&&(At.lightProbeGrid=Se,ci=!0)}if(Nn||z!==T){M.buffers.depth.getReversed()&&T.reversedDepth!==!0&&(T._reversedDepth=!0,T.updateProjectionMatrix()),ge.setValue(C,"projectionMatrix",T.projectionMatrix),ge.setValue(C,"viewMatrix",T.matrixWorldInverse);let ui=ge.map.cameraPosition;ui!==void 0&&ui.setValue(C,$t.setFromMatrixPosition(T.matrixWorld)),P.logarithmicDepthBuffer&&ge.setValue(C,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&ge.setValue(C,"isOrthographic",T.isOrthographicCamera===!0),z!==T&&(z=T,ci=!0,Ki=!0)}if(At.needsLights&&(en.state.sunShadowMap.length>0&&ge.setValue(C,"sunShadowMap",en.state.sunShadowMap,it),en.state.directionalShadowMap.length>0&&ge.setValue(C,"directionalShadowMap",en.state.directionalShadowMap,it),en.state.spotShadowMap.length>0&&ge.setValue(C,"spotShadowMap",en.state.spotShadowMap,it),en.state.pointShadowMap.length>0&&ge.setValue(C,"pointShadowMap",en.state.pointShadowMap,it)),j.isSkinnedMesh){ge.setOptional(C,j,"bindMatrix"),ge.setOptional(C,j,"bindMatrixInverse");let Se=j.skeleton;Se&&(Se.boneTexture===null&&Se.computeBoneTexture(),ge.setValue(C,"boneTexture",Se.boneTexture,it))}j.isBatchedMesh&&(ge.setOptional(C,j,"batchingTexture"),ge.setValue(C,"batchingTexture",j._matricesTexture,it),ge.setOptional(C,j,"batchingIdTexture"),ge.setValue(C,"batchingIdTexture",j._indirectTexture,it),ge.setOptional(C,j,"batchingColorTexture"),j._colorsTexture!==null&&ge.setValue(C,"batchingColorTexture",j._colorsTexture,it));let hi=et.morphAttributes;if((hi.position!==void 0||hi.normal!==void 0||hi.color!==void 0)&&X.update(j,et,dn),(ci||At.receiveShadow!==j.receiveShadow)&&(At.receiveShadow=j.receiveShadow,ge.setValue(C,"receiveShadow",j.receiveShadow)),(J.isMeshStandardMaterial||J.isMeshLambertMaterial||J.isMeshPhongMaterial)&&J.envMap===null&&G.environment!==null&&(Pe.envMapIntensity.value=G.environmentIntensity),Pe.dfgLUT!==void 0&&(Pe.dfgLUT.value=Bv()),ci){if(ge.setValue(C,"toneMappingExposure",I.toneMappingExposure),At.needsLights&&Zp(Pe,Ki),wt&&J.fog===!0&&Bt.refreshFogUniforms(Pe,wt),Bt.refreshMaterialUniforms(Pe,J,Q,H,y.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(C,su(At),Pe,it)}if(J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Fs.upload(C,su(At),Pe,it),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&ge.setValue(C,"center",j.center),ge.setValue(C,"modelViewMatrix",j.modelViewMatrix),ge.setValue(C,"normalMatrix",j.normalMatrix),ge.setValue(C,"modelMatrix",j.matrixWorld),J.uniformsGroups!==void 0){let Se=J.uniformsGroups;for(let ui=0,Ji=Se.length;ui0&&it.useMultisampledRTT(T)===!1?J=tt.get(T).__webglMultisampledFramebuffer:Array.isArray(Nt)?J=Nt[et]:J=Nt,q.copy(T.viewport),V.copy(T.scissor),Z=T.scissorTest}else q.copy(ft).multiplyScalar(Q).floor(),V.copy(Ut).multiplyScalar(Q).floor(),Z=ae;if(et!==0&&(J=B),M.bindFramebuffer(C.FRAMEBUFFER,J)&&M.drawBuffers(T,J),M.viewport(q),M.scissor(V),M.setScissorTest(Z),j){let St=tt.get(T.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+G,St.__webglTexture,et)}else if(wt){let St=G;for(let Pt=0;Pt1&&C.readBuffer(C.COLOR_ATTACHMENT0+St);let Lt=ou(Nt);if(Lt.__formatReadable===!1){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Lt.__typeReadable===!1){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}G>=0&&G<=T.width-J&&et>=0&&et<=T.height-j&&C.readPixels(G,et,J,j,yt.convert(jt),yt.convert(ee),wt)}finally{let Nt=O!==null?tt.get(O).__webglFramebuffer:null;M.bindFramebuffer(C.FRAMEBUFFER,Nt)}}},this.readRenderTargetPixelsAsync=async function(T,G,et,J,j,wt,Rt,St=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&&Rt!==void 0&&(Pt=Pt[Rt]),Pt)if(G>=0&&G<=T.width-J&&et>=0&&et<=T.height-j){M.bindFramebuffer(C.FRAMEBUFFER,Pt);let Nt=T.textures[St],jt=Nt.format,ee=Nt.type;T.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+St);let Lt=ou(Nt);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 ue=C.createBuffer();C.bindBuffer(C.PIXEL_PACK_BUFFER,ue),C.bufferData(C.PIXEL_PACK_BUFFER,wt.byteLength,C.STREAM_READ),C.readPixels(G,et,J,j,yt.convert(jt),yt.convert(ee),0),C.bindBuffer(C.PIXEL_PACK_BUFFER,null);let De=O!==null?tt.get(O).__webglFramebuffer:null;M.bindFramebuffer(C.FRAMEBUFFER,De);let Ee=C.fenceSync(C.SYNC_GPU_COMMANDS_COMPLETE,0);return C.flush(),await wd(C,Ee,4),C.bindBuffer(C.PIXEL_PACK_BUFFER,ue),C.getBufferSubData(C.PIXEL_PACK_BUFFER,0,wt),C.bindBuffer(C.PIXEL_PACK_BUFFER,null),C.deleteBuffer(ue),C.deleteSync(Ee),wt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,G=null,et=0){let J=Math.pow(2,-et),j=Math.floor(T.image.width*J),wt=Math.floor(T.image.height*J),Rt=G!==null?G.x:0,St=G!==null?G.y:0;it.setTexture2D(T,0),C.copyTexSubImage2D(C.TEXTURE_2D,et,0,0,Rt,St,j,wt),M.unbindTexture()},this.copyTextureToTexture=function(T,G,et=null,J=null,j=0,wt=0){let Rt,St,Pt,Nt,jt,ee,Lt,ue,De,Ee=T.isCompressedTexture?T.mipmaps[wt]:T.image;if(et!==null)Rt=et.max.x-et.min.x,St=et.max.y-et.min.y,Pt=et.isBox3?et.max.z-et.min.z:1,Nt=et.min.x,jt=et.min.y,ee=et.isBox3?et.min.z:0;else{let Pe=Math.pow(2,-j);Rt=Math.floor(Ee.width*Pe),St=Math.floor(Ee.height*Pe),T.isDataArrayTexture?Pt=Ee.depth:T.isData3DTexture?Pt=Math.floor(Ee.depth*Pe):Pt=1,Nt=0,jt=0,ee=0}J!==null?(Lt=J.x,ue=J.y,De=J.z):(Lt=0,ue=0,De=0);let ve=yt.convert(G.format),$e=yt.convert(G.type),At;G.isData3DTexture?(it.setTexture3D(G,0),At=C.TEXTURE_3D):G.isDataArrayTexture||G.isCompressedArrayTexture?(it.setTexture2DArray(G,0),At=C.TEXTURE_2D_ARRAY):(it.setTexture2D(G,0),At=C.TEXTURE_2D),M.activeTexture(C.TEXTURE0),M.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,G.flipY),M.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),M.pixelStorei(C.UNPACK_ALIGNMENT,G.unpackAlignment);let en=M.getParameter(C.UNPACK_ROW_LENGTH),le=M.getParameter(C.UNPACK_IMAGE_HEIGHT),dn=M.getParameter(C.UNPACK_SKIP_PIXELS),Nn=M.getParameter(C.UNPACK_SKIP_ROWS),ci=M.getParameter(C.UNPACK_SKIP_IMAGES);M.pixelStorei(C.UNPACK_ROW_LENGTH,Ee.width),M.pixelStorei(C.UNPACK_IMAGE_HEIGHT,Ee.height),M.pixelStorei(C.UNPACK_SKIP_PIXELS,Nt),M.pixelStorei(C.UNPACK_SKIP_ROWS,jt),M.pixelStorei(C.UNPACK_SKIP_IMAGES,ee);let Ki=T.isDataArrayTexture||T.isData3DTexture,ge=G.isDataArrayTexture||G.isData3DTexture;if(T.isDepthTexture){let Pe=tt.get(T),hi=tt.get(G),Se=tt.get(Pe.__renderTarget),ui=tt.get(hi.__renderTarget);M.bindFramebuffer(C.READ_FRAMEBUFFER,Se.__webglFramebuffer),M.bindFramebuffer(C.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"),hf=i=>Yi(i)&&Ai(i.min)&&Ai(i.max),af=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||hf(i.box)&&i.box.max.every(Number.isFinite)&&i.box.min.every((t,e)=>Number.isFinite(t)&&t<=i.box.max[e]));function kv(i){if(!Yi(i)||!Rn(i.elements)||!Rn(i.geometries)||!Rn(i.materials)||!Yi(i.instances))throw new te("META must describe elements, geometries, materials and instances.");if(i.title!=null&&typeof i.title!="string")throw new te("Invalid META title.");let{instances:t}=i;if(!Number.isSafeInteger(t.count)||t.count<0)throw new te("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 te(`Invalid META instance ${n} view.`);for(let n of i.geometries){let s=n.q;if(!hf(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 te("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 te(`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 te(`Invalid META ${n} ${r} view.`)}if(i.annotations!=null&&!Rn(i.annotations))throw new te("Invalid META annotations.");if(i.sheets!=null&&!Rn(i.sheets))throw new te("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 te("Invalid META panorama.");function e(n){return n?.t==="u8"&&Number.isSafeInteger(n.n)&&n.n>=4&&n.n<=16*1024*1024}Hv(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 te("Invalid META material.")}}function Hv(i){if(!Yi(i)||!Rn(i.elements)||i.title!=null&&typeof i.title!="string")throw new te("Invalid review metadata.");for(let l of["textures","grids","viewpoints","bcfTopics","clashTests","linkedFiles","models"])if(i[l]!=null&&!Rn(i[l]))throw new te(`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 te("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)&&af(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 te("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 te("Invalid META BCF topics.");if(i.linkedFiles?.some(l=>!t(l.members)))throw new te("Invalid META linked file members.");if(!af(i.sections))throw new te("Invalid META sections.")}function Vv(i){let t;try{t=JSON.parse(i)}catch(e){throw new te(e.message,{cause:e})}return kv(t),t}function mh(i=document,t){t?.("metadataStart");let e;try{e=cf(i,"ioviewer-meta")}catch(s){throw s instanceof te?s:new te(s.message,{cause:s})}let n=Vv(e);return t?.("metadataEnd"),n}function lf(i,t){let e=Ov[i?.t];if(!e)throw new te(`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 te(`View ${JSON.stringify(i)} is outside the ${t} bytes of binary data.`);return e}function uf(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}=of(s)),t?.("binaryEnd")}catch(c){throw new te(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=lf(c,a);return new h(n.buffer,c.o,c.n)},readView(c){let h=lf(c,a);if(!c.n)return new h(0);!n&&!r&&(o??(o=of(s).bytes));let u=n??o;return u?new h(u.buffer,c.o,c.n):new h(zv(s,c.o,c.n*h.BYTES_PER_ELEMENT))},releaseBinary(){n=null,o=null},props(c){return l??(l=JSON.parse(cf(i,"ioviewer-props"))),l[c]??null}}}var df=new Yt,ff=new kn,gh=32;function _h(i,t=new Float64Array(24)){return df.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ff.setFromProjectionMatrix(df,i.coordinateSystem,i.reversedDepth),ff.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 pf(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 gf(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]=gf(o),i[t+1]=gf(a)}function _f(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[u]&&(s[u]=d))}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(d)?Math.round((d-n[r])/o*a):0;l[h]=f*2**32+u}let c=0;e<0?l.sort():c=Wv(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,u=n;for(;h<=u;){for(;i[h]c;)u--;if(h<=u){let d=i[h];i[h++]=i[u],i[u--]=d}}if(t<=u)n=u;else if(t>=h)e=h;else return a}return a}function wf(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&&Xv(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+=Sf(o,i,l),r.push(o.subarray(l),o.subarray(0,l))}return s}function Xv(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],u=t[l*3+2];cr&&(r=c),ho&&(o=h),ua&&(a=u)}return Math.hypot(r-e,o-n,a-s)/2}function Ef(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 Tf(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,u)=>a(u)-a(h)||i[u].k-i[h].k||h-u);let c=0;for(let h of l){let u=i[h].cells??Math.ceil(i[h].k/n);c+u>s||(r[h]=1,c+=u)}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 Af(i,t,e,n){for(;t>>1;i[s]>=n?t=s+1:e=s}return t}function Rf(i,t,e){let n=i[t];return[n,e>t?i[e]-n:0]}function Cf(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 yf}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 u=s[h*3+a]*e.min[h],d=s[h*3+a]*e.max[h];l+=Math.min(u,d),c+=Math.max(u,d)}n[a]=Math.floor(l/Cn)*Cn,Math.ceil((c-n[a])/Cn)<=Mf||(o=!1)}return o||n.fill(0),o?Gv:ks}function If(i,t){let e=i.length,n=0,s=0;for(let p of i){let m=t.source(t.geometryOf[p]);n+=m.vertices,s+=m.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),u=new Float32Array(e*3),d=new Float32Array(e),f=new Float64Array(3),g=0,_=0;for(let p=0;pMath.min(Math.max(Math.round(i/Cn),0),Mf);function Pf(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]=u)}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[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)throw new Error(`The shader must contain '${t}' exactly once.`);return i.slice(0,n)+e+i.slice(n+t.length)}function Kv(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ri(i.vertexShader,"#include ",`#include +#endif`;function Ri(i,t,e){let n=i.indexOf(t);if(n<0||i.indexOf(t,n+1)>=0)throw new Error(`The shader must contain '${t}' exactly once.`);return i.slice(0,n)+e+i.slice(n+t.length)}function 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 ",Zv),t=Ri(t,"#include ","vec3 transformed = slotPosition;"),t=Ri(t,"#include ",`#include +vTint = state.rgb;`),t=Ri(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ri(t,"#include ",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=Kv,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var Ih=["materials","textures","white","wireframe"],Jv=[245,158,11],jv=[235,235,237],zr=4294967295,$i=2048,Th=256,Qv=16,Ah=1024,ty=.1,ey=8192,ny=1.4,ol=2**-20,rl=17;function iy(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 sy(){this.array=null}function In(i,t,e=!1,n=_e){return new n(i,t,e).onUpload(sy)}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}},Lf=(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],u=i[r+a+9],d=l*e[0],f=l*n[0],g=c*e[1],_=c*n[1],p=h*e[2],m=h*n[2];s[o+a]=Math.min(d,f)+Math.min(g,_)+Math.min(p,m)+u,s[o+a+3]=Math.max(d,f)+Math.max(g,_)+Math.max(p,m)+u}}var oy=i=>{let t=i.getHex(pe);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,u=n.lines,d=u?.count??0,f=r+h+d;this.root=new Re,this.elementCount=n.elements.length,this.pointOffset=r,this.lineOffset=r+h,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(f),this._elementOf.set(t.view(s.element)),this._bucketOf=new Uint32Array(r),this._visible=new Uint8Array(f).fill(1),this._layers=new Map,this._layerHides=new Uint8Array(f),this._highlight=new Uint8Array(f),this._highlighted=[],this._tint=new Map,this._boxes=new Float32Array(f*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 p=t.view(c.geometry),m=t.view(c.matrix),b=this._boxes.subarray(r*6);for(let w=0;wthis._shown(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 d=0;d<=s;d++){let f=this._pixels[n+d];f<0||(fc.count;for(let d=0;d0?o[6]/p:1/0:o[6];u[f]=m;let b=g.cell&&this._detailUsesInstances,w=b&&!pf(r,_[0],_[1],_[2],_[3]+g.pickPadding),S=g.slotBase+g.n,v=-1;if(b){let I=this._slotRadius[g.slotBase],D=this._slotRadius[S-1],N=p+_[3],B=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],L=N-B-I,F=N+B-D,k=Math.fround(o[7]?L>0?I*o[6]/L:1/0:I*m),W=Math.fround(o[7]?F>0?D*o[6]/F:1/0:D*m);Os(W)===Os(k)&&(v=k)}if(v>=0&&!w){g.detailLow=g.detailHigh=v,g.detailEnd=g.n;let I=this._slotCost[g.slotBase]*g.shown;l[Os(v)]+=I,d+=I;continue}let y=0,A=1/0,x=-1,E=0;for(let I=g.slotBase;I=0){y++;continue}let U=(k-o[0])*o[3]+(W-o[1])*o[4]+(O-o[2])*o[5]-D;N=o[7]?U>0?o[6]/U:1/0:o[6]}let B=N===1/0?1/0:Math.fround(D*N);b&&(a[I]=B,A=Math.min(A,B),x=Math.max(x,B));let L=this._slotCost[I];l[Os(B)]+=L,d+=L}if(b){if(y){A=x=v;let I=y*this._slotCost[g.slotBase];l[Os(v)]+=I,d+=I}g.detailLow=A,g.detailHigh=x,g.detailEnd=E}}return this.visibleCost=d,mf(l,d,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),V=z.uvs?t.view(z.uvs):null;U=Pf(Fr(t,z),z.q??null,xf(t,z),q,V),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),u=new Float64Array(o*3),d=new Float32Array(o*3),f=new Uint32Array(o),g=new Float32Array(o),_=new Uint8Array(o),p=new Map,m=this._boxes;for(let O=0;OO-U).map(O=>{let U=p.get(O),z=c(e[U[0]]),q=this._buckets[this._bucketOf[U[0]]].texture!==null,V=[0,1,2].every(K=>(z.max[K]-z.min[K])/Cn<=65535),Z=z.vertices*((V?12:20)+(q?8:0))+z.indices.length*(z.vertices>65535?4:2);return{k:U.length,bytes:Z,members:U,textured:q}}),S=s.mergedCap??bh,v=s.minRepeats??Qv;if(w.reduce((O,U)=>O+U.k*U.bytes,0)>S){let O=s.cellExtent==null?Ef(m,f)*ty:this.visibleBox().getSize(new R).length()*s.cellExtent;for(let U of w)U.k{if(y[U]){for(let z of O.leaves)E.push({shape:O,members:Sh(z,g)});return}for(let z of O.members){x[e[z]]++;let q=this._bucketOf[z]*2+(h[z]===ks?1:0),V=A.get(q);V||A.set(q,V=[]),V.push(z)}});let I=[];for(let O of[...A.keys()].sort((U,z)=>U-z))for(let U of bf(d,f,A.get(O),s.chunkVertices??vf))I.push(Sh(U,g));let D=[...I,...E.map(O=>O.members)].reduce((O,U)=>O+U.length,0);if(D>r)throw new kr(D,r);let N=Math.max(1,Math.ceil(D/$i)),B=new Float32Array($i*N*4);this._state=new mn(new Uint8Array($i*N*4),$i,N),this._state.colorSpace=pe,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(Th),this._dirtyCount=0;let L=new mn(B,$i,N,je,Ye);L.needsUpdate=!0,L.onUpdate=()=>L.image.data=null,this.slotUniforms.slotInfo.value=L,this.slotUniforms.slotState.value=this._state,this._stateBytes=$i*N*20,this._slotOf=new Uint32Array(this._visible.length).fill(zr),this._slotInstance=new Uint32Array(D),this._slotUnit=new Uint32Array(D),this._slotRadius=new Float32Array(D),this._slotCost=new Float32Array(D),this._pixels=new Float32Array(D),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:u,source:c,textured:!1};this._lineSources=new Map;let k=0;for(let O of I){let U=this._buckets[this._bucketOf[O[0]]];F.textured=U.texture!==null;let z=If(O,F);for(let q=0;qO+U,0);let W=new Map;for(let{shape:O,members:U}of E){let z=U[0],q=c(e[z]),V=W.get(O);if(!V){let Z=a.geometries[e[z]].bbox;V=this._shape(q,_[z]===1,O.textured);let K=rt=>Math.max(...rt.map(Math.abs)),lt=Math.max(K(q.min),K(q.max));V.pickExtent=lt,V.pickPadding=Math.max(0,...q.min.map((rt,H)=>Z.min[H]-rt),...q.max.map((rt,H)=>rt-Z.max[H]))+(q.q?ol*(K(q.q.o)+65535*Math.abs(q.q.s)):0),W.set(O,V)}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+m),1,!1,ri);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Nf(this._boxes,e),h=new Oe(new R(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let u=new xi(a,t.material,0),d=new Float32Array(o*16),f=new Float32Array(o*12),g=0;for(let p=0;pthis._range(_,p,b,u),u.visible=!1,this.root.add(u),_}_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=Nf(this._boxes,e);a.boundingSphere=new Oe(new R(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 me(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=(u,d,f)=>this._range(h,u,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=(u,d,f)=>this._range(n,u,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 u=this._lineSources.get(e[h]),d=t[h]===1;for(let f=0;fthis._range(n,h,d,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]&&!ry(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=Df(a,t.sphere),c=a[7]?l>0?this._minPixels*l/a[6]:0:this._minPixels/a[6];r=Math.min(r,Af(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]=Rf(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=pe,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]?Jv:this._tint.get(t)??(this._mode==="white"?jv: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(!Lf(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 Df(i,t){return(t[0]-i[0])*i[3]+(t[1]-i[1])*i[4]+(t[2]-i[2])*i[5]-t[3]}function Nf(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{b!==d&&(b.uniforms.pointIndex.value=o,b.uniforms.pointSize.value=d.opacity>0?d.size:0,b.uniformsNeedUpdate=!0)},f.matrixAutoUpdate=!1,f.matrix.fromArray(ay(r,o)),f.matrixWorldNeedsUpdate=!0,f.frustumCulled=!0,c.computeBoundingSphere(),this.root.add(f),this._materials.push({material:d,color:d.color.clone(),opacity:h?.opacity??1,vertexColors:u})}}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 ay(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,ly=524288,Lh=[245,158,11],Dh=[235,235,237],cy=` +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=` #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); -}`,hy=` +}`,fy=` #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=pe,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 te(`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=[],u=[],d=()=>{if(h.length===0)return;let f=new ce;f.setAttribute("position",new _e(new Float32Array(h),3)),f.setAttribute("lineSlot",new _e(new Float32Array(u),1)),f.computeBoundingSphere();let g=new ln(f,this._material);g.frustumCulled=!1,this.root.add(g),h=[],u=[]};for(let f=0;fly&&u.length>0&&d();for(let L=0;L>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 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.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=uy[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Uf=new R(0,0,1),cl=Math.PI/2-.01;function Bf(i,t,e=4){return Math.hypot(t.x-i.x,t.y-i.y)<=e}function Of(i,t,e,n,s,r){let o=i.clone().sub(e),a=t.clone().sub(e),l=u=>(o.applyQuaternion(u),a.applyQuaternion(u));l(new Fe().setFromAxisAngle(Uf,-n*r));let c=a.clone().sub(o).normalize(),h=c.clone().cross(Uf);if(h.lengthSq()>1e-12){let u=Math.asin(oe.clamp(c.z,-1,1)),d=oe.clamp(s*r,u-cl,u+cl);l(new Fe().setFromAxisAngle(h.normalize(),-d))}return{position:o.add(e),target:a.add(e)}}function zf(i,t,e,n){let s=r=>r.clone().sub(e).multiplyScalar(n).add(e);return{position:s(i),target:s(t)}}var dy=.85,fy=100/3;function kf(i,t,e){let n=i*(t===1?fy:t===2?e:1);return oe.clamp(dy**(-n/100),.5,2)}var Nh=(i,t)=>t>=i?"window":"crossing";function Hf(i,t,e){let n=Ff(i.position,i.target),s=Ff(t.position,t.target),r=n.azimuth??s.azimuth??0,o=s.azimuth??r,a=oe.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,p)=>_+(p-_)*e,c=r+a*e,h=oe.clamp(l(n.elevation,s.elevation),-cl,cl),u=l(n.distance,s.distance),d=i.target.clone().lerp(t.target,e),f=Math.cos(h)*u;return{position:d.clone().add(new R(f*Math.cos(c),f*Math.sin(c),Math.sin(h)*u)),target:d}}function Vf(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 R().setFromMatrixColumn(new Yt().lookAt(t.position,t.target,n),1),u=r.dot(new R().crossVectors(c,h)),d=Math.atan2(Math.abs(u)<1e-9?0:u,c.dot(h)),f=new Fe;return g=>{f.identity().slerp(l,g);let _=s.clone().applyQuaternion(f),p=i.target.clone().lerp(t.target,g),m=_.clone().multiplyScalar(oe.lerp(o,a,g)).add(p),b=e.clone().applyQuaternion(f).applyAxisAngle(_,d*g);return{position:m,target:p,up:b}}}function Ff(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(oe.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var py=.005,Gf=new R(1,-1,.8).normalize(),Uh=.01,Wf=1e-6,my=64,Xf=1.05,gy=5e3,hl=(i,t)=>new CustomEvent(i,{detail:t});function qf({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 R(...i.min),new R(...i.max));if(n.isEmpty())return!0;let s=new R;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()*Xf>Uh*gy}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 R,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(oe.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 R(0,0,-1).applyQuaternion(t.quaternion);t.far=Math.max(1e-6,(r.length()+s.radius)*Xf);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 R),u=Math.max(h.x,h.y,n.radius*2,.01),d=t.getCenter(new R),f=new R(d.x,d.y,t.max.z+u*2);this._set(f,d);let g=Math.max(this.dom.clientWidth/Math.max(this.dom.clientHeight,1),.001),_=Math.max(this.camera.top,1e-6),p=Math.max(h.y/2,h.x/(2*g),1e-4)*1.06;this.camera.zoom=_/p,this.resize();return}let s=Math.max(n.radius,.001),r=oe.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(Gf);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 R),l=Math.max(o.getBoundingSphere(new Oe).radius,1);this._set(a.clone().addScaledVector(Gf,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 R(...t),a=new R(...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(oe.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?Vf(o,a,new R(0,1,0).applyQuaternion(this.camera.quaternion),this.camera.up):d=>Hf(o,a,d),h=performance.now(),u=d=>{let f=Math.min((d-h)/r,1),g=f*f*(3-2*f),_=c(g);this.camera.isOrthographicCamera&&(this.camera.zoom=oe.lerp(l,n,g)),this._set(_.position,_.target,_.up),this._animation=f<1?requestAnimationFrame(u):0};this._animation=requestAnimationFrame(u)}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(Wf,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&&Bf(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=Of(this.camera.position,this.target,e.pivot,s,r,py);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 R))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(oe.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new R(1,0,0).applyQuaternion(n.quaternion),a=new R(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=kf(t.deltaY,t.deltaMode,this.dom.clientHeight),n=this.camera,s=n.position.distanceTo(this.target),r=this._visibleBounds()?.sphere.radius??0,o=my*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:p,width:m,height:b}=this.dom.getBoundingClientRect();if(!m||!b)return;let w=oe.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(w===n.zoom)return;let S=new R((2*(t.clientX-_)/m-1)*n.right,(1-2*(t.clientY-p)/b)*n.top,0).multiplyScalar(1/n.zoom-1/w).applyQuaternion(n.quaternion);n.zoom=w,this._set(n.position.clone().add(S),this.target.clone().add(S));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new R),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Uh,Math.max(Wf,r)),h=oe.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let u=n.position.clone().addScaledVector(a,l),d=this._wheelPick.point,f=d&&d.clone().sub(n.position).dot(a)>=c?d:u,g=zf(n.position,u,f,h);this._set(g.position,g.target)}};function nt(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=nt("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 ye=i=>``,Yf='',re={model:ye(''),views:ye(''),sections:ye(''),clashes:ye(''),bcf:ye(''),timeliner:ye(''),links:ye(''),orbit:ye(''),pan:ye(''),fit:ye(''),projection:ye(Yf),mode2d:ye(''),plane:ye(''),box:ye(`${Yf}`),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 Wr=new R(0,0,1),un={right:new R(1,0,0),left:new R(-1,0,0),back:new R(0,1,0),front:new R(0,-1,0),top:new R(0,0,1),bottom:new R(0,0,-1)},_y={right:Wr,left:Wr,back:Wr,front:Wr,top:un.back,bottom:un.front},Zi=.7,xy=oe.degToRad(1),$f=.01,Zf=96,fl=1.75;function Kf(i){let t=i.split("-"),e=new R;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 vy(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=xy){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 R(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($f)).addScaledVector(un[i],Math.cos($f))}function yy(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):Kf(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 My(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=pe,r}var pl=class{constructor(t,e,n){this.controls=n,this.home={position:e.position.clone(),target:n.target.clone()},this.element=nt("div","ioviewer-viewcube"),this.canvas=nt("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}`),u=new me(new cn(2,2),new Je({map:My(h,s)})),d=_y[l];u.quaternion.setFromRotationMatrix(new Yt().makeBasis(d.clone().cross(c),d,c)),u.position.copy(c),u.name=l,u.userData.label=h,this.faces.add(u)}let r=new ln(new Hi(new gn(2,2,2)),new sn({color:"#5b6575"}));this.highlight=new me(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)):Kf(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=tn("ioviewer-viewcube-arrow",re.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",re.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(Zf,Zf),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?vy(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 R),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=yy(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 by=` +}`,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=` #include #ifdef IO_PICK_POINTS uniform uint pointIndex; @@ -4341,7 +4341,7 @@ void main() { vSlot = vec2( float( slot >> 12 ), float( slot & 4095 ) ); if ( state.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); #endif -}`,Sy=` +}`,Ty=` #include #include #include @@ -4390,10 +4390,10 @@ void main() { uvec4 bytes = ( uvec4( bits ) >> uvec4( 0u, 8u, 16u, 24u ) ) & 255u; gl_FragColor = vec4( bytes ) / 255.0; #endif -}`,jf=i=>i&&{element:i.element,point:i.point.clone()};function li(i,t,e=null){let n=new Ie({vertexShader:by,fragmentShader:Sy,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[u]))return jf(l.hit);let c=this._pick(s,r,n);return this._last={camera:a,key:o.slice(),hit:c},jf(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&&rx===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:u,ids:d,depths:f}=this._measure,g=r-n,_=o-n;this._render(this._material,g,_,s,u,d);let p=(x,E)=>{let I=Math.floor(x)-g,D=Math.floor(E)-_;return I>=0&&I=0&&Dthis._slotAt(m,x),w=p(r,o),S=b(w),v=w;if(S<0&&(this.points||this.lines)){let x=(n+1)**2;for(let E=0;Ex||(x=D,v=E)}}let y=null,A=b(v);if(A>=0){f&&this._render(this._depthMaterial,g,_,s,u,f);let x=f&&new DataView(f.buffer),E=l.matrixWorldInverse.elements.slice(),I=new R,D=U=>{let z=this._vertexAt(b(U),d,x,U,I);return z?-(E[2]*z.x+E[6]*z.y+E[10]*z.z+E[14]):x.getFloat32(U*4,!0)},N=this._vertexAt(A,d,x,v)??this._depthPoint(r,o,s,D(v)),B=this._isPoint(A),L=this._isLine(A)?A-this.scene.slotCount-(this.points?.count??0):-1,F=new Set,k=this._elementAt(A),W=new Set(B||L>=0?[]:[A]);if(L>=0&&F.add(L),!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&&!W.has(z)&&this.scene.slotElement(z)===k&&W.add(z))}let O=l.isPerspectiveCamera;y={rect:s,point:N,element:k,slots:W,lineInstances:F,pointSample:B,depthAt(U,z,q){let V=p(U,z),Z=V<0?-1:b(V);if(Z<0)return 1/0;if(Z!==q)return D(V);let K=Q=>O?1/D(Q):D(Q),lt=K(V);function rt(Q,ut,It){let ft=Math.sign(It),Ut=p(U+ft*Q,z+ft*ut);if(Ut>=0&&b(Ut)===Z)return(K(Ut)-lt)*Math.abs(It);let ae=p(U-ft*Q,z-ft*ut);return ae>=0&&b(ae)===Z?(lt-K(ae))*Math.abs(It):0}let H=lt+rt(1,0,U-Math.floor(U)-.5)+rt(0,1,z-Math.floor(z)-.5);return H>0?O?1/H:H:D(V)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:y},this._last={camera:l,key:this._lastTile.key,hit:S>=0?y:null},y}_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 m=1/0;for(let b=0;b=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 R){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 R((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 u=t===this._depthMaterial?this._pointDepthMaterial:this._pointMaterial;this.points.withPickMaterial(u,()=>a.render(this.points.root,l))}if(this.lines){a.autoClear=!1;let u=t===this._depthMaterial?this._lineDepthMaterial:this._lineMaterial;this.lines.withPickMaterial(u,()=>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,wy=200,Qf=1e6,Ey=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,wy)))}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=Ey),this._cost>gl*1.1?this.budget=Math.max(this.budget*.9,Qf):this._cost0&&(this.budget=Math.max(Math.min(this.budget*1.05,this.scene.visibleCost),Qf))}_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){cu(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 tp(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 ep(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 p=[...t.children].find(v=>np.indexOf(v.dataset.panel)>g);t.insertBefore(_,p??null);let m=nt("section","ioviewer-side-panel ioviewer-floating");m.dataset.panel=l,m.hidden=!0,m.setAttribute("aria-label",h);let b=tn("ioviewer-panel-close",re.close,$("close"));b.addEventListener("click",()=>r(l));let w=nt("header","ioviewer-panel-header");w.append(nt("h2","",h),b);let S=nt("div","ioviewer-panel-body");m.append(w,S),i.append(m),e.set(l,{button:_,panel:m,onClose:f}),u(S)}return{rail:t,openPanel:o,closePanel:r,registerPanel:a}}var sp=[{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 rp(i,t){let e=nt("div","ioviewer-toolbar ioviewer-floating");e.setAttribute("role","toolbar");let n=new Map;for(let a of t){let l=nt("div","ioviewer-toolbar-group");l.setAttribute("role","group"),l.setAttribute("aria-label",$(`group.${a.id}`));let c=nt("div","ioviewer-toolbar-row");for(let h of a.items){let u=tn("ioviewer-tool",re[h],$(`tool.${h}`));u.dataset.tool=h,u.setAttribute("aria-disabled","true");let d={button:u,handler:null};u.addEventListener("click",()=>{u.getAttribute("aria-disabled")!=="true"&&d.handler?.()}),n.set(h,d),c.append(u)}l.append(c,nt("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 Ty="input, textarea, select, [contenteditable]";function Oh(i){return i.key==="ContextMenu"||i.code==="ContextMenu"||i.shiftKey&&(i.key==="F10"||i.code==="F10")}function op(i){if(i.ctrlKey||i.altKey||i.metaKey||i.repeat||i.target?.closest?.(Ty))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 ap(i,t,e,n,s){let r=nt("details","ioviewer-tree-filters");r.hidden=i.length===0;let o=nt("summary","",$("filters.title")),a=nt("div","ioviewer-filter-fields"),l=new Map(t.map(({id:v,name:y})=>[v,y||`#${v}`])),c=v=>v.modelId??t[0]?.id??null,h=v=>v.levelId??(v.level||null),u=v=>v.category??"",d=[{name:$("filters.model"),key:c,labels:new Map},{name:$("level"),key:h,labels:new Map},{name:$("category"),key:u,labels:new Map}],[f,g,_]=d,p=nt("div","ioviewer-filter-actions"),m=nt("button","ioviewer-text-button",$("filters.clear"));m.type="button",m.addEventListener("click",()=>{for(let v of d)v.select&&(v.select.selectedIndex=0);e.value="",n(),e.focus()});let b=nt("button","ioviewer-text-button",$("filters.isolate"));b.type="button",b.addEventListener("click",s),p.append(m,b),r.append(o,a,p);function w(){if(r.open){r.removeEventListener("toggle",w);for(let v of i){let y=c(v),A=l.get(y)??(y==null?"":`#${y}`);y!=null&&f.labels.set(y,A);let x=h(v);if(!g.labels.has(x)){let I=v.level||(x==null?$("filters.noLevel"):`#${x}`);g.labels.set(x,x!=null&&t.length>1&&A?`${I} \xB7 ${A}`:I)}let E=u(v);_.labels.set(E,E||$("noCategory"))}for(let v of d){if(!v.labels.size)continue;let y=new Map;for(let I of v.labels.values())y.set(I,(y.get(I)??0)+1);let A=[...v.labels].map(([I,D])=>[I,y.get(D)>1?`${D} (#${I})`:D]);A.sort((I,D)=>I[1].localeCompare(D[1])),v.keys=A.map(([I])=>I);let x=v.select=nt("select");x.append(new Option($("filters.all"),""));for(let[I,[,D]]of A.entries())x.append(new Option(D,String(I+1)));x.addEventListener("change",n);let E=nt("label","ioviewer-filter-field");E.append(nt("span","",v.name),x),a.append(E)}}}r.addEventListener("toggle",w);function S(){return d.filter(v=>v.select?.selectedIndex>0)}return{element:r,predicate(){let v=S().map(({select:y,keys:A,key:x})=>({key:x,value:A[y.selectedIndex-1]}));return v.length?y=>v.every(({key:A,value:x})=>A(y)===x):null},update(v,y){let A=S().length;o.textContent=A?`${$("filters.title")} (${A})`:$("filters.title"),m.disabled=!A&&!v,b.disabled=!y}}}var Ci=24,Ay=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 Ry(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} +}`,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??""} ${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 lp(i,{elements:t,models:e,selection:n,scene:s,zoomToElement:r,openContextMenu:o}){let a=Cy(t),l=new Int32Array(t.length);a.forEach((V,Z)=>V.indices.forEach(K=>l[K]=Z));let c=new Uint8Array(a.length),h=new Int32Array(a.length),u=new Uint32Array(a.length),d=Ry(t),f="",g=!1,_=new Int32Array(0),p=0,m=-1,b=null,w=!1,S=nt("input","ioviewer-tree-search");S.type="search",S.placeholder=$("searchPlaceholder"),S.setAttribute("aria-label",$("searchPlaceholder"));let v=nt("div","ioviewer-tree");v.setAttribute("role","tree"),v.setAttribute("aria-label",$("panel.model")),v.setAttribute("aria-multiselectable","true"),v.tabIndex=-1;let y=nt("div","ioviewer-tree-spacer");y.setAttribute("role","presentation"),v.append(y);let A=nt("div","ioviewer-tree-empty",$("noMatches")),x=ap(t,e,S,U,()=>s.isolate(_));i.append(x.element,S,v,A);function E(){let V=_[p],Z=x.predicate();if(g=!!(f||Z),g){let lt=f?d(f):t.keys();if(Z){let rt=[];for(let H of lt)Z(t[H])&&rt.push(H);_=Int32Array.from(rt)}else _=Int32Array.from(lt)}else{let lt=a.length;a.forEach((H,Q)=>c[Q]&&(lt+=H.indices.length)),_=new Int32Array(lt);let rt=0;a.forEach((H,Q)=>{if(h[Q]=rt,_[rt++]=-(Q+1),c[Q])for(let ut of H.indices)_[rt++]=ut})}let K=_.indexOf(V);p=K>=0?K:0,y.style.height=`${_.length*Ci}px`,A.hidden=_.length>0||!g,x.update(f,!!s.isolate&&g&&_.some(lt=>s.instancesOf(lt).length>0)),I()}function I(V=v.contains(document.activeElement)){let Z=v.clientHeight;if(Z===0||_.length===0){y.replaceChildren();return}let K=v.scrollTop,{start:lt,end:rt}=zh(K,Ci,Z,_.length,Ay);!V&&(p=rt)&&(p=Math.min(_.length-1,Math.floor(K/Ci)));let H=[];p=rt&&H.push(D(p)),y.replaceChildren(...H),V&&y.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function D(V){let Z=_[V],K=Z<0?-Z-1:l[Z],lt=Z<0?u[K]===a[K].indices.length:n.has(Z),rt=nt("div","tree-row");if(rt.style.top=`${V*Ci}px`,rt.style.height=`${Ci}px`,rt.dataset.row=V,rt.tabIndex=V===p?0:-1,rt.setAttribute("role","treeitem"),rt.classList.toggle("selected",lt),rt.setAttribute("aria-selected",String(lt)),Z<0){rt.classList.add("tree-category"),rt.setAttribute("aria-level","1"),rt.setAttribute("aria-posinset",String(K+1)),rt.setAttribute("aria-setsize",String(a.length)),rt.setAttribute("aria-expanded",String(!!c[K]));let H=nt("span","tree-chevron");H.innerHTML=re.chevron;let{name:Q,indices:ut}=a[K];rt.append(H,nt("span","tree-name",Q||$("noCategory")),nt("span","tree-count",Vr(ut.length)))}else{let H=t[Z];rt.classList.add("tree-element"),rt.setAttribute("aria-level",g?"1":"2"),rt.setAttribute("aria-posinset",String(g?V+1:V-h[K])),rt.setAttribute("aria-setsize",String(g?_.length:a[K].indices.length)),rt.classList.toggle("tree-child",!g),rt.classList.toggle("tree-hidden",s.isVisible?.(Z)===!1),rt.append(nt("span","tree-name",H.name||`#${H.id}`),nt("span","tree-type",H.type??""))}return rt}function N(V){let Z=v.clientHeight;if(Z===0){m=V;return}let K=V*Ci;Kv.scrollTop+Z&&(v.scrollTop=K+Ci-Z)}function B(V){p=V,N(V),I(!0)}function L(V){let Z=l[V];!g&&!c[Z]&&(c[Z]=1,E());let K=_.indexOf(V);K>=0&&(v.contains(document.activeElement)||(p=K),N(K)),I()}function F(V){w=!0;try{n.set(V)}finally{w=!1}}function k(V,Z){let K=_.indexOf(b);K<0&&(K=V,b=_[V]);let lt=_.subarray(Math.min(K,V),Math.max(K,V)+1).filter(rt=>rt>=0);lt.length>0&&F(Z?[...n.values(),...lt]:lt)}function W(V){b=V;let Z=-V-1,K=V<0?a[Z].indices:[V],lt=V<0?u[Z]===K.length:n.has(V),rt=new Set(n.values());for(let H of K)lt?rt.delete(H):rt.add(H);F(rt)}function O(V,Z,K){V>=0&&!n.has(V)&&(b=V,F([V]));let lt=V>=0?V:n.values().next().value??null;o(Z,K,lt,()=>{let rt=_.indexOf(V);rt>=0?B(rt):S.focus()})}S.addEventListener("focus",()=>{y.firstElementChild||q()});function U(){f=S.value.trim(),v.scrollTop=0,m=-1,p=-1,E()}S.addEventListener("input",U),v.addEventListener("scroll",()=>I()),v.addEventListener("focusin",V=>{let Z=V.target.closest(".tree-row");!Z||Z.tabIndex===0||(y.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),p=Number(Z.dataset.row),Z.tabIndex=0)}),v.addEventListener("keydown",V=>{let Z=V.target.closest(".tree-row");if(!Z||V.ctrlKey||V.altKey||V.metaKey)return;let K=Number(Z.dataset.row),lt=_[K];if(Oh(V)){if(V.preventDefault(),!V.repeat){let{left:H,bottom:Q}=Z.getBoundingClientRect();O(lt,H,Q)}return}if(V.key===" "){V.preventDefault(),V.repeat||(V.shiftKey?k(K,!1):W(lt));return}if(V.shiftKey)return;let rt=K;switch(V.key){case"ArrowUp":rt=Math.max(0,K-1);break;case"ArrowDown":rt=Math.min(_.length-1,K+1);break;case"Home":rt=0;break;case"End":rt=_.length-1;break;case"ArrowRight":lt<0&&(c[-lt-1]?rt=K+1:(c[-lt-1]=1,E()));break;case"ArrowLeft":lt>=0&&!g?rt=h[l[lt]]:lt<0&&c[-lt-1]&&(c[-lt-1]=0,E());break;case"Enter":V.repeat||z(lt);break;default:return}V.preventDefault(),rt!==K&&B(rt)});function z(V){if(V>=0){b=V,F([V]),r(V);return}c[-V-1]^=1,E()}v.addEventListener("click",V=>{let Z=V.target.closest(".tree-row");if(!Z)return;let K=Number(Z.dataset.row),lt=V.ctrlKey||V.metaKey;V.shiftKey?k(K,lt):lt?W(_[K]):z(_[K])}),v.addEventListener("contextmenu",V=>{let Z=V.target.closest(".tree-row");Z&&(V.preventDefault(),O(_[Number(Z.dataset.row)],V.clientX,V.clientY))});function q(){m>=0&&v.clientHeight>0&&(N(m),m=-1),I()}new ResizeObserver(q).observe(v),n.addEventListener("change",()=>{let V=-1;u.fill(0);for(let Z of n.values())u[l[Z]]++,V=Z;if(w){I();return}b=null,V>=0?L(V):I()}),s.root?.addEventListener("change",V=>V.detail.kind==="visibility"&&I()),E()}var cp={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},Iy={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},yl=4;function hp(i){let t=nt("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(cp).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,u,d,f=null){let g=cp[c];if(!g)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let m of g){if(m==="-"){let S=nt("div","ioviewer-menu-separator");S.setAttribute("role","separator"),t.append(S);continue}let b=e.get(m),w=nt("button","ioviewer-menu-item");w.type="button",w.tabIndex=-1,w.dataset.item=m,w.setAttribute("role","menuitem"),w.setAttribute("aria-disabled",String(!b.enabled)),b.enabled||(w.title=$("menu.unavailable")),w.append(nt("span","",$(`menu.${m}`)),nt("kbd","",Iy[m]??"")),w.addEventListener("click",()=>{b.enabled&&(s(),b.handler(d))}),t.append(w)}t.hidden=!1;let{width:_,height:p}=t.getBoundingClientRect();t.style.left=`${Math.max(yl,Math.min(h,innerWidth-_-yl))}px`,t.style.top=`${Math.max(yl,Math.min(u,innerHeight-p-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")],u=h.indexOf(document.activeElement),d;switch(c.key){case"ArrowDown":d=(u+1)%h.length;break;case"ArrowUp":d=(u+h.length-1)%h.length;break;case"Home":d=0;break;case"End":d=h.length-1;break;default:return}c.preventDefault(),h[d]?.focus({preventScroll:!0})});function l(c,{enabled:h=!0,handler:u}){let d=e.get(c);if(!d)throw new RangeError(`Unknown menu item: ${c}`);u&&(d.handler=u),d.enabled=h&&!!d.handler}return{element:t,open:a,close:s,setItem:l,get isOpen(){return!t.hidden}}}var Py=1600;function up(i,t,e){let n=()=>i.textContent=`${$("selected")}: ${Vr(t.size)} \xB7 ${$("elements")}: ${Vr(e)}`;t.addEventListener("change",n),n()}function dp(i,t){if(!t)return;let e=nt("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",re.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(nt("span","",n),s),i.append(e),r.observe(e)}function Gs(i,t){let e=nt("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),Py)}function fp(i,t){let e=nt("table");for(let[s,r]of t)e.insertRow().append(nt("th","",s),nt("td","",String(r??"")));let n=nt("section");return n.append(nt("h3","",i),e),n}function pp(i,t,e){let n=nt("h2","ioviewer-properties-title"),s=nt("button","ioviewer-properties-close","\xD7");s.type="button",s.title=$("close"),s.setAttribute("aria-label",$("close")),s.addEventListener("click",()=>t.clear());let r=nt("header");r.append(n,s);let o=nt("div","ioviewer-properties-body");i.replaceChildren(r,o),i.hidden=!0;let a=h=>{let u=[[$("id"),h.id],[$("category"),h.category],[$("type"),h.type],[$("level"),h.level]];return h.sourceId&&u.push([$("sourceId"),h.sourceId]),h.link&&u.push([$("link"),h.link]),fp($("elementGroup"),u)},l=h=>{for(let[u,d]of Object.entries(h??{}))o.append(fp(u,Object.entries(d)))},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(),u=e.meta.elements[h];if(n.textContent=u.name||`#${u.id}`,o.append(a(u)),!e.loadProperties){l(e.props(u.id));return}let d=new AbortController;c=d,o.setAttribute("aria-busy","true"),e.loadProperties(h,d.signal).then(f=>{d.signal.aborted||!f||(n.textContent=f.name||u.name||`#${u.id}`,o.replaceChildren(a({...u,...f})),l(f.properties))}).catch(()=>{d.signal.aborted||o.append(nt("p","",$("badData")))}).finally(()=>{c===d&&o.removeAttribute("aria-busy")})})}async function Ly(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 mp({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,...S]=r.values(),v=e.elementBox(w);for(let y of S)v.union(e.elementBox(y));n.zoomToBox(v)},fitAll:l},h=ip(i);h.registerPanel("model",{icon:re.model,title:$("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:w=>lp(w,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:p,zoomToElement:S=>n.zoomToBox(e.elementBox(S))})});let u=document.createElement("aside");u.id="ioviewer-properties",u.className="ioviewer-floating",i.append(u),pp(u,r,t);let d=rp(i,sp),f=w=>{n.is2D&&w==="orbit"||(n.setLeftButtonMode(w),d.setActive("orbit",w==="orbit"),d.setActive("pan",w==="pan"))};d.setHandler("orbit",()=>f("orbit")),d.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),d.setHandler("fit",l),d.setHandler("projection",()=>{if(n.is2D)return;let w=!n.camera.isOrthographicCamera;n.setProjection(w?"orthographic":"perspective"),d.setActive("projection",w)}),d.setActive("projection",!1);let g=()=>{let w=!!n.is2D;d.setActive("mode2d",w),d.setEnabled("orbit",!w),d.setEnabled("projection",!w),d.setActive("projection",w||n.camera.isOrthographicCamera),d.setActive("orbit",!w&&n.leftButtonMode==="orbit"),d.setActive("pan",w||n.leftButtonMode==="pan")};d.setHandler("mode2d",()=>{n.set2DMode(!n.is2D,e.visibleBox(),!1),g()}),g(),document.fullscreenEnabled&&(d.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{d.setActive("fullscreen",!!document.fullscreenElement),Gs(i,$("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>d.setActive("fullscreen",!!document.fullscreenElement)));let _=hp(i);function p(w,S,v,y){_.open(v===null?"empty":"element",w,S,v,y)}function m(w){if(_.isOpen)return;let S=w===document.body,v=(S?n.dom:w).getBoundingClientRect(),y=S?v.left+v.width/2:v.left,A=S?v.top+v.height/2:v.bottom;p(y,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=>Ly(String(a.elements[w].id)).then(S=>Gs(i,$(S?"idCopied":"copyFailed")),()=>Gs(i,$("copyFailed")))}),n.addEventListener("contextmenu",async w=>{let{x:S,y:v}=w.detail;if(o?.active)return p(S,v,r.values().next().value??null);let y=s.pick(S,v),A=y?.then?await y:y;if(A!==void 0){if(!A||A.element<0)return p(S,v,null);r.has(A.element)||r.set([A.element]),p(S,v,A.element)}});let b=[];return window.addEventListener("keydown",w=>{if(w.defaultPrevented)return;let S=op(w);if(S){if(w.preventDefault(),S==="contextMenu")return m(document.activeElement??document.body);if(S==="escape"&&!_.isOpen){b.some(v=>v())||r.clear();return}_.close(),S!=="escape"&&c[S]?.()}}),up(document.getElementById("ioviewer-status"),r,e.elementCount),dp(i,a.truncated),{shell:h,toolbar:d,contextMenu:_,sync2DState:g,onEscape:w=>b.push(w)}}var kh={x:new R(1,0,0),y:new R(0,1,0),z:new R(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 gp(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 _p(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 R(1,0,0),-n.x),new Ae(new R(-1,0,0),s.x),new Ae(new R(0,1,0),-n.y),new Ae(new R(0,-1,0),s.y),new Ae(new R(0,0,1),-n.z),new Ae(new R(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new R);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 xp(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 R).sub(i.getCenter(new R));o.translate(a.clone().applyAxisAngle(kh.z,t).sub(a))}return o}function vp(i){let{min:t,max:e}=i;return Array.from({length:8},(n,s)=>new R(s&1?e.x:t.x,s&2?e.y:t.y,s&4?e.z:t.z))}function yp(i,t,e){if(t.length===0||i.isEmpty())return!1;let n=vp(i),s=r=>n.every(o=>r.distanceToPoint(o)<0);return e?t.every(s):t.some(s)}function bl(i,t){let e=i.getSize(new R).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 R(1,0,0).applyQuaternion(t),s=new R(0,1,0).applyQuaternion(t),[r,o,a,l]=[1/0,-1/0,1/0,-1/0];for(let h of vp(i)){h.sub(e);let u=h.dot(n),d=h.dot(s);[r,o,a,l]=[Math.min(r,u),Math.max(o,u),Math.min(a,d),Math.max(l,d)]}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,Dy=["off","planes","box"],Ny=.05,Vh=new R(0,0,1),wl=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new R),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 R().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 R().fromArray(e.min),new R().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(!Dy.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 gp(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=Mp(e),this.box=t.clone(),this.boxYaw=e,this._mode="box",this._changed(!0)}setBoxYaw(t){this.box&&(this.boxYaw=Mp(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 R);return this.setBox(e.expandByScalar(Ny*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 R);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=_p(this.box,this.boxMode,this.boxYaw);if(!t.intersection&&this.boxYaw!==0){let e=this.box.getCenter(new R),n=this.box.getSize(new R).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)||yp(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 Mp(i){if(!Number.isFinite(i))throw new RangeError("The section box angle must be finite.");return i>=-Math.PI&&i<=Math.PI?i:oe.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Gh=80,Uy=8,qh=.8,Fy=Math.sin(oe.degToRad(12)),Ii={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Wh=["x","y","z"],By=Math.cos(oe.degToRad(12)),El=new R(0,0,1),Oy=i=>new Je({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),zy=new Je({visible:!1});function Tl(i,t,e,n){let s=new Re,r=Oy(t);for(let a of e)s.add(new me(a,r));let o=new me(n,zy);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)*Uy)}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 R):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new R(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 me(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 R}),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 R),o=s.getSize(new R);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new R(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 R));return 2*Math.max(s,e.near)*Math.tan(oe.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 d=r.active,f=r.origin(d),g=r.normal(d),_=Xr(e,f,g);return _===null?null:{index:d,origin:f,normal:g,offset:r.planes[d].offset,s0:_}}if(o==="rotate"){let d=r.active,f=t===this.boxRing,g=f?t.position.clone():r.origin(d),_=f?null:r.planes[d].quaternion.clone(),p=f?El:new R().setComponent(Wh.indexOf(t.userData.axis),1).applyQuaternion(_),m={index:d,origin:g,quaternion:_,axis:p,yaw:f?r.boxYaw:null};if(Math.abs(p.dot(e.direction))0&&r===0}function Gy(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 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 ${Br} #include @@ -4410,12 +4410,12 @@ void main() { void main() { #include gl_FragColor = vec4( 0.0 ); -}`,side:e,stencilZPass:n,stencilWrite:!0,clipping:!0,clippingPlanes:[t],colorWrite:!1,depthTest:!1,depthWrite:!1});return s.index0AttributeName="q",s}var 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 me(new cn(1,1),new Je({color:Hy,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(d=>d.clone().negate()):o,c=d=>Math.abs(d.distanceToPoint(s.center)){if(!c(f))return;let _=d?-f.normal.dot(d):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 m of this._stencils)r.withMaterial(m,()=>t.render(r.root,n),{section:!0});this._surface.quaternion.setFromUnitVectors(ky,f.normal);let p=Sl(s.modelBox,this._surface.quaternion,f.coplanarPoint(new R));this._surface.position.copy(p.center),this._surface.scale.set(p.width,p.height,1),h.clippingPlanes=l.filter((m,b)=>b!==g),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=u}}};function Yr(i,t,e){let n=nt("div","ioviewer-segmented");n.setAttribute("role","group"),n.setAttribute("aria-label",i);let s=t.map(([o,a])=>{let l=nt("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=nt("label","ioviewer-check"),n=nt("input");return n.type="checkbox",n.addEventListener("change",()=>t(n.checked)),e.append(n,nt("span","",i)),{element:e,input:n}}function Wy(i,t){let e=nt("li","ioviewer-section-plane");e.addEventListener("pointerdown",()=>i.active!==t&&i.setActivePlane(t));let n=nt("span","ioviewer-section-name"),s=tn("ioviewer-icon-button",re.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",re.remove,$("sections.delete"));o.addEventListener("click",()=>i.removePlane(t));let a=nt("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=nt("div","ioviewer-section-head");return l.append(n,s,r.element,o),e.append(l,a),{element:e,update:()=>{let h=i.planes[t],u=h.rotated?` (${$("sections.rotated")})`:"",d=h.axis==="custom"?$("sections.custom"):h.axis.toUpperCase();n.textContent=`${t+1}. ${d}${u}`,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 Sp({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()],u=()=>s.fitBoxToElements(h()),d=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=nt("button","ioviewer-text-button",$("sections.addPlane"));g.type="button",g.addEventListener("click",c);let _=nt("ul","ioviewer-section-list"),p=nt("div","ioviewer-section-empty",$("sections.noPlanes")),m=nt("div","ioviewer-section-block"),b=nt("div","ioviewer-section-row");b.append(nt("span","",$("sections.axis")),f.element,g),m.append(b,_,p);let w=Yr($("sections.box"),[["keepInside",$("sections.keepInside")],["cutInside",$("sections.cutInside")]],F=>s.setBoxMode(F)),S=nt("button","ioviewer-text-button",$("sections.fitSelection"));S.type="button",S.addEventListener("click",u);let v=nt("input","ioviewer-section-slider");Object.assign(v,{type:"range",min:"-180",max:"180",step:"1"}),v.addEventListener("input",()=>s.setBoxYaw(Number(v.value)*Math.PI/180));let y=nt("span");y.setAttribute("aria-hidden","true");let A=nt("label","ioviewer-section-row");A.append(nt("span","",$("sections.boxYaw")),v,y);let x=nt("div","ioviewer-section-block");x.append(w.element,A,S);let E=Yh($("sections.showGizmo"),F=>s.setGizmoVisible(F)),I=Yh($("sections.fill"),F=>s.setFill(F));o||(I.element.title=$(a?"sections.fillUnavailable":"sections.fillNeedsMeshes"));let D=[],N=()=>{d.update(s.mode),m.hidden=s.mode!=="planes",x.hidden=s.mode!=="box",g.disabled=s.planes.length>=qr,D.length!==s.planes.length&&(D=s.planes.map((k,W)=>Wy(s,W)),_.replaceChildren(...D.map(k=>k.element))),D.forEach(k=>k.update()),p.hidden=D.length>0,w.update(s.boxMode),v.value=String(Math.round(s.boxYaw*180/Math.PI)),y.textContent=`${v.value}\xB0`,v.setAttribute("aria-valuetext",y.textContent),E.input.checked=s.gizmoVisible,I.input.checked=s.fill;let F=s.mode==="box"||s.mode==="planes"&&s.planes.some(k=>k.enabled);I.input.disabled=!o||!F,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},B=()=>S.disabled=r.size===0;if(t.registerPanel("sections",{icon:re.sections,title:$("panel.sections"),visible:!s.modelBox.isEmpty(),render:F=>F.append(d.element,m,x,I.element,E.element)}),s.addEventListener("change",N),r.addEventListener("change",B),N(),B(),s.modelBox.isEmpty())return;let L=()=>t.openPanel("sections");e.setHandler("plane",()=>{c(),L()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&u()||s.fitBoxToShown())&&L()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:F=>{s.fitBoxToElements(r.has(F)?h():[F]),L()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var Xy="#facc15",qy=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 _e(new Float32Array(6),3));let n={color:Xy,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Oi(e,new sn(n)),this._markers=new wn(e,new Hn({...n,size:qy,sizeAttenuation:!1}));for(let s of[this._line,this._markers])s.frustumCulled=!1,s.renderOrder=1001,this.group.add(s);this.label=nt("div","ioviewer-measure-label"),this.label.hidden=!0,this._previewMarker=nt("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,Yy=1-1e-6,$y=8,wp={vertex:0,midpoint:1,edge:2},Zy=2e4;function Ky(i,t){let e=new Map,n=new Uint32Array(i.length/3);for(let u=0;u0&&(_.normalize(),l(d,f,_),l(f,g,_),l(g,d,_))}let c=[],h=new Set;for(let{lo:u,hi:d,count:f,crease:g}of s.values())f!==1&&!g||(c.push(u,d),h.add(u),h.add(d));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 Ep(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),u=c.distanceToPoint(t);return(h<0||u<0)&&Il(a,-h,-u)}))return[o];let l=[];return o[0]0))return null;let p=oe.clamp(((r-c)*f+(o-h)*g)/_,0,1);return e+(n-e)*(p*a.w/((1-p)*l.w+p*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;c$y&&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(),u=new Yt().multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),d=a.matrixWorldInverse.elements,f=null;function g(v,y,A,x){if(f&&wp[v]>wp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[E,I]=Ws(A,s);if(!(E>=0&&I>=0&&E$r**2||f?.kind===v&&D>=f.distance||v!=="edge"&&Ml(y,c,h))return;let N=-(d[2]*y.x+d[6]*y.y+d[10]*y.z+d[14]);N-n.depthAt(E,I,x)>2*Cn+Math.abs(N)*2**-21||(f={kind:v,distance:D,point:y.clone()})}let _=Zy*3,p=new Yt,m=new R,b=new xe,{geometry:w,matrix:S}=this.data.meta.instances;for(let v of n.slots){let y=l.slotInstance(v),[A]=this.data.readView({t:"u32",o:w.o+y*4,n:1}),x=this.data.meta.geometries[A],E=Math.max(x.indices.n,x.positions.n/3);if(E>_)continue;_-=E;let{positions:I,vertices:D,edges:N}=this._geometry(A),B=this.data.readView({t:"f32",o:S.o+y*48,n:12});p.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 L=new Map;for(let F of D){let k=new R().fromArray(I,F*3).applyMatrix4(p),W=new xe(k.x,k.y,k.z,1).applyMatrix4(u);L.set(F,[k,W]),g("vertex",k,W,v)}if(f?.kind!=="vertex")for(let F=0;F_)continue;_-=I;let{positions:D,vertices:N,edges:B}=this._geometry(x),L=this.data.readView({t:"f32",o:y.o+A*48,n:12});p.set(L[0],L[3],L[6],L[9],L[1],L[4],L[7],L[10],L[2],L[5],L[8],L[11],0,0,0,1);let F=new Map;for(let k of N){let W=new R().fromArray(D,k*3).applyMatrix4(p),O=new xe(W.x,W.y,W.z,1).applyMatrix4(u);if(F.set(k,[W,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&&V.z>=-V.w&&V.z<=V.w){let[Z,K]=Ws(V,s),lt=(Z-r)**2+(K-o)**2;lt<=$r**2&&(!f||f.kind!=="midpoint"||ltr.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 Jy=8,Ap=4;function Zh(i,t,e,n="dialog"){let s=nt("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(Ap,Math.min(l.left+l.width/2-c/2,innerWidth-c-Ap))}px`,s.style.bottom=`${innerHeight-l.top+Jy}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 jy(i){return i?.initialWireframe?"wireframe":i?.initialWhiteMode?"white":"materials"}function Rp({root:i,toolbar:t,scene:e,meta:n,grids:s,initialBackground:r,setBackground:o,hasMeshes:a=!0}){let l=D=>t.element.querySelector(`[data-tool="${D}"]`),c=l("displayMode"),h=Zh(i,c,$("group.display"));h.element.classList.add("ioviewer-display-modes");let u=nt("div");u.setAttribute("role","menu"),u.setAttribute("aria-label",$("tool.displayMode")),h.element.append(u);let d=(n.textures??[]).length>0,f=Ih.map(D=>{let N=nt("button","ioviewer-menu-item",$(`display.${D}`));return N.type="button",N.dataset.mode=D,N.setAttribute("role","menuitemradio"),N.disabled=D==="textures"&&!d||D==="wireframe"&&!a,N.addEventListener("click",()=>{g(D),h.close(),c.focus()}),u.append(N),N}),g=D=>{e.setDisplayMode(D);for(let N of f)N.setAttribute("aria-checked",String(N.dataset.mode===D))},_=jy(n.options);g(_==="wireframe"&&!a?"materials":_),t.setHandler("displayMode",()=>{h.toggle(),h.isOpen&&u.querySelector('[aria-checked="true"]')?.focus()});let p=nt("div","ioviewer-background-setting"),m=nt("label","",$("display.background")),b=nt("input");Object.assign(b,{type:"color",value:r}),m.append(b);let w=nt("button","ioviewer-text-button",$("display.backgroundReset"));w.type="button",w.disabled=!0;let S=()=>{o(b.value),w.disabled=b.value===r};b.addEventListener("input",S),w.addEventListener("click",()=>{b.value=r,b.focus(),S()});let v=nt("div","ioviewer-bg-presets");for(let[D,N]of[["#14171c","display.bgCadDark"],["#ffffff","display.bgPaper"]]){let B=nt("button","ioviewer-text-button",$(N));B.type="button",B.addEventListener("click",()=>{b.value=D,S()}),v.append(B)}p.append(m,v,w),h.element.append(p),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let y=Zh(i,l("opacity"),$("tool.opacity"));y.element.classList.add("ioviewer-opacity");let A=nt("input","ioviewer-opacity-slider");Object.assign(A,{type:"range",min:"10",max:"100",step:"1",value:"100"}),A.setAttribute("aria-label",$("opacity.label"));let x=nt("output","ioviewer-opacity-value"),E=()=>x.textContent=$("opacity.value").replace("{value}",A.value);A.addEventListener("input",()=>{e.setOpacity(Number(A.value)/100),E()}),E();let I=nt("div","ioviewer-opacity-head");return I.append(nt("span","",$("opacity.label")),x),y.element.append(I,A),t.setHandler("opacity",y.toggle),[h,y]}var Qy=3e3;function Dl(i,t){let e=nt("button",i);return e.type="button",e.setAttribute("title",t),e.append(nt("span","ioviewer-row-name",t)),e}function Cp({shell:i,toolbar:t,controls:e,scene:n,sections:s,selection:r,restoreLinkedModels:o,views:a,bcfTopics:l}){let c=null,h=nt("button","ioviewer-text-button ioviewer-tour");h.type="button";function u(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 S=w.camera.projection==="orthographic";e.setProjection(S?"orthographic":"perspective"),t.setActive("projection",S),e.restoreViewCamera(w.camera)}function d(){u(a[c.next]),c.next=(c.next+1)%a.length;let w=()=>{e.animating?c.frame=requestAnimationFrame(w):c.timer=setTimeout(d,Qy)};c.frame=requestAnimationFrame(w)}let f=w=>h.contains(w.target),g=w=>!f(w)&&p(),_=w=>{f(w)&&(w.key==="Enter"||w.key===" ")||(w.key==="Escape"&&(w.preventDefault(),w.stopPropagation()),p())};function p(){c&&(cancelAnimationFrame(c.frame),clearTimeout(c.timer),c=null,window.removeEventListener("pointerdown",g,!0),window.removeEventListener("wheel",p,!0),window.removeEventListener("keydown",_,!0),b())}function m(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",g,!0),window.addEventListener("wheel",p,!0),window.addEventListener("keydown",_,!0),b(),d()}function b(){let w=$(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?re.pause:re.play),h.append(nt("span","",w)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?p():m()),b(),i.registerPanel("views",{icon:re.views,title:$("panel.views"),visible:a.length>0,render:w=>{let S=nt("div","ioviewer-row-list");for(let v of a){let y=Dl("ioviewer-row ioviewer-view",String(v.name??""));y.addEventListener("click",()=>u(v)),S.append(y)}w.append(h,S)}}),i.registerPanel("bcf",{icon:re.bcf,title:$("panel.bcf"),visible:l.length>0,render:w=>{let S=nt("div","ioviewer-row-list");for(let v of l){let y=nt("details","ioviewer-bcf-topic");y.append(nt("summary","",v.title)),v.status&&y.append(nt("p","ioviewer-bcf-status",v.status)),v.description&&y.append(nt("p","ioviewer-bcf-description",v.description)),v.viewpoints.length||y.append(nt("p","ioviewer-bcf-status",$("bcf.noView"))),v.viewpoints.forEach((A,x)=>{let E=$("bcf.viewpoint").replace("{index}",String(x+1)),I=Dl("ioviewer-row ioviewer-view",E);if(I.addEventListener("click",()=>u(A)),y.append(I),A.missingComponents||A.ambiguousComponents){let D=$("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));y.append(nt("p","ioviewer-bcf-status",D))}}),S.append(y)}w.append(S)}})}function Ip(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):tM(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function tM(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 eM=["New","Active","Reviewed","Approved","Resolved"],Kh=27,nM=8,iM=14,sM=2,rM=new R(1,-1,.8).normalize();function Pp({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 _e(new Float32Array(3),3));let l={color:"#ef4444",depthTest:!1,depthWrite:!1,transparent:!0},c=new wn(a,new Hn({...l,size:iM,sizeAttenuation:!1}));c.frustumCulled=!1,c.renderOrder=1002,o.add(c),o.visible=!1;let h=null,u=null;function d(){o.visible=!1,h?.removeAttribute("aria-current"),h=null,u=null,s.setExtraBounds("clash",null)}function f(b,w){let S=Ip(b,e);S.length?r.set(S):r.clear();let v=new R(...b.point),y=0;for(let E of S){let I=n.elementBox(E);I.isEmpty()||(y=Math.max(y,...I.getSize(new R).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(rM);let x=Math.max(3*y,sM);s.animateTo({position:A.normalize().multiplyScalar(x).add(v),target:v}),a.attributes.position.setXYZ(0,v.x,v.y,v.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=w,u=b,w.setAttribute("aria-current","true"),s.setExtraBounds("clash",new se(v.clone(),v.clone()))}function g(b){let w=Dl("ioviewer-row ioviewer-clash",String(b.name??""));w.setAttribute("title",`${b.name??""}: ${b.element1Name??""} \u2014 ${b.element2Name??""}`);let S=eM.includes(b.status),v=nt("span","ioviewer-clash-status",S?$(`clash.${b.status}`):String(b.status??""));S&&(v.dataset.status=b.status);let y=typeof b.distance=="number"?$h(b.distance):"";return w.append(v,nt("span","ioviewer-clash-distance",y)),b===u&&(h=w,w.setAttribute("aria-current","true")),w.addEventListener("click",()=>f(b,w)),w}function _(b,w){let S=nt("div","ioviewer-clash-test"),v=nt("button","ioviewer-row ioviewer-clash-header");v.type="button",v.setAttribute("aria-expanded","true");let y=`${b.name??""} (${b.clashes.length})`;v.setAttribute("title",y),v.insertAdjacentHTML("afterbegin",re.chevron),v.append(nt("span","ioviewer-row-name",y));let A=nt("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,b.clashes.length*Kh-1)}px`,v.addEventListener("click",()=>{A.hidden=!A.hidden,v.setAttribute("aria-expanded",String(!A.hidden)),w()}),S.append(v,A),{box:S,list:A,clashes:b.clashes,rows:new Map}}function p({list:b,clashes:w,rows:S},{start:v,end:y}){for(let[x,E]of S)(x=y)&&(E.remove(),S.delete(x));let A=null;for(let x=y-1;x>=v;x--){let E=S.get(x);E||(E=g(w[x]),E.style.top=`${x*Kh}px`,b.insertBefore(E,A),S.set(x,E)),A=E}}function m(b){if(!t.length)return;b.classList.add("ioviewer-clashes-body");let w=t.map(v=>_(v,S));for(let v of w)b.append(v.box);function S(){let v=b.scrollTop,y=b.clientHeight,A=w.map(({list:x,clashes:E})=>y&&!x.hidden?zh(v-x.offsetTop,Kh,y,E.length,nM):{start:0,end:0});w.forEach((x,E)=>p(x,A[E]))}b.addEventListener("scroll",S),b.addEventListener("focusin",S),new ResizeObserver(S).observe(b)}return i.registerPanel("clashes",{icon:re.clashes,title:$("panel.clashes"),visible:t.length>0,render:m,onClose:()=>o.visible&&d()}),{group:o}}var oM=["construct","demolish","temporary"],aM=Date.parse("0002-01-01T00:00:00Z");function Lp(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=aM?t:NaN}function Dp(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=Lp(o?.start),l=Lp(o?.end);if(!(a<=l))continue;let c=oM.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(u=>e.get(String(u))).filter(u=>u!==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 Np(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 lM=864e5,cM=["1","5","15"],hM={construct:"#22c55e",demolish:"#ef4444",temporary:"#a855f7"};function Up({root:i,shell:t,timeliner:e,elements:n,scene:s}){let r=Dp(e,n);if(r.tasks.length===0)return t.registerPanel("timeliner",{icon:re.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,u=0,d=!1,f=new Set,g=new Map,_=nt("div","ioviewer-player ioviewer-floating");_.setAttribute("role","group"),_.setAttribute("aria-label",$("player.title")),_.hidden=!0;let p=tn("ioviewer-icon-button ioviewer-player-play",re.play,$("player.play"));p.addEventListener("click",()=>h?N():D());let m=nt("output","ioviewer-player-date"),b=nt("input","ioviewer-player-slider");Object.assign(b,{type:"range",min:String(r.start),max:String(r.end),step:"any"}),b.setAttribute("aria-label",$("player.date")),b.addEventListener("input",()=>A(Number(b.value)));let w=Yr($("player.speed"),cM.map(L=>[L,`${L}\xD7`]),L=>{c=Number(L),w.update(L)});w.update(String(c));let S=tn("ioviewer-panel-close",re.close,$("close"));S.addEventListener("click",E),_.append(p,m,b,w.element,S),i.append(_),new ResizeObserver(()=>{let L=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${L}px`)}).observe(_);function y(){let L=Np(r.tasks,l),F=[...f].filter(U=>!L.hidden.has(U)),k=[...L.hidden].filter(U=>!f.has(U));f=L.hidden;let W=[...g.keys()].filter(U=>L.active.get(U)!==g.get(U)),O=new Map;for(let[U,z]of L.active)g.get(U)!==z&&(O.has(z)||O.set(z,[]),O.get(z).push(U));g=L.active,F.length&&s.setLayerHidden("schedule",F,!1),k.length&&s.setLayerHidden("schedule",k,!0),W.length&&s.setTint(W,null);for(let[U,z]of O)s.setTint(z,hM[U])}function A(L){l=Math.min(Math.max(L,r.start),r.end),b.value=String(l),m.textContent=a.format(l),d&&y()}function x(){d||(d=!0,_.hidden=!1,A(r.start))}function E(){d&&(N(),d=!1,s.setTint([...g.keys()],null),g=new Map,f=new Set,s.clearLayer("schedule"),_.hidden=!0)}function I(L){A(l+Math.max(L-u,0)/1e3*c*lM),u=L,l>=r.end?N():h=requestAnimationFrame(I)}function D(){x(),!h&&(l>=r.end&&A(r.start),u=performance.now(),h=requestAnimationFrame(I),B())}function N(){cancelAnimationFrame(h),h=0,B()}function B(){let L=$(h?"player.pause":"player.play");p.innerHTML=h?re.pause:re.play,p.title=L,p.setAttribute("aria-label",L)}return t.registerPanel("timeliner",{icon:re.timeliner,title:$("panel.timeliner"),render:L=>{let F=nt("button","ioviewer-text-button ioviewer-player-open");F.type="button",F.insertAdjacentHTML("afterbegin",re.play),F.append(nt("span","",$("player.play"))),F.addEventListener("click",D);let k=nt("div","ioviewer-row-list");for(let W of r.tasks){let O=String(W.name??""),U=nt("div","ioviewer-row ioviewer-task");U.dataset.type=W.type,U.setAttribute("title",`${O} \xB7 ${$(`task.${W.type}`)}`);let z=`${o.format(W.start)} \u2013 ${o.format(W.end)}`;U.append(nt("span","ioviewer-row-name",O),nt("span","ioviewer-task-dates",z)),k.append(U)}L.append(F,k)}}),{open:x,close:E,play:D,pause:N,setDate:A,get date(){return l},get isOpen(){return d}}}function Fp({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:nt("input")})),r=()=>n.replaceLayerHidden("links",s.flatMap(({input:o,members:a})=>o.checked?[]:a));return i.registerPanel("links",{icon:re.links,title:$("panel.links"),visible:s.length>0,render:o=>{let a=nt("div","ioviewer-row-list");for(let l of s){let c=String(l.file.name??""),h=nt("label","ioviewer-row ioviewer-check ioviewer-link");h.setAttribute("title",`${c} (${l.file.path??""})`);let{input:u}=l;u.type="checkbox",u.checked=l.members.length===0||l.file.visible!==!1,u.disabled=l.members.length===0,u.addEventListener("change",r),h.append(u,nt("span","ioviewer-row-name",c),nt("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 Bp(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 Op(i,t){return!i||t>=i.min&&t<=i.max}function zp(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 kp(){let i=new pn,t=new Ue(72,1,.15,20);t.up.set(0,0,1);let e=new R,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 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(` `),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(` `),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 me(new cn(2,2),l);return c.frustumCulled=!1,o.add(c),{setScan(h,u){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(u);let d=new se().setFromObject(i),f=d.getSize(e).length();t.far=Math.max(20,f+u.distanceTo(d.getCenter(e)))},draw(h,u,d){t.aspect=u.aspect,t.fov=u.fov,t.updateProjectionMatrix(),t.lookAt(e.copy(t.position).add(d));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 uM=new Intl.NumberFormat(ai,{maximumFractionDigits:2,minimumFractionDigits:2}),Nl=i=>`${uM.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 dM(i,t){return[i*.005,t*.005]}function fM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function pM(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 R,c=new R;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 Hp(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 R),l=o.getCenter(new R),c={x:l.x,y:l.y,side:Math.max(a.x,a.y,.01)*1.12,zoom:1},h={...c},u=C=>50+100*(C-h.x)*h.zoom/h.side,d=C=>50-100*(C-h.y)*h.zoom/h.side,f=C=>Math.min(96,Math.max(4,C)),g=(C,ht,Tt=!1)=>{let P=u(ht.x),M=d(ht.y);return C.style.left=`${Tt?f(P):P}%`,C.style.top=`${Tt?f(M):M}%`,P>=0&&P<=100&&M>=0&&M<=100},_=t.meta.rtcOffset?.[2]??0,p=t.meta.panoramas??[],m=p.map(C=>new R(...C.position)),b=`ioviewer.scan-levels.v1:${location.pathname}`,w=()=>Bp(m.map(C=>C.z+_),o.min.z+_,o.max.z+_),S=null;try{let C=JSON.parse(localStorage.getItem(b));Array.isArray(C)&&(S=C.filter(ht=>Number.isFinite(ht?.min)&&Number.isFinite(ht.max)&&ht.max>ht.min))}catch{S=null}let v=S??w(),y=-1,A=!0,x=C=>Op(v[y],C+_),E=document.createElement("details");E.className="ioviewer-floating ioviewer-scan-map",E.open=!matchMedia("(max-width: 600px)").matches;let I=document.createElement("summary");I.textContent=$("scanMap.title");let D=document.createElement("div");D.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 L=document.createElement("span");L.className="scan-map-axes",L.textContent="Y \u2191";let F=document.createElement("span");F.className="scan-map-scale",D.append(N,B,L,F),E.append(I,D),i.append(E);let k=e.root.children.reduce((C,ht)=>C+ht.geometry.attributes.position.count,0),W=Math.max(1,Math.ceil(k/6e4)),O=e.root.children.map(C=>{let ht=C.geometry.attributes.position,Tt=new Float32Array(Math.ceil(ht.count/W)*3),P=new R;for(let M=0,Y=0;M{if(U=0,!E.open)return;let C=N.getContext("2d");if(!C)return;C.clearRect(0,0,300,300),C.fillStyle="rgba(160, 185, 201, .33)";for(let[P,M]of O.entries())if(e.root.children[P].visible)for(let Y=0;Y{U||(U=requestAnimationFrame(z))},V=new R,Z=null,K=()=>{if(Z){B.hidden=!x(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(V),B.style.rotate=`${Math.atan2(V.x,V.y)}rad`};E.addEventListener("toggle",q),n.root.addEventListener("change",C=>{C.detail.kind==="visibility"&&q()}),s.addEventListener("change",K);let lt=document.createElement("div");lt.className="scan-map-controls";let rt=document.createElement("select");rt.setAttribute("aria-label",$("scanMap.size"));for(let C of["small","medium","large"])rt.add(new Option($(`scanMap.${C}`),C));rt.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=rt.value,rt.addEventListener("change",()=>{i.dataset.scanMapSize=rt.value});let H=(C,ht=0,Tt=0)=>{h=zp(h,C,ht,Tt),q()},Q=()=>{h={...c},q()};lt.append(rt,Kn($("scanMap.zoomOut"),"\u2212",()=>H(.8)),Kn($("scanMap.zoomIn"),"+",()=>H(1.25)),Kn($("scanMap.reset"),"\u21BA",Q)),E.insertBefore(lt,D),N.addEventListener("wheel",C=>{C.preventDefault();let ht=N.getBoundingClientRect();H(C.deltaY<0?1.15:1/1.15,(C.clientX-ht.left)/ht.width-.5,(C.clientY-ht.top)/ht.height-.5)},{passive:!1});let ut;N.addEventListener("pointerdown",C=>{C.button!==0||ut||(N.setPointerCapture(C.pointerId),ut={id:C.pointerId,x:C.clientX,y:C.clientY})}),N.addEventListener("pointermove",C=>{if(ut?.id!==C.pointerId)return;let ht=h.side/(h.zoom*Math.max(1,N.clientWidth));h.x-=(C.clientX-ut.x)*ht,h.y+=(C.clientY-ut.y)*ht,ut.x=C.clientX,ut.y=C.clientY,q()}),N.addEventListener("lostpointercapture",C=>{C.pointerId===ut?.id&&(ut=void 0)}),N.addEventListener("keydown",C=>{let ht={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[C.key];if(ht){let Tt=h.side/h.zoom/10;h.x+=ht[0]*Tt,h.y+=ht[1]*Tt,q()}else if(C.key==="+"||C.key==="="||C.key==="-")H(C.key==="-"?.8:1.25);else if(C.key==="0")Q();else return;C.preventDefault(),C.stopPropagation()});let It=document.createElement("div");It.className="scan-map-controls";let ft=document.createElement("select");ft.setAttribute("aria-label",$("scanMap.levels"));let Ut=document.createElement("p");Ut.className="scan-map-feedback",Ut.setAttribute("role","status");function ae(){try{localStorage.setItem(b,JSON.stringify(v))}catch{Ut.textContent=$("scanMap.levelTemporary")}}function Gt(){ft.replaceChildren(new Option($("scanMap.allLevels"),"-1")),v.forEach((C,ht)=>ft.add(new Option(`${$("scanMap.level").replace("{n}",ht+1)} \xB7 ${Nl(C.min)} \u2013 ${Nl(C.max)}`,String(ht)))),ft.value=String(y),Ct.disabled=y<0;for(let[C,ht]of m.entries())qt.options[C+1].hidden=!x(ht.z);q(),r()}ft.addEventListener("change",()=>{y=Number(ft.value),Ut.textContent="",Gt()});let Jt=Kn($("scanMap.addLevel"),"+",()=>{if($t.isClosed()){let C=m.findIndex(ht=>x(ht.z));Ft(Math.max(0,C))}$t.pickLevel()});Jt.disabled=!p.length;let mt=Kn($("scanMap.autoLevels"),$("scanMap.autoButton"),()=>{let C=w(),ht=C.filter(Tt=>!v.some(P=>P.min{y<0||(v.splice(y,1),y=-1,Ut.textContent="",ae(),Gt())});if(It.append(ft,Jt,mt,Ct),p.length){let C=Kn($("scanMap.spheres"),"\u25C9",()=>{A=!A,C.setAttribute("aria-pressed",String(A)),r()});C.setAttribute("aria-pressed","true"),It.append(C)}E.append(It,Ut);let $t=p.length?mM(i,t,e,Ft,C=>{Z=C,C||dt.forEach(ht=>ht.classList.remove("current")),K()},C=>{y=v.push(C)-1,Ut.textContent=$("scanMap.levelAdded"),ae(),Gt()}):null,qt=document.createElement("select");qt.setAttribute("aria-label",$("scanMap.choosePhoto"));let Me=new Option($("scanMap.choosePhoto"),"");Me.disabled=!0,qt.add(Me);let dt=[];for(let[C,ht]of p.entries()){let Tt=ht.name||t.meta.elements[ht.element].name||String(C+1);qt.add(new Option(Tt,String(C)));let P=document.createElement("button");P.type="button",P.className="scan-map-station",P.title=Tt,P.setAttribute("aria-label",`${$("scanMap.photo")} \xB7 ${Tt}`),P.addEventListener("click",()=>Ft(C)),dt.push(P),D.append(P)}qt.value="",qt.addEventListener("change",()=>Ft(Number(qt.value))),qt.hidden=!p.length,E.append(qt),Gt(),!S&&v.length&&ae();function Ft(C,ht=!1){E.open=!0,qt.value=String(C),dt.forEach((Tt,P)=>Tt.classList.toggle("current",C===P)),$t.open(C,ht),qt.value=""}return{open:Ft,showSphere:(C,ht)=>A&&x(ht)&&n.isVisible(C)}}function mM(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"),Ft=$(dt?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Ft,h.setAttribute("aria-label",Ft),h.setAttribute("aria-pressed",String(dt))});h.setAttribute("aria-pressed","false");let u=document.createElement("button");u.type="button",u.textContent=$("close"),u.addEventListener("click",Gt);let d=!1,f=Kn($("scanMap.intensity"),$("scanMap.intensity"),()=>{d=!d,Me(!1)});f.className="scan-photo-intensity",f.hidden=!0,c.append(f,h,u),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 p=document.createElement("div");p.className="scan-photo-view";let m=document.createElement("span");m.className="scan-photo-crosshair",m.setAttribute("aria-hidden","true");let b=document.createElement("div");b.className="scan-photo-level",b.hidden=!0;let w=document.createElement("span");w.setAttribute("role","status"),b.append(w,Kn($("scanMap.cancel"),$("scanMap.cancel"),mt)),p.append(g,m,_),o.append(a,b,p),i.append(o);let S=t.meta.panoramas.map((dt,Ft)=>{let C=dt.name||t.meta.elements[dt.element].name||String(Ft+1),ht=document.createElement("button");return ht.className="scan-photo-link",ht.type="button",ht.title=C,ht.setAttribute("aria-label",$("scanMap.goToStation").replace("{name}",C)),ht.hidden=!0,ht.addEventListener("click",()=>n(Ft,!0)),p.append(ht),{photo:dt,name:C,button:ht,position:new R(...dt.position)}}),v=t.readView(t.meta.points.element),y=new Xn;y.params.Points.threshold=.12,y.near=.25;let A=new R,x=new R,E=new R,I=[],D=[],N=!1,B,L=t.meta.rtcOffset?.[2]??0,F,k,W,O=0,U=!1,z=!1,q=0,V=0,Z=null,K,lt,rt=new pn,H=new Ue(72,1,.1,20);H.up.set(0,0,1);let Q=new Gn(10,56,28);Q.rotateX(Math.PI/2);let ut=new Je({side:ze}),It=new me(Q,ut);rt.add(It);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(fM(A,q,V)),z?W.draw(F,H,A):F.render(rt,H),H.getWorldDirection(A);for(let dt of I){if(N){dt.button.hidden=!0;continue}E.copy(dt.position).sub(K.position).normalize(),x.copy(E).project(H);let Ft=E.dot(A)>0&&Math.abs(x.x)<.92&&Math.abs(x.y)<.88;dt.button.hidden=!Ft,Ft&&(dt.button.style.left=`${(1+x.x)*50}%`,dt.button.style.top=`${(1-x.y)*50}%`)}s({position:K.position,yaw:q})}},Ut=(dt,Ft)=>{q+=dt,V=oe.clamp(V+Ft,-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,Ut(...dM(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 Ft=g.getBoundingClientRect();$t((dt.clientX-Ft.left)*2/Ft.width-1,1-(dt.clientY-Ft.top)*2/Ft.height)}),g.addEventListener("lostpointercapture",dt=>{Z?.id===dt.pointerId&&(Z=null)}),g.addEventListener("keydown",dt=>{if(N&&dt.key==="Enter"){dt.preventDefault(),$t(0,0);return}let Ft={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[dt.key];Ft&&(dt.preventDefault(),dt.stopPropagation(),Ut(...Ft))}),g.addEventListener("wheel",dt=>{dt.preventDefault(),H.fov=oe.clamp(H.fov+Math.sign(dt.deltaY)*5,32,95),ft()},{passive:!1}),o.addEventListener("keydown",dt=>{dt.key==="Escape"&&(N?mt():Gt()),dt.stopPropagation()});function Gt(){o.hidden=!0,mt(),O++,Z=null,Jt(),s(null),lt?.focus()}function Jt(){z=!1,k?.dispose(),k=void 0,ut.map=null;for(let dt of I)dt.button.hidden=!0;I=[]}function mt(){N=!1,B=void 0,o.classList.remove("is-picking"),b.hidden=!0,ft()}function Ct(){N=!0,B=void 0,o.classList.add("is-picking"),w.textContent=$("scanMap.pickLower"),b.hidden=!1,ft(),(k||z)&&g.focus()}function $t(dt,Ft){if(!k&&!z)return;let C=pM(H,K.position,D,dt,Ft,g.clientWidth,g.clientHeight);if(C===void 0){w.textContent=$(B===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let ht=C+L;B===void 0?(B=ht,w.textContent=$("scanMap.pickUpper").replace("{z}",Nl(ht))):ht<=B?w.textContent=$("scanMap.upperAboveLower").replace("{z}",Nl(B)):(r({min:B,max:ht}),mt())}function qt(dt,Ft){let C=o.hidden;if(C&&(lt=document.activeElement),Jt(),K=S[dt],o.hidden=!1,l.textContent=K.name,It.rotation.z=oe.degToRad(K.photo.yaw),D=e.root.children.filter((ht,Tt)=>v[Tt]===K.photo.element),U=D.some(ht=>ht.geometry.getAttribute("intensity")),f.hidden=!U&&!K.photo.intensity,I=S.filter(ht=>{if(ht===K)return!1;let Tt=E.copy(ht.position).sub(K.position).length();return Tt<=.25?!1:(y.set(K.position,E.multiplyScalar(1/Tt)),y.far=Tt-.25,!y.intersectObjects(D,!1).length)}),C||!Ft){let ht=I.reduce((Tt,P)=>!Tt||P.position.distanceToSquared(K.position){Ft===O&&(_.textContent=$("scanMap.photoError"))},Tt;try{if(F??(F=new Ti({canvas:g,antialias:!0})),F.setPixelRatio(Math.min(devicePixelRatio,2)),C&&U){W??(W=kp()),W.setScan(D,K.position),z=!0,_.textContent="",g.style.visibility="visible",ft(),dt&&g.focus();return}let P=C?K.photo.intensity:K.photo.image;Tt=URL.createObjectURL(new Blob([t.readView(P)],{type:"image/jpeg"}))}catch{ht();return}new fr().load(Tt,P=>{if(URL.revokeObjectURL(Tt),Ft!==O||P.image.width!==2*P.image.height){P.dispose(),ht();return}k?.dispose(),k=P,k.colorSpace=pe,ut.map=k,ut.needsUpdate=!0,_.textContent="",g.style.visibility="visible",ft(),dt&&g.focus()},void 0,()=>{URL.revokeObjectURL(Tt),ht()})}return{open:qt,pickLevel:Ct,isClosed:()=>o.hidden}}var Xs=7;function Vp(i){if(!i?.length)return null;let t=i.map(({position:l})=>new R(...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 R,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[u,d]of t.entries()){if(!h(i[u].element,d.z))continue;let f=-o.copy(d).applyMatrix4(l.matrixWorldInverse).z;if(f<=l.near||f>=l.far||(o.copy(d).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 p=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,m=Xs*p/c.height;n.setMatrixAt(n.count++,r.makeScale(m,m,m).setPosition(d)),s.push({index:u,depth:f,x:g+c.left,y:_+c.top})}n.instanceMatrix.needsUpdate=n.count>0}},pick(l,c){let h;for(let u of s)(!h||u.depth=0&&this.scene.instancesOf(u.element).length>0&&!this.scene.isVisible(u.element))continue;this._p.set(u.position[0],u.position[1],u.position[2]);let d=this._p.clone().applyMatrix4(l);if(t.isPerspectiveCamera&&d.z>=-t.near)continue;let f=c||e.height/(2*Math.max(-d.z,1e-6)*h),g=u.height*f;if(!Number.isFinite(g)||g<1.5||g>800)continue;let _=this._p.clone().applyMatrix4(a);if(_.z<-1||_.z>1)continue;let p=(_.x*.5+.5)*e.width,m=(-_.y*.5+.5)*e.height;if(p<-400||p>e.width+400||m<-400||m>e.height+400)continue;this._x.set(u.position[0]+Math.cos(u.rotation),u.position[1]+Math.sin(u.rotation),u.position[2]).applyMatrix4(a);let b=(this._x.x*.5+.5)*e.width,w=(-this._x.y*.5+.5)*e.height,S=Math.atan2(w-m,b-p),[v,y,A]=u.color?[Math.round(u.color[0]*255),Math.round(u.color[1]*255),Math.round(u.color[2]*255)]:this.lightBackground?[17,24,39]:[229,231,235];this.lightBackground&&v>230&&y>230&&A>230?[v,y,A]=[17,24,39]:!this.lightBackground&&v<20&&y<20&&A<20&&([v,y,A]=[241,245,249]),o.save(),o.translate(p,m),Math.abs(S)>1e-4&&o.rotate(S),o.font=`${g.toFixed(2)}px system-ui, -apple-system, "Segoe UI", Arial, sans-serif`,o.fillStyle=`rgb(${v},${y},${A})`;let x=u.attachment||1,E=(x-1)%3,I=Math.floor((x-1)/3);o.textAlign=E===1?"center":E===2?"right":"left",o.textBaseline=I===1?"middle":I>=2?"bottom":"top";let D=u.text.split(` -`),N=g*1.25,B=I===1?-((D.length-1)*N)/2:I>=2?-(D.length-1)*N:0;for(let L=0;L{}};let c=new Set(l.flatMap(p=>p.elements)),h=nt("div","ioviewer-sheets ioviewer-floating");h.setAttribute("role","tablist"),h.setAttribute("aria-label",$("sheets.label"));let u=new zi(new ce,new sn({color:"#94a3b8",transparent:!0,opacity:.55}));u.visible=!1,t.add(u);let d=null,f=new Map;function g(p,m=!1){let b=l.find(y=>y.key===p)??l[0];if(!b)return;d=b;for(let[y,A]of f){let x=y===b.key;A.classList.toggle("active",x),A.setAttribute("aria-selected",String(x))}let w=new Set(b.elements),S=[];for(let y of c)w.has(y)||S.push(y);if(n.replaceLayerHidden("sheet",S),s?.setSheet(b.key),!b.isModel&&b.paperBounds){let{min:y,max:A}=b.paperBounds,x=y[2];u.geometry.setFromPoints([new R(y[0],y[1],x),new R(A[0],y[1],x),new R(A[0],A[1],x),new R(y[0],A[1],x)]),u.visible=!0}else u.visible=!1;b.background&&o(b.background,!m);let v=b.paperBounds?new se(new R(...b.paperBounds.min),new R(...b.paperBounds.max)):n.visibleBox();r(!!b.is2D,v,!1),a()}for(let p of l){let m=nt("button","ioviewer-sheet-tab",p.name);m.type="button",m.setAttribute("role","tab"),m.dataset.sheet=p.key,m.addEventListener("click",()=>g(p.key,!1)),f.set(p.key,m),h.append(m)}l.length>1&&i.append(h);let _=e.options?.initialSheet??l[0].key;return g(_,!0),{get active(){return d},setSheet:p=>g(p,!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?gM(uf(document,Zr,i),t):Kr($("noWebGL"))}catch(i){if(!(i instanceof te))throw i;Kr($("badData"))}function gM(i,t){let e=new Ti({canvas:Ln,context:t,antialias:!0,stencil:!0,logarithmicDepthBuffer:qf(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;Zr?.("sceneStart");let h=I(),u=new al(i),d=new ll(i);Zr?.("sceneEnd"),i.releaseBinary(),!c&&h.totalCost===0&&u.count===0&&d.count===0&&Kr($("noGeometry"));let f=new _l(h,k,Math.min(h.totalCost,2e7));n.add(h.root),n.add(u.root),n.add(d.root);let g=u.count?Vp(i.meta.panoramas):null;g&&n.add(g.mesh);let _=()=>h.visibleBox(),p=new wl(h,_(),i.meta.sections);u.syncVisibility(h),u.syncAppearance(h),d.syncVisibility(h),d.syncAppearance(h);let m=()=>{let{planes:mt,intersection:Ct}=p.clipping();u.setClipping(mt,Ct),d.setClipping(mt,Ct)};m();let b=h.slotCount>0,w=b&&t.getContextAttributes()?.stencil===!0,S,v=new Al(p,Ln);n.add(v.group);let y=document.getElementById("ioviewer-ui"),A=new Ul(y,i,h),x=new Cl(y),E=new Ll(y,i.meta.grids??[]);n.add(x.group,E.group);function I(){try{return new Hr(i,{...Jh,maxTextureSize:e.capabilities.maxTextureSize})}catch(mt){if(!(mt instanceof kr))throw mt;c=!0,Kr($("tooLarge").replace("{count}",mt.count).replace("{limit}",mt.limit));let Ct=qt=>({o:0,n:0,t:qt}),$t={count:0,geometry:Ct("u32"),material:Ct("u32"),element:Ct("i32"),matrix:Ct("f32")};return new Hr({...i,meta:{...i.meta,instances:$t}})}}let D=!1;Ln.addEventListener("webglcontextlost",()=>{D=!0,Kr($("contextLost"))});let N,B=new Promise(mt=>N=mt),L=Zr,F=!1;function k(){F||D||(F=!0,f.requested(performance.now()),requestAnimationFrame(()=>{if(F=!1,D)return;let mt=Ln.getBoundingClientRect();K.camera.updateMatrixWorld(),Gt&&g?.update(K.camera,mt,Gt.showSphere),v.update(K.camera),x.update(K.camera,mt),E.update(K.camera,mt),A.update(K.camera,mt),f.begin(K.camera,mt.height,performance.now()),L?.("renderStart"),p.fill&&w?(S??(S=new Rl(h,p,i)),S.render(e,n,K.camera)):e.render(n,K.camera),L&&(L("renderEnd"),L=void 0),f.end(performance.now()),lt.update(),N()}))}h.root.addEventListener("change",k),p.addEventListener("change",()=>{m(),k()}),v.addEventListener("change",k),x.addEventListener("change",k),x.addEventListener("previewchange",k),E.addEventListener("change",k);let W=new ml(e,h,a,{points:u,lines:d,pickFloat:Jh.pickFloat}),O=new Pl(W,p,i),U=0,z=null;function q(){cancelAnimationFrame(U),U=0,z=null,x.setPreview(null)}function V(){U=0,z&&x.setPreview(O.target(...z))}function Z(){z&&(x.setPreview(null),cancelAnimationFrame(U),U=requestAnimationFrame(()=>{U=requestAnimationFrame(V)}))}Ln.addEventListener("pointermove",mt=>{if(!x.active||mt.buttons)return q();z=[mt.clientX,mt.clientY],U||(U=requestAnimationFrame(V))});for(let mt of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Ln.addEventListener(mt,q);h.root.addEventListener("change",mt=>{mt.detail.kind!=="appearance"&&Z()});let K=new ul(a,Ln,{pick:(mt,Ct)=>W.pick(mt,Ct)?.point??null,visibleBox:_});K.addEventListener("change",()=>{W.camera=K.camera,Z(),k()}),h.root.addEventListener("change",mt=>{mt.detail.kind==="appearance"&&(u.syncAppearance(h),d.syncAppearance(h)),(mt.detail.kind==="appearance"||mt.detail.kind==="visibility")&&A.update(K.camera,Ln.getBoundingClientRect()),mt.detail.kind==="visibility"&&(u.syncVisibility(h),d.syncVisibility(h),K.invalidateBounds(),K.resize())});let lt,rt=new vl;rt.addEventListener("change",()=>h.setHighlighted([...rt.values()]));let H=mp({root:y,data:i,scene:h,controls:K,picker:W,selection:rt,measure:x});K.addEventListener("mode2d",()=>{H.sync2DState(),lt?.set2D(K.is2D)}),Sp({root:y,...H,sections:p,selection:rt,canFill:w,hasMeshes:b});let{meta:Q}=i,ut=Fp({...H,files:Q.linkedFiles??[],elements:Q.elements,scene:h});Cp({...H,controls:K,scene:h,sections:p,selection:rt,restoreLinkedModels:ut,views:Q.viewpoints??[],bcfTopics:Q.bcfTopics??[]});let It=Pp({...H,tests:Q.clashTests??[],elements:Q.elements,scene:h,controls:K,selection:rt});n.add(It.group);let ft=Up({root:y,...H,timeliner:Q.timeliner,elements:Q.elements,scene:h}),Ut=mt=>{e.setClearColor(r.set(mt),1);let{r:Ct,g:$t,b:qt}=r,dt=.2126*Ct+.7152*$t+.0722*qt>Math.sqrt(.0525)-.05,Ft=dt?"#000":"#fff";y.style.setProperty("--viewport-text",mt===s?"":Ft),d.setLightBackground(dt),A.setLightBackground(dt),k()};{let{r:mt,g:Ct,b:$t}=r,qt=.2126*mt+.7152*Ct+.0722*$t>Math.sqrt(.0525)-.05;d.setLightBackground(qt),A.setLightBackground(qt),qt&&y.style.setProperty("--viewport-text","#000")}for(let mt of Rp({root:y,toolbar:H.toolbar,scene:h,meta:Q,grids:E,initialBackground:s,setBackground:Ut,hasMeshes:b}))H.onEscape(mt.close);H.toolbar.setHandler("distance",()=>{q(),x.setActive(!x.active),x.active||O.release(),H.toolbar.setActive("distance",x.active)}),H.toolbar.setActive("distance",!1),H.onEscape(()=>(q(),x.clear()));let ae=()=>{K.setExtraBounds("grids",E.visible?E.box:null),K.setExtraBounds("measure",x.box)};E.addEventListener("change",ae),x.addEventListener("change",ae),ae(),K.addEventListener("click",mt=>{let{x:Ct,y:$t,ctrl:qt,shift:Me}=mt.detail;if(x.active){let ht=O.target(Ct,$t);ht&&x.add(ht.point);return}let dt=!qt&&!Me?g?.pick(Ct,$t):void 0;if(dt!==void 0){Gt.open(dt);return}let C=W.pick(Ct,$t)?.element??-1;qt?C>=0&&rt.toggle(C):C>=0?rt.set([C]):Me||rt.clear()}),K.addEventListener("boxselect",mt=>{if(x.active)return;let{rect:Ct,mode:$t,ctrl:qt,shift:Me}=mt.detail;if(Ct.width<4||Ct.height<4){!qt&&!Me&&rt.clear();return}let dt=new se,Ft=tp(Ct,$t,ep(h,K.camera,Ln.getBoundingClientRect())),C=p.clipping(),ht=Ft.filter(Tt=>!p.isCut(h.elementBox(Tt,dt),C));rt.set(qt?[...rt.values(),...ht]:ht)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),K.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),K.resize(),K.fitBox(_(),!1);let Gt=Hp(y,i,u,h,K,k);lt=new pl(document.getElementById("ioviewer-ui"),a,K);let Jt=Gp({root:y,world:n,meta:Q,scene:h,annotationsOverlay:A,apply2DMode:(mt,Ct,$t)=>{K.set2DMode(mt,Ct,$t),H.sync2DState(),lt.set2D(K.is2D)},setBackground:Ut,requestRender:k});!Q.sheets?.length&&Q.options?.initial2DMode&&(K.set2DMode(!0,_(),!1),H.sync2DState(),lt.set2D(!0)),window.addEventListener("pointerdown",mt=>{(mt.target===Ln||lt.element.contains(mt.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:h,points:u,lines:d,annotationsOverlay:A,sheetsBar:Jt,motionDetail:f,controls:K,picker:W,selection:rt,ui:H,viewCube:lt,sections:p,sectionGizmo:v,measure:x,measureSnap:O,grids:E,clashes:It,timeliner:ft,ready:B,get camera(){return K.camera}}}})(); +`)}),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}}}})(); /*! Bundled license information: three/build/three.core.js: diff --git a/src/IOViewer/Viewer/src/engine/modelScene.js b/src/IOViewer/Viewer/src/engine/modelScene.js index 4eb7716..2dbd648 100644 --- a/src/IOViewer/Viewer/src/engine/modelScene.js +++ b/src/IOViewer/Viewer/src/engine/modelScene.js @@ -126,12 +126,18 @@ export class ModelScene { const pointCount = points?.count ?? 0; const lines = meta.lines; const lineCount = lines?.count ?? 0; - const instanceCount = count + pointCount + lineCount; + const annotations = meta.annotations ?? []; + const annotationLayouts = options.annotationLayouts ?? []; + const instanceCount = count + pointCount + lineCount + annotationLayouts.length; this.root = new THREE.Group(); this.elementCount = meta.elements.length; this.pointOffset = count; this.lineOffset = count + pointCount; + this.annotationOffset = count + pointCount + lineCount; + this._annotations = annotations; + this._annotationLayouts = annotationLayouts; + this._annotationSheet = null; this._elements = meta.elements; this._meta = meta; this._mode = 'materials'; @@ -141,7 +147,7 @@ export class ModelScene { this._instanceDetail = true; this._pickFrustum = null; this._textures = new Map(); - // Points and lines share the element visibility and bounds, with no triangle draw slots. + // Points, lines and annotations share element visibility and bounds without triangle draw slots. this._elementOf = new Int32Array(instanceCount); this._elementOf.set(data.view(instances.element)); this._bucketOf = new Uint32Array(count); @@ -151,7 +157,7 @@ export class ModelScene { this._highlight = new Uint8Array(instanceCount); this._highlighted = []; this._tint = new Map(); // instance -> sRGB bytes [r, g, b] - this._boxes = new Float32Array(instanceCount * 6); + this._boxes = new Float32Array(this.annotationOffset * 6); this._minPixels = 0; this._viewHeight = 1; this.visibleCost = 0; @@ -178,6 +184,9 @@ export class ModelScene { writeInstanceBox(lineMatrices, i, meta.geometries[lineGeometry[i]].bbox, boxes); } } + for (let i = 0; i < annotationLayouts.length; i++) { + this._elementOf[this.annotationOffset + i] = annotations[i].element; + } this._indexElements(); for (let i = 0; i < count; i++) { @@ -294,7 +303,7 @@ export class ModelScene { // Which instances are drawn now (1 = drawn), all layers combined. visibilityState() { - return this._visible.map((_, i) => (this._shown(i) ? 1 : 0)); + return this._visible.map((_, i) => (this.isInstanceVisible(i) ? 1 : 0)); } // Instance numbers (0..instanceCount-1) of an element. @@ -307,17 +316,27 @@ export class ModelScene { isVisible(index) { this._checkElement(index); for (let k = this._elementStart[index]; k < this._elementStart[index + 1]; k++) { - if (this._shown(this._elementInstances[k])) return true; + if (this.isInstanceVisible(this._elementInstances[k])) return true; } return false; } + setAnnotationSheet(key) { + this._annotationSheet = key; + } + + isAnnotationVisible(index) { + if (!this._shown(this.annotationOffset + index)) return false; + const sheet = this._annotations[index].sheet; + return this._annotationSheet == null || sheet == null || sheet === this._annotationSheet; + } + get instanceCount() { return this._slotOf.length; } isInstanceVisible(index) { - return this._shown(index); + return index < this.annotationOffset ? this._shown(index) : this.isAnnotationVisible(index - this.annotationOffset); } get slotCount() { @@ -397,9 +416,12 @@ export class ModelScene { visibleBox() { const box = new THREE.Box3(); - for (let i = 0; i < this._visible.length; i++) { + for (let i = 0; i < this.annotationOffset; i++) { if (this._shown(i)) this._expandBox(box, i); } + for (let i = this.annotationOffset; i < this._visible.length; i++) { + if (this.isAnnotationVisible(i - this.annotationOffset)) this._expandBox(box, i); + } return box; } @@ -1270,6 +1292,10 @@ export class ModelScene { } _expandBox(box, i) { + if (i >= this.annotationOffset) { + box.union(this._annotationLayouts[i - this.annotationOffset].box); + return; + } if (!finiteBox(this._boxes, i)) return; const b = this._boxes; const o = i * 6; diff --git a/src/IOViewer/Viewer/src/main.js b/src/IOViewer/Viewer/src/main.js index f39f509..cf106f2 100644 --- a/src/IOViewer/Viewer/src/main.js +++ b/src/IOViewer/Viewer/src/main.js @@ -81,13 +81,18 @@ function start(data, context) { // mergedCap, minRepeats, cellExtent, startup (optional phase samples). // A model over what the viewer can draw opens without geometry and says why; the tree and properties still work. let tooLarge = false; + const uiRoot = document.getElementById('ioviewer-ui'); + const annotationsOverlay = new AnnotationsOverlay(uiRoot, data); + const annotationLayouts = annotationsOverlay.layouts; startup?.('sceneStart'); const scene = createScene(); const points = new PointScene(data); const lines = new LineScene(data); startup?.('sceneEnd'); data.releaseBinary(); // the scene has copied what it needs - if (!tooLarge && scene.totalCost === 0 && points.count === 0 && lines.count === 0) showMessage(t('noGeometry')); + if (!tooLarge && scene.totalCost === 0 && points.count === 0 && lines.count === 0 && !annotationLayouts.length) { + showMessage(t('noGeometry')); + } // Starting at the whole model's cost, a GPU that draws it in time orbits at full detail; a slower one shrinks it. // Larger models start at about what an integrated GPU draws at 30 fps (a 200k-element model, 19.2e6): from a 1M one's // 134e6 the first gesture would take some 20 frames of 200 ms to shrink. A faster GPU grows the budget. @@ -115,8 +120,6 @@ function start(data, context) { let sectionCaps; const sectionGizmo = new SectionGizmo(sections, canvas); world.add(sectionGizmo.group); // outside scene.root: the picking id pass renders only the model - const uiRoot = document.getElementById('ioviewer-ui'); - const annotationsOverlay = new AnnotationsOverlay(uiRoot, data, scene); const measure = new Measure(uiRoot); const grids = new GridAxes(uiRoot, data.meta.grids ?? []); world.add(measure.group, grids.group); // overlays too @@ -124,7 +127,7 @@ function start(data, context) { // A model over what the viewer can draw opens without geometry and says why; the tree and properties still work. function createScene() { try { - const model = new ModelScene(data, { ...testOptions, maxTextureSize: renderer.capabilities.maxTextureSize }); + const model = new ModelScene(data, { ...testOptions, maxTextureSize: renderer.capabilities.maxTextureSize, annotationLayouts }); return model; } catch (error) { if (!(error instanceof ModelTooLargeError)) throw error; @@ -132,7 +135,7 @@ function start(data, context) { showMessage(t('tooLarge').replace('{count}', error.count).replace('{limit}', error.limit)); const none = (type) => ({ o: 0, n: 0, t: type }); const instances = { count: 0, geometry: none('u32'), material: none('u32'), element: none('i32'), matrix: none('f32') }; - return new ModelScene({ ...data, meta: { ...data.meta, instances } }); + return new ModelScene({ ...data, meta: { ...data.meta, instances } }, { annotationLayouts }); } } // The model's GPU buffers keep no CPU copy, so a lost context cannot be rebuilt, not even when the browser restores @@ -160,7 +163,7 @@ function start(data, context) { sectionGizmo.update(controls.camera); measure.update(controls.camera, rect); grids.update(controls.camera, rect); - annotationsOverlay.update(controls.camera, rect); + annotationsOverlay.update(controls.camera, rect, scene); motionDetail.begin(controls.camera, rect.height, performance.now()); firstRender?.('renderStart'); if (sections.fill && canFillSections) { @@ -233,7 +236,7 @@ function start(data, context) { lines.syncAppearance(scene); } if (e.detail.kind === 'appearance' || e.detail.kind === 'visibility') { - annotationsOverlay.update(controls.camera, canvas.getBoundingClientRect()); + annotationsOverlay.update(controls.camera, canvas.getBoundingClientRect(), scene); } if (e.detail.kind !== 'visibility') return; // a highlight must not walk every instance for the bounds points.syncVisibility(scene); @@ -350,9 +353,9 @@ function start(data, context) { world, meta, scene, - annotationsOverlay, apply2DMode: (enabled, box, animate) => { controls.set2DMode(enabled, box, animate); + if (!enabled) controls.fitBox(box, animate); ui.sync2DState(); viewCube.set2D(controls.is2D); }, diff --git a/src/IOViewer/Viewer/src/ui/annotationsOverlay.js b/src/IOViewer/Viewer/src/ui/annotationsOverlay.js index cc15932..7052749 100644 --- a/src/IOViewer/Viewer/src/ui/annotationsOverlay.js +++ b/src/IOViewer/Viewer/src/ui/annotationsOverlay.js @@ -1,14 +1,73 @@ import * as THREE from 'three'; +const FONT = 'system-ui, -apple-system, "Segoe UI", Arial, sans-serif'; +const MEASURE_SIZE = 100; +const LINE_STEP = 1.25; +const HORIZONTAL_ALIGN = ['left', 'center', 'right']; +const VERTICAL_ALIGN = ['top', 'middle', 'bottom']; + +function wrapText(text, width, ctx) { + const paragraphs = text.split('\n'); + if (!(width > 0)) return paragraphs; + const lines = []; + for (const paragraph of paragraphs) { + let line = ''; + for (let word of paragraph.match(/\s*\S+|\s+$/gu) ?? []) { + const next = line + word; + if (ctx.measureText(next).width <= width) { + line = next; + continue; + } + if (line) { + lines.push(line); + word = word.trimStart(); + } + line = word; + if (ctx.measureText(word).width <= width) continue; + line = ''; + for (const character of word) { + if (line && ctx.measureText(line + character).width > width) { + lines.push(line); + line = ''; + } + line += character; + } + } + lines.push(line); + } + return lines; +} + +function layoutAnnotation(a, ctx) { + const width = a.width / a.height * MEASURE_SIZE; + const lines = wrapText(a.text, width, ctx); + const attachment = THREE.MathUtils.clamp(Math.trunc(a.attachment || 1), 1, 9) - 1; + const hAlign = attachment % 3; + const vAlign = Math.floor(attachment / 3); + let span = 0; + for (const line of lines) span = Math.max(span, ctx.measureText(line).width / MEASURE_SIZE * a.height); + const height = lines.length * LINE_STEP * a.height; + const left = -span * hAlign / 2; + const top = height * vAlign / 2; + const box = new THREE.Box3(); + const corner = new THREE.Vector3(); + const cos = Math.cos(a.rotation), sin = Math.sin(a.rotation); + for (const x of [left, left + span]) { + for (const y of [top - height, top]) { + corner.set(a.position[0] + x * cos - y * sin, a.position[1] + x * sin + y * cos, a.position[2]); + box.expandByPoint(corner); + } + } + return { lines, box, hAlign, vAlign }; +} + /** * HiDPI Canvas2D overlay drawing crisp CAD text annotations (`META.annotations`) synchronized with the camera. * Respects element visibility, active sheet filtering, rotation, attachment and adaptive light/dark contrast. */ export class AnnotationsOverlay { - constructor(container, data, scene) { + constructor(container, data) { this.annotations = data.meta.annotations ?? []; - this.scene = scene; - this.activeSheet = null; this.lightBackground = false; this.canvas = document.createElement('canvas'); this.canvas.className = 'ioviewer-annotations'; @@ -16,19 +75,17 @@ export class AnnotationsOverlay { if (this.annotations.length === 0) this.canvas.hidden = true; container.append(this.canvas); this._ctx = this.canvas.getContext('2d'); + if (this._ctx) this._ctx.font = `${MEASURE_SIZE}px ${FONT}`; + this.layouts = this._ctx ? this.annotations.map((a) => layoutAnnotation(a, this._ctx)) : []; this._p = new THREE.Vector3(); this._x = new THREE.Vector3(); } - setSheet(sheetKey) { - this.activeSheet = sheetKey ?? null; - } - setLightBackground(light) { this.lightBackground = !!light; } - update(camera, rect) { + update(camera, rect, scene) { if (!this.annotations.length || !this._ctx || rect.width < 1 || rect.height < 1) return; const dpr = window.devicePixelRatio || 1; const targetW = Math.round(rect.width * dpr); @@ -48,9 +105,10 @@ export class AnnotationsOverlay { : 0; const tanHalfFov = camera.isPerspectiveCamera ? Math.tan(THREE.MathUtils.degToRad(camera.fov / 2)) : 0; - for (const a of this.annotations) { - if (this.activeSheet != null && a.sheet != null && a.sheet !== this.activeSheet) continue; - if (a.element >= 0 && this.scene.instancesOf(a.element).length > 0 && !this.scene.isVisible(a.element)) continue; + for (let index = 0; index < this.layouts.length; index++) { + if (!scene.isAnnotationVisible(index)) continue; + const a = this.annotations[index]; + const { lines, hAlign, vAlign } = this.layouts[index]; this._p.set(a.position[0], a.position[1], a.position[2]); const viewPos = this._p.clone().applyMatrix4(viewInv); @@ -58,7 +116,7 @@ export class AnnotationsOverlay { const pxPerUnit = orthoPxPerUnit || (rect.height / (2 * Math.max(-viewPos.z, 1e-6) * tanHalfFov)); const fontPx = a.height * pxPerUnit; - if (!Number.isFinite(fontPx) || fontPx < 1.5 || fontPx > 800) continue; + if (!Number.isFinite(fontPx) || fontPx < 1.5) continue; const ndc = this._p.clone().applyMatrix4(viewProj); if (ndc.z < -1 || ndc.z > 1) continue; @@ -85,19 +143,14 @@ export class AnnotationsOverlay { ctx.save(); ctx.translate(sx, sy); if (Math.abs(angle) > 1e-4) ctx.rotate(angle); - ctx.font = `${fontPx.toFixed(2)}px system-ui, -apple-system, "Segoe UI", Arial, sans-serif`; + ctx.font = `${fontPx.toFixed(2)}px ${FONT}`; ctx.fillStyle = `rgb(${r},${g},${b})`; - const att = a.attachment || 1; - const hMod = (att - 1) % 3; // 0=left, 1=center, 2=right - const vRow = Math.floor((att - 1) / 3); // 0=top, 1=middle, 2=bottom - ctx.textAlign = hMod === 1 ? 'center' : hMod === 2 ? 'right' : 'left'; - ctx.textBaseline = vRow === 1 ? 'middle' : vRow >= 2 ? 'bottom' : 'top'; + ctx.textAlign = HORIZONTAL_ALIGN[hAlign]; + ctx.textBaseline = VERTICAL_ALIGN[vAlign]; - const lines = a.text.split('\n'); - const lineStep = fontPx * 1.25; - const yOffset = vRow === 1 ? -((lines.length - 1) * lineStep) / 2 - : vRow >= 2 ? -(lines.length - 1) * lineStep : 0; + const lineStep = fontPx * LINE_STEP; + const yOffset = -(lines.length - 1) * lineStep * vAlign / 2; for (let i = 0; i < lines.length; i++) { ctx.fillText(lines[i], 0, yOffset + i * lineStep); } diff --git a/src/IOViewer/Viewer/src/ui/sheetsBar.js b/src/IOViewer/Viewer/src/ui/sheetsBar.js index 16bc958..7719699 100644 --- a/src/IOViewer/Viewer/src/ui/sheetsBar.js +++ b/src/IOViewer/Viewer/src/ui/sheetsBar.js @@ -11,7 +11,6 @@ export function mountSheetsBar({ world, meta, scene, - annotationsOverlay, apply2DMode, setBackground, requestRender, @@ -49,8 +48,8 @@ export function mountSheetsBar({ for (const i of allIndices) { if (!keep.has(i)) hide.push(i); } + scene.setAnnotationSheet(sheet.key); scene.replaceLayerHidden('sheet', hide); - annotationsOverlay?.setSheet(sheet.key); if (!sheet.isModel && sheet.paperBounds) { const { min, max } = sheet.paperBounds; @@ -67,9 +66,11 @@ export function mountSheetsBar({ } if (sheet.background) setBackground(sheet.background, !initial); - const box = sheet.paperBounds - ? new THREE.Box3(new THREE.Vector3(...sheet.paperBounds.min), new THREE.Vector3(...sheet.paperBounds.max)) - : scene.visibleBox(); + const box = scene.visibleBox(); + if (!sheet.isModel && sheet.paperBounds) { + box.expandByPoint(new THREE.Vector3(...sheet.paperBounds.min)); + box.expandByPoint(new THREE.Vector3(...sheet.paperBounds.max)); + } apply2DMode(!!sheet.is2D, box, false); requestRender(); } diff --git a/src/IOViewer/Viewer/test/e2e/cad.spec.js b/src/IOViewer/Viewer/test/e2e/cad.spec.js new file mode 100644 index 0000000..6519f34 --- /dev/null +++ b/src/IOViewer/Viewer/test/e2e/cad.spec.js @@ -0,0 +1,47 @@ +import { test, expect } from '@playwright/test'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { viewerDir } from './global-setup.js'; + +test('text-only spaces fit and draw their annotations, including wrapped and hidden labels', async ({ page }) => { + await page.addInitScript(() => { + window.drawnLabels = []; + const { clearRect, fillText } = CanvasRenderingContext2D.prototype; + CanvasRenderingContext2D.prototype.clearRect = function (...args) { + if (this.canvas.classList.contains('ioviewer-annotations')) window.drawnLabels = []; + return clearRect.call(this, ...args); + }; + CanvasRenderingContext2D.prototype.fillText = function (...args) { + if (this.canvas.classList.contains('ioviewer-annotations')) window.drawnLabels.push(args[0]); + return fillText.call(this, ...args); + }; + }); + const errors = []; + page.on('pageerror', (error) => errors.push(error.message)); + await page.goto(pathToFileURL(path.join(viewerDir, 'test-results/cad-annotations.html')).href); + await page.evaluate(() => window.__ioviewer.ready); + + const labels = () => page.evaluate(() => window.drawnLabels); + const mode = () => page.evaluate(() => window.__ioviewer.controls.is2D); + const paper = page.getByRole('tab', { name: 'Paper' }); + const model = page.getByRole('tab', { name: 'Model' }); + await expect(page.locator('#ioviewer-message')).toBeHidden(); + await expect.poll(labels).toEqual(['Plan']); + expect(await mode()).toBe(false); + + await paper.click(); + await expect.poll(labels).toEqual(['North', 'South', 'East']); + expect(await mode()).toBe(true); + + await page.evaluate(() => window.__ioviewer.scene.setVisible([1], false)); + await expect.poll(labels).toEqual([]); + await page.evaluate(() => window.__ioviewer.scene.isolate([1])); + await expect.poll(labels).toEqual(['North', 'South', 'East']); + + await model.click(); + await expect.poll(labels).toEqual([]); + await page.evaluate(() => window.__ioviewer.scene.showAll()); + await expect.poll(labels).toEqual(['Plan']); + expect(await mode()).toBe(false); + expect(errors).toEqual([]); +}); diff --git a/src/IOViewer/Viewer/test/e2e/tools.spec.js b/src/IOViewer/Viewer/test/e2e/tools.spec.js index d61f685..59c4bcd 100644 --- a/src/IOViewer/Viewer/test/e2e/tools.spec.js +++ b/src/IOViewer/Viewer/test/e2e/tools.spec.js @@ -236,7 +236,7 @@ test('opacity slider 10-100 % changes the picture; the popover closes on Esc and await tool(page, 'opacity').click(); await slider.fill('100'); - expect((await shot(page)).equals(opaque)).toBe(true); + await expect.poll(async () => (await shot(page)).equals(opaque)).toBe(true); await page.mouse.click(640, 40); // outside, over empty space: closes, selection kept await expect(page.locator('.ioviewer-opacity')).toBeHidden(); expect(await selected(page)).toEqual([column]); diff --git a/tests/IOViewer.Tests/JsonAndImportTests.cs b/tests/IOViewer.Tests/JsonAndImportTests.cs index efde8db..d264ff7 100644 --- a/tests/IOViewer.Tests/JsonAndImportTests.cs +++ b/tests/IOViewer.Tests/JsonAndImportTests.cs @@ -59,6 +59,44 @@ public void ViewerJson_Format2_RoundTrips() Assert.Contains("\"SectionBox\": {\n \"Min\": [\n -1,", json.ReplaceLineEndings("\n"), StringComparison.Ordinal); // vectors are arrays } + [Fact] + public void ViewerJson_RoundTripsCadTextAndSheets() + { + var doc = SampleDocument(); + doc.InitialSheetKey = "paper"; + doc.Sheets.Add(new ViewerSheet + { + Key = "paper", + ElementIds = [1], + PaperBounds = new BoundingBox3d(new(1, 2, 0), new(5, 6, 0)), + }); + doc.Annotations.Add(new ViewerAnnotation + { + Text = "North South", + Position = new Vector3d(2, 3, 0), + Width = 4, + ElementId = 1, + SheetKey = "paper", + }); + + using var output = new MemoryStream(); + JsonViewerExporter.Export(doc, output); + output.Position = 0; + var restored = JsonViewerImporter.Load(output); + var sheet = Assert.Single(restored.Sheets); + var text = Assert.Single(restored.Annotations); + + Assert.Equal("paper", restored.InitialSheetKey); + Assert.Equal("paper", sheet.Key); + Assert.Equal([1L], sheet.ElementIds); + Assert.Equal(doc.Sheets[0].PaperBounds, sheet.PaperBounds); + Assert.Equal("North South", text.Text); + Assert.Equal(doc.Annotations[0].Position, text.Position); + Assert.Equal(4, text.Width); + Assert.Equal(1, text.ElementId); + Assert.Equal(sheet.Key, text.SheetKey); + } + [Fact] public void ViewerJson_RoundTripsOptionalViewpointState() { diff --git a/tests/fixtures/viewer/cad-annotations.json b/tests/fixtures/viewer/cad-annotations.json new file mode 100644 index 0000000..f9424ed --- /dev/null +++ b/tests/fixtures/viewer/cad-annotations.json @@ -0,0 +1,23 @@ +{ + "Kind": "ioviewer", + "Format": 2, + "Scene": { + "Kind": "ioscene", + "Format": 1, + "Title": "Text-only drawing", + "Models": [{"Id": 1, "Key": "fixture", "Name": "Fixture"}], + "Elements": [ + {"Id": 1, "Name": "Plan label", "ModelId": 1}, + {"Id": 2, "Name": "Paper label", "ModelId": 1} + ] + }, + "Annotations": [ + {"Text": "Plan", "Position": [1000, 2000, 0], "Height": 1, "ElementId": 1, "SheetKey": "model"}, + {"Text": "North South\nEast", "Position": [3000, 4000, 0], "Height": 1, "Width": 4, "ElementId": 2, "SheetKey": "paper"} + ], + "Sheets": [ + {"Key": "paper", "Name": "Paper", "ElementIds": [2]}, + {"Key": "model", "Name": "Model", "IsModelSpace": true, "Is2D": false, "ElementIds": [1]} + ], + "InitialSheetKey": "model" +} From 338b9a686783d9a7158199f07da0ea4f98ccd332 Mon Sep 17 00:00:00 2001 From: mahach666 <79989386+mahach666@users.noreply.github.com> Date: Wed, 2 Dec 2026 15:39:08 +0300 Subject: [PATCH 3/3] Isolate opacity screenshots from the viewer controls --- src/IOViewer/Viewer/test/e2e/tools.spec.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/IOViewer/Viewer/test/e2e/tools.spec.js b/src/IOViewer/Viewer/test/e2e/tools.spec.js index 59c4bcd..1157c8c 100644 --- a/src/IOViewer/Viewer/test/e2e/tools.spec.js +++ b/src/IOViewer/Viewer/test/e2e/tools.spec.js @@ -22,9 +22,9 @@ const selected = (page) => page.evaluate(() => [...window.__ioviewer.selection.v const modeItem = (page, mode) => page.locator(`.ioviewer-display-modes [data-mode="${mode}"]`); // The middle of the canvas, clear of the panels and the toolbar. const VIEW = { x: 340, y: 160, width: 600, height: 420 }; -const shot = async (page) => { +const shot = async (page, options) => { await frame(page); - return page.screenshot({ clip: VIEW }); + return page.screenshot({ clip: VIEW, ...options }); }; // Client position of a world point (META coordinates are RTC: world minus rtcOffset). @@ -221,7 +221,9 @@ test('opacity slider 10-100 % changes the picture; the popover closes on Esc and const errors = await open(page); const column = await indexOf(page, 'Column D2 Level 1'); await page.evaluate((i) => window.__ioviewer.selection.set([i]), column); - const opaque = await shot(page); + // Compare the rendered model independently of the popover, focus and tooltips. + const modelShot = () => shot(page, { style: '#ioviewer-ui { opacity: 0 !important; }' }); + const opaque = await modelShot(); await tool(page, 'opacity').click(); const slider = page.locator('.ioviewer-opacity-slider'); await expect(slider).toHaveAttribute('min', '10'); @@ -229,16 +231,17 @@ test('opacity slider 10-100 % changes the picture; the popover closes on Esc and await expect(page.locator('.ioviewer-opacity-value')).toHaveText('100 %'); await slider.fill('40'); await expect(page.locator('.ioviewer-opacity-value')).toHaveText('40 %'); - expect((await shot(page)).equals(opaque)).toBe(false); + expect((await modelShot()).equals(opaque)).toBe(false); await page.keyboard.press('Escape'); // focus is on the slider await expect(page.locator('.ioviewer-opacity')).toBeHidden(); expect(await selected(page)).toEqual([column]); await tool(page, 'opacity').click(); await slider.fill('100'); - await expect.poll(async () => (await shot(page)).equals(opaque)).toBe(true); + await expect(page.locator('.ioviewer-opacity-value')).toHaveText('100 %'); await page.mouse.click(640, 40); // outside, over empty space: closes, selection kept await expect(page.locator('.ioviewer-opacity')).toBeHidden(); + expect((await modelShot()).equals(opaque)).toBe(true); expect(await selected(page)).toEqual([column]); await tool(page, 'displayMode').click();