diff --git a/Directory.Packages.props b/Directory.Packages.props index bb144f2..26d8a4b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,7 +13,7 @@ - + diff --git a/README.md b/README.md index c7f0ce6..9f8d0ae 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Built clean-room under the [IOExtend](https://github.com/IOExtend) organization. - display modes (materials, textures, white, wireframe), viewport background color, grid lines and a global opacity slider; - saved viewpoints with a viewpoint tour, clash results, a 4D schedule player and linked-file visibility, each shown only when the document has that data. - Imports binary glTF 2.0 (`.glb`), Wavefront OBJ (`.obj`), and JSON: viewer JSON, IOScene scene files and IOViewer 0.1/0.2 snapshots. -- Displays point clouds with source RGB when available and a top-down minimap. The CLI includes Leica LGSX camera panoramas, FARO FLS colour panoramas and registered sets of E57 camera images. Select a station on the minimap to open its photograph. +- Displays point clouds with source RGB when available and a top-down minimap. The CLI includes Leica LGSx camera panoramas, legacy Leica LGS JPEG XR panoramas on Windows, FARO FLS colour panoramas and registered sets of E57 camera images. Select a station or use **Open photo panorama…** at the bottom of the minimap. ### Mouse and keyboard diff --git a/docs/getting-started.md b/docs/getting-started.md index 926c1b4..c52d696 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -151,6 +151,9 @@ arrow keys to look around, and use the wheel to zoom. Arrows inside the photogra heading. The minimap remains available while the photo panel is open. The generated HTML embeds the photographs. Use **Enlarge** to expand a panorama. Pick a minimap size, drag the plan to pan it and use the wheel or the zoom buttons to change its scale. +Use **Intensity** to view the scan points from the panorama's station, shaded by their measured laser signal. +Viewer JSON can carry `PointIntensities` as base64 display-intensity bytes keyed by point geometry id, one byte per vertex. +Zero indicates a missing measurement. A panorama's optional `IntensityJpeg` is used where the measured points are unavailable. The blue spheres mark camera positions in the 3D view. Click a sphere to open its panorama. Use **Panorama spheres in 3D** on the minimap to hide or show the spheres. The spheres follow the selected height band and the model's visibility. The **+** beside the level list starts a level from two clicks in a panorama, lower elevation first. Each elevation comes from the @@ -158,6 +161,10 @@ sampled scan point at that location. Selecting a level filters the map points an separated vertically by more than 2 m can create levels automatically. Use **All heights** to return to the full plan. Level ranges are saved in the browser for that HTML file when local storage is available. +Click a point to select its scan. Orbit and zoom anchor to the point under the cursor. The distance tool snaps to nearby visible +scan points. The **White** display mode and the opacity slider also apply to clouds. Section planes and both +section box modes clip points and meshes together. Wireframe and surface textures apply to meshes. + - Left click selects, Ctrl+click adds or removes, a click on empty space clears the selection. - Left drag orbits around the point under the cursor; middle or right drag pans; the wheel zooms towards the cursor. - Shift+left drag selects with a box: left to right selects objects fully inside, right to left selects objects it touches. @@ -167,7 +174,7 @@ are saved in the browser for that HTML file when local storage is available. Esc press handles one action. In the **Sections** panel, enable **Fill cut faces** to fill the cross-sections of consistently wound, closed meshes. -The fill is visual. Picking and measurement continue to use model triangles. Large models take extra work while +The fill is visual. Picking and measurement continue to use the source geometry. Large models take extra work while fill is enabled. Turn a section box around Z with the blue ring or the **Rotation around Z** slider. Face handles resize along the diff --git a/src/IOViewer.Cli/JpegXr.cs b/src/IOViewer.Cli/JpegXr.cs new file mode 100644 index 0000000..930644e --- /dev/null +++ b/src/IOViewer.Cli/JpegXr.cs @@ -0,0 +1,104 @@ +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using SkiaSharp; + +namespace IOViewer.Cli; + +[SupportedOSPlatform("windows")] +internal static class JpegXr +{ + private static readonly Guid DecoderClass = new("a26cec36-234c-4950-ae16-e34aace71d0d"); + private static readonly Guid Bgr24 = new("6fddc324-4e03-4bfe-b185-3d77768dc90c"); + private static readonly Guid Gray8 = new("6fddc324-4e03-4bfe-b185-3d77768dc908"); + private const int ChangedApartment = unchecked((int)0x80010106); + + internal static SKBitmap Decode(byte[] image, int maxSide) + { + int apartment = CoInitializeEx(0, 0); + if (apartment != ChangedApartment) Marshal.ThrowExceptionForHR(apartment); + nint stream = 0; + Decoder? decoder = null; + BitmapFrame? frame = null; + try + { + stream = SHCreateMemStream(image, image.Length); + if (stream == 0) throw new InvalidDataException("Could not open the JPEG XR memory stream."); + Guid iid = typeof(Decoder).GUID; + Marshal.ThrowExceptionForHR(CoCreateInstance(in DecoderClass, 0, 1, in iid, out decoder)); + decoder.Initialize(stream, 0); + decoder.GetFrame(0, out frame); + frame.GetSize(out uint width, out uint height); + frame.GetPixelFormat(out Guid format); + if (width < 2 || width != height || width > maxSide || (ulong)width * height > 32 * 1024 * 1024) + throw new InvalidDataException("Invalid JPEG XR panorama face dimensions."); + if (format != Bgr24 && format != Gray8) + throw new InvalidDataException("The JPEG XR panorama face must carry 24-bit BGR or 8-bit grayscale."); + + int size = (int)width; + int stride = format == Gray8 ? size : 3 * size; + var bytes = new byte[stride * size]; + frame.CopyPixels(0, stride, bytes.Length, bytes); + var pixels = new SKColor[size * size]; + if (format == Gray8) + { + for (int i = 0; i < pixels.Length; i++) pixels[i] = new SKColor(bytes[i], bytes[i], bytes[i]); + } + else + { + for (int i = 0; i < pixels.Length; i++) + pixels[i] = new SKColor(bytes[3 * i + 2], bytes[3 * i + 1], bytes[3 * i]); + } + return new SKBitmap(size, size) { Pixels = pixels }; + } + catch (COMException ex) + { + throw new InvalidDataException("The Windows JPEG XR decoder could not read the panorama face.", ex); + } + finally + { + if (frame != null) Marshal.ReleaseComObject(frame); + if (decoder != null) Marshal.ReleaseComObject(decoder); + if (stream != 0) Marshal.Release(stream); + if (apartment >= 0) CoUninitialize(); + } + } + + [DllImport("ole32.dll", ExactSpelling = true)] + private static extern int CoInitializeEx(nint reserved, int apartment); + + [DllImport("ole32.dll", ExactSpelling = true)] + private static extern void CoUninitialize(); + + [DllImport("ole32.dll", ExactSpelling = true)] + private static extern int CoCreateInstance(in Guid clsid, nint outer, int context, in Guid iid, + [MarshalAs(UnmanagedType.Interface)] out Decoder decoder); + + [DllImport("shlwapi.dll", ExactSpelling = true)] + private static extern nint SHCreateMemStream(byte[] data, int size); + + [ComImport, Guid("9edde9e7-8dee-47ea-99df-e6faf2ed44bf"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + private interface Decoder + { + void QueryCapability(nint stream, out uint capability); + void Initialize(nint stream, int cacheOptions); + void GetContainerFormat(out Guid format); + void GetDecoderInfo(out nint info); + void CopyPalette(nint palette); + void GetMetadataQueryReader(out nint reader); + void GetPreview(out nint preview); + void GetColorContexts(uint count, nint contexts, out uint actual); + void GetThumbnail(out nint thumbnail); + void GetFrameCount(out uint count); + void GetFrame(uint index, out BitmapFrame frame); + } + + [ComImport, Guid("3b16811b-6a43-4ec9-a813-3d930c13b940"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + private interface BitmapFrame + { + void GetSize(out uint width, out uint height); + void GetPixelFormat(out Guid format); + void GetResolution(out double dpiX, out double dpiY); + void CopyPalette(nint palette); + void CopyPixels(nint rectangle, int stride, int size, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] bytes); + } +} diff --git a/src/IOViewer.Cli/Program.cs b/src/IOViewer.Cli/Program.cs index c68ffe0..5e247b8 100644 --- a/src/IOViewer.Cli/Program.cs +++ b/src/IOViewer.Cli/Program.cs @@ -385,6 +385,8 @@ private static ViewerDocument FromPcl(string path, out IReadOnlyList>(); var colored = new HashSet(); + var capturedIntensities = new Dictionary>(); + var withIntensity = new HashSet(); var sceneOptions = new PclSceneOptions { SubsampleStep = step, @@ -397,6 +399,8 @@ private static ViewerDocument FromPcl(string path, out IReadOnlyList diagnostic.Code == "colours-dropped"); ScanPhotographs.Add(cloud, viewer, messages); return viewer; @@ -409,6 +413,12 @@ void CaptureColor(int geometry, PclPoint point) bytes.Add(color.R); bytes.Add(color.G); bytes.Add(color.B); + if (!showIntensity) return; + if (!capturedIntensities.TryGetValue(geometry, out var levels)) capturedIntensities[geometry] = levels = []; + byte intensity = point.Intensity is float signal && float.IsFinite(signal) + ? (byte)(1 + MathF.Round(254 * MathF.Sqrt(Math.Clamp(signal, 0, 1)))) : (byte)0; + if (intensity != 0) withIntensity.Add(geometry); + levels.Add(intensity); } } diff --git a/src/IOViewer.Cli/ScanPhotographs.cs b/src/IOViewer.Cli/ScanPhotographs.cs index a0153d0..01dd5c3 100644 --- a/src/IOViewer.Cli/ScanPhotographs.cs +++ b/src/IOViewer.Cli/ScanPhotographs.cs @@ -18,6 +18,8 @@ internal static class ScanPhotographs private const int Width = 2048; private const int MaxImageSide = 8192; private const string LeicaCameraPrefix = "SETUP-camera-"; + private const string LeicaIntensityPrefix = "SETUP-scanintensity-"; + private static ReadOnlySpan JpegXrSignature => [0x49, 0x49, 0xbc, 0x01]; internal static int SubsampleStep(PclDocument cloud) { @@ -35,7 +37,7 @@ internal static void Add(PclDocument cloud, ViewerDocument viewer, List photos = cloud switch { - LgsxDocument leica => ReadLeica(leica, diagnostics), + LgsxDocument leica => ReadLeica(leica, viewer, diagnostics), FaroFlsDocument faro => ReadFaro(faro), E57Document e57 => ReadE57(e57), _ => [], @@ -49,7 +51,7 @@ internal static void Add(PclDocument cloud, ViewerDocument viewer, List ReadLeica(LgsxDocument cloud, List diagnostics) + private static IEnumerable ReadLeica(LgsxDocument cloud, ViewerDocument viewer, List diagnostics) { var entries = cloud.Entries.Where(e => e.Name.StartsWith(LeicaCameraPrefix, StringComparison.Ordinal)).ToArray(); if (entries.Length == 0) yield break; @@ -61,6 +63,9 @@ private static IEnumerable ReadLeica(LgsxDocument cloud, List (scan.Id, Element: i + 2L)) .ToDictionary(item => item.Id, item => item.Element, StringComparer.Ordinal); + var intensityEntries = cloud.Entries.ToLookup(e => e.Name, StringComparer.Ordinal); + var measuredElements = viewer.Scene.Instances.Where(instance => viewer.PointIntensities.ContainsKey(instance.GeometryId)) + .Select(instance => instance.ElementId).ToHashSet(); foreach (var entry in entries) { @@ -77,7 +82,8 @@ private static IEnumerable ReadLeica(LgsxDocument cloud, List ReadLeica(LgsxDocument cloud, List ReadLeicaPoses(byte[] database) @@ -120,7 +141,9 @@ internal static byte[] ProjectLeicaCube(byte[][] faces, Quaternion rotation) File.WriteAllBytes(path, database); using var connection = new SqliteConnection(new SqliteConnectionStringBuilder { - DataSource = path, Mode = SqliteOpenMode.ReadOnly, Pooling = false + DataSource = path, + Mode = SqliteOpenMode.ReadOnly, + Pooling = false, }.ToString()); connection.Open(); using var command = connection.CreateCommand(); @@ -200,6 +223,7 @@ internal static byte[][] ReadCube(ReadOnlySpan data) { if (!data.StartsWith("CUBE"u8)) throw new InvalidDataException("Missing Leica cube header."); data = data[4..]; + if (data.StartsWith(JpegXrSignature)) return ReadJpegXrCube(data); ReadOnlySpan start = [0xFF, 0xD8, 0xFF, 0xE0, 0, 16, 0x4a, 0x46, 0x49, 0x46, 0]; var levels = new SortedDictionary>(); while (true) @@ -225,6 +249,41 @@ internal static byte[][] ReadCube(ReadOnlySpan data) return selected.Value?.ToArray() ?? throw new InvalidDataException("A Leica panorama needs six matching JPEG faces."); } + private static byte[][] ReadJpegXrCube(ReadOnlySpan data) + { + var faces = new byte[6][]; + for (int face = 0; face < faces.Length; face++) + { + if (data.Length < 8 || !data.StartsWith(JpegXrSignature)) + throw new InvalidDataException("A Leica panorama needs six JPEG XR faces."); + uint directoryOffset = BinaryPrimitives.ReadUInt32LittleEndian(data[4..]); + if (directoryOffset < 8 || directoryOffset > data.Length - 2) + throw new InvalidDataException("Invalid JPEG XR image directory."); + var directory = data[(int)directoryOffset..]; + int entries = BinaryPrimitives.ReadUInt16LittleEndian(directory); + if (entries > (directory.Length - 2) / 12) + throw new InvalidDataException("Incomplete JPEG XR image directory."); + uint pixels = 0, bytes = 0; + for (int i = 0; i < entries; i++) + { + var field = directory[(2 + i * 12)..]; + ushort tag = BinaryPrimitives.ReadUInt16LittleEndian(field); + if (tag == 0xbcc0) pixels = BinaryPrimitives.ReadUInt32LittleEndian(field[8..]); + if (tag == 0xbcc1) bytes = BinaryPrimitives.ReadUInt32LittleEndian(field[8..]); + } + if (pixels < directoryOffset + 2 + entries * 12 || bytes == 0 || (ulong)pixels + bytes > (ulong)data.Length) + throw new InvalidDataException("Invalid JPEG XR image range."); + int end = (int)(pixels + bytes); + faces[face] = data[..end].ToArray(); + data = data[end..]; + if (face == faces.Length - 1) break; + int next = data.IndexOf(JpegXrSignature); + if (next < 0 || next > 4096) throw new InvalidDataException("Missing JPEG XR cube face."); + data = data[next..]; + } + return faces; + } + private static IEnumerable ReadFaro(FaroFlsDocument cloud) { if (cloud.ReadColorPanorama(Width) is not { } rgb) yield break; @@ -320,8 +379,14 @@ private static Quaternion UnitQuaternion(double x, double y, double z, double w) return Quaternion.Normalize(value); } - private static SKBitmap LoadJpeg(byte[] bytes) + private static SKBitmap LoadLeicaFace(byte[] bytes) { + if (bytes.AsSpan().StartsWith(JpegXrSignature)) + { + if (!OperatingSystem.IsWindows()) + throw new InvalidDataException("JPEG XR Leica panoramas require Windows."); + return JpegXr.Decode(bytes, MaxImageSide); + } if (bytes.Length < 3 || bytes[0] != 255 || bytes[1] != 216 || bytes[2] != 255) throw new InvalidDataException("A photo face does not hold JPEG data."); return LoadImage(bytes); @@ -355,7 +420,7 @@ private sealed class Frame(SKBitmap image, (Vector3 Forward, Vector3 Right, Vect public readonly SKColor[] Pixels = image.Pixels; } - private static byte[] Project(IReadOnlyList frames) + private static byte[] Project(IReadOnlyList frames, bool grayscale = false) { const int Height = Width / 2; var pixels = new SKColor[Width * Height]; @@ -390,7 +455,7 @@ private static byte[] Project(IReadOnlyList frames) } }); - return Encode(pixels); + return Encode(pixels, grayscale); } private static bool TryProject(Vector3 ray, Frame frame, float closest, out float depth, out float u, out float v) @@ -404,10 +469,12 @@ private static bool TryProject(Vector3 ray, Frame frame, float closest, out floa return u >= -.5f && v >= -.5f && u <= frame.Width - .5f && v <= frame.Height - .5f; } - private static byte[] Encode(SKColor[] pixels) + private static byte[] Encode(SKColor[] pixels, bool grayscale = false) { using var bitmap = new SKBitmap(Width, Width / 2) { Pixels = pixels }; - using var image = SKImage.FromBitmap(bitmap); + using var gray = grayscale ? bitmap.Copy(SKColorType.Gray8) + ?? throw new InvalidDataException("Could not create a grayscale panorama.") : null; + using var image = SKImage.FromBitmap(gray ?? bitmap); using var jpeg = image.Encode(SKEncodedImageFormat.Jpeg, 88); return jpeg.ToArray(); } diff --git a/src/IOViewer.Cli/SceneFederation.cs b/src/IOViewer.Cli/SceneFederation.cs index e358d16..f0e843b 100644 --- a/src/IOViewer.Cli/SceneFederation.cs +++ b/src/IOViewer.Cli/SceneFederation.cs @@ -94,6 +94,12 @@ internal static void Append(ViewerDocument target, ViewerDocument source, string throw new InvalidDataException("Point colors reference an unknown geometry."); target.PointColors.Add(geometryId, colors); } + foreach (var (id, values) in source.PointIntensities) + { + if (!geometryIds.TryGetValue(id, out int geometryId)) + throw new InvalidDataException("Point intensities reference an unknown geometry."); + target.PointIntensities.Add(geometryId, values); + } double yaw = Math.Atan2(placement.XAxis.Y, placement.XAxis.X) * (180 / Math.PI); foreach (var panorama in source.Panoramas) { diff --git a/src/IOViewer/Exporters/JsonViewerExporter.cs b/src/IOViewer/Exporters/JsonViewerExporter.cs index d315601..5c7b9c4 100644 --- a/src/IOViewer/Exporters/JsonViewerExporter.cs +++ b/src/IOViewer/Exporters/JsonViewerExporter.cs @@ -75,6 +75,7 @@ internal sealed class ViewerJsonFile public List? BcfTopics { get; set; } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public Dictionary? PointColors { get; set; } + public Dictionary? PointIntensities { get; set; } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public List? Panoramas { get; set; } @@ -88,6 +89,7 @@ internal sealed class ViewerJsonFile ViewpointStates = doc.ViewpointStates is { Count: > 0 } ? doc.ViewpointStates : null, BcfTopics = doc.BcfTopics is { Count: > 0 } ? doc.BcfTopics : null, 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, }; @@ -100,6 +102,7 @@ internal sealed class ViewerJsonFile ViewpointStates = ViewpointStates ?? [], BcfTopics = BcfTopics ?? [], PointColors = PointColors ?? [], + PointIntensities = PointIntensities ?? [], Panoramas = Panoramas ?? [], }; } diff --git a/src/IOViewer/Exporters/ViewerPayloadWriter.cs b/src/IOViewer/Exporters/ViewerPayloadWriter.cs index 449bed2..0046b92 100644 --- a/src/IOViewer/Exporters/ViewerPayloadWriter.cs +++ b/src/IOViewer/Exporters/ViewerPayloadWriter.cs @@ -60,7 +60,8 @@ internal sealed class ViewerPayloadWriter private InstanceViews _instances; private InstanceViews _pointViews; private readonly Dictionary _pointColors; - private readonly List<(int Element, Vector3d Position, double Yaw, BlobView Image, string? Name)> _panoramas = []; + private readonly Dictionary _pointIntensities; + private readonly List<(int Element, Vector3d Position, double Yaw, BlobView Image, BlobView? Intensity, string? Name)> _panoramas = []; private ViewerPayloadWriter(ViewerDocument doc, HtmlViewerOptions options) { @@ -69,6 +70,7 @@ private ViewerPayloadWriter(ViewerDocument doc, HtmlViewerOptions options) _firstListedModel = doc.ShowHostInModelList ? 0 : 1; _bcfTopics = doc.BcfTopics; _pointColors = doc.PointColors; + _pointIntensities = doc.PointIntensities; _options = options; } @@ -84,16 +86,26 @@ public static ViewerPayloadWriter Create(ViewerDocument doc, HtmlViewerOptions o { if (panorama is null || !elementIndex.TryGetValue(panorama.ElementId, out int element) || !IsFinite(panorama.Position - writer._rtcOffset) || !double.IsFinite(panorama.YawDegrees) - || panorama.Jpeg is not { Length: >= 4 and <= 16 * 1024 * 1024 } image - || image[0] != 0xff || image[1] != 0xd8 || image[^2] != 0xff || image[^1] != 0xd9) + || !IsPanoramaJpeg(panorama.Jpeg)) throw new InvalidDataException("A panorama needs a scene element, finite placement and a JPEG up to 16 MiB."); + BlobView? intensity = null; + if (panorama.IntensityJpeg is { } image) + { + if (!IsPanoramaJpeg(image)) + throw new InvalidDataException("A panorama intensity layer needs a JPEG up to 16 MiB."); + intensity = writer._blob.Add(image.AsSpan()); + } writer._panoramas.Add((element, panorama.Position - writer._rtcOffset, panorama.YawDegrees, - writer._blob.Add(image.AsSpan()), panorama.Name)); + writer._blob.Add(panorama.Jpeg.AsSpan()), intensity, panorama.Name)); } writer.ValidateMetadata(); return writer; } + private static bool IsPanoramaJpeg(byte[]? image) => + image is { Length: >= 4 and <= 16 * 1024 * 1024 } && + image[0] == 0xff && image[1] == 0xd8 && image[^2] == 0xff && image[^1] == 0xd9; + internal static void WriteClusterReview(ViewerDocument doc, HtmlViewerOptions options, Vector3d origin, Stream output) { var writer = new ViewerPayloadWriter(doc, options) { _rtcOffset = origin }; @@ -277,6 +289,12 @@ private Dictionary Build() || colors is null || colors.LongLength != 3L * geometry.Vertices.Count) throw new InvalidDataException($"Point geometry {id} needs exactly three color bytes per vertex."); } + foreach (var (id, values) in _pointIntensities) + { + if (!geometries.TryGetValue(id, out var geometry) || geometry.Topology != SceneTopology.Points + || values is null || values.Length != geometry.Vertices.Count) + throw new InvalidDataException($"Point geometry {id} needs one intensity byte per vertex."); + } // Instances per geometry, and the largest axis length of any of them: grid steps in local units grow by it. var uses = new Dictionary(); @@ -401,17 +419,20 @@ private void AddPointInstance(SceneGeometry geometry, SceneInstance instance, Di int geometryIndex; Vector3d translation; byte[]? colors = _pointColors.GetValueOrDefault(geometry.Id); + byte[]? intensities = _pointIntensities.GetValueOrDefault(geometry.Id); if (GeometryQuantizer.TryQuantize(rtc, out var origin, out var q)) { var local = box.IsEmpty ? box : new BoundingBox3d(box.Min - origin, box.Max - origin); - geometryIndex = AddGeometry(q, null, Vector3d.Zero, Array.Empty(), null, null, local, points: true, colors: colors); + geometryIndex = AddGeometry(q, null, Vector3d.Zero, Array.Empty(), null, null, local, + points: true, colors: colors, intensities: intensities); translation = origin; } else { var min = box.IsEmpty ? Vector3d.Zero : box.Min; var bounds = new BoundingBox3d(Vector3d.Zero, box.Max - min); - geometryIndex = AddGeometry(null, Floats(rtc, min), null, Array.Empty(), null, null, bounds, points: true, colors: colors); + geometryIndex = AddGeometry(null, Floats(rtc, min), null, Array.Empty(), null, null, bounds, + points: true, colors: colors, intensities: intensities); translation = min; } @@ -572,7 +593,8 @@ 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) + 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) { int vertexCount = (q?.Length ?? positions!.Length) / 3; ushort[]? indices16 = null; @@ -601,6 +623,8 @@ private int AddGeometry(ushort[]? q, float[]? positions, Vector3d? origin, IRead hasher.AddBytes(Bytes(uvs)); hasher.Add(colors is null); hasher.AddBytes(Bytes(colors)); + hasher.Add(intensities is null); + hasher.AddBytes(Bytes(intensities)); int hash = hasher.ToHashCode(); if (!_geometriesByHash.TryGetValue(hash, out var candidates)) @@ -617,7 +641,8 @@ private int AddGeometry(ushort[]? q, float[]? positions, Vector3d? origin, IRead && (indices16 is not null ? Same(indices16, entry.Indices) : Same(indices32, entry.Indices)) && Same(normals, entry.Normals) && Same(uvs, entry.Uvs) - && Same(colors, entry.Colors)) + && Same(colors, entry.Colors) + && Same(intensities, entry.Intensities)) { return candidate; } @@ -631,7 +656,8 @@ private int AddGeometry(ushort[]? q, float[]? positions, Vector3d? origin, IRead uvs is null ? null : _blob.Add(uvs), bounds, points, - colors is null ? null : _blob.Add(colors.AsSpan())); + colors is null ? null : _blob.Add(colors.AsSpan()), + intensities is null ? null : _blob.Add(intensities.AsSpan())); _geometries.Add(written); candidates.Add(_geometries.Count - 1); return _geometries.Count - 1; @@ -771,6 +797,7 @@ public void WriteMeta(Stream output) WriteView(w, "normals", g.Normals); WriteView(w, "uvs", g.Uvs); WriteView(w, "colors", g.Colors); + WriteView(w, "intensities", g.Intensities); WriteBox(w, "bbox", g.Bounds, Vector3d.Zero); w.WriteEndObject(); FlushIfLarge(w); @@ -807,7 +834,7 @@ public void WriteMeta(Stream output) if (_panoramas.Count > 0) { w.WriteStartArray("panoramas"); - foreach (var (element, position, yaw, image, name) in _panoramas) + foreach (var (element, position, yaw, image, intensity, name) in _panoramas) { w.WriteStartObject(); w.WriteNumber("element", element); @@ -815,6 +842,7 @@ public void WriteMeta(Stream output) WriteVector(w, "position", position); w.WriteNumber("yaw", yaw); WriteView(w, "image", image); + if (intensity != null) WriteView(w, "intensity", intensity); w.WriteEndObject(); } w.WriteEndArray(); @@ -1206,7 +1234,8 @@ private sealed record PreparedViewpoint(SectionState? Sections, int[]? HiddenEle private readonly record struct MaterialKey(byte R, byte G, byte B, double Opacity, int? Texture); // 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); + private sealed record GeometryEntry(BlobView Positions, Vector3d? Origin, BlobView Indices, BlobView? Normals, BlobView? Uvs, + BoundingBox3d Bounds, bool Points, 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/ViewerDocument.cs b/src/IOViewer/Model/ViewerDocument.cs index 2c2f254..128fa29 100644 --- a/src/IOViewer/Model/ViewerDocument.cs +++ b/src/IOViewer/Model/ViewerDocument.cs @@ -52,6 +52,9 @@ public ViewerDocument(SceneDocument scene) /// RGB bytes in vertex order for point geometries, keyed by geometry id. public Dictionary PointColors { get; set; } = []; + /// One display intensity byte per point, keyed by geometry id. Zero indicates a missing measurement. + public Dictionary PointIntensities { get; set; } = []; + /// Equirectangular photographs attached to scan elements. public List Panoramas { get; set; } = []; @@ -69,4 +72,7 @@ public sealed record ViewerPanorama(long ElementId, Vector3d Position, byte[] Jp { /// Name of the camera station when several stations share a single scene element. public string? Name { get; init; } + + /// Optional 2:1 scan-intensity JPEG in the same orientation as the photograph. + public byte[]? IntensityJpeg { get; init; } } diff --git a/src/IOViewer/Viewer/dist/viewer.js b/src/IOViewer/Viewer/dist/viewer.js index e5379fc..3da3db3 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 Pl=(i,t,e)=>t.has(i)||tu("Cannot "+e);var hi=(i,t,e)=>(Pl(i,t,"read from private field"),e?e.call(i):t.get(i)),Ll=(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)=>(Pl(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),Zr=(i,t,e)=>(Pl(i,t,"access private method"),e);var Uu=0,uc=1,Fu=2;var mr=1,Bu=2,Ts=3,Hn=0,De=1,Ne=2,Vn=0,As=1,dc=2,fc=3,pc=4,Ou=5;var ki=100,zu=101,ku=102,Hu=103,Vu=104,Gu=200,Wu=201,Xu=202,qu=203,mc=204,gc=205,Yu=206,$u=207,Zu=208,Ju=209,Ku=210,ju=211,Qu=212,td=213,ed=214,Ao=0,Ro=1,Co=2,ds=3,Io=4,Po=5,Lo=6,Do=7,gr=0,nd=1,id=2,bn=0,_c=1,xc=2,vc=3,yc=4,Mc=5,bc=6,Sc=7;var wc=300,Mi=301,Hi=302,oa=303,aa=304,_r=306,fs=1e3,Pn=1001,No=1002,ke=1003,sd=1004;var xr=1005;var Xe=1006,la=1007;var bi=1008;var nn=1009,Ec=1010,Tc=1011,Rs=1012,ca=1013,Sn=1014,Ye=1015,wn=1016,ha=1017,ua=1018,Cs=1020,Ac=35902,Rc=35899,Cc=1021,Ic=1022,sn=1023,Ln=1026,Si=1027,Is=1028,da=1029,wi=1030,fa=1031;var pa=1033,vr=33776,yr=33777,Mr=33778,br=33779,ma=35840,ga=35841,_a=35842,xa=35843,va=36196,ya=37492,Ma=37496,ba=37488,Sa=37489,Sr=37490,wa=37491,Ea=37808,Ta=37809,Aa=37810,Ra=37811,Ca=37812,Ia=37813,Pa=37814,La=37815,Da=37816,Na=37817,Ua=37818,Fa=37819,Ba=37820,Oa=37821,za=36492,ka=36494,Ha=36495,Va=36283,Ga=36284,wr=36285,Wa=36286;var Zs=2300,Uo=2301,wo=2302,nc=2303,ic=2400,sc=2401,rc=2402;var rd=3200;var Er=0,od=1,ii="",Te="srgb",Js="srgb-linear",Ks="linear",ue="srgb";var Eo=7680;var Pc=34055,Lc=34056;var Dc=517;var ad=519,ld=512,cd=513,hd=514,Xa=515,ud=516,dd=517,qa=518,fd=519,Nc=35044,Tr=35048;var Uc="300 es",xn=2e3,ps=2001;function Hp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Vp(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ms(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function pd(){let i=ms("canvas");return i.style.display="block",i}var nu={},gs=null;function js(...i){let t="THREE."+i.shift();gs?gs("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 Ht(...i){i=md(i);let t="THREE."+i.shift();if(gs)gs("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(gs)gs("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,Ht(...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={[Ao]:Ro,[Co]:Lo,[Io]:Do,[ds]:Po,[Ro]:Ao,[Lo]:Co,[Do]:Io,[Po]:ds},Dn=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 ee(i,t,e){return Math.max(t,Math.min(e,i))}function Fc(i,t){return(i%t+t)%t}function Gp(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Wp(i,t,e){return i!==t?(e-i)/(t-i):0}function $s(i,t,e){return(1-e)*i+e*t}function Xp(i,t,e,n){return $s(i,t,1-Math.exp(-e*n))}function qp(i,t=1){return t-Math.abs(Fc(i,t*2)-t)}function Yp(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function $p(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Zp(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Jp(i,t){return i+Math.random()*(t-i)}function Kp(i){return i*(.5-Math.random())}function jp(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 Qp(i){return i*hs}function tm(i){return i*_s}function em(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function nm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function im(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function sm(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 _n(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 ae={DEG2RAD:hs,RAD2DEG:_s,generateUUID:jn,clamp:ee,euclideanModulo:Fc,mapLinear:Gp,inverseLerp:Wp,lerp:$s,damp:Xp,pingpong:qp,smoothstep:Yp,smootherstep:$p,randInt:Zp,randFloat:Jp,randFloatSpread:Kp,seededRandom:jp,degToRad:Qp,radToDeg:tm,isPowerOfTwo:em,ceilPowerOfTwo:nm,floorPowerOfTwo:im,setQuaternionFromProperEuler:sm,normalize:de,denormalize:_n},Hc=class Hc{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=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(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(ee(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}};Hc.prototype.isVector2=!0;var Xt=Hc,Le=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 b=Math.acos(m),E=Math.sin(b);p=Math.sin(p*b)/E,a=Math.sin(a*b)/E,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 b=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=b,c*=b,h*=b,d*=b}}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(ee(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}},Vc=class Vc{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=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(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 Dl.copy(this).projectOnVector(t),this.sub(Dl)}reflect(t){return this.sub(Dl.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(ee(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}};Vc.prototype.isVector3=!0;var L=Vc,Dl=new L,su=new Le,Gc=class Gc{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],b=s[1],E=s[4],v=s[7],y=s[2],S=s[5],A=s[8];return r[0]=o*_+a*b+l*y,r[3]=o*m+a*E+l*S,r[6]=o*p+a*v+l*A,r[1]=c*_+h*b+d*y,r[4]=c*m+h*E+d*S,r[7]=c*p+h*v+d*A,r[2]=u*_+f*b+g*y,r[5]=u*m+f*E+g*S,r[8]=u*p+f*v+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 Ui("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Nl.makeScale(t,e)),this}rotate(t){return Ui("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Nl.makeRotation(-t)),this}translate(t,e){return Ui("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Nl.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)}};Gc.prototype.isMatrix3=!0;var qt=Gc,Nl=new qt,ru=new qt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ou=new qt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rm(){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=Qn(s.r),s.g=Qn(s.g),s.b=Qn(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=us(s.r),s.g=us(s.g),s.b=us(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===ii?Ks: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:Ks,toXYZ:ru,fromXYZ:ou,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Te},outputColorSpaceConfig:{drawingBufferColorSpace:Te}},[Te]:{primaries:t,whitePoint:n,transfer:ue,toXYZ:ru,fromXYZ:ou,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Te}}}),i}var te=rm();function Qn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function us(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Zi,Fo=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{Zi===void 0&&(Zi=ms("canvas")),Zi.width=t.width,Zi.height=t.height;let s=Zi.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=Zi}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=ms("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(Fl).x}get height(){return this.source.getSize(Fl).y}get depth(){return this.source.getSize(Fl).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!==wc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case fs:t.x=t.x-Math.floor(t.x);break;case Pn:t.x=t.x<0?0:1;break;case No: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 fs:t.y=t.y-Math.floor(t.y);break;case Pn:t.y=t.y<0?0:1;break;case No: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++}};He.DEFAULT_IMAGE=null;He.DEFAULT_MAPPING=wc;He.DEFAULT_ANISOTROPY=1;var Wc=class Wc{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 E=(c+1)/2,v=(f+1)/2,y=(p+1)/2,S=(h+u)/4,A=(d+_)/4,x=(g+m)/4;return E>v&&E>y?E<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(E),s=S/n,r=A/n):v>y?v<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(v),n=S/s,r=x/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=A/r,s=x/r),this.set(n,s,r,e),this}let b=Math.sqrt((m-g)*(m-g)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(d-_)/b,this.z=(u-h)/b,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=ee(this.x,t.x,e.x),this.y=ee(this.y,t.y,e.y),this.z=ee(this.z,t.z,e.z),this.w=ee(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=ee(this.x,t,e),this.y=ee(this.y,t,e),this.z=ee(this.z,t,e),this.w=ee(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ee(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}};Wc.prototype.isVector4=!0;var ge=Wc,Bo=class extends Dn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xe,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 ge(0,0,t,e),this.scissorTest=!1,this.viewport=new ge(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new He(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(pm)))}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},di={h:0,s:0,l:0},jr={h:0,s:0,l:0};function Ol(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var Vt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Te){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,te.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=te.workingColorSpace){return this.r=t,this.g=e,this.b=n,te.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=te.workingColorSpace){if(t=Fc(t,1),e=ee(e,0,1),n=ee(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=Ol(o,r,t+1/3),this.g=Ol(o,r,t),this.b=Ol(o,r,t-1/3)}return te.colorSpaceToWorking(this,s),this}setStyle(t,e=Te){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=Te){let n=xd[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=Qn(t.r),this.g=Qn(t.g),this.b=Qn(t.b),this}copyLinearToSRGB(t){return this.r=us(t.r),this.g=us(t.g),this.b=us(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Te){return te.workingToColorSpace(Je.copy(this),t),Math.round(ee(Je.r*255,0,255))*65536+Math.round(ee(Je.g*255,0,255))*256+Math.round(ee(Je.b*255,0,255))}getHexString(t=Te){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=te.workingColorSpace){te.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){mn.subVectors(s,e),Yn.subVectors(n,e),zl.subVectors(t,e);let o=mn.dot(mn),a=mn.dot(Yn),l=mn.dot(zl),c=Yn.dot(Yn),h=Yn.dot(zl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,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,$n)===null?!1:$n.x>=0&&$n.y>=0&&$n.x+$n.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,$n)===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,$n.x),l.addScaledVector(o,$n.y),l.addScaledVector(a,$n.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return Gl.setScalar(0),Wl.setScalar(0),Xl.setScalar(0),Gl.fromBufferAttribute(t,e),Wl.fromBufferAttribute(t,n),Xl.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(Gl,r.x),o.addScaledVector(Wl,r.y),o.addScaledVector(Xl,r.z),o}static isFrontFacing(t,e,n,s){return mn.subVectors(n,e),Yn.subVectors(t,e),mn.cross(Yn).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 mn.subVectors(this.c,this.b),Yn.subVectors(this.a,this.b),mn.cross(Yn).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;Qi.subVectors(s,n),ts.subVectors(r,n),kl.subVectors(t,n);let l=Qi.dot(kl),c=ts.dot(kl);if(l<=0&&c<=0)return e.copy(n);Hl.subVectors(t,s);let h=Qi.dot(Hl),d=ts.dot(Hl);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(Qi,o);Vl.subVectors(t,r);let f=Qi.dot(Vl),g=ts.dot(Vl);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(ts,a);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return pu.subVectors(r,s),a=(d-h)/(d-h+(f-g)),e.copy(s).addScaledVector(pu,a);let p=1/(m+_+u);return o=_*p,a=u*p,e.copy(n).addScaledVector(Qi,o).addScaledVector(ts,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},le=class{constructor(t=new L(1/0,1/0,1/0),e=new L(-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,gn),gn.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(Vs),to.subVectors(this.max,Vs),es.subVectors(t.a,Vs),ns.subVectors(t.b,Vs),is.subVectors(t.c,Vs),fi.subVectors(ns,es),pi.subVectors(is,ns),Pi.subVectors(es,is);let e=[0,-fi.z,fi.y,0,-pi.z,pi.y,0,-Pi.z,Pi.y,fi.z,0,-fi.x,pi.z,0,-pi.x,Pi.z,0,-Pi.x,-fi.y,fi.x,0,-pi.y,pi.x,0,-Pi.y,Pi.x,0];return!ql(e,es,ns,is,to)||(e=[1,0,0,0,1,0,0,0,1],!ql(e,es,ns,is,to))?!1:(eo.crossVectors(fi,pi),e=[eo.x,eo.y,eo.z],ql(e,es,ns,is,to))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,gn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(gn).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:(Zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Zn),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}},Zn=[new L,new L,new L,new L,new L,new L,new L,new L],gn=new L,Qr=new le,es=new L,ns=new L,is=new L,fi=new L,pi=new L,Pi=new L,Vs=new L,to=new L,eo=new L,Li=new L;function ql(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 L,no=new Xt,mm=0,Ae=class extends Dn{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:mm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Nc,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;Gs.subVectors(t,this.center);let e=Gs.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Gs,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):(Yl.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Gs.copy(t.center).add(Yl)),this.expandByPoint(Gs.copy(t.center).sub(Yl))),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}},_m=0,un=new Yt,$l=new Ge,ss=new L,on=new le,Ws=new le,Oe=new L,fe=class i extends Dn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_m++}),this.uuid=jn(),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(Hp(t)?er:tr)(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 qt().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 un.makeRotationFromQuaternion(t),this.applyMatrix4(un),this}rotateX(t){return un.makeRotationX(t),this.applyMatrix4(un),this}rotateY(t){return un.makeRotationY(t),this.applyMatrix4(un),this}rotateZ(t){return un.makeRotationZ(t),this.applyMatrix4(un),this}translate(t,e,n){return un.makeTranslation(t,e,n),this.applyMatrix4(un),this}scale(t,e,n){return un.makeScale(t,e,n),this.applyMatrix4(un),this}lookAt(t){return $l.lookAt(t),$l.updateMatrix(),this.applyMatrix4($l.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ss).negate(),this.translate(ss.x,ss.y,ss.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 le);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 L(-1/0,-1/0,-1/0),new L(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||vm.getNormalMatrix(t),s=this.coplanarPoint(Zl).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}},ym=0,vn=class extends Dn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ym++}),this.uuid=jn(),this.name="",this.type="Material",this.blending=As,this.side=Hn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=mc,this.blendDst=gc,this.blendEquation=ki,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=ds,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ad,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Eo,this.stencilZFail=Eo,this.stencilZPass=Eo,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 Vt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.retroreflectivity!==void 0&&(this.retroreflectivity=t.retroreflectivity),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.clippingPlanes!==void 0&&(this.clippingPlanes=t.clippingPlanes.map(n=>new we().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 Xt().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 Xt().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 Jn=new L,Jl=new L,io=new L,so=new L,Fi=class{constructor(t=new L,e=new L(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,Jn)),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=Jn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Jn.copy(this.origin).addScaledVector(this.direction,e),Jn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Jl.copy(t).add(e).multiplyScalar(.5),io.copy(e).sub(t).normalize(),so.copy(this.origin).sub(Jl);let r=t.distanceTo(e)*.5,o=-this.direction.dot(io),a=so.dot(this.direction),l=-so.dot(io),c=so.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(Jl).addScaledVector(io,u),f}intersectSphere(t,e){if(t.radius<0)return null;Jn.subVectors(t.center,this.origin);let n=Jn.dot(this.direction),s=Jn.dot(Jn)-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,Jn)!==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,b=n.y-o.y,E=n.z-o.z,v=Math.abs(l),y=Math.abs(c),S=Math.abs(h),A,x,T,C,D,U,F,I,B,G,q,O;if(v>=y&&v>=S?(T=l,U=d,B=g,O=p,l>=0?(A=c,x=h,C=u,D=f,F=_,I=m,G=b,q=E):(A=h,x=c,C=f,D=u,F=m,I=_,G=E,q=b)):y>=S?(T=c,U=u,B=_,O=b,c>=0?(A=h,x=l,C=f,D=d,F=m,I=g,G=E,q=p):(A=l,x=h,C=d,D=f,F=g,I=m,G=p,q=E)):(T=h,U=f,B=m,O=E,h>=0?(A=l,x=c,C=d,D=u,F=g,I=_,G=p,q=b):(A=c,x=l,C=u,D=d,F=_,I=g,G=b,q=p)),T===0)return null;let N=A/T,z=x/T,W=1/T,k=C-N*U,K=D-z*U,lt=F-N*B,ht=I-z*B,at=G-N*O,Y=q-z*O,tt=at*ht-Y*lt,dt=k*Y-K*at,It=lt*K-ht*k;if(s){if(tt<0||dt<0||It<0)return null}else if((tt<0||dt<0||It<0)&&(tt>0||dt>0||It>0))return null;let ot=tt+dt+It;if(ot===0)return null;let Tt=W*(tt*U+dt*B+It*O);return(ot>0?Tt<0:Tt>0)?null:this.at(Tt/ot,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 vn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Nn,this.combine=gr,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 Yt,Di=new Fi,ro=new We,gu=new L,oo=new L,ao=new L,lo=new L,Kl=new L,co=new L,_u=new L,ho=new L,_e=class extends Ge{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 g=0,_=u.length;g<_;g++){let m=u[g],p=o[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let v=b,y=E;ve.far?null:{distance:c,point:ho.clone(),object:i}}function uo(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,oo),i.getVertexPosition(l,ao),i.getVertexPosition(c,lo);let h=Mm(i,t,e,n,oo,ao,lo,_u);if(h){let d=new L;Kn.getBarycoord(_u,oo,ao,lo,d),s&&(h.uv=Kn.getInterpolatedAttribute(s,a,l,c,d,new Xt)),r&&(h.uv1=Kn.getInterpolatedAttribute(r,a,l,c,d,new Xt)),o&&(h.normal=Kn.getInterpolatedAttribute(o,a,l,c,d,new L),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new L,materialIndex:0};Kn.getNormal(oo,ao,lo,u.normal),h.face=u,h.barycoord=d}return h}var Un=class extends He{constructor(t=null,e=1,n=1,s,r,o,a,l,c=ke,h=ke,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 ei=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}},rs=new Yt,xu=new Yt,fo=[],vu=new le,bm=new Yt,Xs=new _e,qs=new We,gi=class extends _e{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ei(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,po.y=s.normal.y>0?t.max.y:t.min.y,po.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(po)<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 vn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Vt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},ko=new L,Ho=new L,yu=new Yt,Ys=new Fi,mo=new We,jl=new L,Mu=new L,Bi=class extends Ge{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;jl.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(jl);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 L,Su=new L,yn=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 ir=class extends He{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}},sr=class extends He{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 _i=class extends He{constructor(t,e,n=Sn,s,r,o,a=ke,l=ke,c,h=Ln,d=1){if(h!==Ln&&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 xs(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return e.compareFunction=this.compareFunction,e}},Vo=class extends _i{constructor(t,e=Sn,n=Mi,s,r,o=ke,a=ke,l,c=Ln){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}},rr=class extends He{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},dn=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;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 ye(c,3)),this.setAttribute("normal",new ye(h,3)),this.setAttribute("uv",new ye(d,2));function g(_,m,p,b,E,v,y,S,A,x,T){let C=v/A,D=y/x,U=v/2,F=y/2,I=S/2,B=A+1,G=x+1,q=0,O=0,N=new L;for(let z=0;z0?1:-1,h.push(N.x,N.y,N.z),d.push(k/A),d.push(1-z/x),q+=1}}for(let z=0;z0&&E(!0),e>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new ye(d,3)),this.setAttribute("normal",new ye(u,3)),this.setAttribute("uv",new ye(f,2));function b(){let v=new L,y=new L,S=0,A=(e-t)/n;for(let x=0;x<=r;x++){let T=[],C=x/r,D=C*(e-t)+t;for(let U=0;U<=s;U++){let F=U/s,I=F*l+a,B=Math.sin(I),G=Math.cos(I);y.x=D*B,y.y=-C*n+m,y.z=D*G,d.push(y.x,y.y,y.z),v.set(B,A,G).normalize(),u.push(v.x,v.y,v.z),f.push(F,1-C),T.push(g++)}_.push(T)}for(let x=0;x0||T!==0)&&(h.push(C,D,F),S+=3),(e>0||T!==r-1)&&(h.push(D,U,F),S+=3)}c.addGroup(p,S,0),p+=S}function E(v){let y=g,S=new Xt,A=new L,x=0,T=v===!0?t:e,C=v===!0?1:-1;for(let U=1;U<=s;U++)d.push(0,m*C,0),u.push(0,C,0),f.push(.5,.5),g++;let D=g;for(let U=0;U<=s;U++){let I=U/s*l+a,B=Math.cos(I),G=Math.sin(I);A.x=T*G,A.y=m*C,A.z=T*B,d.push(A.x,A.y,A.z),u.push(0,C,0),S.x=B*.5+.5,S.y=G*.5*C+.5,f.push(S.x,S.y),g++}for(let U=0;U0)&&f.push(E,v,S),(p!==n-1||l{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||l0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Vt().setHex(s.value);break;case"v2":this.uniforms[n].value=new Xt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new L().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ge().fromArray(s.value);break;case"m3":this.uniforms[n].value=new qt().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}},Go=class extends qe{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var ar=class extends vn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Vt(16777215),this.specular=new Vt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new Xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Nn,this.combine=gr,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 Ss=class extends vn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Er,this.normalScale=new Xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Nn,this.combine=gr,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}},Wo=class extends vn{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}},Xo=class extends vn{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 os(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function tc(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&&Vp(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()===wo,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,tc(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}ln.prototype.ValueTypeName="";ln.prototype.TimeBufferType=Float32Array;ln.prototype.ValueBufferType=Float32Array;ln.prototype.DefaultInterpolation=Uo;var vi=class extends ln{constructor(t,e,n){super(t,e,n)}};vi.prototype.ValueTypeName="bool";vi.prototype.ValueBufferType=Array;vi.prototype.DefaultInterpolation=Zs;vi.prototype.InterpolantFactoryMethodLinear=void 0;vi.prototype.InterpolantFactoryMethodSmooth=void 0;var Jo=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};Jo.prototype.ValueTypeName="color";var Ko=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};Ko.prototype.ValueTypeName="number";var jo=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)Le.slerpFlat(r,0,o,c-a,o,c,l);return r}},lr=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new jo(this.times,this.values,this.getValueSize(),t)}};lr.prototype.ValueTypeName="quaternion";lr.prototype.InterpolantFactoryMethodSmooth=void 0;var yi=class extends ln{constructor(t,e,n){super(t,e,n)}};yi.prototype.ValueTypeName="string";yi.prototype.ValueBufferType=Array;yi.prototype.DefaultInterpolation=Zs;yi.prototype.InterpolantFactoryMethodLinear=void 0;yi.prototype.InterpolantFactoryMethodSmooth=void 0;var Qo=class extends ln{constructor(t,e,n,s){super(t,e,n,s)}};Qo.prototype.ValueTypeName="vector";var To={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 ta=class{constructor(t,e,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;df.start-g.start);let u=0;for(let f=1;f0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(let n in t.uniforms){let s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new 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;f 0 +#endif`,ng=`#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`,ng=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; - uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,ig=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,sg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,rg=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,rg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) - diffuseColor *= vColor; #endif`,og=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#endif`,ag=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + diffuseColor *= vColor; +#endif`,ag=`#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 ) + varying vec4 vColor; +#endif`,cg=`#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`,cg=`#define PI 3.141592653589793 +#endif`,hg=`#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`,hg=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,ug=`#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`,ug=`vec3 transformedNormal = objectNormal; +#endif`,dg=`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`,dg=`#ifdef USE_DISPLACEMENTMAP +#endif`,fg=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,fg=`#ifdef USE_DISPLACEMENTMAP +#endif`,pg=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,pg=`#ifdef USE_EMISSIVEMAP +#endif`,mg=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,mg=`#ifdef USE_EMISSIVEMAP +#endif`,gg=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,gg="gl_FragColor = linearToOutputTexel( gl_FragColor );",_g=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,_g="gl_FragColor = linearToOutputTexel( gl_FragColor );",xg=`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 ); -}`,xg=`#ifdef USE_ENVMAP +}`,vg=`#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`,vg=`#ifdef USE_ENVMAP +#endif`,yg=`#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`,yg=`#ifdef USE_ENVMAP +#endif`,Mg=`#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`,Mg=`#ifdef USE_ENVMAP +#endif`,bg=`#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`,bg=`#ifdef USE_ENVMAP +#endif`,Sg=`#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`,Sg=`#ifdef USE_FOG - vFogDepth = - mvPosition.z; #endif`,wg=`#ifdef USE_FOG - varying float vFogDepth; + vFogDepth = - mvPosition.z; #endif`,Eg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Tg=`#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`,Tg=`#ifdef USE_FOG +#endif`,Ag=`#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`,Ag=`#ifdef USE_GRADIENTMAP +#endif`,Rg=`#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 -}`,Rg=`#ifdef USE_LIGHTMAP +}`,Cg=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,Cg=`LambertMaterial material; +#endif`,Ig=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,Ig=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Pg=`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`,Pg=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Lg=`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 `,Lg=`#ifdef USE_ENVMAP +#include `,Dg=`#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`,Dg=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Ng=`varying vec3 vViewPosition; +#endif`,Ng=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Ug=`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`,Ug=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Fg=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,Fg=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Bg=`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`,Bg=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Og=`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`,Og=`uniform sampler2D dfgLUT; +#endif`,zg=`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=` +}`,kg=` 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`,Hg=`#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`,Hg=`#if defined( RE_IndirectDiffuse ) +#endif`,Vg=`#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`,Vg=`#ifdef USE_LIGHT_PROBES_GRID +#endif`,Gg=`#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`,Gg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) - gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,Wg=`#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 ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,Xg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,qg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,qg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,Yg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,Yg=`#ifdef USE_MAP +#endif`,$g=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,$g=`#ifdef USE_MAP +#endif`,Zg=`#ifdef USE_MAP uniform sampler2D map; -#endif`,Zg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,Jg=`#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`,Jg=`#if defined( USE_POINTS_UV ) +#endif`,Kg=`#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`,Kg=`float metalnessFactor = metalness; +#endif`,jg=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,jg=`#ifdef USE_METALNESSMAP +#endif`,Qg=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,Qg=`#ifdef USE_INSTANCING_MORPH +#endif`,t_=`#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`,t_=`#if defined( USE_MORPHCOLORS ) +#endif`,e_=`#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`,e_=`#ifdef USE_MORPHNORMALS +#endif`,n_=`#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`,n_=`#ifdef USE_MORPHTARGETS +#endif`,i_=`#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`,i_=`#ifdef USE_MORPHTARGETS +#endif`,s_=`#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`,s_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,r_=`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;`,r_=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,o_=`#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;`,r_=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,o_=`#ifndef FLAT_SHADED +#endif`,a_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,a_=`#ifndef FLAT_SHADED +#endif`,l_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,l_=`#ifndef FLAT_SHADED +#endif`,c_=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,r_=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,c_=`#ifdef USE_NORMALMAP +#endif`,h_=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,r_=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,h_=`#ifdef USE_CLEARCOAT +#endif`,u_=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,u_=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,d_=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,d_=`#ifdef USE_CLEARCOATMAP +#endif`,f_=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,r_=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,f_=`#ifdef USE_IRIDESCENCEMAP +#endif`,p_=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,p_=`#ifdef OPAQUE +#endif`,m_=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,m_=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,g_=`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 -}`,g_=`#ifdef PREMULTIPLIED_ALPHA +}`,__=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,__=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,x_=`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;`,x_=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,v_=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,v_=`#ifdef DITHERING +#endif`,y_=`#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`,y_=`float roughnessFactor = roughness; +#endif`,M_=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,M_=`#ifdef USE_ROUGHNESSMAP +#endif`,b_=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,b_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,S_=`#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;`,x_=`#ifdef DITHERING } #endif #endif -#endif`,S_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,w_=`#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;`,x_=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,w_=`#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`,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 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else @@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,E_=`float getShadowMask() { +#endif`,T_=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING #endif #endif return shadow; -}`,T_=`#ifdef USE_SKINNING +}`,A_=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,A_=`#ifdef USE_SKINNING +#endif`,R_=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,R_=`#ifdef USE_SKINNING +#endif`,C_=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -2254,7 +2254,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,C_=`#ifdef USE_SKINNING +#endif`,I_=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,I_=`float specularStrength; +#endif`,P_=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,P_=`#ifdef USE_SPECULARMAP +#endif`,L_=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,L_=`#if defined( TONE_MAPPING ) +#endif`,D_=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,D_=`#ifndef saturate +#endif`,N_=`#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; }`,N_=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,U_=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,N_=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,U_=`#ifdef USE_TRANSMISSION +#endif`,F_=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,N_=`#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`,F_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,B_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,N_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,B_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,O_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,N_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,O_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,z_=`#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; }`,N_=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,z_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,k_=`#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; }`,N_=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,k_=`varying vec2 vUv; +#endif`,H_=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,H_=`uniform sampler2D t2D; +}`,V_=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2780,14 +2780,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,V_=`varying vec3 vWorldDirection; +}`,G_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,G_=`#ifdef ENVMAP_TYPE_CUBE +}`,W_=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; @@ -2809,14 +2809,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,W_=`varying vec3 vWorldDirection; +}`,X_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,X_=`uniform samplerCube tCube; +}`,q_=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2826,7 +2826,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,q_=`#include +}`,Y_=`#include #include #include #include @@ -2853,7 +2853,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,Y_=`#if DEPTH_PACKING == 3200 +}`,$_=`#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 -}`,$_=`#define DISTANCE +}`,Z_=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2918,7 +2918,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,Z_=`#define DISTANCE +}`,J_=`#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 ); -}`,J_=`varying vec3 vWorldDirection; +}`,K_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,K_=`uniform sampler2D tEquirect; +}`,j_=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2956,7 +2956,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,j_=`uniform float scale; +}`,Q_=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2978,7 +2978,7 @@ void main() { #include #include #include -}`,Q_=`uniform vec3 diffuse; +}`,t0=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3006,7 +3006,7 @@ void main() { #include #include #include -}`,t0=`#include +}`,e0=`#include #include #include #include @@ -3038,7 +3038,7 @@ void main() { #include #include #include -}`,e0=`uniform vec3 diffuse; +}`,n0=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -3086,7 +3086,7 @@ void main() { #include #include #include -}`,n0=`#define LAMBERT +}`,i0=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3125,7 +3125,7 @@ void main() { #include #include #include -}`,i0=`#define LAMBERT +}`,s0=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3183,7 +3183,7 @@ void main() { #include #include #include -}`,s0=`#define MATCAP +}`,r0=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3217,7 +3217,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,r0=`#define MATCAP +}`,o0=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3263,7 +3263,7 @@ void main() { #include #include #include -}`,o0=`#define NORMAL +}`,a0=`#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 -}`,a0=`#define NORMAL +}`,l0=`#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 -}`,l0=`#define PHONG +}`,c0=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3356,7 +3356,7 @@ void main() { #include #include #include -}`,c0=`#define PHONG +}`,h0=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3416,7 +3416,7 @@ void main() { #include #include #include -}`,h0=`#define STANDARD +}`,u0=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3459,7 +3459,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,u0=`#define STANDARD +}`,d0=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3587,7 +3587,7 @@ void main() { #include #include #include -}`,d0=`#define TOON +}`,f0=`#define TOON varying vec3 vViewPosition; #include #include @@ -3624,7 +3624,7 @@ void main() { #include #include #include -}`,f0=`#define TOON +}`,p0=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3676,7 +3676,7 @@ void main() { #include #include #include -}`,p0=`uniform float size; +}`,m0=`uniform float size; uniform float scale; #include #include @@ -3707,7 +3707,7 @@ void main() { #include #include #include -}`,m0=`uniform vec3 diffuse; +}`,g0=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3732,7 +3732,7 @@ void main() { #include #include #include -}`,g0=`#include +}`,_0=`#include #include #include #include @@ -3755,7 +3755,7 @@ void main() { #include #include #include -}`,_0=`uniform vec3 color; +}`,x0=`uniform vec3 color; uniform float opacity; #include #include @@ -3771,7 +3771,7 @@ void main() { #include #include #include -}`,x0=`uniform float rotation; +}`,v0=`uniform float rotation; uniform vec2 center; #include #include @@ -3795,7 +3795,7 @@ void main() { #include #include #include -}`,v0=`uniform vec3 diffuse; +}`,y0=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3820,7 +3820,7 @@ void main() { #include #include #include -}`,Kt={alphahash_fragment:km,alphahash_pars_fragment:Hm,alphamap_fragment:Vm,alphamap_pars_fragment:Gm,alphatest_fragment:Wm,alphatest_pars_fragment:Xm,aomap_fragment:qm,aomap_pars_fragment:Ym,batching_pars_vertex:$m,batching_vertex:Zm,begin_vertex:Jm,beginnormal_vertex:Km,bsdfs:jm,iridescence_fragment:Qm,bumpmap_pars_fragment:tg,clipping_planes_fragment:eg,clipping_planes_pars_fragment:ng,clipping_planes_pars_vertex:ig,clipping_planes_vertex:sg,color_fragment:rg,color_pars_fragment:og,color_pars_vertex:ag,color_vertex:lg,common:cg,cube_uv_reflection_fragment:hg,defaultnormal_vertex:ug,displacementmap_pars_vertex:dg,displacementmap_vertex:fg,emissivemap_fragment:pg,emissivemap_pars_fragment:mg,colorspace_fragment:gg,colorspace_pars_fragment:_g,envmap_fragment:xg,envmap_common_pars_fragment:vg,envmap_pars_fragment:yg,envmap_pars_vertex:Mg,envmap_physical_pars_fragment:Lg,envmap_vertex:bg,fog_vertex:Sg,fog_pars_vertex:wg,fog_fragment:Eg,fog_pars_fragment:Tg,gradientmap_pars_fragment:Ag,lightmap_pars_fragment:Rg,lights_lambert_fragment:Cg,lights_lambert_pars_fragment:Ig,lights_pars_begin:Pg,lights_toon_fragment:Dg,lights_toon_pars_fragment:Ng,lights_phong_fragment:Ug,lights_phong_pars_fragment:Fg,lights_physical_fragment:Bg,lights_physical_pars_fragment:Og,lights_fragment_begin:zg,lights_fragment_maps:kg,lights_fragment_end:Hg,lightprobes_pars_fragment:Vg,logdepthbuf_fragment:Gg,logdepthbuf_pars_fragment:Wg,logdepthbuf_pars_vertex:Xg,logdepthbuf_vertex:qg,map_fragment:Yg,map_pars_fragment:$g,map_particle_fragment:Zg,map_particle_pars_fragment:Jg,metalnessmap_fragment:Kg,metalnessmap_pars_fragment:jg,morphinstance_vertex:Qg,morphcolor_vertex:t_,morphnormal_vertex:e_,morphtarget_pars_vertex:n_,morphtarget_vertex:i_,normal_fragment_begin:s_,normal_fragment_maps:r_,normal_pars_fragment:o_,normal_pars_vertex:a_,normal_vertex:l_,normalmap_pars_fragment:c_,clearcoat_normal_fragment_begin:h_,clearcoat_normal_fragment_maps:u_,clearcoat_pars_fragment:d_,iridescence_pars_fragment:f_,opaque_fragment:p_,packing:m_,premultiplied_alpha_fragment:g_,project_vertex:__,dithering_fragment:x_,dithering_pars_fragment:v_,roughnessmap_fragment:y_,roughnessmap_pars_fragment:M_,shadowmap_pars_fragment:b_,shadowmap_pars_vertex:S_,shadowmap_vertex:w_,shadowmask_pars_fragment:E_,skinbase_vertex:T_,skinning_pars_vertex:A_,skinning_vertex:R_,skinnormal_vertex:C_,specularmap_fragment:I_,specularmap_pars_fragment:P_,tonemapping_fragment:L_,tonemapping_pars_fragment:D_,transmission_fragment:N_,transmission_pars_fragment:U_,uv_pars_fragment:F_,uv_pars_vertex:B_,uv_vertex:O_,worldpos_vertex:z_,background_vert:k_,background_frag:H_,backgroundCube_vert:V_,backgroundCube_frag:G_,cube_vert:W_,cube_frag:X_,depth_vert:q_,depth_frag:Y_,distance_vert:$_,distance_frag:Z_,equirect_vert:J_,equirect_frag:K_,linedashed_vert:j_,linedashed_frag:Q_,meshbasic_vert:t0,meshbasic_frag:e0,meshlambert_vert:n0,meshlambert_frag:i0,meshmatcap_vert:s0,meshmatcap_frag:r0,meshnormal_vert:o0,meshnormal_frag:a0,meshphong_vert:l0,meshphong_frag:c0,meshphysical_vert:h0,meshphysical_frag:u0,meshtoon_vert:d0,meshtoon_frag:f0,points_vert:p0,points_frag:m0,shadow_vert:g0,shadow_frag:_0,sprite_vert:x0,sprite_frag:v0},yt={common:{diffuse:{value:new Vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qt}},envmap:{envMap:{value:null},envMapRotation:{value:new qt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qt},normalScale:{value:new Xt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new L},probesMax:{value:new L},probesResolution:{value:new L}},points:{diffuse:{value:new Vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0},uvTransform:{value:new qt}},sprite:{diffuse:{value:new Vt(16777215)},opacity:{value:1},center:{value:new Xt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qt},alphaMap:{value:null},alphaMapTransform:{value:new qt},alphaTest:{value:0}}},Wn={basic:{uniforms:je([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.fog]),vertexShader:Kt.meshbasic_vert,fragmentShader:Kt.meshbasic_frag},lambert:{uniforms:je([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)},envMapIntensity:{value:1}}]),vertexShader:Kt.meshlambert_vert,fragmentShader:Kt.meshlambert_frag},phong:{uniforms:je([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Kt.meshphong_vert,fragmentShader:Kt.meshphong_frag},standard:{uniforms:je([yt.common,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.roughnessmap,yt.metalnessmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Kt.meshphysical_vert,fragmentShader:Kt.meshphysical_frag},toon:{uniforms:je([yt.common,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.gradientmap,yt.fog,yt.lights,{emissive:{value:new Vt(0)}}]),vertexShader:Kt.meshtoon_vert,fragmentShader:Kt.meshtoon_frag},matcap:{uniforms:je([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,{matcap:{value:null}}]),vertexShader:Kt.meshmatcap_vert,fragmentShader:Kt.meshmatcap_frag},points:{uniforms:je([yt.points,yt.fog]),vertexShader:Kt.points_vert,fragmentShader:Kt.points_frag},dashed:{uniforms:je([yt.common,yt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Kt.linedashed_vert,fragmentShader:Kt.linedashed_frag},depth:{uniforms:je([yt.common,yt.displacementmap]),vertexShader:Kt.depth_vert,fragmentShader:Kt.depth_frag},normal:{uniforms:je([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,{opacity:{value:1}}]),vertexShader:Kt.meshnormal_vert,fragmentShader:Kt.meshnormal_frag},sprite:{uniforms:je([yt.sprite,yt.fog]),vertexShader:Kt.sprite_vert,fragmentShader:Kt.sprite_frag},background:{uniforms:{uvTransform:{value:new qt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Kt.background_vert,fragmentShader:Kt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qt}},vertexShader:Kt.backgroundCube_vert,fragmentShader:Kt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Kt.cube_vert,fragmentShader:Kt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Kt.equirect_vert,fragmentShader:Kt.equirect_frag},distance:{uniforms:je([yt.common,yt.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Kt.distance_vert,fragmentShader:Kt.distance_frag},shadow:{uniforms:je([yt.lights,yt.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:Kt.shadow_vert,fragmentShader:Kt.shadow_frag}};Wn.physical={uniforms:je([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qt},clearcoatNormalScale:{value:new Xt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qt},sheen:{value:0},sheenColor:{value:new Vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qt},transmissionSamplerSize:{value:new Xt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qt},attenuationDistance:{value:0},attenuationColor:{value:new Vt(0)},specularColor:{value:new Vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qt},anisotropyVector:{value:new Xt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qt}}]),vertexShader:Kt.meshphysical_vert,fragmentShader:Kt.meshphysical_frag};var Ya={r:0,b:0,g:0},y0=new Yt,Wd=new qt;Wd.set(-1,0,0,0,1,0,0,0,1);function M0(i,t,e,n,s,r){let o=new Vt(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){let v=b.backgroundBlurriness>0;E=t.get(E,v)}return E}function g(b){let E=!1,v=f(b);v===null?m(o,a):v&&v.isColor&&(m(v,1),E=!0);let y=i.xr.getEnvironmentBlendMode();y==="additive"?e.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||E)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(b,E){let v=f(E);v&&(v.isCubeTexture||v.mapping===_r)?(c===void 0&&(c=new _e(new dn(1,1,1),new qe({name:"BackgroundCubeMaterial",uniforms:Vi(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:De,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(y,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=v,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(y0.makeRotationFromEuler(E.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Wd),c.material.toneMapped=te.getTransfer(v.colorSpace)!==ue,(h!==v||d!==v.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=v,d=v.version,u=i.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new _e(new Mn(2,2),new qe({name:"BackgroundMaterial",uniforms:Vi(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:Hn,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=v,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=te.getTransfer(v.colorSpace)!==ue,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||d!==v.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=v,d=v.version,u=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(Ya,Bc(i)),e.buffers.color.setClear(Ya.r,Ya.g,Ya.b,E,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,E=1){o.set(b),a=E,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(b){a=b,m(o,a)},render:g,addToRenderList:_,dispose:p}}function b0(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(D,U,F,I,B){let G=!1,q=d(D,I,F,U);r!==q&&(r=q,c(r.object)),G=f(D,I,F,B),G&&g(D,I,F,B),B!==null&&t.update(B,i.ELEMENT_ARRAY_BUFFER),(G||o)&&(o=!1,v(D,U,F,I),B!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(B).buffer))}function l(){return i.createVertexArray()}function c(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function d(D,U,F,I){let B=I.wireframe===!0,G=n[U.id];G===void 0&&(G={},n[U.id]=G);let q=D.isInstancedMesh===!0?D.id:0,O=G[q];O===void 0&&(O={},G[q]=O);let N=O[F.id];N===void 0&&(N={},O[F.id]=N);let z=N[B];return z===void 0&&(z=u(l()),N[B]=z),z}function u(D){let U=[],F=[],I=[];for(let B=0;B=0){let W=B[N],k=G[N];if(k===void 0&&(N==="instanceMatrix"&&D.instanceMatrix&&(k=D.instanceMatrix),N==="instanceColor"&&D.instanceColor&&(k=D.instanceColor)),W===void 0||W.attribute!==k||k&&W.data!==k.data)return!0;q++}return r.attributesNum!==q||r.index!==I}function g(D,U,F,I){let B={},G=U.attributes,q=0,O=F.getAttributes();for(let N in O)if(O[N].location>=0){let W=G[N];W===void 0&&(N==="instanceMatrix"&&D.instanceMatrix&&(W=D.instanceMatrix),N==="instanceColor"&&D.instanceColor&&(W=D.instanceColor));let k={};k.attribute=W,W&&W.data&&(k.data=W.data),B[N]=k,q++}r.attributes=B,r.attributesNum=q,r.index=I}function _(){let D=r.newAttributes;for(let U=0,F=D.length;U=0){let z=B[O];if(z===void 0&&(O==="instanceMatrix"&&D.instanceMatrix&&(z=D.instanceMatrix),O==="instanceColor"&&D.instanceColor&&(z=D.instanceColor)),z!==void 0){let W=z.normalized,k=z.itemSize,K=t.get(z);if(K===void 0)continue;let lt=K.buffer,ht=K.type,at=K.bytesPerElement,Y=ht===i.INT||ht===i.UNSIGNED_INT||z.gpuType===ca;if(z.isInterleavedBufferAttribute){let tt=z.data,dt=tt.stride,It=z.offset;if(tt.isInstancedInterleavedBuffer){for(let ot=0;ot0&&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),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=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:b,maxVaryings:E,maxFragmentUniforms:v,maxSamples:y,samples:S}}function E0(i){let t=this,e=null,n=0,s=!1,r=!1,o=new we,a=new qt,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 b=r?0:n,E=b*4,v=p.clippingState||null;l.value=v,v=h(g,u,E,f);for(let y=0;y!==E;++y)v[y]=e[y];p.clippingState=v,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(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,b=u.matrixWorldInverse;a.getNormalMatrix(b),(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=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?y:0,y,y),d.setRenderTarget(s),p&&d.render(_,l),d.render(t,l)}d.toneMapping=f,d.autoClear=u,t.background=b}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===Mi||t.mapping===Hi;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;Ps(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Ar)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rg-Ls?n-g+Ls:0),p=4*(this._cubeSize-_);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=g-e,Ps(r,m,p,3*_,2*_),s.setRenderTarget(r),s.render(a,Ar),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Ps(t,m,p,3*_,2*_),s.setRenderTarget(t),s.render(a,Ar)}_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-Ls?s-this._lodMax+Ls:0),u=4*(this._cubeSize-h);Ps(e,d,u,3*h,2*h),o.setRenderTarget(e),o.render(l,Ar)}};function I0(i){let t=[],e=[],n=i,s=i-Ls+1+T0;for(let r=0;r2?0:-1,v=[b,E,0,b+2/3,E,0,b+2/3,E+1,0,b,E,0,b+2/3,E+1,0,b,E+1,0];g.set(v,f*u*p);for(let y=0;yLs&&n--}return{lodMeshes:e,sizeLods:t}}function Sd(i,t,e){let n=new Ve(i,t,e);return n.texture.mapping=_r,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ps(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function P0(i,t,e){return new qe({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:R0,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:Ka(),fragmentShader:` +}`,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:` precision highp float; precision highp int; @@ -3924,7 +3924,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:Vn,depthTest:!1,depthWrite:!1})}function L0(i,t,e){return new qe({name:"SphericalGaussianBlur",defines:{SAMPLES:A0,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:Ka(),fragmentShader:` + `,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:` precision highp float; precision highp int; @@ -3984,7 +3984,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `,blending:Vn,depthTest:!1,depthWrite:!1})}function wd(){return new qe({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ka(),fragmentShader:` + `,blending:Xn,depthTest:!1,depthWrite:!1})}function wd(){return new Ue({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ja(),fragmentShader:` precision mediump float; precision mediump int; @@ -4003,7 +4003,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:Vn,depthTest:!1,depthWrite:!1})}function Ed(){return new qe({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ka(),fragmentShader:` + `,blending:Xn,depthTest:!1,depthWrite:!1})}function Ed(){return new Ue({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ja(),fragmentShader:` precision mediump float; precision mediump int; @@ -4019,7 +4019,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:Vn,depthTest:!1,depthWrite:!1})}function Ka(){return` + `,blending:Xn,depthTest:!1,depthWrite:!1})}function ja(){return` precision mediump float; precision mediump int; @@ -4034,7 +4034,7 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}var Ja=class extends Ve{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 ir(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 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:` varying vec3 vWorldDirection; @@ -4069,7 +4069,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},s=new dn(5,5,5),r=new qe({name:"CubemapFromEquirect",uniforms:Vi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:De,blending:Vn});r.uniforms.tEquirect.value=e;let o=new _e(s,r),a=e.minFilter;return e.minFilter===bi&&(e.minFilter=Xe),new ia(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 D0(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===oa||f===aa)if(t.has(u)){let g=t.get(u).texture;return a(g,u.mapping)}else{let g=u.image;if(g&&g.height>0){let _=new Ja(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===oa||f===aa,_=f===Mi||f===Hi;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 Za(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 b=u.image;return g&&b&&b.height>0||_&&b&&l(b)?(n===null&&(n=new Za(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===oa?u.mapping=Mi:f===aa&&(u.mapping=Hi),u}function l(u){let f=0,g=6;for(let _=0;_=65535?er:tr)(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&&(y=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);let S=new Float32Array(v*y*4*d),A=new Qs(S,v,y,d);A.type=Ye,A.needsUpdate=!0;let x=E*4;for(let C=0;C0){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&&b[0].isRenderPass===!0;let y=o.width,S=o.height;b.length>0&&a===null&&(a=new Ve(y,S,{type:wn,depthBuffer:!1,stencilBuffer:!1}),l=new Ve(y,S,{type:wn,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 Ue(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 Cx=37297,Ix=0;function Px(i,t){let e=i.split(` + }`,depthTest:!1,depthWrite:!1}),d=new pe(c,h),u=new Vn(-1,1,1,-1,0,1),f=null,m=null,_=!1,g,p=null,M=[],T=!1;this.setSize=function(S,v){o.setSize(S,v),a!==null&&a.setSize(S,v),l!==null&&l.setSize(S,v);for(let b=0;b0&&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(` `),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 qt;function Lx(i){te._getMatrix(Dd,te.workingColorSpace,i);let t=`mat3( ${Dd.elements.map(e=>e.toFixed(4))} )`;switch(te.getTransfer(i)){case Ks:return[t,"LinearTransferOETF"];case ue:return[t,"sRGBTransferOETF"];default:return Ht("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 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()+` `+r+` -`+Px(i.getShaderSource(t),a)}else return r}function Dx(i,t){let e=Lx(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` -`)}var Nx={[_c]:"Linear",[xc]:"Reinhard",[vc]:"Cineon",[yc]:"ACESFilmic",[bc]:"AgX",[Sc]:"Neutral",[Mc]:"Custom"};function Ux(i,t){let e=Nx[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 $a=new L;function Fx(){te.getLuminanceCoefficients($a);let i=$a.x.toFixed(4),t=$a.y.toFixed(4),e=$a.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(` -`)}function Bx(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cr).join(` -`)}function Ox(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 nh(i){return i.replace(kx,Vx)}var Hx=new Map;function Vx(i,t){let e=Kt[t];if(e===void 0){let n=Hx.get(t);if(n!==void 0)e=Kt[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 nh(e)}var Gx=/#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(Gx,Wx)}function Wx(i,t,e,n){let s="";for(let r=parseInt(t);r/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);r0&&(m+=` -`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Cr).join(` +#define LOW_PRECISION`),t}var qx={[gr]:"SHADOWMAP_TYPE_PCF",[As]:"SHADOWMAP_TYPE_VSM"};function Yx(i){return qx[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var $x={[Mi]:"ENVMAP_TYPE_CUBE",[Vi]:"ENVMAP_TYPE_CUBE",[xr]:"ENVMAP_TYPE_CUBE_UV"};function Zx(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":$x[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var Jx={[Vi]:"ENVMAP_MODE_REFRACTION"};function Kx(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":Jx[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var jx={[_r]:"ENVMAP_BLENDING_MULTIPLY",[nd]:"ENVMAP_BLENDING_MIX",[id]:"ENVMAP_BLENDING_ADD"};function Qx(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":jx[i.combine]||"ENVMAP_BLENDING_NONE"}function tv(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 ev(i,t,e,n){let s=i.getContext(),r=e.defines,o=e.vertexShader,a=e.fragmentShader,l=Yx(e),c=Zx(e),h=Kx(e),d=Qx(e),u=tv(e),f=Ox(e),m=zx(r),_=s.createProgram(),g,p,M=e.glslVersion?"#version "+e.glslVersion+` +`:"";e.isRawShaderMaterial?(g=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Ir).join(` +`),g.length>0&&(g+=` +`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Ir).join(` `),p.length>0&&(p+=` -`)):(m=[Od(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(Cr).join(` -`),p=[Od(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!==bn?"#define TONE_MAPPING":"",e.toneMapping!==bn?Kt.tonemapping_pars_fragment:"",e.toneMapping!==bn?Ux("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Kt.colorspace_pars_fragment,Dx("linearToOutputTexel",e.outputColorSpace),Fx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` -`].filter(Cr).join(` -`)),o=nh(o),o=Ud(o,e),o=Fd(o,e),a=nh(a),a=Ud(a,e),a=Fd(a,e),o=Bd(o),a=Bd(a),e.isRawShaderMaterial!==!0&&(b=`#version 300 es -`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)):(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,p=["#define varying in",e.glslVersion===Uc?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Uc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`+g,p=["#define varying in",e.glslVersion===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);let E=b+m+o,v=b+p+a,y=Ld(s,s.VERTEX_SHADER,E),S=Ld(s,s.FRAGMENT_SHADER,v);s.attachShader(_,y),s.attachShader(_,S),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 U=s.getProgramInfoLog(_)||"",F=s.getShaderInfoLog(y)||"",I=s.getShaderInfoLog(S)||"",B=U.trim(),G=F.trim(),q=I.trim(),O=!0,N=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(O=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,y,S);else{let z=Nd(s,y,"vertex"),W=Nd(s,S,"fragment");Wt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` +`+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)+` Material Name: `+D.name+` Material Type: `+D.type+` -Program Info Log: `+B+` -`+z+` -`+W)}else B!==""?Ht("WebGLProgram: Program Info Log:",B):(G===""||q==="")&&(N=!1);N&&(D.diagnostics={runnable:O,programLog:B,vertexShader:{log:G,prefix:m},fragmentShader:{log:q,prefix:p}})}s.deleteShader(y),s.deleteShader(S),x=new Ds(s,_),T=zx(s,_)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let T;this.getAttributes=function(){return T===void 0&&A(this),T};let C=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=s.getProgramParameter(_,Cx)),C},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Ix++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=y,this.fragmentShader=S,this}var ev=0,ih=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 sh(t),e.set(t,n)),n}},sh=class{constructor(t){this.id=ev++,this.code=t,this.usedTimes=0}};function nv(i){return i===wi||i===Sr||i===wr}function iv(i,t,e,n,s,r){let o=new vs,a=new ih,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(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,T,C,D,U,F){let I=D.fog,B=U.geometry,G=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?D.environment:null,q=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=t.get(x.envMap||G,q),N=O&&O.mapping===_r?O.image.height:null,z=f[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&Ht("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));let W=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,k=W!==void 0?W.length:0,K=0;B.morphAttributes.position!==void 0&&(K=1),B.morphAttributes.normal!==void 0&&(K=2),B.morphAttributes.color!==void 0&&(K=3);let lt,ht,at,Y;if(z){let xe=Wn[z];lt=xe.vertexShader,ht=xe.fragmentShader}else{lt=x.vertexShader,ht=x.fragmentShader;let xe=a.getVertexShaderStage(x),ce=a.getFragmentShaderStage(x);a.update(x,xe,ce),at=xe.id,Y=ce.id}let tt=i.getRenderTarget(),dt=i.state.buffers.depth.getReversed(),It=U.isInstancedMesh===!0,ot=U.isBatchedMesh===!0,Tt=!!x.map,jt=!!x.matcap,Bt=!!O,ut=!!x.aoMap,Lt=!!x.lightMap,Ot=!!x.bumpMap&&x.wireframe===!1,zt=!!x.normalMap,Zt=!!x.displacementMap,Ee=!!x.emissiveMap,ie=!!x.metalnessMap,re=!!x.roughnessMap,R=x.anisotropy>0,wt=x.clearcoat>0,kt=x.dispersion>0,P=x.retroreflectivity>0,M=x.iridescence>0,X=x.sheen>0,j=x.transmission>0,nt=R&&!!x.anisotropyMap,ft=wt&&!!x.clearcoatMap,pt=wt&&!!x.clearcoatNormalMap,it=wt&&!!x.clearcoatRoughnessMap,rt=M&&!!x.iridescenceMap,mt=M&&!!x.iridescenceThicknessMap,Nt=X&&!!x.sheenColorMap,vt=X&&!!x.sheenRoughnessMap,gt=!!x.specularMap,Ut=!!x.specularColorMap,Gt=!!x.specularIntensityMap,$t=j&&!!x.transmissionMap,V=j&&!!x.thicknessMap,_t=!!x.gradientMap,st=!!x.alphaMap,xt=x.alphaTest>0,St=!!x.alphaHash,ct=!!x.extensions,Ft=bn;x.toneMapped&&(tt===null||tt.isXRRenderTarget===!0)&&(Ft=i.toneMapping);let Pt={shaderID:z,shaderType:x.type,shaderName:x.name,vertexShader:lt,fragmentShader:ht,defines:x.defines,customVertexShaderID:at,customFragmentShaderID:Y,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:ot,batchingColor:ot&&U._colorsTexture!==null,instancing:It,instancingColor:It&&U.instanceColor!==null,instancingMorph:It&&U.morphTexture!==null,outputColorSpace:tt===null?i.outputColorSpace:tt.isXRRenderTarget===!0?tt.texture.colorSpace:te.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Tt,matcap:jt,envMap:Bt,envMapMode:Bt&&O.mapping,envMapCubeUVHeight:N,aoMap:ut,lightMap:Lt,bumpMap:Ot,normalMap:zt,displacementMap:Zt,emissiveMap:Ee,normalMapObjectSpace:zt&&x.normalMapType===od,normalMapTangentSpace:zt&&x.normalMapType===Er,packedNormalMap:zt&&x.normalMapType===Er&&nv(x.normalMap.format),metalnessMap:ie,roughnessMap:re,anisotropy:R,anisotropyMap:nt,clearcoat:wt,clearcoatMap:ft,clearcoatNormalMap:pt,clearcoatRoughnessMap:it,dispersion:kt,retroreflection:P,iridescence:M,iridescenceMap:rt,iridescenceThicknessMap:mt,sheen:X,sheenColorMap:Nt,sheenRoughnessMap:vt,specularMap:gt,specularColorMap:Ut,specularIntensityMap:Gt,transmission:j,transmissionMap:$t,thicknessMap:V,gradientMap:_t,opaque:x.transparent===!1&&x.blending===As&&x.alphaToCoverage===!1,alphaMap:st,alphaTest:xt,alphaHash:St,combine:x.combine,mapUv:Tt&&g(x.map.channel),aoMapUv:ut&&g(x.aoMap.channel),lightMapUv:Lt&&g(x.lightMap.channel),bumpMapUv:Ot&&g(x.bumpMap.channel),normalMapUv:zt&&g(x.normalMap.channel),displacementMapUv:Zt&&g(x.displacementMap.channel),emissiveMapUv:Ee&&g(x.emissiveMap.channel),metalnessMapUv:ie&&g(x.metalnessMap.channel),roughnessMapUv:re&&g(x.roughnessMap.channel),anisotropyMapUv:nt&&g(x.anisotropyMap.channel),clearcoatMapUv:ft&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:pt&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:rt&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:mt&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:Nt&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:vt&&g(x.sheenRoughnessMap.channel),specularMapUv:gt&&g(x.specularMap.channel),specularColorMapUv:Ut&&g(x.specularColorMap.channel),specularIntensityMapUv:Gt&&g(x.specularIntensityMap.channel),transmissionMapUv:$t&&g(x.transmissionMap.channel),thicknessMapUv:V&&g(x.thicknessMap.channel),alphaMapUv:st&&g(x.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(zt||R),vertexNormals:!!B.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!B.attributes.uv&&(Tt||st),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||B.attributes.normal===void 0&&zt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:dt,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:B.attributes.position!==void 0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:k,morphTextureStride:K,numSunLights:T.sun.length,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numSunLightShadows:T.sunShadowMap.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:F.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&C.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ft,decodeVideoTexture:Tt&&x.map.isVideoTexture===!0&&te.getTransfer(x.map.colorSpace)===ue,decodeVideoTextureEmissive:Ee&&x.emissiveMap.isVideoTexture===!0&&te.getTransfer(x.emissiveMap.colorSpace)===ue,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Ne,flipSided:x.side===De,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||ot)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Pt.vertexUv1s=l.has(1),Pt.vertexUv2s=l.has(2),Pt.vertexUv3s=l.has(3),l.clear(),Pt}function m(x){let T=[];if(x.shaderID?T.push(x.shaderID):(T.push(x.customVertexShaderID),T.push(x.customFragmentShaderID)),x.defines!==void 0)for(let C in x.defines)T.push(C),T.push(x.defines[C]);return x.isRawShaderMaterial===!1&&(p(T,x),b(T,x),T.push(i.outputColorSpace)),T.push(x.customProgramCacheKey),T.join()}function p(x,T){x.push(T.precision),x.push(T.outputColorSpace),x.push(T.envMapMode),x.push(T.envMapCubeUVHeight),x.push(T.mapUv),x.push(T.alphaMapUv),x.push(T.lightMapUv),x.push(T.aoMapUv),x.push(T.bumpMapUv),x.push(T.normalMapUv),x.push(T.displacementMapUv),x.push(T.emissiveMapUv),x.push(T.metalnessMapUv),x.push(T.roughnessMapUv),x.push(T.anisotropyMapUv),x.push(T.clearcoatMapUv),x.push(T.clearcoatNormalMapUv),x.push(T.clearcoatRoughnessMapUv),x.push(T.iridescenceMapUv),x.push(T.iridescenceThicknessMapUv),x.push(T.sheenColorMapUv),x.push(T.sheenRoughnessMapUv),x.push(T.specularMapUv),x.push(T.specularColorMapUv),x.push(T.specularIntensityMapUv),x.push(T.transmissionMapUv),x.push(T.thicknessMapUv),x.push(T.combine),x.push(T.fogExp2),x.push(T.sizeAttenuation),x.push(T.morphTargetsCount),x.push(T.morphAttributeCount),x.push(T.numSunLights),x.push(T.numDirLights),x.push(T.numPointLights),x.push(T.numSpotLights),x.push(T.numSpotLightMaps),x.push(T.numHemiLights),x.push(T.numRectAreaLights),x.push(T.numSunLightShadows),x.push(T.numDirLightShadows),x.push(T.numPointLightShadows),x.push(T.numSpotLightShadows),x.push(T.numSpotLightShadowsWithMaps),x.push(T.numLightProbes),x.push(T.shadowMapType),x.push(T.toneMapping),x.push(T.numClippingPlanes),x.push(T.numClipIntersection),x.push(T.depthPacking)}function b(x,T){o.disableAll(),T.instancing&&o.enable(0),T.instancingColor&&o.enable(1),T.instancingMorph&&o.enable(2),T.matcap&&o.enable(3),T.envMap&&o.enable(4),T.normalMapObjectSpace&&o.enable(5),T.normalMapTangentSpace&&o.enable(6),T.clearcoat&&o.enable(7),T.iridescence&&o.enable(8),T.alphaTest&&o.enable(9),T.vertexColors&&o.enable(10),T.vertexAlphas&&o.enable(11),T.vertexUv1s&&o.enable(12),T.vertexUv2s&&o.enable(13),T.vertexUv3s&&o.enable(14),T.vertexTangents&&o.enable(15),T.anisotropy&&o.enable(16),T.alphaHash&&o.enable(17),T.batching&&o.enable(18),T.dispersion&&o.enable(19),T.retroreflection&&o.enable(24),T.batchingColor&&o.enable(20),T.gradientMap&&o.enable(21),T.packedNormalMap&&o.enable(22),T.vertexNormals&&o.enable(23),x.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reversedDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),T.numLightProbeGrids>0&&o.enable(22),T.hasPositionAttribute&&o.enable(23),x.push(o.mask)}function E(x){let T=f[x.type],C;if(T){let D=Wn[T];C=vd.clone(D.uniforms)}else C=x.uniforms;return C}function v(x,T){let C=h.get(T);return C!==void 0?++C.usedTimes:(C=new tv(i,T,x,s),c.push(C),h.set(T,C)),C}function y(x){if(--x.usedTimes===0){let T=c.indexOf(x);c[T]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function S(x){a.remove(x)}function A(){a.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:v,releaseProgram:y,releaseShaderCache:S,programs:c,dispose:A}}function sv(){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 rv(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,g,_,m,p){let b=i[t];return b===void 0?(b={id:u.id,object:u,geometry:f,material:g,materialVariant:o(u),groupOrder:_,renderOrder:u.renderOrder,z:m,group:p},i[t]=b):(b.id=u.id,b.object=u,b.geometry=f,b.material=g,b.materialVariant=o(u),b.groupOrder=_,b.renderOrder=u.renderOrder,b.z=m,b.group=p),t++,b}function l(u,f,g,_,m,p,b){b.reversedDepth===!0&&(m=-m);let E=a(u,f,g,_,m,p);g.transmission>0?n.push(E):g.transparent===!0?s.push(E):e.push(E)}function c(u,f,g,_,m,p){let b=a(u,f,g,_,m,p);g.transmission>0?n.unshift(b):g.transparent===!0?s.unshift(b):e.unshift(b)}function h(u,f){e.length>1&&e.sort(u||rv),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 av(){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 L,color:new Vt};break;case"SpotLight":e={position:new L,direction:new L,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new L,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new L,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":e={color:new Vt,position:new L,halfWidth:new L,halfHeight:new L};break}return i[t.id]=e,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={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var cv=0;function hv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function uv(i){let t=new av,e=lv(),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 L);let s=new L,r=new Yt,o=new Yt;function a(c){let h=0,d=0,u=0;for(let U=0;U<9;U++)n.probe[U].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,b=0,E=0,v=0,y=0,S=0,A=0,x=0,T=0,C=0;c.sort(hv);for(let U=0,F=c.length;U0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=yt.LTC_FLOAT_1,n.rectAreaLTC2=yt.LTC_FLOAT_2):(n.rectAreaLTC1=yt.LTC_HALF_1,n.rectAreaLTC2=yt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let D=n.hash;(D.sunLength!==f||D.directionalLength!==m||D.pointLength!==p||D.spotLength!==b||D.rectAreaLength!==E||D.hemiLength!==v||D.numSunShadows!==g||D.numDirectionalShadows!==y||D.numPointShadows!==S||D.numSpotShadows!==A||D.numSpotMaps!==x||D.numLightProbes!==C)&&(n.sun.length=f,n.directional.length=m,n.spot.length=b,n.rectArea.length=E,n.point.length=p,n.hemi.length=v,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=_,n.sunShadowCascade.length=_,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.directionalShadowMatrix.length=y,n.pointShadow.length=S,n.pointShadowMap.length=S,n.pointShadowMatrix.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-T,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=C,D.sunLength=f,D.directionalLength=m,D.pointLength=p,D.spotLength=b,D.rectAreaLength=E,D.hemiLength=v,D.numSunShadows=g,D.numDirectionalShadows=y,D.numPointShadows=S,D.numSpotShadows=A,D.numSpotMaps=x,D.numLightProbes=C,n.version=cv++)}function l(c,h){let d=0,u=0,f=0,g=0,_=0,m=0,p=h.matrixWorldInverse;for(let b=0,E=c.length;b=o.length?(a=new Hd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var fv=`void main() { +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() { gl_Position = vec4( position, 1.0 ); -}`,pv=`uniform sampler2D shadow_pass; +}`,mv=`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 ); -}`,mv=[new L(1,0,0),new L(-1,0,0),new L(0,1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1)],gv=[new L(0,-1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1),new L(0,-1,0),new L(0,-1,0)],Vd=new Yt,Rr=new L,Kc=new L;function _v(i,t,e){let n=new Fn,s=new Xt,r=new Xt,o=new ge,a=new Wo,l=new Xo,c={},h=e.maxTextureSize,d={[Hn]:De,[De]:Hn,[Ne]:Ne},u=new qe({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Xt},radius:{value:4}},vertexShader:fv,fragmentShader:pv}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new fe;g.setAttribute("position",new Ae(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new _e(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=mr;let p=this.type;this.render=function(S,A,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===Bu&&(Ht("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=mr);let T=i.getRenderTarget(),C=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),U=i.state;U.setBlending(Vn),U.buffers.depth.getReversed()===!0?U.buffers.color.setClear(0,0,0,0):U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let F=p!==this.type;F&&A.traverse(function(I){I.material&&(Array.isArray(I.material)?I.material.forEach(B=>B.needsUpdate=!0):I.material.needsUpdate=!0)});for(let I=0,B=S.length;Ih||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/O.x),s.x=r.x*O.x,q.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/O.y),s.y=r.y*O.y,q.mapSize.y=r.y));let N=i.state.buffers.depth.getReversed();if(q.camera._reversedDepth=N,q.map===null||F===!0){if(q.map!==null&&(q.map.depthTexture!==null&&(q.map.depthTexture.dispose(),q.map.depthTexture=null),q.map.dispose()),this.type===Ts){if(G.isPointLight){Ht("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}q.map=new Ve(s.x,s.y,{format:wi,type:wn,minFilter:Xe,magFilter:Xe,generateMipmaps:!1}),q.map.texture.name=G.name+".shadowMap",q.map.depthTexture=new _i(s.x,s.y,Ye),q.map.depthTexture.name=G.name+".shadowMapDepth",q.map.depthTexture.format=Ln,q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=ke,q.map.depthTexture.magFilter=ke}else G.isPointLight?(q.map=new Ja(s.x),q.map.depthTexture=new Vo(s.x,Sn)):(q.map=new Ve(s.x,s.y),q.map.depthTexture=new _i(s.x,s.y,Sn)),q.map.depthTexture.name=G.name+".shadowMap",q.map.depthTexture.format=Ln,this.type===mr?(q.map.depthTexture.compareFunction=N?qa:Xa,q.map.depthTexture.minFilter=Xe,q.map.depthTexture.magFilter=Xe):(q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=ke,q.map.depthTexture.magFilter=ke);q.camera.updateProjectionMatrix()}q.map.isWebGLCubeRenderTarget!==!0&&(q.map.width!==s.x||q.map.height!==s.y)&&q.map.setSize(s.x,s.y);let z=q.map.isWebGLCubeRenderTarget?6:q.getViewportCount();G.isPointLight!==!0&&q.updateMatrices(G,x);for(let W=0;W0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let U=C.uuid,F=A.uuid,I=c[U];I===void 0&&(I={},c[U]=I);let B=I[F];B===void 0&&(B=C.clone(),I[F]=B,A.addEventListener("dispose",y)),C=B}if(C.visible=A.visible,C.wireframe=A.wireframe,T===Ts?C.side=A.shadowSide!==null?A.shadowSide:A.side:C.side=A.shadowSide!==null?A.shadowSide:d[A.side],C.alphaMap=A.alphaMap,C.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,C.map=A.map,C.clipShadows=A.clipShadows,C.clippingPlanes=A.clippingPlanes,C.clipIntersection=A.clipIntersection,C.displacementMap=A.displacementMap,C.displacementScale=A.displacementScale,C.displacementBias=A.displacementBias,C.wireframeLinewidth=A.wireframeLinewidth,C.linewidth=A.linewidth,x.isPointLight===!0&&C.isMeshDistanceMaterial===!0){let U=i.properties.get(C);U.light=x}return C}function v(S,A,x,T,C){if(S.visible===!1)return;if(S.layers.test(A.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&C===Ts)&&(!S.frustumCulled||S.intersectsFrustum(n))){S.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,S.matrixWorld);let F=t.update(S),I=S.material;if(Array.isArray(I)){let B=F.groups;for(let G=0,q=B.length;G=1):N.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(N)[1]),q=O>=2);let z=null,W={},k=i.getParameter(i.SCISSOR_BOX),K=i.getParameter(i.VIEWPORT),lt=new ge().fromArray(k),ht=new ge().fromArray(K);function at(V,_t,st,xt){let St=new Uint8Array(4),ct=i.createTexture();i.bindTexture(V,ct),i.texParameteri(V,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(V,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ft=0;Ft"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Xt,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 _(P,M){return g?new OffscreenCanvas(P,M):ms("canvas")}function m(P,M,X){let j=1,nt=kt(P);if((nt.width>X||nt.height>X)&&(j=X/Math.max(nt.width,nt.height)),j<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 ft=Math.floor(j*nt.width),pt=Math.floor(j*nt.height);u===void 0&&(u=_(ft,pt));let it=M?_(ft,pt):u;return it.width=ft,it.height=pt,it.getContext("2d").drawImage(P,0,0,ft,pt),Ht("WebGLRenderer: Texture has been resized from ("+nt.width+"x"+nt.height+") to ("+ft+"x"+pt+")."),it}else return"data"in P&&Ht("WebGLRenderer: Image in DataTexture is too big ("+nt.width+"x"+nt.height+")."),P;return P}function p(P){return P.generateMipmaps}function b(P){i.generateMipmap(P)}function E(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 v(P,M,X,j,nt,ft=!1){if(P!==null){if(i[P]!==void 0)return i[P];Ht("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let pt;j&&(pt=t.get("EXT_texture_norm16"),pt||Ht("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let it=M;if(M===i.RED&&(X===i.FLOAT&&(it=i.R32F),X===i.HALF_FLOAT&&(it=i.R16F),X===i.UNSIGNED_BYTE&&(it=i.R8),X===i.UNSIGNED_SHORT&&pt&&(it=pt.R16_EXT),X===i.SHORT&&pt&&(it=pt.R16_SNORM_EXT)),M===i.RED_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.R8UI),X===i.UNSIGNED_SHORT&&(it=i.R16UI),X===i.UNSIGNED_INT&&(it=i.R32UI),X===i.BYTE&&(it=i.R8I),X===i.SHORT&&(it=i.R16I),X===i.INT&&(it=i.R32I)),M===i.RG&&(X===i.FLOAT&&(it=i.RG32F),X===i.HALF_FLOAT&&(it=i.RG16F),X===i.UNSIGNED_BYTE&&(it=i.RG8),X===i.UNSIGNED_SHORT&&pt&&(it=pt.RG16_EXT),X===i.SHORT&&pt&&(it=pt.RG16_SNORM_EXT)),M===i.RG_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.RG8UI),X===i.UNSIGNED_SHORT&&(it=i.RG16UI),X===i.UNSIGNED_INT&&(it=i.RG32UI),X===i.BYTE&&(it=i.RG8I),X===i.SHORT&&(it=i.RG16I),X===i.INT&&(it=i.RG32I)),M===i.RGB_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.RGB8UI),X===i.UNSIGNED_SHORT&&(it=i.RGB16UI),X===i.UNSIGNED_INT&&(it=i.RGB32UI),X===i.BYTE&&(it=i.RGB8I),X===i.SHORT&&(it=i.RGB16I),X===i.INT&&(it=i.RGB32I)),M===i.RGBA_INTEGER&&(X===i.UNSIGNED_BYTE&&(it=i.RGBA8UI),X===i.UNSIGNED_SHORT&&(it=i.RGBA16UI),X===i.UNSIGNED_INT&&(it=i.RGBA32UI),X===i.BYTE&&(it=i.RGBA8I),X===i.SHORT&&(it=i.RGBA16I),X===i.INT&&(it=i.RGBA32I)),M===i.RGB&&(X===i.UNSIGNED_SHORT&&pt&&(it=pt.RGB16_EXT),X===i.SHORT&&pt&&(it=pt.RGB16_SNORM_EXT),X===i.UNSIGNED_INT_5_9_9_9_REV&&(it=i.RGB9_E5),X===i.UNSIGNED_INT_10F_11F_11F_REV&&(it=i.R11F_G11F_B10F)),M===i.RGBA){let rt=ft?Ks:te.getTransfer(nt);X===i.FLOAT&&(it=i.RGBA32F),X===i.HALF_FLOAT&&(it=i.RGBA16F),X===i.UNSIGNED_BYTE&&(it=rt===ue?i.SRGB8_ALPHA8:i.RGBA8),X===i.UNSIGNED_SHORT&&pt&&(it=pt.RGBA16_EXT),X===i.SHORT&&pt&&(it=pt.RGBA16_SNORM_EXT),X===i.UNSIGNED_SHORT_4_4_4_4&&(it=i.RGBA4),X===i.UNSIGNED_SHORT_5_5_5_1&&(it=i.RGB5_A1)}return(it===i.R16F||it===i.R32F||it===i.RG16F||it===i.RG32F||it===i.RGBA16F||it===i.RGBA32F)&&t.get("EXT_color_buffer_float"),it}function y(P,M){let X;return P?M===null||M===Sn||M===Cs?X=i.DEPTH24_STENCIL8:M===Ye?X=i.DEPTH32F_STENCIL8:M===Rs&&(X=i.DEPTH24_STENCIL8,Ht("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Sn||M===Cs?X=i.DEPTH_COMPONENT24:M===Ye?X=i.DEPTH_COMPONENT32F:M===Rs&&(X=i.DEPTH_COMPONENT16),X}function S(P,M){return p(P)===!0||P.isFramebufferTexture&&P.minFilter!==ke&&P.minFilter!==Xe?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),T(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&d.delete(M)}function x(P){let M=P.target;M.removeEventListener("dispose",x),D(M)}function T(P){let M=n.get(P);if(M.__webglInit===void 0)return;let X=P.source,j=f.get(X);if(j){let nt=j[M.__cacheKey];nt.usedTimes--,nt.usedTimes===0&&C(P),Object.keys(j).length===0&&f.delete(X)}n.remove(P)}function C(P){let M=n.get(P);i.deleteTexture(M.__webglTexture);let X=P.source,j=f.get(X);delete j[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 j=0;j<6;j++){if(Array.isArray(M.__webglFramebuffer[j]))for(let nt=0;nt=s.maxTextures&&Ht("WebGLTextures: Trying to use "+(P+1)+" texture units while this GPU supports only "+s.maxTextures),U+=1,P}function q(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 X=n.get(P);if(P.isVideoTexture&&R(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&X.__version!==P.version){let j=P.image;if(j===null)Ht("WebGLRenderer: Texture marked for update but no image data found.");else if(j.complete===!1)Ht("WebGLRenderer: Texture marked for update but image is incomplete");else{dt(X,P,M);return}}else P.isExternalTexture&&(X.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,X.__webglTexture,i.TEXTURE0+M)}function N(P,M){let X=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&X.__version!==P.version){dt(X,P,M);return}else P.isExternalTexture&&(X.__webglTexture=P.sourceTexture?P.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,X.__webglTexture,i.TEXTURE0+M)}function z(P,M){let X=n.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&X.__version!==P.version){dt(X,P,M);return}e.bindTexture(i.TEXTURE_3D,X.__webglTexture,i.TEXTURE0+M)}function W(P,M){let X=n.get(P);if(P.isCubeDepthTexture!==!0&&P.version>0&&X.__version!==P.version){It(X,P,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,X.__webglTexture,i.TEXTURE0+M)}let k={[fs]:i.REPEAT,[Pn]:i.CLAMP_TO_EDGE,[No]:i.MIRRORED_REPEAT},K={[ke]:i.NEAREST,[sd]:i.NEAREST_MIPMAP_NEAREST,[xr]:i.NEAREST_MIPMAP_LINEAR,[Xe]:i.LINEAR,[la]:i.LINEAR_MIPMAP_NEAREST,[bi]:i.LINEAR_MIPMAP_LINEAR},lt={[ld]:i.NEVER,[fd]:i.ALWAYS,[cd]:i.LESS,[Xa]:i.LEQUAL,[hd]:i.EQUAL,[qa]:i.GEQUAL,[ud]:i.GREATER,[dd]:i.NOTEQUAL};function ht(P,M){if(M.type===Ye&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===Xe||M.magFilter===la||M.magFilter===xr||M.magFilter===bi||M.minFilter===Xe||M.minFilter===la||M.minFilter===xr||M.minFilter===bi)&&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,k[M.wrapS]),i.texParameteri(P,i.TEXTURE_WRAP_T,k[M.wrapT]),(P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY)&&i.texParameteri(P,i.TEXTURE_WRAP_R,k[M.wrapR]),i.texParameteri(P,i.TEXTURE_MAG_FILTER,K[M.magFilter]),i.texParameteri(P,i.TEXTURE_MIN_FILTER,K[M.minFilter]),M.compareFunction&&(i.texParameteri(P,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(P,i.TEXTURE_COMPARE_FUNC,lt[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===ke||M.minFilter!==xr&&M.minFilter!==bi||M.type===Ye&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){let X=t.get("EXT_texture_filter_anisotropic");i.texParameterf(P,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function at(P,M){let X=!1;P.__webglInit===void 0&&(P.__webglInit=!0,M.addEventListener("dispose",A));let j=M.source,nt=f.get(j);nt===void 0&&(nt={},f.set(j,nt));let ft=q(M);if(ft!==P.__cacheKey){nt[ft]===void 0&&(nt[ft]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,X=!0),nt[ft].usedTimes++;let pt=nt[P.__cacheKey];pt!==void 0&&(nt[P.__cacheKey].usedTimes--,pt.usedTimes===0&&C(M)),P.__cacheKey=ft,P.__webglTexture=nt[ft].texture}return X}function Y(P,M,X){return Math.floor(Math.floor(P/X)/M)}function tt(P,M,X,j){let ft=P.updateRanges;if(ft.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,M.width,M.height,X,j,M.data);else{ft.sort((Nt,vt)=>Nt.start-vt.start);let pt=0;for(let Nt=1;Nt0){Gt&&$t&&e.texStorage2D(i.TEXTURE_2D,_t,vt,Ut[0].width,Ut[0].height);for(let st=0,xt=Ut.length;st0){let St=kc(gt.width,gt.height,M.format,M.type);for(let ct of M.layerUpdates){let Ft=gt.data.subarray(ct*St/gt.data.BYTES_PER_ELEMENT,(ct+1)*St/gt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,ct,gt.width,gt.height,1,mt,Ft)}}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,0,gt.width,gt.height,rt.depth,mt,gt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,st,vt,gt.width,gt.height,rt.depth,0,gt.data,0,0);else Ht("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Gt?V&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,st,0,0,0,gt.width,gt.height,rt.depth,mt,Nt,gt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,st,vt,gt.width,gt.height,rt.depth,0,mt,Nt,gt.data);M.layerUpdates.size>0&&M.clearLayerUpdates()}else{Gt&&$t&&e.texStorage2D(i.TEXTURE_2D,_t,vt,Ut[0].width,Ut[0].height);for(let st=0,xt=Ut.length;st0){let st=kc(rt.width,rt.height,M.format,M.type);for(let xt of M.layerUpdates){let St=rt.data.subarray(xt*st/rt.data.BYTES_PER_ELEMENT,(xt+1)*st/rt.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,xt,rt.width,rt.height,1,mt,Nt,St)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,mt,Nt,rt.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,vt,rt.width,rt.height,rt.depth,0,mt,Nt,rt.data);else if(M.isData3DTexture)Gt?($t&&e.texStorage3D(i.TEXTURE_3D,_t,vt,rt.width,rt.height,rt.depth),V&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,mt,Nt,rt.data)):e.texImage3D(i.TEXTURE_3D,0,vt,rt.width,rt.height,rt.depth,0,mt,Nt,rt.data);else if(M.isFramebufferTexture){if($t)if(Gt)e.texStorage2D(i.TEXTURE_2D,_t,vt,rt.width,rt.height);else{let st=rt.width,xt=rt.height;for(let St=0;St<_t;St++)e.texImage2D(i.TEXTURE_2D,St,vt,st,xt,0,mt,Nt,null),st>>=1,xt>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in i){let st=i.canvas;if(st.hasAttribute("layoutsubtree")||st.setAttribute("layoutsubtree","true"),rt.parentNode!==st){st.appendChild(rt),d.add(M),st.onpaint=xt=>{let St=xt.changedElements;for(let ct of d)St.includes(ct.image)&&(ct.needsUpdate=!0)},st.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,rt);else{let St=i.RGBA,ct=i.RGBA,Ft=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,St,ct,Ft,rt)}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(Ut.length>0){if(Gt&&$t){let st=kt(Ut[0]);e.texStorage2D(i.TEXTURE_2D,_t,vt,st.width,st.height)}for(let st=0,xt=Ut.length;st0&&xt++;let ct=kt(vt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,xt,$t,ct.width,ct.height)}for(let ct=0;ct<6;ct++)if(Nt){V?st&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,0,0,vt[ct].width,vt[ct].height,Ut,Gt,vt[ct].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,$t,vt[ct].width,vt[ct].height,0,Ut,Gt,vt[ct].data);for(let Ft=0;Ft>ft),gt=Math.max(1,M.height>>ft);nt===i.TEXTURE_3D||nt===i.TEXTURE_2D_ARRAY?e.texImage3D(nt,ft,rt,vt,gt,M.depth,0,pt,it,null):e.texImage2D(nt,ft,rt,vt,gt,0,pt,it,null)}e.bindFramebuffer(i.FRAMEBUFFER,P),re(M)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,j,nt,Nt.__webglTexture,0,ie(M)):(nt===i.TEXTURE_2D||nt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&nt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,j,nt,Nt.__webglTexture,ft),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(P,M,X){if(i.bindRenderbuffer(i.RENDERBUFFER,P),M.depthBuffer){let j=M.depthTexture,nt=j&&j.isDepthTexture?j.type:null,ft=y(M.stencilBuffer,nt),pt=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;re(M)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ie(M),ft,M.width,M.height):X?i.renderbufferStorageMultisample(i.RENDERBUFFER,ie(M),ft,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,ft,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,pt,i.RENDERBUFFER,P)}else{let j=M.textures;for(let nt=0;nt{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,j.removeEventListener("dispose",nt)};j.addEventListener("dispose",nt),M.__depthDisposeCallback=nt}M.__boundDepthTexture=j}if(P.depthTexture&&!M.__autoAllocateDepthBuffer)if(X)for(let j=0;j<6;j++)jt(M.__webglFramebuffer[j],P,j);else{let j=P.texture.mipmaps;j&&j.length>0?jt(M.__webglFramebuffer[0],P,0):jt(M.__webglFramebuffer,P,0)}else if(X){M.__webglDepthbuffer=[];for(let j=0;j<6;j++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[j]),M.__webglDepthbuffer[j]===void 0)M.__webglDepthbuffer[j]=i.createRenderbuffer(),Tt(M.__webglDepthbuffer[j],P,!1);else{let nt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ft=M.__webglDepthbuffer[j];i.bindRenderbuffer(i.RENDERBUFFER,ft),i.framebufferRenderbuffer(i.FRAMEBUFFER,nt,i.RENDERBUFFER,ft)}}else{let j=P.texture.mipmaps;if(j&&j.length>0?e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Tt(M.__webglDepthbuffer,P,!1);else{let nt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ft=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ft),i.framebufferRenderbuffer(i.FRAMEBUFFER,nt,i.RENDERBUFFER,ft)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function ut(P,M,X){let j=n.get(P);M!==void 0&&ot(j.__webglFramebuffer,P,P.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),X!==void 0&&Bt(P)}function Lt(P){let M=P.texture,X=n.get(P),j=n.get(M);P.addEventListener("dispose",x);let nt=P.textures,ft=P.isWebGLCubeRenderTarget===!0,pt=nt.length>1;if(pt||(j.__webglTexture===void 0&&(j.__webglTexture=i.createTexture()),j.__version=M.version,o.memory.textures++),ft){X.__webglFramebuffer=[];for(let it=0;it<6;it++)if(M.mipmaps&&M.mipmaps.length>0){X.__webglFramebuffer[it]=[];for(let rt=0;rt0){X.__webglFramebuffer=[];for(let it=0;it0&&re(P)===!1){X.__webglMultisampledFramebuffer=i.createFramebuffer(),X.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let it=0;it0)for(let rt=0;rt0)for(let rt=0;rt0){if(re(P)===!1){let M=P.textures,X=P.width,j=P.height,nt=i.COLOR_BUFFER_BIT,ft=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pt=n.get(P),it=M.length>1;if(it)for(let mt=0;mt0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,pt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,pt.__webglFramebuffer);for(let mt=0;mt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function R(P){let M=o.render.frame;h.get(P)!==M&&(h.set(P,M),P.update())}function wt(P,M){let X=P.colorSpace,j=P.format,nt=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||X!==Js&&X!==ii&&(te.getTransfer(X)===ue?(j!==sn||nt!==nn)&&Ht("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Wt("WebGLTextures: Unsupported texture color space:",X)),M}function kt(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=G,this.resetTextureUnits=F,this.getTextureUnits=I,this.setTextureUnits=B,this.setTexture2D=O,this.setTexture2DArray=N,this.setTexture3D=z,this.setTextureCube=W,this.rebindTextures=ut,this.setupRenderTarget=Lt,this.updateRenderTargetMipmap=Ot,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=Bt,this.setupFrameBufferTexture=ot,this.useMultisampledRTT=re,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function yv(i,t){function e(n,s=ii){let r,o=te.getTransfer(s);if(n===nn)return i.UNSIGNED_BYTE;if(n===ha)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ua)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Ac)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Rc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Ec)return i.BYTE;if(n===Tc)return i.SHORT;if(n===Rs)return i.UNSIGNED_SHORT;if(n===ca)return i.INT;if(n===Sn)return i.UNSIGNED_INT;if(n===Ye)return i.FLOAT;if(n===wn)return i.HALF_FLOAT;if(n===Cc)return i.ALPHA;if(n===Ic)return i.RGB;if(n===sn)return i.RGBA;if(n===Ln)return i.DEPTH_COMPONENT;if(n===Si)return i.DEPTH_STENCIL;if(n===Is)return i.RED;if(n===da)return i.RED_INTEGER;if(n===wi)return i.RG;if(n===fa)return i.RG_INTEGER;if(n===pa)return i.RGBA_INTEGER;if(n===vr||n===yr||n===Mr||n===br)if(o===ue)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===vr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===yr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===br)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===vr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===yr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===br)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ma||n===ga||n===_a||n===xa)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ma)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ga)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===_a)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===xa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===va||n===ya||n===Ma||n===ba||n===Sa||n===Sr||n===wa)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===va||n===ya)return o===ue?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ma)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ba)return r.COMPRESSED_R11_EAC;if(n===Sa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Sr)return r.COMPRESSED_RG11_EAC;if(n===wa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ea||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)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ea)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ta)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Aa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ra)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ca)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ia)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Pa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===La)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Da)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Na)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ua)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Fa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ba)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Oa)return o===ue?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===za||n===ka||n===Ha)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===za)return o===ue?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ka)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ha)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Va||n===Ga||n===wr||n===Wa)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Va)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ga)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===wr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Wa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Cs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var Mv=` +}`,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=` void main() { gl_Position = vec4( position, 1.0 ); -}`,bv=` +}`,Sv=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4217,7 +4217,7 @@ void main() { } -}`,rh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new rr(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 qe({vertexShader:Mv,fragmentShader:bv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new _e(new Mn(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},oh=class extends Dn{constructor(t,e){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null,_=typeof XRWebGLBinding<"u",m=new rh,p={},b=e.getContextAttributes(),E=null,v=null,y=[],S=[],A=new Xt,x=null,T=null,C=new ze;C.viewport=new ge;let D=new ze;D.viewport=new ge;let U=[C,D],F=new sa,I=null,B=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let tt=y[Y];return tt===void 0&&(tt=new ys,y[Y]=tt),tt.getTargetRaySpace()},this.getControllerGrip=function(Y){let tt=y[Y];return tt===void 0&&(tt=new ys,y[Y]=tt),tt.getGripSpace()},this.getHand=function(Y){let tt=y[Y];return tt===void 0&&(tt=new ys,y[Y]=tt),tt.getHandSpace()};function G(Y){let tt=S.indexOf(Y.inputSource);if(tt===-1)return;let dt=y[tt];dt!==void 0&&(dt.update(Y.inputSource,Y.frame,c||o),dt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function q(){s.removeEventListener("select",G),s.removeEventListener("selectstart",G),s.removeEventListener("selectend",G),s.removeEventListener("squeeze",G),s.removeEventListener("squeezestart",G),s.removeEventListener("squeezeend",G),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",O);for(let Y=0;Y=0&&(S[It]=null,y[It].disconnect(dt))}for(let tt=0;tt=S.length){S.push(dt),It=Tt;break}else if(S[Tt]===null){S[Tt]=dt,It=Tt;break}if(It===-1)break}let ot=y[It];ot&&ot.connect(dt)}}let N=new L,z=new L;function W(Y,tt,dt){N.setFromMatrixPosition(tt.matrixWorld),z.setFromMatrixPosition(dt.matrixWorld);let It=N.distanceTo(z),ot=tt.projectionMatrix.elements,Tt=dt.projectionMatrix.elements,jt=ot[14]/(ot[10]-1),Bt=ot[14]/(ot[10]+1),ut=(ot[9]+1)/ot[5],Lt=(ot[9]-1)/ot[5],Ot=(ot[8]-1)/ot[0],zt=(Tt[8]+1)/Tt[0],Zt=jt*Ot,Ee=jt*zt,ie=It/(-Ot+zt),re=ie*-Ot;if(tt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(re),Y.translateZ(ie),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),ot[10]===-1)Y.projectionMatrix.copy(tt.projectionMatrix),Y.projectionMatrixInverse.copy(tt.projectionMatrixInverse);else{let R=jt+ie,wt=Bt+ie,kt=Zt-re,P=Ee+(It-re),M=ut*Bt/wt*R,X=Lt*Bt/wt*R;Y.projectionMatrix.makePerspective(kt,P,M,X,R,wt),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function k(Y,tt){tt===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(tt.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(s===null)return;let tt=Y.near,dt=Y.far;m.texture!==null&&(m.depthNear>0&&(tt=m.depthNear),m.depthFar>0&&(dt=m.depthFar)),F.near=D.near=C.near=tt,F.far=D.far=C.far=dt,(I!==F.near||B!==F.far)&&(s.updateRenderState({depthNear:F.near,depthFar:F.far}),I=F.near,B=F.far),F.layers.mask=Y.layers.mask|6,C.layers.mask=F.layers.mask&-5,D.layers.mask=F.layers.mask&-3;let It=Y.parent,ot=F.cameras;k(F,It);for(let Tt=0;Tt0&&(m.alphaTest.value=p.alphaTest);let b=t.get(p),E=b.envMap,v=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(Sv.makeRotationFromEuler(v)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Zd),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,b,E){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=E*.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,b){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===De&&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=b.texture,m.transmissionSamplerSize.value.set(b.width,b.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 b=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Ev(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,y){let S=y.program;n.uniformBlockBinding(v,S)}function c(v,y){let S=s[v.id];S===void 0&&(m(v),S=h(v),s[v.id]=S,v.addEventListener("dispose",b));let A=y.program;n.updateUBOMapping(v,A);let x=t.render.frame;r[v.id]!==x&&(u(v),r[v.id]=x)}function h(v){let y=d();v.__bindingPointIndex=y;let S=i.createBuffer(),A=v.__size,x=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,S),S}function d(){for(let v=0;v0&&(S+=A-x),v.__size=S,v.__cache={},this}function p(v){let y={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(y.boundary=4,y.storage=4):v.isVector2?(y.boundary=8,y.storage=8):v.isVector3||v.isColor?(y.boundary=16,y.storage=12):v.isVector4?(y.boundary=16,y.storage=16):v.isMatrix3?(y.boundary=48,y.storage=48):v.isMatrix4?(y.boundary=64,y.storage=64):v.isTexture?Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(v)?(y.boundary=16,y.storage=v.byteLength):Ht("WebGLRenderer: Unsupported uniform value type.",v),y}function b(v){let y=v.target;y.removeEventListener("dispose",b);let S=o.indexOf(y.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function E(){for(let v in s)i.deleteBuffer(s[v]);o=[],s={},r={}}return{bind:l,update:c,dispose:E}}var Tv=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]),Gn=null;function Av(){return Gn===null&&(Gn=new Un(Tv,16,16,wi,wn),Gn.name="DFG_LUT",Gn.minFilter=Xe,Gn.magFilter=Xe,Gn.wrapS=Pn,Gn.wrapT=Pn,Gn.generateMipmaps=!1,Gn.needsUpdate=!0),Gn}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 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([pa,fa,da]),p=new Set([nn,Sn,Rs,Cs,ha,ua]),b=new Uint32Array(4),E=new Int32Array(4),v=new L,y=null,S=null,A=[],x=[],T=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=bn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let C=this,D=!1,U=null,F=null,I=null,B=null;this._outputColorSpace=Te;let G=0,q=0,O=null,N=-1,z=null,W=new ge,k=new ge,K=null,lt=new Vt(0),ht=0,at=e.width,Y=e.height,tt=1,dt=null,It=null,ot=new ge(0,0,at,Y),Tt=new ge(0,0,at,Y),jt=!1,Bt=new Fn,ut=!1,Lt=!1,Ot=new Yt,zt=new L,Zt=new ge,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ie=!1;function re(){return O===null?tt:1}let R=n;function wt(w,H){return e.getContext(w,H)}let kt,P,M,X,j,nt,ft,pt,it,rt,mt,Nt,vt,gt,Ut,Gt,$t,V,_t,st,xt,St,ct;try{let w={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",xe,!1),e.addEventListener("webglcontextrestored",ce,!1),e.addEventListener("webglcontextcreationerror",fn,!1),R===null){let H="webgl2";if(R=wt(H,w),R===null)throw wt(H)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Ft()}catch(w){throw e.removeEventListener("webglcontextlost",xe,!1),e.removeEventListener("webglcontextrestored",ce,!1),e.removeEventListener("webglcontextcreationerror",fn,!1),Wt("WebGLRenderer: "+w.message),w}function Ft(){kt=new N0(R),kt.init(),xt=new yv(R,kt),P=new w0(R,kt,t,xt),M=new xv(R,kt),P.reversedDepthBuffer&&u&&M.buffers.depth.setReversed(!0),F=R.createFramebuffer(),I=R.createFramebuffer(),B=R.createFramebuffer(),X=new B0(R),j=new sv,nt=new vv(R,kt,M,j,P,xt,X),ft=new D0(C),pt=new zm(R),St=new b0(R,pt),it=new U0(R,pt,X,St),rt=new z0(R,it,pt,St,X),V=new O0(R,P,nt),Ut=new E0(j),mt=new iv(C,ft,kt,P,St,Ut),Nt=new wv(C,j),vt=new ov,gt=new dv(kt),$t=new M0(C,ft,M,rt,g,l),Gt=new _v(C,rt,P),ct=new Ev(R,X,P,M),_t=new S0(R,kt,X),st=new F0(R,kt,X),X.programs=mt.programs,C.capabilities=P,C.extensions=kt,C.properties=j,C.renderLists=vt,C.shadowMap=Gt,C.state=M,C.info=X}_!==nn&&(T=new H0(_,e.width,e.height,a,s,r));let Pt=new oh(C,R);this.xr=Pt,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){let w=kt.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){let w=kt.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return tt},this.setPixelRatio=function(w){w!==void 0&&(tt=w,this.setSize(at,Y,!1))},this.getSize=function(w){return w.set(at,Y)},this.setSize=function(w,H,Q=!0){if(Pt.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}at=w,Y=H,e.width=Math.floor(w*tt),e.height=Math.floor(H*tt),Q===!0&&(e.style.width=w+"px",e.style.height=H+"px"),T!==null&&T.setSize(e.width,e.height),this.setViewport(0,0,w,H)},this.getDrawingBufferSize=function(w){return w.set(at*tt,Y*tt).floor()},this.setDrawingBufferSize=function(w,H,Q){at=w,Y=H,tt=Q,e.width=Math.floor(w*Q),e.height=Math.floor(H*Q),this.setViewport(0,0,w,H)},this.setEffects=function(w){if(_===nn){Wt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(w){for(let H=0;H{function bt(){if(Z.forEach(function(At){let Rt=j.get(At).currentProgram;(Rt===void 0||Rt.isReady())&&Z.delete(At)}),Z.size===0){J(w);return}setTimeout(bt,10)}kt.get("KHR_parallel_shader_compile")!==null?bt():setTimeout(bt,10)})};let Cl=null;function Fp(w){Cl&&Cl(w)}function Xh(){Ii.stop()}function qh(){Ii.start()}let Ii=new Gd;Ii.setAnimationLoop(Fp),typeof self<"u"&&Ii.setContext(self),this.setAnimationLoop=function(w){Cl=w,Pt.setAnimationLoop(w),w===null?Ii.stop():Ii.start()},Pt.addEventListener("sessionstart",Xh),Pt.addEventListener("sessionend",qh),this.render=function(w,H){if(H!==void 0&&H.isCamera!==!0){Wt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;U!==null&&U.renderStart(w,H);let Q=Pt.enabled===!0&&Pt.isPresenting===!0,Z=T!==null&&(O===null||Q)&&T.begin(C,O);if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),Pt.enabled===!0&&Pt.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Pt.cameraAutoUpdate===!0&&Pt.updateCamera(H),H=Pt.getCamera()),w.isScene===!0&&w.onBeforeRender(C,w,H,O),S=gt.get(w,x.length),S.init(H),S.state.textureUnits=nt.getTextureUnits(),x.push(S),Ot.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Bt.setFromProjectionMatrix(Ot,xn,H.reversedDepth),Lt=this.localClippingEnabled,ut=Ut.init(this.clippingPlanes,Lt),y=vt.get(w,A.length),y.init(),A.push(y),Pt.enabled===!0&&Pt.isPresenting===!0){let At=C.xr.getDepthSensingMesh();At!==null&&Il(At,H,-1/0,C.sortObjects)}Il(w,H,0,C.sortObjects),y.finish(),U!==null&&U.updateLights(S.state.lightsArray),C.sortObjects===!0&&y.sort(dt,It),ie=Pt.enabled===!1||Pt.isPresenting===!1||Pt.hasDepthSensing()===!1,ie&&$t.addToRenderList(y,w),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ut===!0&&Ut.beginShadows();let J=S.state.shadowsArray;if(Gt.render(J,w,H),ut===!0&&Ut.endShadows(),(Z&&T.hasRenderPass())===!1){let At=y.opaque,Mt=y.transmissive;if(S.setupLights(),H.isArrayCamera){let Rt=H.cameras;if(Mt.length>0)for(let Dt=0,Jt=Rt.length;Dt0&&$h(At,Mt,w,H),ie&&$t.render(w),Yh(y,w,H)}O!==null&&q===0&&(nt.updateMultisampleRenderTarget(O),nt.updateRenderTargetMipmap(O)),Z&&T.end(C),w.isScene===!0&&w.onAfterRender(C,w,H),St.resetDefaultState(),N=-1,z=null,x.pop(),x.length>0?(S=x[x.length-1],nt.setTextureUnits(S.state.textureUnits),ut===!0&&Ut.setGlobalState(C.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?y=A[A.length-1]:y=null,U!==null&&U.renderEnd()};function Il(w,H,Q,Z){if(w.visible===!1)return;if(w.layers.test(H.layers)){if(w.isGroup)Q=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(H);else if(w.isLightProbeGrid)S.pushLightProbeGrid(w);else if(w.isLight)S.pushLight(w),w.castShadow&&S.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||w.intersectsFrustum(Bt)){Z&&Zt.setFromMatrixPosition(w.matrixWorld).applyMatrix4(Ot);let At=rt.update(w),Mt=w.material;Mt.visible&&y.push(w,At,Mt,Q,Zt.z,null,H)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||w.intersectsFrustum(Bt))){let At=rt.update(w),Mt=w.material;if(Z&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),Zt.copy(w.boundingSphere.center)):(At.boundingSphere===null&&At.computeBoundingSphere(),Zt.copy(At.boundingSphere.center)),Zt.applyMatrix4(w.matrixWorld).applyMatrix4(Ot)),Array.isArray(Mt)){let Rt=At.groups;for(let Dt=0,Jt=Rt.length;Dt0&&Yr(J,H,Q),bt.length>0&&Yr(bt,H,Q),At.length>0&&Yr(At,H,Q),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function $h(w,H,Q,Z){if((Q.isScene===!0?Q.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Z.id]===void 0){let Ct=kt.has("EXT_color_buffer_half_float")||kt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Z.id]=new Ve(1,1,{generateMipmaps:!0,type:Ct?wn:nn,minFilter:bi,samples:Math.max(4,P.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:te.workingColorSpace})}let bt=S.state.transmissionRenderTarget[Z.id],At=Z.viewport||W;bt.setSize(At.z*C.transmissionResolutionScale,At.w*C.transmissionResolutionScale);let Mt=C.getRenderTarget(),Rt=C.getActiveCubeFace(),Dt=C.getActiveMipmapLevel();C.setRenderTarget(bt),C.getClearColor(lt),ht=C.getClearAlpha(),ht<1&&C.setClearColor(16777215,.5),C.clear(),ie&&$t.render(Q);let Jt=C.toneMapping;C.toneMapping=bn;let Qt=Z.viewport;if(Z.viewport!==void 0&&(Z.viewport=void 0),S.setupLightsView(Z),ut===!0&&Ut.setGlobalState(C.clippingPlanes,Z),Yr(w,Q,Z),nt.updateMultisampleRenderTarget(bt),nt.updateRenderTargetMipmap(bt),kt.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let he=0,Ie=H.length;he0,Z.currentProgram=Qt,Z.uniformsList=null,Qt}function Jh(w){if(w.uniformsList===null){let H=w.currentProgram.getUniforms();w.uniformsList=Ds.seqWithValue(H.seq,w.uniforms)}return w.uniformsList}function Kh(w,H){let Q=j.get(w);Q.outputColorSpace=H.outputColorSpace,Q.batching=H.batching,Q.batchingColor=H.batchingColor,Q.instancing=H.instancing,Q.instancingColor=H.instancingColor,Q.instancingMorph=H.instancingMorph,Q.skinning=H.skinning,Q.morphTargets=H.morphTargets,Q.morphNormals=H.morphNormals,Q.morphColors=H.morphColors,Q.morphTargetsCount=H.morphTargetsCount,Q.numClippingPlanes=H.numClippingPlanes,Q.numIntersection=H.numClipIntersection,Q.vertexAlphas=H.vertexAlphas,Q.vertexTangents=H.vertexTangents,Q.toneMapping=H.toneMapping}function Bp(w,H){if(w.length===0)return null;if(w.length===1)return w[0].texture!==null?w[0]:null;v.setFromMatrixPosition(H.matrixWorld);for(let Q=0,Z=w.length;Q0),Ct=!!Q.morphAttributes.position,he=!!Q.morphAttributes.normal,Ie=!!Q.morphAttributes.color,be=bn;Z.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(be=C.toneMapping);let me=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,$e=me!==void 0?me.length:0,Et=j.get(Z),tn=S.state.lights;if(ut===!0&&(Lt===!0||w!==z)){let ve=w===z&&Z.id===N;Ut.setState(Z,w,ve)}let oe=!1;Z.version===Et.__version?(Et.needsLights&&Et.lightsStateVersion!==tn.state.version||Et.outputColorSpace!==Mt||J.isBatchedMesh&&Et.batching===!1||!J.isBatchedMesh&&Et.batching===!0||J.isBatchedMesh&&Et.batchingColor===!0&&J._colorsTexture===null||J.isBatchedMesh&&Et.batchingColor===!1&&J._colorsTexture!==null||J.isInstancedMesh&&Et.instancing===!1||!J.isInstancedMesh&&Et.instancing===!0||J.isSkinnedMesh&&Et.skinning===!1||!J.isSkinnedMesh&&Et.skinning===!0||J.isInstancedMesh&&Et.instancingColor===!0&&J.instanceColor===null||J.isInstancedMesh&&Et.instancingColor===!1&&J.instanceColor!==null||J.isInstancedMesh&&Et.instancingMorph===!0&&J.morphTexture===null||J.isInstancedMesh&&Et.instancingMorph===!1&&J.morphTexture!==null||Et.envMap!==Dt||Z.fog===!0&&Et.fog!==bt||Et.numClippingPlanes!==void 0&&(Et.numClippingPlanes!==Ut.numPlanes||Et.numIntersection!==Ut.numIntersection)||Et.vertexAlphas!==Jt||Et.vertexTangents!==Qt||Et.morphTargets!==Ct||Et.morphNormals!==he||Et.morphColors!==Ie||Et.toneMapping!==be||Et.morphTargetsCount!==$e||!!Et.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(oe=!0):(oe=!0,Et.__version=Z.version);let hn=Et.currentProgram;oe===!0&&(hn=$r(Z,H,J),U&&Z.isNodeMaterial&&U.onUpdateProgram(Z,hn,Et));let Cn=!1,ai=!1,Yi=!1,pe=hn.getUniforms(),Ce=Et.uniforms;if(M.useProgram(hn.program)&&(Cn=!0,ai=!0,Yi=!0),Z.id!==N&&(N=Z.id,ai=!0),Et.needsLights){let ve=Bp(S.state.lightProbeGridArray,J);Et.lightProbeGrid!==ve&&(Et.lightProbeGrid=ve,ai=!0)}if(Cn||z!==w){M.buffers.depth.getReversed()&&w.reversedDepth!==!0&&(w._reversedDepth=!0,w.updateProjectionMatrix()),pe.setValue(R,"projectionMatrix",w.projectionMatrix),pe.setValue(R,"viewMatrix",w.matrixWorldInverse);let ci=pe.map.cameraPosition;ci!==void 0&&ci.setValue(R,zt.setFromMatrixPosition(w.matrixWorld)),P.logarithmicDepthBuffer&&pe.setValue(R,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)&&pe.setValue(R,"isOrthographic",w.isOrthographicCamera===!0),z!==w&&(z=w,ai=!0,Yi=!0)}if(Et.needsLights&&(tn.state.sunShadowMap.length>0&&pe.setValue(R,"sunShadowMap",tn.state.sunShadowMap,nt),tn.state.directionalShadowMap.length>0&&pe.setValue(R,"directionalShadowMap",tn.state.directionalShadowMap,nt),tn.state.spotShadowMap.length>0&&pe.setValue(R,"spotShadowMap",tn.state.spotShadowMap,nt),tn.state.pointShadowMap.length>0&&pe.setValue(R,"pointShadowMap",tn.state.pointShadowMap,nt)),J.isSkinnedMesh){pe.setOptional(R,J,"bindMatrix"),pe.setOptional(R,J,"bindMatrixInverse");let ve=J.skeleton;ve&&(ve.boneTexture===null&&ve.computeBoneTexture(),pe.setValue(R,"boneTexture",ve.boneTexture,nt))}J.isBatchedMesh&&(pe.setOptional(R,J,"batchingTexture"),pe.setValue(R,"batchingTexture",J._matricesTexture,nt),pe.setOptional(R,J,"batchingIdTexture"),pe.setValue(R,"batchingIdTexture",J._indirectTexture,nt),pe.setOptional(R,J,"batchingColorTexture"),J._colorsTexture!==null&&pe.setValue(R,"batchingColorTexture",J._colorsTexture,nt));let li=Q.morphAttributes;if((li.position!==void 0||li.normal!==void 0||li.color!==void 0)&&V.update(J,Q,hn),(ai||Et.receiveShadow!==J.receiveShadow)&&(Et.receiveShadow=J.receiveShadow,pe.setValue(R,"receiveShadow",J.receiveShadow)),(Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&H.environment!==null&&(Ce.envMapIntensity.value=H.environmentIntensity),Ce.dfgLUT!==void 0&&(Ce.dfgLUT.value=Av()),ai){if(pe.setValue(R,"toneMappingExposure",C.toneMappingExposure),Et.needsLights&&zp(Ce,Yi),bt&&Z.fog===!0&&Nt.refreshFogUniforms(Ce,bt),Nt.refreshMaterialUniforms(Ce,Z,tt,Y,S.state.transmissionRenderTarget[w.id]),Et.needsLights&&Et.lightProbeGrid){let ve=Et.lightProbeGrid;Ce.probesSH.value=ve.texture,Ce.probesMin.value.copy(ve.boundingBox.min),Ce.probesMax.value.copy(ve.boundingBox.max),Ce.probesResolution.value.copy(ve.resolution)}Ds.upload(R,Jh(Et),Ce,nt)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0&&(Ds.upload(R,Jh(Et),Ce,nt),Z.uniformsNeedUpdate=!1),Z.isSpriteMaterial&&pe.setValue(R,"center",J.center),pe.setValue(R,"modelViewMatrix",J.modelViewMatrix),pe.setValue(R,"normalMatrix",J.normalMatrix),pe.setValue(R,"modelMatrix",J.matrixWorld),Z.uniformsGroups!==void 0){let ve=Z.uniformsGroups;for(let ci=0,$i=ve.length;ci<$i;ci++){let Qh=ve[ci];ct.update(Qh,hn),ct.bind(Qh,hn)}}return hn}function zp(w,H){w.ambientLightColor.needsUpdate=H,w.lightProbe.needsUpdate=H,w.sunLights.needsUpdate=H,w.sunLightShadows.needsUpdate=H,w.directionalLights.needsUpdate=H,w.directionalLightShadows.needsUpdate=H,w.pointLights.needsUpdate=H,w.pointLightShadows.needsUpdate=H,w.spotLights.needsUpdate=H,w.spotLightShadows.needsUpdate=H,w.rectAreaLights.needsUpdate=H,w.hemisphereLights.needsUpdate=H}function kp(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(w,H,Q){let Z=j.get(w);Z.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1&&(Z.__useRenderToTexture=!1),j.get(w.texture).__webglTexture=H,j.get(w.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:Q,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,H){let Q=j.get(w);Q.__webglFramebuffer=H,Q.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(w,H=0,Q=0){O=w,G=H,q=Q;let Z=null,J=!1,bt=!1;if(w){let Mt=j.get(w);if(Mt.__useDefaultFramebuffer!==void 0){M.bindFramebuffer(R.FRAMEBUFFER,Mt.__webglFramebuffer),W.copy(w.viewport),k.copy(w.scissor),K=w.scissorTest,M.viewport(W),M.scissor(k),M.setScissorTest(K),N=-1;return}else if(Mt.__webglFramebuffer===void 0)nt.setupRenderTarget(w);else if(Mt.__hasExternalTextures)nt.rebindTextures(w,j.get(w.texture).__webglTexture,j.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){let Jt=w.depthTexture;if(Mt.__boundDepthTexture!==Jt){if(Jt!==null&&j.has(Jt)&&(w.width!==Jt.image.width||w.height!==Jt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");nt.setupDepthRenderbuffer(w)}}let Rt=w.texture;(Rt.isData3DTexture||Rt.isDataArrayTexture||Rt.isCompressedArrayTexture)&&(bt=!0);let Dt=j.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray(Dt[H])?Z=Dt[H][Q]:Z=Dt[H],J=!0):w.samples>0&&nt.useMultisampledRTT(w)===!1?Z=j.get(w).__webglMultisampledFramebuffer:Array.isArray(Dt)?Z=Dt[Q]:Z=Dt,W.copy(w.viewport),k.copy(w.scissor),K=w.scissorTest}else W.copy(ot).multiplyScalar(tt).floor(),k.copy(Tt).multiplyScalar(tt).floor(),K=jt;if(Q!==0&&(Z=F),M.bindFramebuffer(R.FRAMEBUFFER,Z)&&M.drawBuffers(w,Z),M.viewport(W),M.scissor(k),M.setScissorTest(K),J){let Mt=j.get(w.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_CUBE_MAP_POSITIVE_X+H,Mt.__webglTexture,Q)}else if(bt){let Mt=H;for(let Rt=0;Rt1&&R.readBuffer(R.COLOR_ATTACHMENT0+Mt);let Ct=jh(Dt);if(Ct.__formatReadable===!1){Wt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ct.__typeReadable===!1){Wt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=w.width-Z&&Q>=0&&Q<=w.height-J&&R.readPixels(H,Q,Z,J,xt.convert(Jt),xt.convert(Qt),bt)}finally{let Dt=O!==null?j.get(O).__webglFramebuffer:null;M.bindFramebuffer(R.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(w,H,Q,Z,J,bt,At,Mt=0){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Rt=j.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&At!==void 0&&(Rt=Rt[At]),Rt)if(H>=0&&H<=w.width-Z&&Q>=0&&Q<=w.height-J){M.bindFramebuffer(R.FRAMEBUFFER,Rt);let Dt=w.textures[Mt],Jt=Dt.format,Qt=Dt.type;w.textures.length>1&&R.readBuffer(R.COLOR_ATTACHMENT0+Mt);let Ct=jh(Dt);if(Ct.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ct.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let he=R.createBuffer();R.bindBuffer(R.PIXEL_PACK_BUFFER,he),R.bufferData(R.PIXEL_PACK_BUFFER,bt.byteLength,R.STREAM_READ),R.readPixels(H,Q,Z,J,xt.convert(Jt),xt.convert(Qt),0),R.bindBuffer(R.PIXEL_PACK_BUFFER,null);let Ie=O!==null?j.get(O).__webglFramebuffer:null;M.bindFramebuffer(R.FRAMEBUFFER,Ie);let be=R.fenceSync(R.SYNC_GPU_COMMANDS_COMPLETE,0);return R.flush(),await gd(R,be,4),R.bindBuffer(R.PIXEL_PACK_BUFFER,he),R.getBufferSubData(R.PIXEL_PACK_BUFFER,0,bt),R.bindBuffer(R.PIXEL_PACK_BUFFER,null),R.deleteBuffer(he),R.deleteSync(be),bt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(w,H=null,Q=0){let Z=Math.pow(2,-Q),J=Math.floor(w.image.width*Z),bt=Math.floor(w.image.height*Z),At=H!==null?H.x:0,Mt=H!==null?H.y:0;nt.setTexture2D(w,0),R.copyTexSubImage2D(R.TEXTURE_2D,Q,0,0,At,Mt,J,bt),M.unbindTexture()},this.copyTextureToTexture=function(w,H,Q=null,Z=null,J=0,bt=0){let At,Mt,Rt,Dt,Jt,Qt,Ct,he,Ie,be=w.isCompressedTexture?w.mipmaps[bt]:w.image;if(Q!==null)At=Q.max.x-Q.min.x,Mt=Q.max.y-Q.min.y,Rt=Q.isBox3?Q.max.z-Q.min.z:1,Dt=Q.min.x,Jt=Q.min.y,Qt=Q.isBox3?Q.min.z:0;else{let Ce=Math.pow(2,-J);At=Math.floor(be.width*Ce),Mt=Math.floor(be.height*Ce),w.isDataArrayTexture?Rt=be.depth:w.isData3DTexture?Rt=Math.floor(be.depth*Ce):Rt=1,Dt=0,Jt=0,Qt=0}Z!==null?(Ct=Z.x,he=Z.y,Ie=Z.z):(Ct=0,he=0,Ie=0);let me=xt.convert(H.format),$e=xt.convert(H.type),Et;H.isData3DTexture?(nt.setTexture3D(H,0),Et=R.TEXTURE_3D):H.isDataArrayTexture||H.isCompressedArrayTexture?(nt.setTexture2DArray(H,0),Et=R.TEXTURE_2D_ARRAY):(nt.setTexture2D(H,0),Et=R.TEXTURE_2D),M.activeTexture(R.TEXTURE0),M.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,H.flipY),M.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),M.pixelStorei(R.UNPACK_ALIGNMENT,H.unpackAlignment);let tn=M.getParameter(R.UNPACK_ROW_LENGTH),oe=M.getParameter(R.UNPACK_IMAGE_HEIGHT),hn=M.getParameter(R.UNPACK_SKIP_PIXELS),Cn=M.getParameter(R.UNPACK_SKIP_ROWS),ai=M.getParameter(R.UNPACK_SKIP_IMAGES);M.pixelStorei(R.UNPACK_ROW_LENGTH,be.width),M.pixelStorei(R.UNPACK_IMAGE_HEIGHT,be.height),M.pixelStorei(R.UNPACK_SKIP_PIXELS,Dt),M.pixelStorei(R.UNPACK_SKIP_ROWS,Jt),M.pixelStorei(R.UNPACK_SKIP_IMAGES,Qt);let Yi=w.isDataArrayTexture||w.isData3DTexture,pe=H.isDataArrayTexture||H.isData3DTexture;if(w.isDepthTexture){let Ce=j.get(w),li=j.get(H),ve=j.get(Ce.__renderTarget),ci=j.get(li.__renderTarget);M.bindFramebuffer(R.READ_FRAMEBUFFER,ve.__webglFramebuffer),M.bindFramebuffer(R.DRAW_FRAMEBUFFER,ci.__webglFramebuffer);for(let $i=0;$i=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(ah(l,0,a.join(""))i!==null&&typeof i=="object"&&!Array.isArray(i),si=i=>Array.isArray(i)&&i.every(Wi),Ti=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number"),ef=i=>Wi(i)&&Ti(i.min)&&Ti(i.max),jd=i=>i==null||Wi(i)&&si(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 Iv(i){if(!Wi(i)||!si(i.elements)||!si(i.geometries)||!si(i.materials)||!Wi(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[e,n,s]of[["geometry","u32",t.count],["material","u32",t.count],["element","i32",t.count],["matrix","f32",t.count*12]])if(t[e]?.t!==n||t[e].n!==s)throw new se(`Invalid META instance ${e} view.`);for(let e of i.geometries){let n=e.q;if(!ef(e.bbox)||!["u16","u32"].includes(e.indices?.t)||e.positions?.t!==(n?"u16":"f32")||n&&(!Ti(n.o)||typeof n.s!="number")||e.normals!=null&&!["f32","i16"].includes(e.normals.t)||e.uvs!=null&&e.uvs.t!=="f32"||e.kind!=null&&e.kind!=="points"||e.colors!=null&&(e.kind!=="points"||e.colors.t!=="u8"||e.colors.n!==e.positions.n))throw new se("Invalid META geometry.")}if(i.points!=null){let e=i.points;if(!Wi(e)||!Number.isSafeInteger(e.count)||e.count<0)throw new se("Invalid META point count.");for(let[n,s,r]of[["geometry","u32",e.count],["material","u32",e.count],["element","i32",e.count],["matrix","f32",e.count*12]])if(e[n]?.t!==s||e[n].n!==r)throw new se(`Invalid META point ${n} view.`)}if(i.panoramas!=null&&(!si(i.panoramas)||i.panoramas.some(e=>!Number.isInteger(e.element)||e.element<0||e.element>=i.elements.length||e.name!=null&&typeof e.name!="string"||!Ti(e.position)||!e.position.every(Number.isFinite)||!Number.isFinite(e.yaw)||e.image?.t!=="u8"||!Number.isSafeInteger(e.image.n)||e.image.n<4||e.image.n>16*1024*1024)))throw new se("Invalid META panorama.");Pv(i);for(let e of i.materials){let n=e.texture;if(!Ti(e.color)||typeof e.opacity!="number"||n!=null&&(!Number.isInteger(n)||n<0||n>=(i.textures?.length??0)))throw new se("Invalid META material.")}}function Pv(i){if(!Wi(i)||!si(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&&!si(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=Ir(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=>!si(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)||!si(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 Lv(i){let t;try{t=JSON.parse(i)}catch(e){throw new se(e.message,{cause:e})}return Iv(t),t}function lh(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=Lv(e);return t?.("metadataEnd"),n}function Qd(i,t){let e=Rv[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=lh(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(Cv(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 Yt,rf=new Fn,ch=32;function hh(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 uh(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 En=.0009765625,fh=32767,Pr=i=>i<0?-1:1;function lf(i){let t=Math.min(Math.max(i,-1),1)*fh;return Pr(t)*Math.round(Math.abs(t))}function Lr(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))*Pr(o),(1-Math.abs(o))*Pr(a)]),i[t]=lf(o),i[t+1]=lf(a)}function cf(i,t,e,n){let s=Math.max(e/fh,-1),r=Math.max(n/fh,-1),o=1-Math.abs(s)-Math.abs(r);o<0&&([s,r]=[(1-Math.abs(r))*Pr(s),(1-Math.abs(s))*Pr(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 Dr(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 Qa(i,t){let e=Dr(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=Nv(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&&Uv(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 Uv(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 mh=384*2**20;function xf(i,{cap:t=mh,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 tl(i,t){return i>65535?new Uint32Array(t):new Uint16Array(t)}function gh(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===En){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/En)*En,Math.ceil((c-n[a])/En)<=ff||(o=!1)}return o||n.fill(0),o?Dv:Fs}function bf(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]]===Fs,o=r?new Float32Array(n*4):new Uint16Array(n*4),a=new Int16Array(n*2),l=t.textured?new Float32Array(n*2):null,c=tl(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/En),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 el(i){if(!i.normals&&i.oct){i.normals=new Float32Array(i.vertices*3);for(let t=0;t=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.0 ? - t : t, n.y >= 0.0 ? - t : t ); return n; -}`,Ur=` +}`,Fr=` 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;`,_h=` +vec3 slotPosition = info.xyz + q.xyz * info.w;`,xh=` #ifndef IO_NO_HIDE_BRANCH if ( state.a < 0.5 ) gl_Position = vec4( 0.0, 0.0, 2.0, 1.0 ); -#endif`,zv=` +#endif`,kv=` vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); @@ -4248,27 +4248,41 @@ 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 kv(i){Object.assign(i.uniforms,this.userData.slotUniforms);let t=Ai(i.vertexShader,"#include ",`#include -${Nr}`);t=Ai(t,"#include ",`${Ur} -vTint = state.rgb;`),t=Ai(t,"#include ","vec3 objectNormal = ioOct( normal.xy );"),t=Ai(t,"#include ",zv),t=Ai(t,"#include ","vec3 transformed = slotPosition;"),t=Ai(t,"#include ",`#include -${_h}`),i.vertexShader=t;let e=Ai(i.fragmentShader,"#include ",`#include -varying vec3 vTint;`);e=Ai(e,"#include ","diffuseColor.rgb *= vTint;"),i.fragmentShader=e}function xh(i,t,e=!1){return i.userData.slotUniforms=t,i.onBeforeCompile=kv,i.index0AttributeName="q",e&&(i.defines={IO_NO_HIDE_BRANCH:""}),i}var bh=["materials","textures","white","wireframe"],Hv=[245,158,11],Vv=[235,235,237],Fr=4294967295,Xi=2048,vh=256,Gv=16,yh=1024,Wv=.1,Xv=8192,qv=1.4,il=2**-20,nl=17;function Yv(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 $v(){this.array=null}function Tn(i,t,e=!1,n=Ae){return new n(i,t,e).onUpload($v)}var Br=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+il*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],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 Jv=i=>{let t=i.getHex(Te);return[t>>16&255,t>>8&255,t&255]},Or=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 g=t.view(c.geometry),_=t.view(c.matrix),m=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=hh(n,this._planes);let{x:r,y:o,z:a}=n.position;this._pickViewPadding=il*(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 le){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+=Mh(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 b=g.cell&&this._detailUsesInstances,E=b&&!of(r,_[0],_[1],_[2],_[3]+g.pickPadding),v=g.slotBase+g.n,y=-1;if(b){let C=this._slotRadius[g.slotBase],D=this._slotRadius[v-1],U=m+_[3],F=Math.abs(o[3])*_[4]+Math.abs(o[4])*_[5]+Math.abs(o[5])*_[6],I=U-F-C,B=U+F-D,G=Math.fround(o[7]?I>0?C*o[6]/I:1/0:C*p),q=Math.fround(o[7]?B>0?D*o[6]/B:1/0:D*p);Us(q)===Us(G)&&(y=G)}if(y>=0&&!E){g.detailLow=g.detailHigh=y,g.detailEnd=g.n;let C=this._slotCost[g.slotBase]*g.shown;l[Us(y)]+=C,u+=C;continue}let S=0,A=1/0,x=-1,T=0;for(let C=g.slotBase;C=0){S++;continue}let N=(G-o[0])*o[3]+(q-o[1])*o[4]+(O-o[2])*o[5]-D;U=o[7]?N>0?o[6]/N:1/0:o[6]}let F=U===1/0?1/0:Math.fround(D*U);b&&(a[C]=F,A=Math.min(A,F),x=Math.max(x,F));let I=this._slotCost[C];l[Us(F)]+=I,u+=I}if(b){if(S){A=x=y;let C=S*this._slotCost[g.slotBase];l[Us(y)]+=C,u+=C}g.detailLow=A,g.detailHigh=x,g.detailEnd=T}}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+=Mh(r,r.first,Math.max(r.last+1,r.first)),e+=Mh(r,r.first,Math.max(r.end,r.first)),s++);return{drawn:e,inView:n,draws:s}}drawnInstances(t){t.updateMatrixWorld();let e=new Fn().setFromProjectionMatrix(new Yt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),n={info:{render:{frame:-1}}},s=new We,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 N=l.get(O);if(!N){let z=a.geometries[O],W=t.view(z.indices),k=z.uvs?t.view(z.uvs):null;N=Sf(Dr(t,z),z.q??null,hf(t,z),W,k),N.drawable=N.indices.length>=3&&N.min.every(Number.isFinite)&&N.max.every(Number.isFinite),l.set(O,N)}return N},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-N).map(O=>{let N=m.get(O),z=c(e[N[0]]),W=this._buckets[this._bucketOf[N[0]]].texture!==null,k=[0,1,2].every(lt=>(z.max[lt]-z.min[lt])/En<=65535),K=z.vertices*((k?12:20)+(W?8:0))+z.indices.length*(z.vertices>65535?4:2);return{k:N.length,bytes:K,members:N,textured:W}}),v=s.mergedCap??mh,y=s.minRepeats??Gv;if(E.reduce((O,N)=>O+N.k*N.bytes,0)>v){let O=s.cellExtent==null?_f(p,f)*Wv:this.visibleBox().getSize(new L).length()*s.cellExtent;for(let N of E)N.k{if(S[N]){for(let z of O.leaves)T.push({shape:O,members:gh(z,g)});return}for(let z of O.members){x[e[z]]++;let W=this._bucketOf[z]*2+(h[z]===Fs?1:0),k=A.get(W);k||A.set(W,k=[]),k.push(z)}});let C=[];for(let O of[...A.keys()].sort((N,z)=>N-z))for(let N of pf(u,f,A.get(O),s.chunkVertices??uf))C.push(gh(N,g));let D=[...C,...T.map(O=>O.members)].reduce((O,N)=>O+N.length,0);if(D>r)throw new Br(D,r);let U=Math.max(1,Math.ceil(D/Xi)),F=new Float32Array(Xi*U*4);this._state=new Un(new Uint8Array(Xi*U*4),Xi,U),this._state.colorSpace=Te,this._state.onUpdate=()=>{this._fullPending=!1,this._pendingRanges=0},this._fullPending=!0,this._pendingRanges=0,this._dirty=new Uint32Array(vh),this._dirtyCount=0;let I=new Un(F,Xi,U,sn,Ye);I.needsUpdate=!0,I.onUpdate=()=>I.image.data=null,this.slotUniforms.slotInfo.value=I,this.slotUniforms.slotState.value=this._state,this._stateBytes=Xi*U*20,this._slotOf=new Uint32Array(this._visible.length).fill(Fr),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(yh),this._detailBins=new Float64Array(ch),this._detailBytes=0,this._unitScale=null,this._cutInView=0,this._cutFrame=-1,this._mergedBytes=0,this._instancedBytes=0,this._lineBytes=0;let B={matrices:n,geometryOf:e,mirrored:_,kind:h,origins:d,source:c,textured:!1};this._lineSources=new Map;let G=0;for(let O of C){let N=this._buckets[this._bucketOf[O[0]]];B.textured=N.texture!==null;let z=bf(O,B);for(let W=0;WO+N,0);let q=new Map;for(let{shape:O,members:N}of T){let z=N[0],W=c(e[z]),k=q.get(O);if(!k){let K=a.geometries[e[z]].bbox;k=this._shape(W,_[z]===1,O.textured);let lt=at=>Math.max(...at.map(Math.abs)),ht=Math.max(lt(W.min),lt(W.max));k.pickExtent=ht,k.pickPadding=Math.max(0,...W.min.map((at,Y)=>K.min[Y]-at),...W.max.map((at,Y)=>at-K.max[Y]))+(W.q?il*(lt(W.q.o)+65535*Math.abs(W.q.s)):0),q.set(O,k)}for(let K=0;KO+N,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,ei);a.setAttribute("slotBase",l),a.setIndex(s.index);let c=Af(this._boxes,e),h=new We(new L(c[0],c[1],c[2]),c[3]);a.boundingSphere=h;let d=new gi(a,t.material,0),u=new Float32Array(o*16),f=new Float32Array(o*12),g=0;for(let m=0;mthis._range(_,m,b,d),d.visible=!1,this.root.add(d),_}_chunk(t,e,n,s,r,o){let a=new Es;a.instanceCount=1,a.setAttribute("q",Tn(s.q,4)),a.setAttribute("normal",Tn(s.o,2,!0)),s.uv&&a.setAttribute("uv",Tn(s.uv,2)),a.setAttribute("slotBase",Tn(new Float32Array([n]),1,!1,ei)),a.setIndex(Tn(s.index,1));let l=Af(this._boxes,e);a.boundingSphere=new We(new L(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 _e(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 gi(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=tl(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]&&!Zv(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&&(dh(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:xh(new Ss({side:Ne}),this.slotUniforms,n),wire:xh(new Ss({side:Ne,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 He(s),e.colorSpace=Te,e.wrapS=e.wrapT=fs,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}_colorOf(t){if(t>=this._bucketOf.length){let e=this._pointMaterials[t-this._bucketOf.length];return this._meta.materials[e].color.map(n=>Math.round(n*255))}return this._highlight[t]?Hv:this._tint.get(t)??(this._mode==="white"?Vv:this._buckets[this._bucketOf[t]].bytes)}_applyColor(t){let e=this._slotOf[t];e!==Fr&&(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===Fr)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._dirtyCountvh)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 Mh(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 sl=class{constructor(t){this.root=new Re,this._objects=[];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;o0?t:null}setOpacity(t){for(let e of this._objects)e.material.opacity=t,e.material.transparent=t<1}};function Kv(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 jv={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.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.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.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.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"}},ri=(globalThis.navigator?.language??"").toLowerCase().startsWith("ru")?"ru":"en",zr=new Intl.NumberFormat(ri).format;function $(i,t=ri){let e=jv[t][i];if(e===void 0)throw new Error(`Missing UI string '${i}'.`);return e}var Rf=new L(0,0,1),rl=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 Le().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(ae.clamp(c.z,-1,1)),u=ae.clamp(s*r,d-rl,d+rl);l(new Le().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 Qv=.85,ty=100/3;function Df(i,t,e){let n=i*(t===1?ty:t===2?e:1);return ae.clamp(Qv**(-n/100),.5,2)}var Sh=(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=ae.euclideanModulo(o-r+Math.PI,2*Math.PI)-Math.PI,l=(_,m)=>_+(m-_)*e,c=r+a*e,h=ae.clamp(l(n.elevation,s.elevation),-rl,rl),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 L(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 Le().setFromUnitVectors(s,r),c=e.clone().applyQuaternion(l),h=new L().setFromMatrixColumn(new Yt().lookAt(t.position,t.target,n),1),d=r.dot(new L().crossVectors(c,h)),u=Math.atan2(Math.abs(d)<1e-9?0:d,c.dot(h)),f=new Le;return g=>{f.identity().slerp(l,g);let _=s.clone().applyQuaternion(f),m=i.target.clone().lerp(t.target,g),p=_.clone().multiplyScalar(ae.lerp(o,a,g)).add(m),b=e.clone().applyQuaternion(f).applyAxisAngle(_,u*g);return{position:p,target:m,up:b}}}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(ae.clamp(e.z/n,-1,1)):0,azimuth:s>1e-9*Math.max(n,1e-12)?Math.atan2(e.y,e.x):null}}var ey=.005,ny=new L(1,-1,.8).normalize(),Eh=.01,Ff=1e-6,iy=64,Bf=1.05,sy=5e3,wh=(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 le(new L(...i.min),new L(...i.max));if(n.isEmpty())return!0;let s=new L;for(let r of t??[])for(let o of Ir(r)){if(!e(o))return!0;n.expandByPoint(s.fromArray(o))}return n.getSize(s).length()*Bf>Eh*sy}var ol=class extends EventTarget{constructor(t,e,{pick:n=()=>null,visibleBox:s=()=>new le}={}){super(),this.dom=e,this.pick=n,this.visibleBox=s,this.target=new L,this.leftButtonMode="orbit",this._perspective=t,this._defaultFov=t.fov,this._orthographic=new zn(-1,1,1,-1),this.camera=t,this._drag=null,this._wheelPick=null,this._animation=0,this._overlay=null,this._bounds=null,this._extraBounds=new Map,e.style.touchAction="none",e.addEventListener("pointerdown",r=>this._down(r)),e.addEventListener("pointermove",r=>this._move(r)),e.addEventListener("pointerup",r=>this._up(r)),e.addEventListener("pointercancel",()=>this._end()),e.addEventListener("lostpointercapture",r=>this._lostCapture(r)),window.addEventListener("blur",()=>this._end()),e.addEventListener("wheel",r=>this._wheel(r),{passive:!1}),e.addEventListener("contextmenu",r=>r.preventDefault())}setLeftButtonMode(t){if(t!=="orbit"&&t!=="pan")throw new RangeError(`Unknown left button mode: ${t}`);this.leftButtonMode=t}setProjection(t){if(t!=="perspective"&&t!=="orthographic")throw new RangeError(`Unknown projection: ${t}`);let e=t==="perspective"?this._perspective:this._orthographic,n=this.camera;if(e!==n){this._stopAnimation(),e.position.copy(n.position),n.isOrthographicCamera&&e.position.sub(this.target).divideScalar(n.zoom).add(this.target),e.zoom=1,e.quaternion.copy(n.quaternion),e.up.copy(n.up),n.parent?.add(e),n.parent?.remove(n);for(let s of[...n.children])e.add(s);this.camera=e,this.resize()}}resize(){let t=this.camera,e=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),n=Math.max(t.position.distanceTo(this.target),1e-6);if(t.isPerspectiveCamera)t.aspect=e;else{let r=n*Math.tan(ae.degToRad(this._perspective.fov/2));Object.assign(t,{top:r,bottom:-r,left:-r*e,right:r*e})}let s=this._rangeSphere();if(s){let r=s.center.clone().sub(t.position),o=new L(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(Eh,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 le;for(let n of this._extraBounds.values())e.union(n);return e.getBoundingSphere(new We)}invalidateBounds(){this._bounds=null}_visibleBounds(){if(!this._bounds){let t=this.visibleBox();this._bounds={box:t,sphere:t.isEmpty()?null:t.getBoundingSphere(new We)}}return this._bounds.sphere&&this._bounds}fitBox(t,e=!0){if(t.isEmpty())return;let n=t.getBoundingSphere(new We),s=Math.max(n.radius,.001),r=ae.degToRad(this._perspective.fov/2),o=this.dom.clientWidth/Math.max(this.dom.clientHeight,1),a=s/Math.sin(Math.min(r,Math.atan(Math.tan(r)*o))),l=this.camera.position.clone().sub(this.target);l.lengthSq()<1e-12&&l.copy(ny);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 L(...t),a=new L(...e);if(this.resetCameraStyle(),!n){this.animateTo({position:o,target:a});return}this._stopAnimation(),this.camera.up.fromArray(n),this._perspective.fov=s??this._defaultFov;let l=Math.max(o.distanceTo(a),1e-6);this.camera.zoom=r==null?1:2*l*Math.tan(ae.degToRad(this._perspective.fov/2))/r,this._set(o,a)}animateTo({position:t,target:e,zoom:n=1,overPole:s=!1},r=400){this._stopAnimation();let o={position:this.camera.position.clone(),target:this.target.clone()},a={position:t??o.position,target:e??o.target},l=this.camera.zoom,c=s?Uf(o,a,new L(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),g=f*f*(3-2*f),_=c(g);this.camera.isOrthographicCamera&&(this.camera.zoom=ae.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.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,ey);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 L))}let r=n.isPerspectiveCamera?2*this._drag.depth*Math.tan(ae.degToRad(n.fov/2))/(s*n.zoom):(n.top-n.bottom)/n.zoom/s,o=new L(1,0,0).applyQuaternion(n.quaternion),a=new L(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=Sh(e.down.x,n.x);this.dispatchEvent(wh("boxselect",{rect:s,mode:r,ctrl:t.ctrlKey,shift:t.shiftKey}))}else!e.moved&&e.button===0?this.dispatchEvent(wh("click",{x:n.x,y:n.y,button:0,ctrl:t.ctrlKey,shift:t.shiftKey})):!e.moved&&e.button===2&&this.dispatchEvent(wh("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:Sh(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=iy*Math.max(r,.001);if(n.isOrthographicCamera){let{left:_,top:m,width:p,height:b}=this.dom.getBoundingClientRect();if(!p||!b)return;let E=ae.clamp(n.zoom/e,Math.max(1e-6,Math.min(n.zoom,s/o)),1e6);if(E===n.zoom)return;let v=new L((2*(t.clientX-_)/p-1)*n.right,(1-2*(t.clientY-m)/b)*n.top,0).multiplyScalar(1/n.zoom-1/E).applyQuaternion(n.quaternion);n.zoom=E,this._set(n.position.clone().add(v),this.target.clone().add(v));return}this._wheelPick||(this._wheelPick={point:this._anchor(t.clientX,t.clientY)},requestAnimationFrame(()=>this._wheelPick=null));let a=n.getWorldDirection(new L),l=this._gestureDepth(this._wheelPick.point,a);if(!Number.isFinite(l))return;let c=Math.min(Eh,Math.max(Ff,r)),h=ae.clamp(l*e,c,Math.max(l,o))/l;if(h===1)return;let d=n.position.clone().addScaledVector(a,l),u=this._wheelPick.point,f=u&&u.clone().sub(n.position).dot(a)>=c?u:d,g=Lf(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 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 Bs(i){i.preventDefault(),i.stopPropagation()}function al(i){Bs(i);let t=i.button===2,e=()=>{window.removeEventListener("pointerup",n,!0),setTimeout(()=>{window.removeEventListener("click",Bs,!0),t&&window.removeEventListener("contextmenu",Bs,!0)})},n=s=>{Bs(s),e()};window.addEventListener("pointerup",n,!0),window.addEventListener("click",Bs,!0),t&&window.addEventListener("contextmenu",Bs,!0)}function kr(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=>``,zf='',ne={model:Me(''),views:Me(''),sections:Me(''),clashes:Me(''),bcf:Me(''),timeliner:Me(''),links:Me(''),orbit:Me(''),pan:Me(''),fit:Me(''),projection:Me(zf),plane:Me(''),box:Me(`${zf}`),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 Hr=new L(0,0,1),cn={right:new L(1,0,0),left:new L(-1,0,0),back:new L(0,1,0),front:new L(0,-1,0),top:new L(0,0,1),bottom:new L(0,0,-1)},ry={right:Hr,left:Hr,back:Hr,front:Hr,top:cn.back,bottom:cn.front},qi=.7,oy=ae.degToRad(1),kf=.01,Hf=96,ll=1.75;function Vf(i){let t=i.split("-"),e=new L;for(let n of t){if(!Object.hasOwn(cn,n))throw new RangeError(`Unknown view cube region: ${i}`);e.add(cn[n])}if(new Set(t).size!==t.length||e.lengthSq()!==t.length)throw new RangeError(`Unknown view cube region: ${i}`);return e.normalize()}function ay(i){let t=[];return Math.abs(i.z)>=qi&&t.push(i.z>0?"top":"bottom"),Math.abs(i.y)>=qi&&t.push(i.y>0?"back":"front"),Math.abs(i.x)>=qi&&t.push(i.x>0?"right":"left"),t.join("-")}function Th(i,t=oy){let e=i.clone().normalize(),n=Math.cos(t);return Object.keys(cn).find(s=>e.dot(cn[s])>=n)??null}function Gf(i){let t=new L(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(cn[s])));return e.find(s=>t.dot(cn[s])>=n-1e-9)}function Ah(i,t){return cn[Gf(t)].clone().multiplyScalar(Math.sin(kf)).addScaledVector(cn[i],Math.cos(kf))}function ly(i,t){let e=Th(i);if(!e)return null;let n=e==="top"||e==="bottom";if(t==="left"||t==="right")return(n?Ah(e,i):Vf(e)).applyAxisAngle(Hr,t==="right"?Math.PI/2:-Math.PI/2);if(t!=="up"&&t!=="down")throw new RangeError(`Unknown arrow: ${t}`);if(!n)return Ah(t==="up"?"top":"bottom",i);let s=cn[Gf(i)];return t==="up"==(e==="top")?s.clone().negate():s.clone()}function cy(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 sr(e);return r.colorSpace=Te,r}var cl=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 ti,this.camera=new zn(-ll,ll,ll,-ll,.1,10),this.faces=new Re;let s=getComputedStyle(t).fontFamily;for(let[l,c]of Object.entries(cn)){let h=$(`face.${l}`),d=new _e(new Mn(2,2),new Ke({map:cy(h,s)})),u=ry[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 yn(new zi(new dn(2,2,2)),new an({color:"#5b6575"}));this.highlight=new _e(new dn(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 kn,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?Ah(c,n.camera.position.clone().sub(n.target)):Vf(c))}),this.arrows=["up","down","left","right"].map(l=>{let c=Qe("ioviewer-viewcube-arrow",ne.chevron,$(`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",ne.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 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=Th(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 Xt((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?ay(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(cn[l]),new L),n=a=>a===0?[-qi,qi]:a>0?[qi,1.02]:[-1.02,-qi],[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=ly(n,t);if(!s)return;let r=Th(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 hy=` +#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=` #include -${Nr} +#ifdef IO_PICK_POINTS +uniform uint pointIndex; +uniform float pointSize; +flat varying uint vPoint; +flat varying uint vVertex; +#else +${Ur} +varying vec2 vSlot; +#endif #include #include varying vec3 vPos; -varying vec2 vSlot; -#ifdef IO_PICK_DEPTH +#if defined( IO_PICK_DEPTH ) && !defined( IO_PICK_POINTS ) varying float vViewDepth; #endif void main() { - ${Ur} + #ifdef IO_PICK_POINTS + vec3 transformed = position; + gl_PointSize = pointSize; + vPoint = pointIndex; + vVertex = uint( gl_VertexID ); + #else + ${Fr} vec3 transformed = slotPosition; + #endif #include #include #include - #ifdef IO_PICK_DEPTH + #if defined( IO_PICK_DEPTH ) && !defined( IO_PICK_POINTS ) vViewDepth = -mvPosition.z; #endif vec4 wp = vec4( transformed, 1.0 ); @@ -4276,51 +4290,76 @@ void main() { wp = instanceMatrix * wp; #endif vPos = ( modelMatrix * wp ).xyz; + #ifdef IO_PICK_POINTS + if ( pointSize <= 0.0 ) 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 ); -}`,uy=` + #endif +}`,dy=` #include #include #include varying vec3 vPos; +#ifdef IO_PICK_POINTS +flat varying uint vPoint; +flat varying uint vVertex; +#else varying vec2 vSlot; #ifdef IO_PICK_DEPTH varying float vViewDepth; #endif +#endif void main() { #include #include - float id = floor( vSlot.x + 0.5 ) * 4096.0 + floor( vSlot.y + 0.5 ) + 1.0; + #ifdef IO_PICK_POINTS + uint id = 0x80000000u | vPoint; + float sampleId = -float( vPoint + 1u ); + #else + float sampleId = floor( vSlot.x + 0.5 ) * 4096.0 + floor( vSlot.y + 0.5 ) + 1.0; + uint id = uint( sampleId ); + #endif #if defined( IO_PICK_DEPTH ) + #ifdef IO_PICK_POINTS + uint bits = vVertex; + #else uint bits = floatBitsToUint( vViewDepth ); - uvec4 bytes = ( uvec4( bits ) >> uvec4( 0u, 8u, 16u, 24u ) ) & 255u; - gl_FragColor = vec4( bytes ) / 255.0; + #endif #elif defined( IO_PICK_RGBA8 ) - gl_FragColor = vec4( mod( id, 256.0 ), mod( floor( id / 256.0 ), 256.0 ), mod( floor( id / 65536.0 ), 256.0 ), floor( id / 16777216.0 ) ) / 255.0; + uint bits = id; #else - gl_FragColor = vec4( vPos, id ); + gl_FragColor = vec4( vPos, sampleId ); + #endif + #if defined( IO_PICK_DEPTH ) || defined( IO_PICK_RGBA8 ) + 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 Rh(i,t){let e=new qe({vertexShader:hy,fragmentShader:uy,uniforms:i,defines:t?{[t]:""}:{},side:Ne,clipping:!0});return e.index0AttributeName="q",e}var hl=class{constructor(t,e,n,s={}){this.renderer=t,this.scene=e,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",o=>{o.detail.kind!=="appearance"&&(this._last=this._lastTile=null)});let r=e.slotUniforms;this._float=s.pickFloat!==!1&&t.extensions.has("EXT_color_buffer_float"),this._float?(this._material=Rh(r,null),this._target=new Ve(1,1,{type:Ye}),this._pixel=new Float32Array(4)):(this._material=Rh(r,"IO_PICK_RGBA8"),this._depthMaterial=Rh(r,"IO_PICK_DEPTH"),this._target=new Ve(1,1),this._pixel=new Uint8Array(4))}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&&ry===a[S]))return c.tile;let h=n*2+1;(!this._measure||this._measure.target.width!==h)&&(this._measure?.target.dispose(),this._measure={target:new Ve(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=(y,S)=>{let A=Math.floor(y)-g,x=Math.floor(S)-_;return A>=0&&A=0&&x(this._float?Math.round(u[y*4+3]):p.getUint32(y*4,!0))-1,E=b(m(r,o)),v=null;if(E>=0){f&&this._render(this._depthMaterial,g,_,s,d,f);let y=f&&new DataView(f.buffer),S=l.matrixWorldInverse.elements.slice(),A=F=>{if(y)return y.getFloat32(F*4,!0);let I=F*4;return-(S[2]*u[I]+S[6]*u[I+1]+S[10]*u[I+2]+S[14])},x=m(r,o),T=this._float?new L().fromArray(u,x*4):this._depthPoint(r,o,s,A(x)),C=new Set([E]),D=this.scene.slotElement(E);if(D>=0)for(let F=0;F=0&&!C.has(I)&&this.scene.slotElement(I)===D&&C.add(I)}let U=l.isPerspectiveCamera;v={rect:s,point:T,element:D,slots:C,depthAt(F,I,B){let G=m(F,I),q=G<0?-1:b(G);if(q<0)return 1/0;if(q!==B)return A(G);let O=k=>U?1/A(k):A(k),N=O(G);function z(k,K,lt){let ht=Math.sign(lt),at=m(F+ht*k,I+ht*K);if(at>=0&&b(at)===q)return(O(at)-N)*Math.abs(lt);let Y=m(F-ht*k,I-ht*K);return Y>=0&&b(Y)===q?(N-O(Y))*Math.abs(lt):0}let W=N+z(1,0,F-Math.floor(F)-.5)+z(0,1,I-Math.floor(I)-.5);return W>0?U?1/W:W:A(G)}}}return this._lastTile={camera:l,key:a.slice(),radius:n,tile:v},this._last={camera:l,key:this._lastTile.key,hit:v},v}_pick(t,e,n){let s=this._render(this._material,t,e,n),r=(this._float?Math.round(s[3]):new Uint32Array(s.buffer)[0])-1;if(r<0)return null;let o=this.scene.slotElement(r);if(this._float)return{element:o,point:new L(s[0],s[1],s[2])};let a=this._render(this._depthMaterial,t,e,n);return{element:o,point:this._depthPoint(t,e,n,new DataView(a.buffer).getFloat32(0,!0))}}_depthPoint(t,e,n,s){let r=this.camera,o=new L((t+.5)/n.width*2-1,1-(e+.5)/n.height*2,-1).applyMatrix4(r.projectionMatrixInverse);return r.isPerspectiveCamera?o.multiplyScalar(-s/o.z):o.z=-s,o.applyMatrix4(r.matrixWorld)}_render(t,e,n,s,r=this._target,o=this._pixel){let{renderer:a,camera:l}=this,c={target:a.getRenderTarget(),color:a.getClearColor(new Vt),alpha:a.getClearAlpha()},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{a.setRenderTarget(r),a.setClearColor(0,0),this.scene.withMaterial(t,()=>a.render(this.scene.root,l),{pickCamera:l}),a.readRenderTargetPixels(r,0,0,r.width,r.height,o)}finally{a.setRenderTarget(c.target),a.setClearColor(c.color,c.alpha),l.clearViewOffset()}return o}};var ul=33.333333333333336,dy=200,Xf=1e6,fy=20,dl=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,dy)))}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>ul*1.1?(this._refine=!1,this._fastFrames=0):this._refine||(this._fastFrames=this.minPixels>0&&t=fy),this._cost>ul*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 An,Os,fl,pl=class extends EventTarget{constructor(){super(...arguments);Ll(this,Os);Ll(this,An,new Set)}get size(){return hi(this,An).size}has(e){return hi(this,An).has(e)}values(){return hi(this,An).values()}set(e){eu(this,An,new Set(e)),Zr(this,Os,fl).call(this)}toggle(e){hi(this,An).delete(e)||hi(this,An).add(e),Zr(this,Os,fl).call(this)}clear(){hi(this,An).size!==0&&(hi(this,An).clear(),Zr(this,Os,fl).call(this))}};An=new WeakMap,Os=new WeakSet,fl=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 Yt().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse).elements,{left:s,top:r,width:o,height:a}=e,l=new le,c=[];for(let h=0;hn===l?r(l):o(l));let m=[...t.children].find(y=>$f.indexOf(y.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 b=Qe("ioviewer-panel-close",ne.close,$("close"));b.addEventListener("click",()=>r(l));let E=et("header","ioviewer-panel-header");E.append(et("h2","",h),b);let v=et("div","ioviewer-panel-body");p.append(E,v),i.append(p),e.set(l,{button:_,panel:p,onClose:f}),d(v)}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",$(`group.${a.id}`));let c=et("div","ioviewer-toolbar-row");for(let h of a.items){let d=Qe("ioviewer-tool",ne[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 py="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?.(py))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","",$("filters.title")),a=et("div","ioviewer-filter-fields"),l=new Map(t.map(({id:y,name:S})=>[y,S||`#${y}`])),c=y=>y.modelId??t[0]?.id??null,h=y=>y.levelId??(y.level||null),d=y=>y.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 y of u)y.select&&(y.select.selectedIndex=0);e.value="",n(),e.focus()});let b=et("button","ioviewer-text-button",$("filters.isolate"));b.type="button",b.addEventListener("click",s),m.append(p,b),r.append(o,a,m);function E(){if(r.open){r.removeEventListener("toggle",E);for(let y of i){let S=c(y),A=l.get(S)??(S==null?"":`#${S}`);S!=null&&f.labels.set(S,A);let x=h(y);if(!g.labels.has(x)){let C=y.level||(x==null?$("filters.noLevel"):`#${x}`);g.labels.set(x,x!=null&&t.length>1&&A?`${C} \xB7 ${A}`:C)}let T=d(y);_.labels.set(T,T||$("noCategory"))}for(let y of u){if(!y.labels.size)continue;let S=new Map;for(let C of y.labels.values())S.set(C,(S.get(C)??0)+1);let A=[...y.labels].map(([C,D])=>[C,S.get(D)>1?`${D} (#${C})`:D]);A.sort((C,D)=>C[1].localeCompare(D[1])),y.keys=A.map(([C])=>C);let x=y.select=et("select");x.append(new Option($("filters.all"),""));for(let[C,[,D]]of A.entries())x.append(new Option(D,String(C+1)));x.addEventListener("change",n);let T=et("label","ioviewer-filter-field");T.append(et("span","",y.name),x),a.append(T)}}}r.addEventListener("toggle",E);function v(){return u.filter(y=>y.select?.selectedIndex>0)}return{element:r,predicate(){let y=v().map(({select:S,keys:A,key:x})=>({key:x,value:A[S.selectedIndex-1]}));return y.length?S=>y.every(({key:A,value:x})=>A(S)===x):null},update(y,S){let A=v().length;o.textContent=A?`${$("filters.title")} (${A})`:$("filters.title"),p.disabled=!A&&!y,b.disabled=!S}}}var Ri=24,my=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 gy(i){let t=null;return e=>{let n=e.trim().toLowerCase();t??(t=i.map(r=>`${r.name??""} +}`,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??""} ${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=_y(t),l=new Int32Array(t.length);a.forEach((k,K)=>k.indices.forEach(lt=>l[lt]=K));let c=new Uint8Array(a.length),h=new Int32Array(a.length),d=new Uint32Array(a.length),u=gy(t),f="",g=!1,_=new Int32Array(0),m=0,p=-1,b=null,E=!1,v=et("input","ioviewer-tree-search");v.type="search",v.placeholder=$("searchPlaceholder"),v.setAttribute("aria-label",$("searchPlaceholder"));let y=et("div","ioviewer-tree");y.setAttribute("role","tree"),y.setAttribute("aria-label",$("panel.model")),y.setAttribute("aria-multiselectable","true"),y.tabIndex=-1;let S=et("div","ioviewer-tree-spacer");S.setAttribute("role","presentation"),y.append(S);let A=et("div","ioviewer-tree-empty",$("noMatches")),x=Qf(t,e,v,N,()=>s.isolate(_));i.append(x.element,v,y,A);function T(){let k=_[m],K=x.predicate();if(g=!!(f||K),g){let ht=f?u(f):t.keys();if(K){let at=[];for(let Y of ht)K(t[Y])&&at.push(Y);_=Int32Array.from(at)}else _=Int32Array.from(ht)}else{let ht=a.length;a.forEach((Y,tt)=>c[tt]&&(ht+=Y.indices.length)),_=new Int32Array(ht);let at=0;a.forEach((Y,tt)=>{if(h[tt]=at,_[at++]=-(tt+1),c[tt])for(let dt of Y.indices)_[at++]=dt})}let lt=_.indexOf(k);m=lt>=0?lt:0,S.style.height=`${_.length*Ri}px`,A.hidden=_.length>0||!g,x.update(f,!!s.isolate&&g&&_.some(ht=>s.instancesOf(ht).length>0)),C()}function C(k=y.contains(document.activeElement)){let K=y.clientHeight;if(K===0||_.length===0){S.replaceChildren();return}let lt=y.scrollTop,{start:ht,end:at}=Ih(lt,Ri,K,_.length,my);!k&&(m=at)&&(m=Math.min(_.length-1,Math.floor(lt/Ri)));let Y=[];m=at&&Y.push(D(m)),S.replaceChildren(...Y),k&&S.querySelector('[tabindex="0"]')?.focus({preventScroll:!0})}function D(k){let K=_[k],lt=K<0?-K-1:l[K],ht=K<0?d[lt]===a[lt].indices.length:n.has(K),at=et("div","tree-row");if(at.style.top=`${k*Ri}px`,at.style.height=`${Ri}px`,at.dataset.row=k,at.tabIndex=k===m?0:-1,at.setAttribute("role","treeitem"),at.classList.toggle("selected",ht),at.setAttribute("aria-selected",String(ht)),K<0){at.classList.add("tree-category"),at.setAttribute("aria-level","1"),at.setAttribute("aria-posinset",String(lt+1)),at.setAttribute("aria-setsize",String(a.length)),at.setAttribute("aria-expanded",String(!!c[lt]));let Y=et("span","tree-chevron");Y.innerHTML=ne.chevron;let{name:tt,indices:dt}=a[lt];at.append(Y,et("span","tree-name",tt||$("noCategory")),et("span","tree-count",zr(dt.length)))}else{let Y=t[K];at.classList.add("tree-element"),at.setAttribute("aria-level",g?"1":"2"),at.setAttribute("aria-posinset",String(g?k+1:k-h[lt])),at.setAttribute("aria-setsize",String(g?_.length:a[lt].indices.length)),at.classList.toggle("tree-child",!g),at.classList.toggle("tree-hidden",s.isVisible?.(K)===!1),at.append(et("span","tree-name",Y.name||`#${Y.id}`),et("span","tree-type",Y.type??""))}return at}function U(k){let K=y.clientHeight;if(K===0){p=k;return}let lt=k*Ri;lty.scrollTop+K&&(y.scrollTop=lt+Ri-K)}function F(k){m=k,U(k),C(!0)}function I(k){let K=l[k];!g&&!c[K]&&(c[K]=1,T());let lt=_.indexOf(k);lt>=0&&(y.contains(document.activeElement)||(m=lt),U(lt)),C()}function B(k){E=!0;try{n.set(k)}finally{E=!1}}function G(k,K){let lt=_.indexOf(b);lt<0&&(lt=k,b=_[k]);let ht=_.subarray(Math.min(lt,k),Math.max(lt,k)+1).filter(at=>at>=0);ht.length>0&&B(K?[...n.values(),...ht]:ht)}function q(k){b=k;let K=-k-1,lt=k<0?a[K].indices:[k],ht=k<0?d[K]===lt.length:n.has(k),at=new Set(n.values());for(let Y of lt)ht?at.delete(Y):at.add(Y);B(at)}function O(k,K,lt){k>=0&&!n.has(k)&&(b=k,B([k]));let ht=k>=0?k:n.values().next().value??null;o(K,lt,ht,()=>{let at=_.indexOf(k);at>=0?F(at):v.focus()})}v.addEventListener("focus",()=>{S.firstElementChild||W()});function N(){f=v.value.trim(),y.scrollTop=0,p=-1,m=-1,T()}v.addEventListener("input",N),y.addEventListener("scroll",()=>C()),y.addEventListener("focusin",k=>{let K=k.target.closest(".tree-row");!K||K.tabIndex===0||(S.querySelector('[tabindex="0"]')?.setAttribute("tabindex","-1"),m=Number(K.dataset.row),K.tabIndex=0)}),y.addEventListener("keydown",k=>{let K=k.target.closest(".tree-row");if(!K||k.ctrlKey||k.altKey||k.metaKey)return;let lt=Number(K.dataset.row),ht=_[lt];if(Ch(k)){if(k.preventDefault(),!k.repeat){let{left:Y,bottom:tt}=K.getBoundingClientRect();O(ht,Y,tt)}return}if(k.key===" "){k.preventDefault(),k.repeat||(k.shiftKey?G(lt,!1):q(ht));return}if(k.shiftKey)return;let at=lt;switch(k.key){case"ArrowUp":at=Math.max(0,lt-1);break;case"ArrowDown":at=Math.min(_.length-1,lt+1);break;case"Home":at=0;break;case"End":at=_.length-1;break;case"ArrowRight":ht<0&&(c[-ht-1]?at=lt+1:(c[-ht-1]=1,T()));break;case"ArrowLeft":ht>=0&&!g?at=h[l[ht]]:ht<0&&c[-ht-1]&&(c[-ht-1]=0,T());break;case"Enter":k.repeat||z(ht);break;default:return}k.preventDefault(),at!==lt&&F(at)});function z(k){if(k>=0){b=k,B([k]),r(k);return}c[-k-1]^=1,T()}y.addEventListener("click",k=>{let K=k.target.closest(".tree-row");if(!K)return;let lt=Number(K.dataset.row),ht=k.ctrlKey||k.metaKey;k.shiftKey?G(lt,ht):ht?q(_[lt]):z(_[lt])}),y.addEventListener("contextmenu",k=>{let K=k.target.closest(".tree-row");K&&(k.preventDefault(),O(_[Number(K.dataset.row)],k.clientX,k.clientY))});function W(){p>=0&&y.clientHeight>0&&(U(p),p=-1),C()}new ResizeObserver(W).observe(y),n.addEventListener("change",()=>{let k=-1;d.fill(0);for(let K of n.values())d[l[K]]++,k=K;if(E){C();return}b=null,k>=0?I(k):C()}),s.root?.addEventListener("change",k=>k.detail.kind==="visibility"&&C()),T()}var ep={element:["properties","hide","isolate","showAll","-","zoomTo","sectionBox","-","copyId"],empty:["showAll","fitAll","resetSections"]},xy={hide:"H",isolate:"I",showAll:"Shift+H",zoomTo:"F"},ml=4;function np(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(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(),al(c))}function a(c,h,d,u,f=null){let g=ep[c];if(!g)throw new RangeError(`Unknown menu: ${c}`);s(),n=f;for(let p of g){if(p==="-"){let v=et("div","ioviewer-menu-separator");v.setAttribute("role","separator"),t.append(v);continue}let b=e.get(p),E=et("button","ioviewer-menu-item");E.type="button",E.tabIndex=-1,E.dataset.item=p,E.setAttribute("role","menuitem"),E.setAttribute("aria-disabled",String(!b.enabled)),b.enabled||(E.title=$("menu.unavailable")),E.append(et("span","",$(`menu.${p}`)),et("kbd","",xy[p]??"")),E.addEventListener("click",()=>{b.enabled&&(s(),b.handler(u))}),t.append(E)}t.hidden=!1;let{width:_,height:m}=t.getBoundingClientRect();t.style.left=`${Math.max(ml,Math.min(h,innerWidth-_-ml))}px`,t.style.top=`${Math.max(ml,Math.min(d,innerHeight-m-ml))}px`,window.addEventListener("pointerdown",o,!0),window.addEventListener("wheel",s,!0),window.addEventListener("scroll",r,!0),window.addEventListener("resize",s),f&&t.querySelector("button")?.focus({preventScroll:!0})}t.addEventListener("keydown",c=>{if(c.key==="Tab"){s();return}if(c.key==="Escape"){c.preventDefault(),s();return}let h=[...t.querySelectorAll("button")],d=h.indexOf(document.activeElement),u;switch(c.key){case"ArrowDown":u=(d+1)%h.length;break;case"ArrowUp":u=(d+h.length-1)%h.length;break;case"Home":u=0;break;case"End":u=h.length-1;break;default:return}c.preventDefault(),h[u]?.focus({preventScroll:!0})});function l(c,{enabled:h=!0,handler:d}){let u=e.get(c);if(!u)throw new RangeError(`Unknown menu item: ${c}`);d&&(u.handler=d),u.enabled=h&&!!u.handler}return{element:t,open:a,close:s,setItem:l,get isOpen(){return!t.hidden}}}var vy=1600;function ip(i,t,e){let n=()=>i.textContent=`${$("selected")}: ${zr(t.size)} \xB7 ${$("elements")}: ${zr(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=$("truncated").replace("{meshes}",t.meshes).replace("{total}",t.totalMeshes),s=Qe("ioviewer-panel-close",ne.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 zs(i,t){let e=et("div","ioviewer-toast",t);e.setAttribute("role","status"),i.append(e),setTimeout(()=>e.remove(),vy)}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=$("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]),rp($("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=`${$("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 yy(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[b,...E]=r.values(),v=e.elementBox(b);for(let y of E)v.union(e.elementBox(y));n.zoomToBox(v)},fitAll:l},h=Zf(i);h.registerPanel("model",{icon:ne.model,title:$("panel.model"),visible:a.elements.length>0||!!e.setVisible,render:b=>tp(b,{elements:a.elements,models:a.models??[],selection:r,scene:e,openContextMenu:_,zoomToElement:E=>n.zoomToBox(e.elementBox(E))})});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=b=>{n.setLeftButtonMode(b),u.setActive("orbit",b==="orbit"),u.setActive("pan",b==="pan")};u.setHandler("orbit",()=>f("orbit")),u.setHandler("pan",()=>f("pan")),f(n.leftButtonMode),u.setHandler("fit",l),u.setHandler("projection",()=>{let b=!n.camera.isOrthographicCamera;n.setProjection(b?"orthographic":"perspective"),u.setActive("projection",b)}),u.setActive("projection",!1),document.fullscreenEnabled&&(u.setHandler("fullscreen",()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{u.setActive("fullscreen",!!document.fullscreenElement),zs(i,$("fullscreenUnavailable"))})}),document.addEventListener("fullscreenchange",()=>u.setActive("fullscreen",!!document.fullscreenElement)));let g=np(i);function _(b,E,v,y){g.open(v===null?"empty":"element",b,E,v,y)}function m(b){if(g.isOpen)return;let E=b===document.body,v=(E?n.dom:b).getBoundingClientRect(),y=E?v.left+v.width/2:v.left,S=E?v.top+v.height/2:v.bottom;_(y,S,r.values().next().value??null,()=>b.focus({preventScroll:!0}))}g.setItem("properties",{handler:b=>r.set([b])});for(let b of["hide","isolate","showAll","zoomTo","fitAll"])g.setItem(b,{handler:c[b]});g.setItem("copyId",{handler:b=>yy(String(a.elements[b].id)).then(E=>zs(i,$(E?"idCopied":"copyFailed")),()=>zs(i,$("copyFailed")))}),n.addEventListener("contextmenu",async b=>{let{x:E,y:v}=b.detail;if(o?.active)return _(E,v,r.values().next().value??null);let y=s.pick(E,v),S=y?.then?await y:y;if(S!==void 0){if(!S||S.element<0)return _(E,v,null);r.has(S.element)||r.set([S.element]),_(E,v,S.element)}});let p=[];return window.addEventListener("keydown",b=>{if(b.defaultPrevented)return;let E=jf(b);if(E){if(b.preventDefault(),E==="contextMenu")return m(document.activeElement??document.body);if(E==="escape"&&!g.isOpen){p.some(v=>v())||r.clear();return}g.close(),E!=="escape"&&c[E]?.()}}),ip(document.getElementById("ioviewer-status"),r,e.elementCount),sp(i,a.truncated),{shell:h,toolbar:u,contextMenu:g,onEscape:b=>p.push(b)}}var Ph={x:new L(1,0,0),y:new L(0,1,0),z:new L(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 we(s,-r):new we(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 we(new L(1,0,0),-n.x),new we(new L(-1,0,0),s.x),new we(new L(0,1,0),-n.y),new we(new L(0,-1,0),s.y),new we(new L(0,0,1),-n.z),new we(new L(0,0,-1),s.z)];if(e!==0){let o=i.getCenter(new L);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 L).sub(i.getCenter(new L));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 L(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 gl(i,t){let e=i.getSize(new L).multiplyScalar(.5);return Math.abs(t.x)*e.x+Math.abs(t.y)*e.y+Math.abs(t.z)*e.z}function Vr(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 _l(i,t,e){let n=new L(1,0,0).applyQuaternion(t),s=new L(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 Gr=6,My=["off","planes","box"],by=.05,Dh=new L(0,0,1),xl=class extends EventTarget{constructor(t,e,n){super(),this.scene=t,this.modelBox=e.clone(),this.center=e.getCenter(new L),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 L().fromArray(r),c=new Le().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 le(new L().fromArray(e.min),new L().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(!My.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>=Gr||this.modelBox.isEmpty())return null;let n=new Le().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 gl(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 le;for(let s of t)e.union(this.scene.elementBox(s));if(e.isEmpty())return!1;let n=e.getSize(new L);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 L);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 L),n=this.box.getSize(new L).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 le(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:ae.euclideanModulo(i+Math.PI,2*Math.PI)-Math.PI}var Nh=80,Sy=8,Bh=.8,wy=Math.sin(ae.degToRad(12)),Ci={x:"#ef4444",y:"#22c55e",z:"#3b82f6",centre:"#e2e8f0",hover:"#facc15",frame:"#93c5fd",fill:"#60a5fa"},Uh=["x","y","z"],Ey=Math.cos(ae.degToRad(12)),vl=new L(0,0,1),Ty=i=>new Ke({color:i,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9}),Ay=new Ke({visible:!1});function yl(i,t,e,n){let s=new Re,r=Ty(t);for(let a of e)s.add(new _e(a,r));let o=new _e(n,Ay);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=yl("rotate",Ci[t],[e(new bs(Bh,.018,8,64))],e(new bs(Bh,.09,8,48)));return n.name=i,n.userData.axis=t,n}var Ml=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 kn,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(vl.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)*Sy)}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 L):e.clone().sub(n.position).normalize();return Math.abs(t.dot(s))new L(r/2,o/2,0))),n=new Ke({color:Ci.fill,transparent:!0,opacity:.12,side:Ne,depthWrite:!1}),s=new an({color:Ci.frame});this.planeVisuals=Array.from({length:Gr},()=>{let r=new Re;return r.add(new _e(t,n),new nr(e,s)),this.group.add(r),r})}_buildPlaneGizmo(){let t=(n,s)=>n.rotateX(Math.PI/2).translate(0,0,s),e=yl("move",Ci.z,[t(new Oi(.025,.025,1),.5),t(new or(.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 yn(new zi(new dn(1,1,1)),new an({color:Ci.frame})),this.group.add(this.boxWire);let t=new On(1,16,12),e=new On(1.6,8,6);this.boxHandles=[];for(let s of Uh)for(let r of[-1,1]){let o=yl("face",Ci[s],[t],e);o.name=`face${r>0?"+":"-"}${s}`,Object.assign(o.userData,{axis:s,sign:r,normal:new L}),this.boxHandles.push(o)}let n=yl("centre",Ci.centre,[new dn(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=_l(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 L),o=s.getSize(new L);this.boxWire.position.copy(r),this.boxWire.scale.copy(o).max(new L(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(vl,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 L));return 2*Math.max(s,e.near)*Math.tan(ae.degToRad(e.fov/2))/n}_ray(t){let e=this.dom.getBoundingClientRect(),n=new Xt((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),_=Vr(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?vl:new L().setComponent(Uh.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 Py(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 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 -${Nr} +${Ur} #include uniform highp sampler2D closedSlots; void main() { - ${Ur} + ${Fr} vec3 transformed = slotPosition; #include #include - ${_h} + ${xh} 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 bl=class{constructor(t,e,n,s){this.model=t,this.sections=e,this.data=n,this.drawStencils=s,this._farSide=new we,this._surface=new _e(new Mn(1,1),new Ke({color:Cy,side:Ne,forceSinglePass:!0,stencilWrite:!0,stencilFunc:Dc,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(Ry,f.normal);let m=_l(s.modelBox,this._surface.quaternion,f.coplanarPoint(new L));this._surface.position.copy(m.center),this._surface.scale.set(m.width,m.height,1),h.clippingPlanes=l.filter((p,b)=>b!==g),t.render(this._surface,n)}),t.render(e,n)}finally{t.autoClear=d}}};function Wr(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 Ly(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",ne.flip,$("sections.flip"));s.addEventListener("click",()=>i.updatePlane(t,{flipped:!i.planes[t].flipped}));let r=Oh($("sections.enabled"),h=>i.updatePlane(t,{enabled:h})),o=Qe("ioviewer-icon-button",ne.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 gp({root:i,shell:t,toolbar:e,contextMenu:n,sections:s,selection:r,canFill:o}){let a="z",l=()=>{s.addPlane(a)===null&&(s.setMode("planes"),zs(i,$("sections.maxPlanes")))},c=()=>[...r.values()],h=()=>s.fitBoxToElements(c()),d=Wr($("sections.mode"),[["planes",$("sections.planes")],["box",$("sections.box")],["off",$("sections.off")]],I=>s.setMode(I)),u=Wr($("sections.axis"),["x","y","z"].map(I=>[I,I.toUpperCase()]),I=>u.update(a=I));u.update(a);let f=et("button","ioviewer-text-button",$("sections.addPlane"));f.type="button",f.addEventListener("click",l);let g=et("ul","ioviewer-section-list"),_=et("div","ioviewer-section-empty",$("sections.noPlanes")),m=et("div","ioviewer-section-block"),p=et("div","ioviewer-section-row");p.append(et("span","",$("sections.axis")),u.element,f),m.append(p,g,_);let b=Wr($("sections.box"),[["keepInside",$("sections.keepInside")],["cutInside",$("sections.cutInside")]],I=>s.setBoxMode(I)),E=et("button","ioviewer-text-button",$("sections.fitSelection"));E.type="button",E.addEventListener("click",h);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 y=et("span");y.setAttribute("aria-hidden","true");let S=et("label","ioviewer-section-row");S.append(et("span","",$("sections.boxYaw")),v,y);let A=et("div","ioviewer-section-block");A.append(b.element,S,E);let x=Oh($("sections.showGizmo"),I=>s.setGizmoVisible(I)),T=Oh($("sections.fill"),I=>s.setFill(I));o||(T.element.title=$("sections.fillUnavailable"));let C=[],D=()=>{d.update(s.mode),m.hidden=s.mode!=="planes",A.hidden=s.mode!=="box",f.disabled=s.planes.length>=Gr,C.length!==s.planes.length&&(C=s.planes.map((B,G)=>Ly(s,G)),g.replaceChildren(...C.map(B=>B.element))),C.forEach(B=>B.update()),_.hidden=C.length>0,b.update(s.boxMode),v.value=String(Math.round(s.boxYaw*180/Math.PI)),y.textContent=`${v.value}\xB0`,v.setAttribute("aria-valuetext",y.textContent),x.input.checked=s.gizmoVisible,T.input.checked=s.fill;let I=s.mode==="box"||s.mode==="planes"&&s.planes.some(B=>B.enabled);T.input.disabled=!o||!I,e.setActive("plane",s.mode==="planes"),e.setActive("box",s.mode==="box")},U=()=>E.disabled=r.size===0;if(t.registerPanel("sections",{icon:ne.sections,title:$("panel.sections"),visible:!s.modelBox.isEmpty(),render:I=>I.append(d.element,m,A,T.element,x.element)}),s.addEventListener("change",D),r.addEventListener("change",U),D(),U(),s.modelBox.isEmpty())return;let F=()=>t.openPanel("sections");e.setHandler("plane",()=>{l(),F()}),e.setHandler("box",()=>{(s.mode==="box"||r.size&&h()||s.fitBoxToShown())&&F()}),e.setHandler("resetSections",()=>s.reset()),n.setItem("sectionBox",{handler:I=>{s.fitBoxToElements(r.has(I)?c():[I]),F()}}),n.setItem("resetSections",{handler:()=>s.reset()})}var Dy="#facc15",Ny=9;function zh(i,t=ri){return`${new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!1}).format(i)} ${$("unit.m",t)}`}var Sl=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:Dy,depthTest:!1,depthWrite:!1,transparent:!0};this._line=new Bi(e,new an(n)),this._markers=new ni(e,new Bn({...n,size:Ny,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 le().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&&kr(this._previewMarker,this.preview.point,t,e),this.distance!==null&&kr(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,Uy=1-1e-6,Fy=8,xp={vertex:0,midpoint:1,edge:2},By=2e4;function Oy(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 wl(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 zy(i,t,e,n,s,r){let o=[0,1];if(!wl(o,e.w+e.z,n.w+n.z)||!wl(o,e.w-e.z,n.w-n.z))return[];if(!r||!s.length)return s.every(c=>wl(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)&&wl(a,-h,-d)}))return[o];let l=[];return o[0]0))return null;let m=ae.clamp(((r-c)*f+(o-h)*g)/_,0,1);return e+(n-e)*(m*a.w/((1-m)*l.w+m*a.w))}var El=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=Qa({view:this.data.readView},n);e={positions:s,...Oy(s,this.data.readView(n.indices))}}return this.cache.set(t,e),this.cache.size>Fy&&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;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(y,S,A,x){if(f&&xp[y]>xp[f.kind]||A.w<=0||A.z<-A.w||A.z>A.w)return;let[T,C]=kh(A,s);if(!(T>=0&&C>=0&&T_p**2||f?.kind===y&&D>=f.distance||y!=="edge"&&lp(S,c,h))return;let U=-(u[2]*S.x+u[6]*S.y+u[10]*S.z+u[14]);U-n.depthAt(T,C,x)>2*En+Math.abs(U)*2**-21||(f={kind:y,distance:D,point:S.clone()})}let _=By*3,m=new Yt,p=new L,b=new ge,{geometry:E,matrix:v}=this.data.meta.instances;for(let y of n.slots){let S=l.slotInstance(y),[A]=this.data.readView({t:"u32",o:E.o+S*4,n:1}),x=this.data.meta.geometries[A],T=Math.max(x.indices.n,x.positions.n/3);if(T>_)continue;_-=T;let{positions:C,vertices:D,edges:U}=this._geometry(A),F=this.data.readView({t:"f32",o:v.o+S*48,n:12});m.set(F[0],F[3],F[6],F[9],F[1],F[4],F[7],F[10],F[2],F[5],F[8],F[11],0,0,0,1);let I=new Map;for(let B of D){let G=new L().fromArray(C,B*3).applyMatrix4(m),q=new ge(G.x,G.y,G.z,1).applyMatrix4(d);I.set(B,[G,q]),g("vertex",G,q,y)}if(f?.kind!=="vertex")for(let B=0;Br.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)kr(n,s,t,e)}};var Hy=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(),al(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+Hy}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 Vy(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}){let a=x=>t.element.querySelector(`[data-tool="${x}"]`),l=a("displayMode"),c=Hh(i,l,$("group.display"));c.element.classList.add("ioviewer-display-modes");let h=et("div");h.setAttribute("role","menu"),h.setAttribute("aria-label",$("tool.displayMode")),c.element.append(h);let d=(n.textures??[]).length>0,u=bh.map(x=>{let T=et("button","ioviewer-menu-item",$(`display.${x}`));return T.type="button",T.dataset.mode=x,T.setAttribute("role","menuitemradio"),T.disabled=x==="textures"&&!d,T.addEventListener("click",()=>{f(x),c.close(),l.focus()}),h.append(T),T}),f=x=>{e.setDisplayMode(x);for(let T of u)T.setAttribute("aria-checked",String(T.dataset.mode===x))};f(Vy(n.options)),t.setHandler("displayMode",()=>{c.toggle(),c.isOpen&&h.querySelector('[aria-checked="true"]')?.focus()});let g=et("div","ioviewer-background-setting"),_=et("label","",$("display.background")),m=et("input");Object.assign(m,{type:"color",value:r}),_.append(m);let p=et("button","ioviewer-text-button",$("display.backgroundReset"));p.type="button",p.disabled=!0;let b=()=>{o(m.value),p.disabled=m.value===r};m.addEventListener("input",b),p.addEventListener("click",()=>{m.value=r,m.focus(),b()}),g.append(_,p),c.element.append(g),t.setActive("grids",s.visible),s.count>0&&t.setHandler("grids",()=>{s.setVisible(!s.visible),t.setActive("grids",s.visible)});let E=Hh(i,a("opacity"),$("tool.opacity"));E.element.classList.add("ioviewer-opacity");let v=et("input","ioviewer-opacity-slider");Object.assign(v,{type:"range",min:"10",max:"100",step:"1",value:"100"}),v.setAttribute("aria-label",$("opacity.label"));let y=et("output","ioviewer-opacity-value"),S=()=>y.textContent=$("opacity.value").replace("{value}",v.value);v.addEventListener("input",()=>{e.setOpacity(Number(v.value)/100),S()}),S();let A=et("div","ioviewer-opacity-head");return A.append(et("span","",$("opacity.label")),y),E.element.append(A,v),t.setHandler("opacity",E.toggle),[c,E]}var Gy=3e3;function Al(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(E){E.sections!=null&&s.restore(E.sections),E.hiddenElements!=null&&n.setHiddenElements(E.hiddenElements),E.visibleElements!=null&&n.isolate(E.visibleElements),E.hiddenModelKeys!=null&&o(E.hiddenModelKeys),E.selectedElements!=null&&r.set(E.selectedElements);let v=E.camera.projection==="orthographic";e.setProjection(v?"orthographic":"perspective"),t.setActive("projection",v),e.restoreViewCamera(E.camera)}function u(){d(a[c.next]),c.next=(c.next+1)%a.length;let E=()=>{e.animating?c.frame=requestAnimationFrame(E):c.timer=setTimeout(u,Gy)};c.frame=requestAnimationFrame(E)}let f=E=>h.contains(E.target),g=E=>!f(E)&&m(),_=E=>{f(E)&&(E.key==="Enter"||E.key===" ")||(E.key==="Escape"&&(E.preventDefault(),E.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),b())}function p(){c={next:0,frame:0,timer:0},window.addEventListener("pointerdown",g,!0),window.addEventListener("wheel",m,!0),window.addEventListener("keydown",_,!0),b(),u()}function b(){let E=$(c?"views.stop":"views.tour");h.replaceChildren(),h.insertAdjacentHTML("afterbegin",c?ne.pause:ne.play),h.append(et("span","",E)),h.setAttribute("aria-pressed",String(!!c))}h.addEventListener("click",()=>c?m():p()),b(),i.registerPanel("views",{icon:ne.views,title:$("panel.views"),visible:a.length>0,render:E=>{let v=et("div","ioviewer-row-list");for(let y of a){let S=Al("ioviewer-row ioviewer-view",String(y.name??""));S.addEventListener("click",()=>d(y)),v.append(S)}E.append(h,v)}}),i.registerPanel("bcf",{icon:ne.bcf,title:$("panel.bcf"),visible:l.length>0,render:E=>{let v=et("div","ioviewer-row-list");for(let y of l){let S=et("details","ioviewer-bcf-topic");S.append(et("summary","",y.title)),y.status&&S.append(et("p","ioviewer-bcf-status",y.status)),y.description&&S.append(et("p","ioviewer-bcf-description",y.description)),y.viewpoints.length||S.append(et("p","ioviewer-bcf-status",$("bcf.noView"))),y.viewpoints.forEach((A,x)=>{let T=$("bcf.viewpoint").replace("{index}",String(x+1)),C=Al("ioviewer-row ioviewer-view",T);if(C.addEventListener("click",()=>d(A)),S.append(C),A.missingComponents||A.ambiguousComponents){let D=$("bcf.components").replace("{missing}",String(A.missingComponents)).replace("{ambiguous}",String(A.ambiguousComponents));S.append(et("p","ioviewer-bcf-status",D))}}),v.append(S)}E.append(v)}})}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):Wy(t,s);r>=0&&!e.includes(r)&&e.push(r)}return e}function Wy(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 Xy=["New","Active","Reviewed","Approved","Resolved"],Vh=27,qy=8,Yy=14,$y=2,Zy=new L(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 ni(a,new Bn({...l,size:Yy,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(b,E){let v=bp(b,e);v.length?r.set(v):r.clear();let y=new L(...b.point),S=0;for(let T of v){let C=n.elementBox(T);C.isEmpty()||(S=Math.max(S,...C.getSize(new L).toArray()))}let A=s.camera.position.clone().sub(s.target);A.lengthSq()<1e-12&&A.copy(Zy);let x=Math.max(3*S,$y);s.animateTo({position:A.normalize().multiplyScalar(x).add(y),target:y}),a.attributes.position.setXYZ(0,y.x,y.y,y.z),a.attributes.position.needsUpdate=!0,o.visible=!0,h?.removeAttribute("aria-current"),h=E,d=b,E.setAttribute("aria-current","true"),s.setExtraBounds("clash",new le(y.clone(),y.clone()))}function g(b){let E=Al("ioviewer-row ioviewer-clash",String(b.name??""));E.setAttribute("title",`${b.name??""}: ${b.element1Name??""} \u2014 ${b.element2Name??""}`);let v=Xy.includes(b.status),y=et("span","ioviewer-clash-status",v?$(`clash.${b.status}`):String(b.status??""));v&&(y.dataset.status=b.status);let S=typeof b.distance=="number"?zh(b.distance):"";return E.append(y,et("span","ioviewer-clash-distance",S)),b===d&&(h=E,E.setAttribute("aria-current","true")),E.addEventListener("click",()=>f(b,E)),E}function _(b,E){let v=et("div","ioviewer-clash-test"),y=et("button","ioviewer-row ioviewer-clash-header");y.type="button",y.setAttribute("aria-expanded","true");let S=`${b.name??""} (${b.clashes.length})`;y.setAttribute("title",S),y.insertAdjacentHTML("afterbegin",ne.chevron),y.append(et("span","ioviewer-row-name",S));let A=et("div","ioviewer-clash-list");return A.style.height=`${Math.max(0,b.clashes.length*Vh-1)}px`,y.addEventListener("click",()=>{A.hidden=!A.hidden,y.setAttribute("aria-expanded",String(!A.hidden)),E()}),v.append(y,A),{box:v,list:A,clashes:b.clashes,rows:new Map}}function m({list:b,clashes:E,rows:v},{start:y,end:S}){for(let[x,T]of v)(x=S)&&(T.remove(),v.delete(x));let A=null;for(let x=S-1;x>=y;x--){let T=v.get(x);T||(T=g(E[x]),T.style.top=`${x*Vh}px`,b.insertBefore(T,A),v.set(x,T)),A=T}}function p(b){if(!t.length)return;b.classList.add("ioviewer-clashes-body");let E=t.map(y=>_(y,v));for(let y of E)b.append(y.box);function v(){let y=b.scrollTop,S=b.clientHeight,A=E.map(({list:x,clashes:T})=>S&&!x.hidden?Ih(y-x.offsetTop,Vh,S,T.length,qy):{start:0,end:0});E.forEach((x,T)=>m(x,A[T]))}b.addEventListener("scroll",v),b.addEventListener("focusin",v),new ResizeObserver(v).observe(b)}return i.registerPanel("clashes",{icon:ne.clashes,title:$("panel.clashes"),visible:t.length>0,render:p,onClose:()=>o.visible&&u()}),{group:o}}var Jy=["construct","demolish","temporary"],Ky=Date.parse("0002-01-01T00:00:00Z");function wp(i){let t=typeof i=="string"?Date.parse(i):NaN;return t>=Ky?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=Jy.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 jy=864e5,Qy=["1","5","15"],tM={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:ne.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=Qe("ioviewer-icon-button ioviewer-player-play",ne.play,$("player.play"));m.addEventListener("click",()=>h?U():D());let p=et("output","ioviewer-player-date"),b=et("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 E=Wr($("player.speed"),Qy.map(I=>[I,`${I}\xD7`]),I=>{c=Number(I),E.update(I)});E.update(String(c));let v=Qe("ioviewer-panel-close",ne.close,$("close"));v.addEventListener("click",T),_.append(m,p,b,E.element,v),i.append(_),new ResizeObserver(()=>{let I=_.hidden?0:_.offsetHeight+8;i.style.setProperty("--player-space",`${I}px`)}).observe(_);function S(){let I=Tp(r.tasks,l),B=[...f].filter(N=>!I.hidden.has(N)),G=[...I.hidden].filter(N=>!f.has(N));f=I.hidden;let q=[...g.keys()].filter(N=>I.active.get(N)!==g.get(N)),O=new Map;for(let[N,z]of I.active)g.get(N)!==z&&(O.has(z)||O.set(z,[]),O.get(z).push(N));g=I.active,B.length&&s.setLayerHidden("schedule",B,!1),G.length&&s.setLayerHidden("schedule",G,!0),q.length&&s.setTint(q,null);for(let[N,z]of O)s.setTint(z,tM[N])}function A(I){l=Math.min(Math.max(I,r.start),r.end),b.value=String(l),p.textContent=a.format(l),u&&S()}function x(){u||(u=!0,_.hidden=!1,A(r.start))}function T(){u&&(U(),u=!1,s.setTint([...g.keys()],null),g=new Map,f=new Set,s.clearLayer("schedule"),_.hidden=!0)}function C(I){A(l+Math.max(I-d,0)/1e3*c*jy),d=I,l>=r.end?U():h=requestAnimationFrame(C)}function D(){x(),!h&&(l>=r.end&&A(r.start),d=performance.now(),h=requestAnimationFrame(C),F())}function U(){cancelAnimationFrame(h),h=0,F()}function F(){let I=$(h?"player.pause":"player.play");m.innerHTML=h?ne.pause:ne.play,m.title=I,m.setAttribute("aria-label",I)}return t.registerPanel("timeliner",{icon:ne.timeliner,title:$("panel.timeliner"),render:I=>{let B=et("button","ioviewer-text-button ioviewer-player-open");B.type="button",B.insertAdjacentHTML("afterbegin",ne.play),B.append(et("span","",$("player.play"))),B.addEventListener("click",D);let G=et("div","ioviewer-row-list");for(let q of r.tasks){let O=String(q.name??""),N=et("div","ioviewer-row ioviewer-task");N.dataset.type=q.type,N.setAttribute("title",`${O} \xB7 ${$(`task.${q.type}`)}`);let z=`${o.format(q.start)} \u2013 ${o.format(q.end)}`;N.append(et("span","ioviewer-row-name",O),et("span","ioviewer-task-dates",z)),G.append(N)}I.append(B,G)}}),{open:x,close:T,play:D,pause:U,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:ne.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 Cp(i,t,e){let n=i.filter(Number.isFinite).sort((o,a)=>o-a),s=[];for(let o of n){let a=s.at(-1);!a||o-a.at(-1)>2?s.push([o]):a.push(o)}if(s.length<2||s.some(o=>o.length<2||o.at(-1)-o[0]>2))return[];let r=[Math.min(t,n[0])];for(let o=1;o({min:r[a],max:o}))}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}}var eM=new Intl.NumberFormat(ri,{maximumFractionDigits:2,minimumFractionDigits:2}),Rl=i=>`${eM.format(i)} ${$("scanMap.metres")}`;function oi(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 nM(i,t){return[i*.005,t*.005]}function iM(i,t,e){return i.set(Math.cos(e)*Math.cos(t),Math.cos(e)*Math.sin(t),Math.sin(e))}function sM(i,t,e,n,s,r,o){let a=new kn;a.setFromCamera(new Xt(n,s),i),a.ray.origin.copy(t),a.near=.05,a.params.Points.threshold=.12;let l=new L,c=new L;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 Lp(i,t,e,n,s,r){if(!e.count)return;let o=new le().setFromObject(e.root);if(o.isEmpty())return;let a=o.getSize(new L),l=o.getCenter(new L),c={x:l.x,y:l.y,side:Math.max(a.x,a.y,.01)*1.12,zoom:1},h={...c},d=R=>50+100*(R-h.x)*h.zoom/h.side,u=R=>50-100*(R-h.y)*h.zoom/h.side,f=R=>Math.min(96,Math.max(4,R)),g=(R,wt,kt=!1)=>{let P=d(wt.x),M=u(wt.y);return R.style.left=`${kt?f(P):P}%`,R.style.top=`${kt?f(M):M}%`,P>=0&&P<=100&&M>=0&&M<=100},_=t.meta.rtcOffset?.[2]??0,m=t.meta.panoramas??[],p=m.map(R=>new L(...R.position)),b=`ioviewer.scan-levels.v1:${location.pathname}`,E=()=>Cp(p.map(R=>R.z+_),o.min.z+_,o.max.z+_),v=null;try{let R=JSON.parse(localStorage.getItem(b));Array.isArray(R)&&(v=R.filter(wt=>Number.isFinite(wt?.min)&&Number.isFinite(wt.max)&&wt.max>wt.min))}catch{v=null}let y=v??E(),S=-1,A=!0,x=R=>Ip(y[S],R+_),T=document.createElement("details");T.className="ioviewer-floating ioviewer-scan-map",T.open=!matchMedia("(max-width: 600px)").matches;let C=document.createElement("summary");C.textContent=$("scanMap.title");let D=document.createElement("div");D.className="scan-map-plot";let U=document.createElement("canvas");U.width=U.height=300,U.setAttribute("role","img"),U.setAttribute("aria-label",$("scanMap.plan")),U.tabIndex=0;let F=document.createElement("span");F.className="scan-map-camera",F.setAttribute("aria-hidden","true");let I=document.createElement("span");I.className="scan-map-axes",I.textContent="Y \u2191";let B=document.createElement("span");B.className="scan-map-scale",D.append(U,F,I,B),T.append(C,D),i.append(T);let G=e.root.children.reduce((R,wt)=>R+wt.geometry.attributes.position.count,0),q=Math.max(1,Math.ceil(G/6e4)),O=e.root.children.map(R=>{let wt=R.geometry.attributes.position,kt=new Float32Array(Math.ceil(wt.count/q)*3),P=new L;for(let M=0,X=0;M{if(N=0,!T.open)return;let R=U.getContext("2d");if(!R)return;R.clearRect(0,0,300,300),R.fillStyle="rgba(160, 185, 201, .33)";for(let[P,M]of O.entries())if(e.root.children[P].visible)for(let X=0;X{N||(N=requestAnimationFrame(z))},k=new L,K=null,lt=()=>{if(K){F.hidden=!x(K.position.z),g(F,K.position,!0),F.style.rotate=`${Math.PI/2-K.yaw}rad`;return}F.hidden=!1,g(F,s.camera.position,!0),s.camera.getWorldDirection(k),F.style.rotate=`${Math.atan2(k.x,k.y)}rad`};T.addEventListener("toggle",W),n.root.addEventListener("change",R=>{R.detail.kind==="visibility"&&W()}),s.addEventListener("change",lt);let ht=document.createElement("div");ht.className="scan-map-controls";let at=document.createElement("select");at.setAttribute("aria-label",$("scanMap.size"));for(let R of["small","medium","large"])at.add(new Option($(`scanMap.${R}`),R));at.value=matchMedia("(max-width: 600px)").matches?"small":"medium",i.dataset.scanMapSize=at.value,at.addEventListener("change",()=>{i.dataset.scanMapSize=at.value});let Y=(R,wt=0,kt=0)=>{h=Pp(h,R,wt,kt),W()},tt=()=>{h={...c},W()};ht.append(at,oi($("scanMap.zoomOut"),"\u2212",()=>Y(.8)),oi($("scanMap.zoomIn"),"+",()=>Y(1.25)),oi($("scanMap.reset"),"\u21BA",tt)),T.insertBefore(ht,D),U.addEventListener("wheel",R=>{R.preventDefault();let wt=U.getBoundingClientRect();Y(R.deltaY<0?1.15:1/1.15,(R.clientX-wt.left)/wt.width-.5,(R.clientY-wt.top)/wt.height-.5)},{passive:!1});let dt;U.addEventListener("pointerdown",R=>{R.button!==0||dt||(U.setPointerCapture(R.pointerId),dt={id:R.pointerId,x:R.clientX,y:R.clientY})}),U.addEventListener("pointermove",R=>{if(dt?.id!==R.pointerId)return;let wt=h.side/(h.zoom*Math.max(1,U.clientWidth));h.x-=(R.clientX-dt.x)*wt,h.y+=(R.clientY-dt.y)*wt,dt.x=R.clientX,dt.y=R.clientY,W()}),U.addEventListener("lostpointercapture",R=>{R.pointerId===dt?.id&&(dt=void 0)}),U.addEventListener("keydown",R=>{let wt={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[R.key];if(wt){let kt=h.side/h.zoom/10;h.x+=wt[0]*kt,h.y+=wt[1]*kt,W()}else if(R.key==="+"||R.key==="="||R.key==="-")Y(R.key==="-"?.8:1.25);else if(R.key==="0")tt();else return;R.preventDefault(),R.stopPropagation()});let It=document.createElement("div");It.className="scan-map-controls";let ot=document.createElement("select");ot.setAttribute("aria-label",$("scanMap.levels"));let Tt=document.createElement("p");Tt.className="scan-map-feedback",Tt.setAttribute("role","status");function jt(){try{localStorage.setItem(b,JSON.stringify(y))}catch{Tt.textContent=$("scanMap.levelTemporary")}}function Bt(){ot.replaceChildren(new Option($("scanMap.allLevels"),"-1")),y.forEach((R,wt)=>ot.add(new Option(`${$("scanMap.level").replace("{n}",wt+1)} \xB7 ${Rl(R.min)} \u2013 ${Rl(R.max)}`,String(wt)))),ot.value=String(S),Ot.disabled=S<0;for(let[R,wt]of p.entries())Zt.options[R+1].hidden=!x(wt.z);W(),r()}ot.addEventListener("change",()=>{S=Number(ot.value),Tt.textContent="",Bt()});let ut=oi($("scanMap.addLevel"),"+",()=>{if(zt.isClosed()){let R=p.findIndex(wt=>x(wt.z));re(Math.max(0,R))}zt.pickLevel()});ut.disabled=!m.length;let Lt=oi($("scanMap.autoLevels"),$("scanMap.autoButton"),()=>{let R=E(),wt=R.filter(kt=>!y.some(P=>P.min{S<0||(y.splice(S,1),S=-1,Tt.textContent="",jt(),Bt())});if(It.append(ot,ut,Lt,Ot),m.length){let R=oi($("scanMap.spheres"),"\u25C9",()=>{A=!A,R.setAttribute("aria-pressed",String(A)),r()});R.setAttribute("aria-pressed","true"),It.append(R)}T.append(It,Tt);let zt=m.length?rM(i,t,e,re,R=>{K=R,R||ie.forEach(wt=>wt.classList.remove("current")),lt()},R=>{S=y.push(R)-1,Tt.textContent=$("scanMap.levelAdded"),jt(),Bt()}):null,Zt=document.createElement("select");Zt.setAttribute("aria-label",$("scanMap.choosePhoto"));let Ee=new Option($("scanMap.choosePhoto"),"");Ee.disabled=!0,Zt.add(Ee);let ie=[];for(let[R,wt]of m.entries()){let kt=wt.name||t.meta.elements[wt.element].name||String(R+1);Zt.add(new Option(kt,String(R)));let P=document.createElement("button");P.type="button",P.className="scan-map-station",P.title=kt,P.setAttribute("aria-label",`${$("scanMap.photo")} \xB7 ${kt}`),P.addEventListener("click",()=>re(R)),ie.push(P),D.append(P)}Zt.value="",Zt.addEventListener("change",()=>re(Number(Zt.value))),Zt.hidden=!m.length,T.append(Zt),Bt(),!v&&y.length&&jt();function re(R,wt=!1){T.open=!0,Zt.value=String(R),ie.forEach((kt,P)=>kt.classList.toggle("current",R===P)),zt.open(R,wt),Zt.value=""}return{open:re,showSphere:(R,wt)=>A&&x(wt)&&n.isVisible(R)}}function rM(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=oi($("scanMap.enlargePhoto"),$("scanMap.enlargePhoto"),()=>{let ut=o.classList.toggle("is-expanded"),Lt=$(ut?"scanMap.shrinkPhoto":"scanMap.enlargePhoto");h.textContent=h.title=Lt,h.setAttribute("aria-label",Lt),h.setAttribute("aria-pressed",String(ut))});h.setAttribute("aria-pressed","false");let d=document.createElement("button");d.type="button",d.textContent=$("close"),d.addEventListener("click",dt),c.append(h,d),a.append(l,c);let u=document.createElement("canvas");u.tabIndex=0,u.setAttribute("aria-label",$("scanMap.photoControls"));let f=document.createElement("p");f.setAttribute("role","status");let g=document.createElement("div");g.className="scan-photo-view";let _=document.createElement("span");_.className="scan-photo-crosshair",_.setAttribute("aria-hidden","true");let m=document.createElement("div");m.className="scan-photo-level",m.hidden=!0;let p=document.createElement("span");p.setAttribute("role","status"),m.append(p,oi($("scanMap.cancel"),$("scanMap.cancel"),ot)),g.append(u,_,f),o.append(a,m,g),i.append(o);let b=t.meta.panoramas.map((ut,Lt)=>{let Ot=ut.name||t.meta.elements[ut.element].name||String(Lt+1),zt=document.createElement("button");return zt.className="scan-photo-link",zt.type="button",zt.title=Ot,zt.setAttribute("aria-label",$("scanMap.goToStation").replace("{name}",Ot)),zt.hidden=!0,zt.addEventListener("click",()=>n(Lt,!0)),g.append(zt),{photo:ut,name:Ot,button:zt,position:new L(...ut.position)}}),E=t.readView(t.meta.points.element),v=new kn;v.params.Points.threshold=.12,v.near=.25;let y=new L,S=new L,A=new L,x=[],T=[],C=!1,D,U=t.meta.rtcOffset?.[2]??0,F,I,B=0,G=0,q=0,O=null,N,z,W=new ti,k=new ze(72,1,.1,20);k.up.set(0,0,1);let K=new On(10,56,28);K.rotateX(Math.PI/2);let lt=new Ke({side:De}),ht=new _e(K,lt);W.add(ht);let at=()=>{if(!(o.hidden||!I)){F.setSize(u.clientWidth,u.clientHeight,!1),k.aspect=u.clientWidth/Math.max(1,u.clientHeight),k.updateProjectionMatrix(),k.lookAt(iM(y,G,q)),F.render(W,k),k.getWorldDirection(y);for(let ut of x){if(C){ut.button.hidden=!0;continue}A.copy(ut.position).sub(N.position).normalize(),S.copy(A).project(k);let Lt=A.dot(y)>0&&Math.abs(S.x)<.92&&Math.abs(S.y)<.88;ut.button.hidden=!Lt,Lt&&(ut.button.style.left=`${(1+S.x)*50}%`,ut.button.style.top=`${(1-S.y)*50}%`)}s({position:N.position,yaw:G})}},Y=(ut,Lt)=>{G+=ut,q=ae.clamp(q+Lt,-1.55,1.55),at()};new ResizeObserver(at).observe(u),u.addEventListener("pointerdown",ut=>{ut.button!==0||O||(u.setPointerCapture(ut.pointerId),O={id:ut.pointerId,x:ut.clientX,y:ut.clientY,moved:!1})}),u.addEventListener("pointermove",ut=>{O?.id===ut.pointerId&&(C&&!O.moved&&Math.hypot(ut.clientX-O.x,ut.clientY-O.y)<5||(O.moved=!0,Y(...nM(ut.clientX-O.x,ut.clientY-O.y)),O.x=ut.clientX,O.y=ut.clientY))}),u.addEventListener("pointerup",ut=>{if(O?.id!==ut.pointerId||O.moved||!C)return;let Lt=u.getBoundingClientRect();jt((ut.clientX-Lt.left)*2/Lt.width-1,1-(ut.clientY-Lt.top)*2/Lt.height)}),u.addEventListener("lostpointercapture",ut=>{O?.id===ut.pointerId&&(O=null)}),u.addEventListener("keydown",ut=>{if(C&&ut.key==="Enter"){ut.preventDefault(),jt(0,0);return}let Lt={ArrowLeft:[.12,0],ArrowRight:[-.12,0],ArrowUp:[0,.12],ArrowDown:[0,-.12]}[ut.key];Lt&&(ut.preventDefault(),ut.stopPropagation(),Y(...Lt))}),u.addEventListener("wheel",ut=>{ut.preventDefault(),k.fov=ae.clamp(k.fov+Math.sign(ut.deltaY)*5,32,95),at()},{passive:!1}),o.addEventListener("keydown",ut=>{ut.key==="Escape"&&(C?ot():dt()),ut.stopPropagation()});function dt(){o.hidden=!0,ot(),B++,O=null,It(),s(null),z?.focus()}function It(){I?.dispose(),I=void 0,lt.map=null;for(let ut of x)ut.button.hidden=!0;x=[]}function ot(){C=!1,D=void 0,o.classList.remove("is-picking"),m.hidden=!0,at()}function Tt(){C=!0,D=void 0,o.classList.add("is-picking"),p.textContent=$("scanMap.pickLower"),m.hidden=!1,at(),I&&u.focus()}function jt(ut,Lt){if(!I)return;let Ot=sM(k,N.position,T,ut,Lt,u.clientWidth,u.clientHeight);if(Ot===void 0){p.textContent=$(D===void 0?"scanMap.noLowerHit":"scanMap.noUpperHit");return}let zt=Ot+U;D===void 0?(D=zt,p.textContent=$("scanMap.pickUpper").replace("{z}",Rl(zt))):zt<=D?p.textContent=$("scanMap.upperAboveLower").replace("{z}",Rl(D)):(r({min:D,max:zt}),ot())}function Bt(ut,Lt){let Ot=++B,zt=o.hidden;zt&&(z=document.activeElement),It(),N=b[ut],o.hidden=!1,l.textContent=N.name,u.style.visibility="hidden",f.textContent=$("scanMap.loading");let Zt=()=>{Ot===B&&(f.textContent=$("scanMap.photoError"))},Ee;try{F??(F=new Ei({canvas:u,antialias:!0})),F.setPixelRatio(Math.min(devicePixelRatio,2)),Ee=URL.createObjectURL(new Blob([t.readView(N.photo.image)],{type:"image/jpeg"}))}catch{Zt();return}new cr().load(Ee,ie=>{if(URL.revokeObjectURL(Ee),Ot!==B||ie.image.width!==2*ie.image.height){ie.dispose(),Zt();return}if(I?.dispose(),I=ie,I.colorSpace=Te,lt.map=I,lt.needsUpdate=!0,ht.rotation.z=ae.degToRad(N.photo.yaw),T=e.root.children.filter((re,R)=>E[R]===N.photo.element),x=b.filter(re=>{if(re===N)return!1;let R=A.copy(re.position).sub(N.position).length();return R<=.25?!1:(v.set(N.position,A.multiplyScalar(1/R)),v.far=R-.25,!v.intersectObjects(T,!1).length)}),zt||!Lt){let re=x.reduce((R,wt)=>!R||wt.position.distanceToSquared(N.position){URL.revokeObjectURL(Ee),Zt()})}return{open:Bt,pickLevel:Tt,isClosed:()=>o.hidden}}var ks=7;function Dp(i){if(!i?.length)return null;let t=i.map(({position:l})=>new L(...l)),e=new ar({color:"#72bfff",depthTest:!1,depthWrite:!1}),n=new gi(new On(1,12,8),e,i.length);n.count=0,n.frustumCulled=!1,n.renderOrder=10,n.instanceMatrix.setUsage(Tr);let s=[],r=new Yt,o=new L,a=new Xt;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<-ks||g>c.width+ks||_<-ks||_>c.height+ks)continue;let m=l.isOrthographicCamera?(l.top-l.bottom)/l.zoom:l.getViewSize(f,a).y,p=ks*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.depthh.visibleBox(),_=new xl(h,g(),i.meta.sections);d.syncVisibility(h),d.setClipping(_.clipping().planes);let m=t.getContextAttributes()?.stencil===!0,p,b=new Ml(_,Xn);n.add(b.group);let E=document.getElementById("ioviewer-ui"),v=new Sl(E),y=new Tl(E,i.meta.grids??[]);n.add(v.group,y.group);function S(){try{return new Or(i,{...Gh,maxTextureSize:e.capabilities.maxTextureSize})}catch(ot){if(!(ot instanceof Br))throw ot;c=!0,qr($("tooLarge").replace("{count}",ot.count).replace("{limit}",ot.limit));let Tt=Bt=>({o:0,n:0,t:Bt}),jt={count:0,geometry:Tt("u32"),material:Tt("u32"),element:Tt("i32"),matrix:Tt("f32")};return new Or({...i,meta:{...i.meta,instances:jt}})}}let A=!1;Xn.addEventListener("webglcontextlost",()=>{A=!0,qr($("contextLost"))});let x,T=new Promise(ot=>x=ot),C=Xr,D=!1;function U(){D||A||(D=!0,u.requested(performance.now()),requestAnimationFrame(()=>{if(D=!1,A)return;let ot=Xn.getBoundingClientRect();z.camera.updateMatrixWorld(),dt&&f?.update(z.camera,ot,dt.showSphere),b.update(z.camera),v.update(z.camera,ot),y.update(z.camera,ot),u.begin(z.camera,ot.height,performance.now()),C?.("renderStart"),_.fill&&m?(p??(p=new bl(h,_,i)),p.render(e,n,z.camera)):e.render(n,z.camera),C&&(C("renderEnd"),C=void 0),u.end(performance.now()),It.update(),x()}))}h.root.addEventListener("change",U),_.addEventListener("change",()=>{d.setClipping(_.clipping().planes),U()}),b.addEventListener("change",U),v.addEventListener("change",U),v.addEventListener("previewchange",U),y.addEventListener("change",U);let F=new hl(e,h,a,{pickFloat:Gh.pickFloat}),I=new El(F,_,i),B=0,G=null;function q(){cancelAnimationFrame(B),B=0,G=null,v.setPreview(null)}function O(){B=0,G&&v.setPreview(I.target(...G))}function N(){G&&(v.setPreview(null),cancelAnimationFrame(B),B=requestAnimationFrame(()=>{B=requestAnimationFrame(O)}))}Xn.addEventListener("pointermove",ot=>{if(!v.active||ot.buttons)return q();G=[ot.clientX,ot.clientY],B||(B=requestAnimationFrame(O))});for(let ot of["pointerdown","pointerleave","pointercancel","webglcontextlost"])Xn.addEventListener(ot,q);h.root.addEventListener("change",ot=>{ot.detail.kind!=="appearance"&&N()});let z=new ol(a,Xn,{pick:(ot,Tt)=>F.pick(ot,Tt)?.point??null,visibleBox:g});z.addEventListener("change",()=>{F.camera=z.camera,N(),U()}),h.root.addEventListener("change",ot=>{ot.detail.kind==="visibility"&&(d.syncVisibility(h),z.invalidateBounds(),z.resize())});let W=new pl;W.addEventListener("change",()=>h.setHighlighted([...W.values()]));let k=ap({root:E,data:i,scene:h,controls:z,picker:F,selection:W,measure:v});gp({root:E,...k,sections:_,selection:W,canFill:m});let{meta:K}=i,lt=Rp({...k,files:K.linkedFiles??[],elements:K.elements,scene:h});Mp({...k,controls:z,scene:h,sections:_,selection:W,restoreLinkedModels:lt,views:K.viewpoints??[],bcfTopics:K.bcfTopics??[]});let ht=Sp({...k,tests:K.clashTests??[],elements:K.elements,scene:h,controls:z,selection:W});n.add(ht.group);let at=Ap({root:E,...k,timeliner:K.timeliner,elements:K.elements,scene:h}),Y=ot=>{e.setClearColor(r.set(ot),1);let{r:Tt,g:jt,b:Bt}=r,Lt=.2126*Tt+.7152*jt+.0722*Bt>Math.sqrt(.0525)-.05?"#000":"#fff";E.style.setProperty("--viewport-text",ot===s?"":Lt),U()};for(let ot of yp({root:E,toolbar:k.toolbar,scene:h,meta:K,grids:y,initialBackground:s,setBackground:Y}))k.onEscape(ot.close);k.toolbar.setHandler("distance",()=>{q(),v.setActive(!v.active),v.active||I.release(),k.toolbar.setActive("distance",v.active)}),k.toolbar.setActive("distance",!1),k.onEscape(()=>(q(),v.clear()));let tt=()=>{z.setExtraBounds("grids",y.visible?y.box:null),z.setExtraBounds("measure",v.box)};y.addEventListener("change",tt),v.addEventListener("change",tt),tt(),z.addEventListener("click",ot=>{let{x:Tt,y:jt,ctrl:Bt,shift:ut}=ot.detail;if(v.active){let Zt=I.target(Tt,jt);Zt&&v.add(Zt.point);return}let Lt=!Bt&&!ut?f?.pick(Tt,jt):void 0;if(Lt!==void 0){dt.open(Lt);return}let zt=F.pick(Tt,jt)?.element??-1;Bt?zt>=0&&W.toggle(zt):zt>=0?W.set([zt]):ut||W.clear()}),z.addEventListener("boxselect",ot=>{if(v.active)return;let{rect:Tt,mode:jt,ctrl:Bt,shift:ut}=ot.detail;if(Tt.width<4||Tt.height<4){!Bt&&!ut&&W.clear();return}let Lt=new le,Ot=qf(Tt,jt,Yf(h,z.camera,Xn.getBoundingClientRect())),zt=_.clipping(),Zt=Ot.filter(Ee=>!_.isCut(h.elementBox(Ee,Lt),zt));W.set(Bt?[...W.values(),...Zt]:Zt)}),window.addEventListener("resize",()=>{e.setSize(window.innerWidth,window.innerHeight,!1),z.resize()}),e.setSize(window.innerWidth,window.innerHeight,!1),z.resize(),z.fitBox(g(),!1);let dt=Lp(E,i,d,h,z,U),It=new cl(document.getElementById("ioviewer-ui"),a,z);window.addEventListener("pointerdown",ot=>{(ot.target===Xn||It.element.contains(ot.target))&&document.activeElement?.blur()},!0),window.__ioviewer={scene:h,points:d,motionDetail:u,controls:z,picker:F,selection:W,ui:k,viewCube:It,sections:_,sectionGizmo:b,measure:v,measureSnap:I,grids:y,clashes:ht,timeliner:at,ready:T,get camera(){return z.camera}}}})(); +}`,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(` +`),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(` +`),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}}}})(); /*! Bundled license information: three/build/three.core.js: diff --git a/src/IOViewer/Viewer/playwright.config.js b/src/IOViewer/Viewer/playwright.config.js index 9311911..447a2c7 100644 --- a/src/IOViewer/Viewer/playwright.config.js +++ b/src/IOViewer/Viewer/playwright.config.js @@ -17,7 +17,7 @@ export default defineConfig({ name: 'firefox', testMatch: ['**/smoke.spec.js', '**/selection.spec.js', '**/sections.spec.js', '**/accessibility.spec.js', '**/tree-selection.spec.js', '**/tree-filters.spec.js', '**/federation.spec.js', '**/bcf.spec.js', - '**/measure-snap.spec.js'], + '**/measure-snap.spec.js', '**/point-tools.spec.js'], use: { browserName: 'firefox', // Under Linux, Xvfb supplies the display Firefox uses to create a WebGL context in CI. diff --git a/src/IOViewer/Viewer/src/data.js b/src/IOViewer/Viewer/src/data.js index 297b52b..cd38f28 100644 --- a/src/IOViewer/Viewer/src/data.js +++ b/src/IOViewer/Viewer/src/data.js @@ -110,7 +110,8 @@ function validateMeta(meta) { || (g.normals != null && !['f32', 'i16'].includes(g.normals.t)) || (g.uvs != null && g.uvs.t !== 'f32') || (g.kind != null && g.kind !== 'points') - || (g.colors != null && (g.kind !== 'points' || g.colors.t !== 'u8' || g.colors.n !== g.positions.n))) { + || (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.'); } } @@ -127,9 +128,12 @@ function validateMeta(meta) { 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) || - p.image?.t !== 'u8' || !Number.isSafeInteger(p.image.n) || p.image.n < 4 || p.image.n > 16 * 1024 * 1024))) { + !panoramaImage(p.image) || (p.intensity != null && !panoramaImage(p.intensity))))) { throw new ModelDataError('Invalid META panorama.'); } + function panoramaImage(view) { + return view?.t === 'u8' && Number.isSafeInteger(view.n) && view.n >= 4 && view.n <= 16 * 1024 * 1024; + } validateReviewMeta(meta); for (const material of meta.materials) { const index = material.texture; diff --git a/src/IOViewer/Viewer/src/engine/modelScene.js b/src/IOViewer/Viewer/src/engine/modelScene.js index b728b45..d9ee324 100644 --- a/src/IOViewer/Viewer/src/engine/modelScene.js +++ b/src/IOViewer/Viewer/src/engine/modelScene.js @@ -324,6 +324,13 @@ export class ModelScene { return target.setRGB(r / 255, g / 255, b / 255, THREE.SRGBColorSpace); } + instanceColorOverride(i, target) { + const rgb = this._colorOverride(i); + if (!rgb) return false; + target.setRGB(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, THREE.SRGBColorSpace); + return true; + } + // Element of a slot, -1 for an instance without one. slotElement(slot) { return this._elementOf[this._slotInstance[slot]]; @@ -1167,13 +1174,19 @@ export class ModelScene { } } - // sRGB bytes instance i is drawn with: highlight, else tint, else white in white mode, else the material's. + _colorOverride(i) { + return this._highlight[i] ? HIGHLIGHT : this._tint.get(i) ?? (this._mode === 'white' ? WHITE : null); + } + + // sRGB bytes for the instance colour. Point batches may also have per-vertex colours. _colorOf(i) { + const override = this._colorOverride(i); + if (override) return override; if (i >= this._bucketOf.length) { const material = this._pointMaterials[i - this._bucketOf.length]; return this._meta.materials[material].color.map((c) => Math.round(c * 255)); } - return this._highlight[i] ? HIGHLIGHT : this._tint.get(i) ?? (this._mode === 'white' ? WHITE : this._buckets[this._bucketOf[i]].bytes); + return this._buckets[this._bucketOf[i]].bytes; } _applyColor(i) { diff --git a/src/IOViewer/Viewer/src/engine/picking.js b/src/IOViewer/Viewer/src/engine/picking.js index 321d254..9b993a4 100644 --- a/src/IOViewer/Viewer/src/engine/picking.js +++ b/src/IOViewer/Viewer/src/engine/picking.js @@ -6,21 +6,35 @@ import { SLOT_DECODE, SLOT_PARS } from './slotShader.js'; // (0 = nothing). vSlot carries the slot in two exact halves (a non-flat varying, constant over a triangle). const VERTEX = /* glsl */ ` #include +#ifdef IO_PICK_POINTS +uniform uint pointIndex; +uniform float pointSize; +flat varying uint vPoint; +flat varying uint vVertex; +#else ${SLOT_PARS} +varying vec2 vSlot; +#endif #include #include varying vec3 vPos; -varying vec2 vSlot; -#ifdef IO_PICK_DEPTH +#if defined( IO_PICK_DEPTH ) && !defined( IO_PICK_POINTS ) varying float vViewDepth; #endif void main() { + #ifdef IO_PICK_POINTS + vec3 transformed = position; + gl_PointSize = pointSize; + vPoint = pointIndex; + vVertex = uint( gl_VertexID ); + #else ${SLOT_DECODE} vec3 transformed = slotPosition; + #endif #include #include #include - #ifdef IO_PICK_DEPTH + #if defined( IO_PICK_DEPTH ) && !defined( IO_PICK_POINTS ) vViewDepth = -mvPosition.z; #endif vec4 wp = vec4( transformed, 1.0 ); @@ -28,38 +42,60 @@ void main() { wp = instanceMatrix * wp; #endif vPos = ( modelMatrix * wp ).xyz; + #ifdef IO_PICK_POINTS + if ( pointSize <= 0.0 ) 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 }`; -// IO_PICK_RGBA8: slot + 1 as 4 bytes; IO_PICK_DEPTH: the bits of the view-space depth, both little-endian. +// 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. const FRAGMENT = /* glsl */ ` #include #include #include varying vec3 vPos; +#ifdef IO_PICK_POINTS +flat varying uint vPoint; +flat varying uint vVertex; +#else varying vec2 vSlot; #ifdef IO_PICK_DEPTH varying float vViewDepth; #endif +#endif void main() { #include #include - float id = floor( vSlot.x + 0.5 ) * 4096.0 + floor( vSlot.y + 0.5 ) + 1.0; + #ifdef IO_PICK_POINTS + uint id = 0x80000000u | vPoint; + float sampleId = -float( vPoint + 1u ); + #else + float sampleId = floor( vSlot.x + 0.5 ) * 4096.0 + floor( vSlot.y + 0.5 ) + 1.0; + uint id = uint( sampleId ); + #endif #if defined( IO_PICK_DEPTH ) + #ifdef IO_PICK_POINTS + uint bits = vVertex; + #else uint bits = floatBitsToUint( vViewDepth ); - uvec4 bytes = ( uvec4( bits ) >> uvec4( 0u, 8u, 16u, 24u ) ) & 255u; - gl_FragColor = vec4( bytes ) / 255.0; + #endif #elif defined( IO_PICK_RGBA8 ) - gl_FragColor = vec4( mod( id, 256.0 ), mod( floor( id / 256.0 ), 256.0 ), mod( floor( id / 65536.0 ), 256.0 ), floor( id / 16777216.0 ) ) / 255.0; + uint bits = id; #else - gl_FragColor = vec4( vPos, id ); + gl_FragColor = vec4( vPos, sampleId ); + #endif + #if defined( IO_PICK_DEPTH ) || defined( IO_PICK_RGBA8 ) + uvec4 bytes = ( uvec4( bits ) >> uvec4( 0u, 8u, 16u, 24u ) ) & 255u; + gl_FragColor = vec4( bytes ) / 255.0; #endif }`; const copy = (hit) => hit && { element: hit.element, point: hit.point.clone() }; -function pickMaterial(uniforms, define) { +function pickMaterial(uniforms, define, points = false) { const material = new THREE.ShaderMaterial({ vertexShader: VERTEX, fragmentShader: FRAGMENT, @@ -68,20 +104,21 @@ function pickMaterial(uniforms, define) { side: THREE.DoubleSide, clipping: true, }); - material.index0AttributeName = 'q'; + if (points) material.defines.IO_PICK_POINTS = ''; + else material.index0AttributeName = 'q'; return material; } /** - * GPU picking over ModelScene: the shown, unclipped model is drawn once into a 1x1 target through a view offset at the - * cursor, so the cost does not grow with the element count. With float targets (EXT_color_buffer_float) one pass gives - * the slot and the exact surface point; without them (or options.pickFloat === false) two RGBA8 passes give the slot - * and the depth, from which the point is unprojected. `camera` is public: set it when the active camera changes. + * GPU picking draws shown, unclipped triangles and points into a small target, with shared depth for both. + * Float targets return a hit's position and ID. RGBA8 uses a second pass to recover depth or the cloud vertex index. + * `camera` is public: set it when the active camera changes. */ export class Picker { constructor(renderer, modelScene, camera, options = {}) { this.renderer = renderer; this.scene = modelScene; + this.points = options.points?.count ? options.points : 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; @@ -95,16 +132,24 @@ export class Picker { if (e.detail.kind !== 'appearance') this._last = this._lastTile = null; }); const uniforms = modelScene.slotUniforms; + const pointUniforms = { pointIndex: { value: 0 }, pointSize: { value: 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; if (this._float) { this._material = pickMaterial(uniforms, null); - this._target = new THREE.WebGLRenderTarget(1, 1, { type: THREE.FloatType }); - this._pixel = new Float32Array(4); + 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); } else { this._material = pickMaterial(uniforms, 'IO_PICK_RGBA8'); this._depthMaterial = pickMaterial(uniforms, 'IO_PICK_DEPTH'); - this._target = new THREE.WebGLRenderTarget(1, 1); - this._pixel = new Uint8Array(4); + 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); + } } } @@ -163,31 +208,46 @@ export class Picker { const row = Math.floor(py) - top; return col >= 0 && col < side && row >= 0 && row < side ? (side - 1 - row) * side + col : -1; }; - const encoded = this._float ? null : new DataView(ids.buffer); - const slotAtIndex = (i) => (this._float ? Math.round(ids[i * 4 + 3]) : encoded.getUint32(i * 4, true)) - 1; - const slot = slotAtIndex(index(x, y)); + const slotIds = this._float ? ids : new Uint32Array(ids.buffer); + const slotAtIndex = (i) => this._slotAt(slotIds, i); + 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; + for (let j = 0; j < side * side; j++) { + if (!this._isPoint(slotAtIndex(j))) continue; + const distance = (j % side - radius) ** 2 + (Math.floor(j / side) - radius) ** 2; + if (distance > nearest) continue; + nearest = distance; + sample = j; + } + } let tile = null; - if (slot >= 0) { + const sampleSlot = slotAtIndex(sample); + if (sampleSlot >= 0) { if (depths) this._render(this._depthMaterial, left, top, rect, target, depths); const encodedDepth = depths && new DataView(depths.buffer); const m = camera.matrixWorldInverse.elements.slice(); + const scratch = new THREE.Vector3(); const depth = (i) => { - if (encodedDepth) return encodedDepth.getFloat32(i * 4, true); - const start = i * 4; - return -(m[2] * ids[start] + m[6] * ids[start + 1] + m[10] * ids[start + 2] + m[14]); + const point = this._vertexAt(slotAtIndex(i), ids, encodedDepth, i, scratch); + return point ? -(m[2] * point.x + m[6] * point.y + m[10] * point.z + m[14]) + : encodedDepth.getFloat32(i * 4, true); }; - const i = index(x, y); - const point = this._float ? new THREE.Vector3().fromArray(ids, i * 4) : this._depthPoint(x, y, rect, depth(i)); - const slots = new Set([slot]); - const element = this.scene.slotElement(slot); - if (element >= 0) { + const point = this._vertexAt(sampleSlot, ids, encodedDepth, sample) ?? this._depthPoint(x, y, rect, depth(sample)); + const pointSample = this._isPoint(sampleSlot); + const element = this._elementAt(sampleSlot); + const slots = new Set([sampleSlot]); + if (!pointSample && element >= 0) { for (let j = 0; j < side * side; j++) { const nearby = slotAtIndex(j); - if (nearby >= 0 && !slots.has(nearby) && this.scene.slotElement(nearby) === element) slots.add(nearby); + if (nearby >= 0 && !this._isPoint(nearby) && !slots.has(nearby) && this.scene.slotElement(nearby) === element) slots.add(nearby); } } const perspective = camera.isPerspectiveCamera; - tile = { rect, point, element, slots, depthAt(px, py, candidateSlot) { + tile = { rect, point, element, slots, pointSample, depthAt(px, py, candidateSlot) { const j = index(px, py); const front = j < 0 ? -1 : slotAtIndex(j); if (front < 0) return Infinity; @@ -209,18 +269,43 @@ export class Picker { } }; } this._lastTile = { camera, key: key.slice(), radius, tile }; - this._last = { camera, key: this._lastTile.key, hit: tile }; + this._last = { camera, key: this._lastTile.key, hit: slot >= 0 ? tile : null }; return tile; } _pick(x, y, rect) { - const pixel = this._render(this._material, x, y, rect); - const slot = (this._float ? Math.round(pixel[3]) : new Uint32Array(pixel.buffer)[0]) - 1; + const radius = (this._target.width - 1) / 2; + const center = (this._target.width ** 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); if (slot < 0) return null; - const element = this.scene.slotElement(slot); - if (this._float) return { element, point: new THREE.Vector3(pixel[0], pixel[1], pixel[2]) }; - const bytes = this._render(this._depthMaterial, x, y, rect); - return { element, point: this._depthPoint(x, y, rect, new DataView(bytes.buffer).getFloat32(0, true)) }; + 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)); + 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; + return id - 1; + } + + _isPoint(slot) { + return slot >= this.scene.slotCount; + } + + _elementAt(slot) { + return this._isPoint(slot) ? this.scene.instance(this.scene.instanceCount - this.points.count + slot - this.scene.slotCount).element + : this.scene.slotElement(slot); + } + + _vertexAt(slot, ids, depths, i, target = new THREE.Vector3()) { + if (this._float) return target.fromArray(ids, i * 4); + if (!this._isPoint(slot)) return null; + return this.points.position(slot - this.scene.slotCount, depths.getUint32(i * 4, true), target); } _depthPoint(x, y, rect, depth) { @@ -236,7 +321,8 @@ export class Picker { // Draws the model with `material` into the requested tile at pixel (x, y) and reads it back. _render(material, x, y, rect, target = this._target, pixels = this._pixel) { const { renderer, camera } = this; - const previous = { target: renderer.getRenderTarget(), color: renderer.getClearColor(new THREE.Color()), alpha: renderer.getClearAlpha() }; + const previous = { target: renderer.getRenderTarget(), color: renderer.getClearColor(new THREE.Color()), + alpha: renderer.getClearAlpha(), autoClear: renderer.autoClear }; const source = this.scene._buckets[0]?.material; // setClipping gives every bucket the same planes material.clippingPlanes = source?.clippingPlanes ?? null; material.clipIntersection = source?.clipIntersection ?? false; @@ -246,10 +332,16 @@ export class Picker { renderer.setRenderTarget(target); renderer.setClearColor(0x000000, 0); this.scene.withMaterial(material, () => renderer.render(this.scene.root, camera), { pickCamera: camera }); + if (this.points) { + renderer.autoClear = false; // keep the triangles' depth for the point pass + const pointMaterial = material === this._depthMaterial ? this._pointDepthMaterial : this._pointMaterial; + this.points.withPickMaterial(pointMaterial, () => renderer.render(this.points.root, camera)); + } renderer.readRenderTargetPixels(target, 0, 0, target.width, target.height, pixels); } finally { renderer.setRenderTarget(previous.target); renderer.setClearColor(previous.color, previous.alpha); + renderer.autoClear = previous.autoClear; camera.clearViewOffset(); } return pixels; diff --git a/src/IOViewer/Viewer/src/engine/pointScene.js b/src/IOViewer/Viewer/src/engine/pointScene.js index e33ec3f..3c79a57 100644 --- a/src/IOViewer/Viewer/src/engine/pointScene.js +++ b/src/IOViewer/Viewer/src/engine/pointScene.js @@ -4,13 +4,11 @@ import { geometryPositions } from './quantize.js'; // Point-sprite clouds (META `points`, export format 4), drawn beside the merged triangle chunks of ModelScene. // Each point instance is one THREE.Points over its geometry's positions, placed by the instance matrix (RTC). Colour is -// per-vertex when the geometry carries a `colors` view, else the instance material colour. Points participate in -// visibility (synced from ModelScene), section clipping and the shared bounds; they are not picked, measured or -// detail-cut in this version. +// per-vertex when the geometry carries a `colors` view, else the instance material colour. export class PointScene { constructor(data) { this.root = new THREE.Group(); - this._objects = []; + this._materials = []; const points = data.meta.points; this.count = points?.count ?? 0; if (!this.count) return; @@ -25,6 +23,12 @@ export class PointScene { const positions = geometryPositions(data, g); const geometry = new THREE.BufferGeometry(); geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3)); + if (g.intensities) { + const values = data.view(g.intensities); + if (values.length * 3 !== positions.length) + throw new ModelDataError(`Point geometry ${geometryOf[i]} intensities do not match its positions.`); + geometry.setAttribute('intensity', new THREE.BufferAttribute(values.slice(), 1, true)); + } const material = data.meta.materials[materialOf[i]]; let vertexColors = false; @@ -45,39 +49,75 @@ export class PointScene { size: 2, sizeAttenuation: false, vertexColors, - color: vertexColors ? 0xffffff : new THREE.Color(...(material?.color ?? [0.8, 0.8, 0.8])), + color: vertexColors ? 0xffffff + : new THREE.Color().setRGB(...(material?.color ?? [0.8, 0.8, 0.8]), THREE.SRGBColorSpace), }); const object = new THREE.Points(geometry, pointsMaterial); + object.onBeforeRender = (_renderer, _world, _camera, _geometry, drawMaterial) => { + if (drawMaterial === pointsMaterial) return; + drawMaterial.uniforms.pointIndex.value = i; + drawMaterial.uniforms.pointSize.value = pointsMaterial.opacity > 0 ? pointsMaterial.size : 0; + drawMaterial.uniformsNeedUpdate = true; + }; object.matrixAutoUpdate = false; object.matrix.fromArray(columnMajor(matrices, i)); object.matrixWorldNeedsUpdate = true; object.frustumCulled = true; geometry.computeBoundingSphere(); this.root.add(object); - this._objects.push(object); + this._materials.push({ material: pointsMaterial, color: pointsMaterial.color.clone(), opacity: material?.opacity ?? 1, vertexColors }); } } // ModelScene appends point instances after meshes in its visibility state. syncVisibility(scene) { const first = scene.instanceCount - this.count; - for (let i = 0; i < this._objects.length; i++) { - this._objects[i].visible = scene.isInstanceVisible(first + i); + for (const [i, object] of this.root.children.entries()) { + object.visible = scene.isInstanceVisible(first + i); } } - setClipping(planes) { - for (const object of this._objects) { - object.material.clippingPlanes = planes.length > 0 ? planes : null; + syncAppearance(scene) { + const first = scene.instanceCount - this.count; + for (const [i, source] of this._materials.entries()) { + const { material } = source; + const override = scene.instanceColorOverride(first + i, material.color); + if (!override) material.color.copy(source.color); + const vertexColors = source.vertexColors && !override; + const opacity = scene.opacity * source.opacity; + const transparent = opacity < 1; + if (material.vertexColors !== vertexColors || material.transparent !== transparent) material.needsUpdate = true; + material.vertexColors = vertexColors; + material.opacity = opacity; + material.transparent = transparent; + material.depthWrite = !transparent; } } - setOpacity(opacity) { - for (const object of this._objects) { - object.material.opacity = opacity; - object.material.transparent = opacity < 1; + setClipping(planes, intersection = false) { + this.clippingPlanes = planes.length > 0 ? planes : null; + this.clipIntersection = intersection; + for (const { material } of this._materials) { + material.clippingPlanes = this.clippingPlanes; + material.clipIntersection = intersection; } } + + withPickMaterial(material, draw) { + material.clippingPlanes = this.clippingPlanes; + material.clipIntersection = this.clipIntersection; + for (const object of this.root.children) object.material = material; + try { + draw(); + } finally { + for (const [i, object] of this.root.children.entries()) object.material = this._materials[i].material; + } + } + + position(instance, vertex, target) { + const object = this.root.children[instance]; + return target.fromBufferAttribute(object.geometry.attributes.position, vertex).applyMatrix4(object.matrixWorld); + } } // The writer stores the three axes then the translation (12 floats); three wants a column-major mat4. diff --git a/src/IOViewer/Viewer/src/i18n.js b/src/IOViewer/Viewer/src/i18n.js index 03238c5..c5a4404 100644 --- a/src/IOViewer/Viewer/src/i18n.js +++ b/src/IOViewer/Viewer/src/i18n.js @@ -14,6 +14,7 @@ const dictionaries = { 'scanMap.choosePhoto': 'Открыть фотопанораму…', 'scanMap.spheres': 'Сферы панорам в 3D', 'scanMap.photo': 'Фотопанорама', + 'scanMap.intensity': 'Интенсивность', 'scanMap.goToStation': 'Перейти к станции {name}', 'scanMap.photoControls': 'Фотопанорама. Стрелки поворачивают камеру, колесо меняет масштаб.', 'scanMap.loading': 'Загрузка фотографии…', @@ -135,6 +136,7 @@ const dictionaries = { 'sections.boxYaw': 'Поворот вокруг Z', 'sections.fill': 'Заливка срезов', 'sections.fillUnavailable': 'Заливка недоступна без буфера трафарета WebGL', + 'sections.fillNeedsMeshes': 'Для заливки сечений нужна замкнутая полигональная геометрия', 'sections.maxPlanes': 'Не больше 6 плоскостей', 'unit.m': 'м', 'display.materials': 'Материалы', @@ -177,6 +179,7 @@ const dictionaries = { 'scanMap.choosePhoto': 'Open photo panorama…', '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…', @@ -298,6 +301,7 @@ const dictionaries = { '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', diff --git a/src/IOViewer/Viewer/src/main.js b/src/IOViewer/Viewer/src/main.js index 2603e97..eebcc3b 100644 --- a/src/IOViewer/Viewer/src/main.js +++ b/src/IOViewer/Viewer/src/main.js @@ -96,8 +96,14 @@ function start(data, context) { // Sections never change which elements are shown, so they leave the bounds (orbit pivot, near/far) as they are. const sections = new Sections(scene, visibleBox(), data.meta.sections); points.syncVisibility(scene); - points.setClipping(sections.clipping().planes); - const canFillSections = context.getContextAttributes()?.stencil === true; + points.syncAppearance(scene); + const syncPointClipping = () => { + const { planes, intersection } = sections.clipping(); + points.setClipping(planes, intersection); + }; + syncPointClipping(); + const hasMeshes = scene.slotCount > 0; + const canFillSections = hasMeshes && context.getContextAttributes()?.stencil === true; let sectionCaps; const sectionGizmo = new SectionGizmo(sections, canvas); world.add(sectionGizmo.group); // outside scene.root: the picking id pass renders only the model @@ -162,7 +168,7 @@ function start(data, context) { } scene.root.addEventListener('change', requestRender); sections.addEventListener('change', () => { - points.setClipping(sections.clipping().planes); + syncPointClipping(); requestRender(); }); sectionGizmo.addEventListener('change', requestRender); @@ -170,7 +176,7 @@ function start(data, context) { measure.addEventListener('previewchange', requestRender); grids.addEventListener('change', requestRender); - const picker = new Picker(renderer, scene, camera, { pickFloat: testOptions.pickFloat }); + const picker = new Picker(renderer, scene, camera, { points, pickFloat: testOptions.pickFloat }); const measureSnap = new MeasureSnap(picker, sections, data); let measureFrame = 0, measureHover = null; function clearMeasurePreview() { @@ -212,6 +218,7 @@ function start(data, context) { requestRender(); }); scene.root.addEventListener('change', (e) => { + if (e.detail.kind === 'appearance') points.syncAppearance(scene); if (e.detail.kind !== 'visibility') return; // a highlight must not walk every instance for the bounds points.syncVisibility(scene); controls.invalidateBounds(); @@ -221,7 +228,7 @@ function start(data, context) { const selection = new Selection(); selection.addEventListener('change', () => scene.setHighlighted([...selection.values()])); const ui = mountUI({ root: uiRoot, data, scene, controls, picker, selection, measure }); - mountSections({ root: uiRoot, ...ui, sections, selection, canFill: canFillSections }); + mountSections({ root: uiRoot, ...ui, sections, selection, canFill: canFillSections, hasMeshes }); const { meta } = data; const restoreLinkedModels = mountLinks({ ...ui, files: meta.linkedFiles ?? [], elements: meta.elements, scene }); mountViews({ ...ui, controls, scene, sections, selection, restoreLinkedModels, @@ -238,7 +245,8 @@ function start(data, context) { uiRoot.style.setProperty('--viewport-text', color === initialBackground ? '' : text); requestRender(); }; - for (const popover of mountDisplay({ root: uiRoot, toolbar: ui.toolbar, scene, meta, grids, initialBackground, setBackground })) ui.onEscape(popover.close); + for (const popover of mountDisplay({ root: uiRoot, toolbar: ui.toolbar, scene, meta, grids, initialBackground, setBackground, hasMeshes })) + ui.onEscape(popover.close); ui.toolbar.setHandler('distance', () => { clearMeasurePreview(); measure.setActive(!measure.active); diff --git a/src/IOViewer/Viewer/src/tools/display.js b/src/IOViewer/Viewer/src/tools/display.js index d0281a1..9d46985 100644 --- a/src/IOViewer/Viewer/src/tools/display.js +++ b/src/IOViewer/Viewer/src/tools/display.js @@ -13,7 +13,7 @@ export function initialDisplayMode(options) { * the grid axes and their labels (off when there are none), `opacity` opens a * 10–100 % slider for the whole model. Returns the popovers, for Esc. */ -export function mountDisplay({ root, toolbar, scene, meta, grids, initialBackground, setBackground }) { +export function mountDisplay({ root, toolbar, scene, meta, grids, initialBackground, setBackground, hasMeshes = true }) { const anchor = (id) => toolbar.element.querySelector(`[data-tool="${id}"]`); const displayButton = anchor('displayMode'); @@ -29,7 +29,7 @@ export function mountDisplay({ root, toolbar, scene, meta, grids, initialBackgro item.type = 'button'; item.dataset.mode = mode; item.setAttribute('role', 'menuitemradio'); - item.disabled = mode === 'textures' && !hasTextures; + item.disabled = (mode === 'textures' && !hasTextures) || (mode === 'wireframe' && !hasMeshes); item.addEventListener('click', () => { setMode(mode); modes.close(); @@ -42,7 +42,8 @@ export function mountDisplay({ root, toolbar, scene, meta, grids, initialBackgro scene.setDisplayMode(mode); for (const item of items) item.setAttribute('aria-checked', String(item.dataset.mode === mode)); }; - setMode(initialDisplayMode(meta.options)); + const initial = initialDisplayMode(meta.options); + setMode(initial === 'wireframe' && !hasMeshes ? 'materials' : initial); toolbar.setHandler('displayMode', () => { modes.toggle(); if (modes.isOpen) menu.querySelector('[aria-checked="true"]')?.focus(); diff --git a/src/IOViewer/Viewer/src/tools/measureSnap.js b/src/IOViewer/Viewer/src/tools/measureSnap.js index cda7c1b..5225772 100644 --- a/src/IOViewer/Viewer/src/tools/measureSnap.js +++ b/src/IOViewer/Viewer/src/tools/measureSnap.js @@ -124,6 +124,7 @@ export class MeasureSnap { target(clientX, clientY) { const tile = this.picker.measureTile(clientX, clientY, SNAP_RADIUS + 1); if (!tile) return null; + if (tile.pointSample) return { kind: 'vertex', point: tile.point.clone() }; const { rect } = tile; const x = clientX - rect.left, y = clientY - rect.top; const { camera, scene } = this.picker; diff --git a/src/IOViewer/Viewer/src/ui/panoramaPoints.js b/src/IOViewer/Viewer/src/ui/panoramaPoints.js new file mode 100644 index 0000000..dda0583 --- /dev/null +++ b/src/IOViewer/Viewer/src/ui/panoramaPoints.js @@ -0,0 +1,110 @@ +import * as THREE from 'three'; + +export function createPanoramaPoints() { + const scene = new THREE.Scene(); + const camera = new THREE.PerspectiveCamera(72, 1, .15, 20); + camera.up.set(0, 0, 1); + const target = new THREE.Vector3(); + const material = new THREE.ShaderMaterial({ + 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('\n'), + 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('\n'), + }); + const buffer = new THREE.WebGLRenderTarget(1, 1, { depthTexture: new THREE.DepthTexture(1, 1) }); + const bufferSize = new THREE.Vector2(); + const screen = new THREE.Scene(); + const screenCamera = new THREE.Camera(); + const composite = new THREE.ShaderMaterial({ + depthTest: false, + depthWrite: false, + uniforms: { + levels: { value: buffer.texture }, + depth: { value: buffer.depthTexture }, + sampleStep: { value: new THREE.Vector2() }, + range: { value: new THREE.Vector2() }, + }, + vertexShader: [ + 'varying vec2 uvScreen;', + 'void main() { uvScreen = uv; gl_Position = vec4(position, 1.0); }', + ].join('\n'), + 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('\n'), + }); + const quad = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), composite); + quad.frustumCulled = false; + screen.add(quad); + return { + setScan(scan, position) { + scene.clear(); + for (const source of scan) { + if (!source.geometry.getAttribute('intensity')) continue; + const points = new THREE.Points(source.geometry, material); + points.matrixAutoUpdate = false; + points.matrix.copy(source.matrixWorld); + scene.add(points); + } + camera.position.copy(position); + const bounds = new THREE.Box3().setFromObject(scene); + const extent = bounds.getSize(target).length(); + camera.far = Math.max(20, extent + position.distanceTo(bounds.getCenter(target))); + }, + draw(renderer, view, direction) { + camera.aspect = view.aspect; + camera.fov = view.fov; + camera.updateProjectionMatrix(); + camera.lookAt(target.copy(camera.position).add(direction)); + const pixelRatio = renderer.getPixelRatio(); + material.uniforms.size.value = 5.5 * pixelRatio; + renderer.getDrawingBufferSize(bufferSize); + buffer.setSize(bufferSize.x, bufferSize.y); + // Filter only nearby returns on the same surface, keeping doorways and depth breaks intact. + composite.uniforms.sampleStep.value.set(2 * pixelRatio / bufferSize.x, 2 * pixelRatio / bufferSize.y); + composite.uniforms.range.value.set(camera.near, camera.far); + renderer.setRenderTarget(buffer); + renderer.render(scene, camera); + renderer.setRenderTarget(null); + renderer.render(screen, screenCamera); + }, + }; +} diff --git a/src/IOViewer/Viewer/src/ui/scanLevels.js b/src/IOViewer/Viewer/src/ui/scanLevels.js index 0132ab7..3d3f9c3 100644 --- a/src/IOViewer/Viewer/src/ui/scanLevels.js +++ b/src/IOViewer/Viewer/src/ui/scanLevels.js @@ -2,14 +2,22 @@ const heightGap = 2; export function detectScanLevels(stations, min, max) { const sorted = stations.filter(Number.isFinite).sort((a, b) => a - b); - const groups = []; + const candidates = []; for (const z of sorted) { - const group = groups.at(-1); - if (!group || z - group.at(-1) > heightGap) groups.push([z]); + const group = candidates.at(-1); + if (!group || z - group.at(-1) > heightGap / 2) candidates.push([z]); else group.push(z); } - // A lone station or a connected ramp does not provide evidence for a distinct storey. - if (groups.length < 2 || groups.some((g) => g.length < 2 || g.at(-1) - g[0] > heightGap)) return []; + // Ignore isolated stations on stairs, and join bands whose typical heights are still too close. + const groups = []; + for (const group of candidates) { + if (group.length < 2) continue; + const previous = groups.at(-1); + if (previous && group[Math.floor(group.length / 2)] - previous[Math.floor(previous.length / 2)] < heightGap) + previous.push(...group); + else groups.push(group); + } + if (groups.length < 2) return []; const boundaries = [Math.min(min, sorted[0])]; for (let i = 1; i < groups.length; i++) { boundaries.push((groups[i - 1].at(-1) + groups[i][0]) / 2); diff --git a/src/IOViewer/Viewer/src/ui/scanMap.js b/src/IOViewer/Viewer/src/ui/scanMap.js index d246391..e68899a 100644 --- a/src/IOViewer/Viewer/src/ui/scanMap.js +++ b/src/IOViewer/Viewer/src/ui/scanMap.js @@ -1,6 +1,7 @@ import * as THREE from 'three'; import { lang, t } from '../i18n.js'; import { detectScanLevels, levelContains, mapZoom } from './scanLevels.js'; +import { createPanoramaPoints } from './panoramaPoints.js'; const elevationFormat = new Intl.NumberFormat(lang, { maximumFractionDigits: 2, minimumFractionDigits: 2 }); const elevation = (z) => `${elevationFormat.format(z)} ${t('scanMap.metres')}`; @@ -339,7 +340,14 @@ function photoPanel(root, data, points, show, onPose, onLevel) { close.type = 'button'; close.textContent = t('close'); close.addEventListener('click', hide); - actions.append(resize, close); + let prefersIntensity = false; + const intensity = mapButton(t('scanMap.intensity'), t('scanMap.intensity'), () => { + prefersIntensity = !prefersIntensity; + loadPhoto(false); + }); + intensity.className = 'scan-photo-intensity'; + intensity.hidden = true; + actions.append(intensity, resize, close); header.append(title, actions); const canvas = document.createElement('canvas'); canvas.tabIndex = 0; @@ -386,7 +394,8 @@ function photoPanel(root, data, points, show, onPose, onLevel) { let picking = false, lower; const offsetZ = data.meta.rtcOffset?.[2] ?? 0; - let renderer, texture, revision = 0; + let renderer, texture, pointView, revision = 0; + let hasPointIntensity = false, showPointIntensity = false; let yaw = 0, pitch = 0, drag = null; let active, returnFocus; const world = new THREE.Scene(); @@ -398,12 +407,13 @@ function photoPanel(root, data, points, show, onPose, onLevel) { const sphere = new THREE.Mesh(geometry, material); world.add(sphere); const draw = () => { - if (panel.hidden || !texture) return; + if (panel.hidden || (!texture && !showPointIntensity)) return; renderer.setSize(canvas.clientWidth, canvas.clientHeight, false); camera.aspect = canvas.clientWidth / Math.max(1, canvas.clientHeight); camera.updateProjectionMatrix(); camera.lookAt(photoDirection(forward, yaw, pitch)); - renderer.render(world, camera); + if (showPointIntensity) pointView.draw(renderer, camera, forward); + else renderer.render(world, camera); camera.getWorldDirection(forward); for (const station of neighbours) { if (picking) { station.button.hidden = true; continue; } @@ -480,6 +490,7 @@ function photoPanel(root, data, points, show, onPose, onLevel) { returnFocus?.focus(); } function clearPhoto() { + showPointIntensity = false; texture?.dispose(); texture = undefined; material.map = null; @@ -500,10 +511,10 @@ function photoPanel(root, data, points, show, onPose, onLevel) { instructions.textContent = t('scanMap.pickLower'); editBar.hidden = false; draw(); - if (texture) canvas.focus(); + if (texture || showPointIntensity) canvas.focus(); } function pickAt(x, y) { - if (!texture) return; + if (!texture && !showPointIntensity) return; const hit = pickPhotoElevation(camera, active.position, activeScan, x, y, canvas.clientWidth, canvas.clientHeight); if (hit === undefined) { instructions.textContent = t(lower === undefined ? 'scanMap.noLowerHit' : 'scanMap.noUpperHit'); @@ -521,13 +532,45 @@ function photoPanel(root, data, points, show, onPose, onLevel) { } } function open(index, keepDirection) { - const load = ++revision; const opening = panel.hidden; if (opening) returnFocus = document.activeElement; clearPhoto(); active = stations[index]; panel.hidden = false; title.textContent = active.name; + sphere.rotation.z = THREE.MathUtils.degToRad(active.photo.yaw); + activeScan = points.root.children.filter((_, i) => scanElements[i] === active.photo.element); + hasPointIntensity = activeScan.some(object => object.geometry.getAttribute('intensity')); + intensity.hidden = !hasPointIntensity && !active.photo.intensity; + neighbours = stations.filter((station) => { + if (station === active) return false; + const distance = heading.copy(station.position).sub(active.position).length(); + if (distance <= .25) return false; + ray.set(active.position, heading.multiplyScalar(1 / distance)); + ray.far = distance - .25; + return !ray.intersectObjects(activeScan, false).length; + }); + if (opening || !keepDirection) { + const nearest = neighbours.reduce((best, station) => !best + || station.position.distanceToSquared(active.position) < best.position.distanceToSquared(active.position) + ? station : best, null); + if (nearest) { + heading.copy(nearest.position).sub(active.position); + yaw = Math.atan2(heading.y, heading.x); + pitch = THREE.MathUtils.clamp(Math.atan2(heading.z, Math.hypot(heading.x, heading.y)), -1.55, 1.55); + } else { + yaw = sphere.rotation.z; + pitch = 0; + } + camera.fov = 72; + } + loadPhoto(true); + } + function loadPhoto(focusCanvas) { + const load = ++revision; + const useIntensity = prefersIntensity && (hasPointIntensity || Boolean(active.photo.intensity)); + showPointIntensity = false; + intensity.setAttribute('aria-pressed', String(useIntensity)); canvas.style.visibility = 'hidden'; status.textContent = t('scanMap.loading'); const error = () => { if (load === revision) status.textContent = t('scanMap.photoError'); }; @@ -535,7 +578,18 @@ function photoPanel(root, data, points, show, onPose, onLevel) { try { renderer ??= new THREE.WebGLRenderer({ canvas, antialias: true }); renderer.setPixelRatio(Math.min(devicePixelRatio, 2)); - url = URL.createObjectURL(new Blob([data.readView(active.photo.image)], { type: 'image/jpeg' })); + if (useIntensity && hasPointIntensity) { + pointView ??= createPanoramaPoints(); + pointView.setScan(activeScan, active.position); + showPointIntensity = true; + status.textContent = ''; + canvas.style.visibility = 'visible'; + draw(); + if (focusCanvas) canvas.focus(); + return; + } + const image = useIntensity ? active.photo.intensity : active.photo.image; + url = URL.createObjectURL(new Blob([data.readView(image)], { type: 'image/jpeg' })); } catch { error(); return; @@ -552,34 +606,10 @@ function photoPanel(root, data, points, show, onPose, onLevel) { texture.colorSpace = THREE.SRGBColorSpace; material.map = texture; material.needsUpdate = true; - sphere.rotation.z = THREE.MathUtils.degToRad(active.photo.yaw); - activeScan = points.root.children.filter((_, i) => scanElements[i] === active.photo.element); - neighbours = stations.filter((station) => { - if (station === active) return false; - const distance = heading.copy(station.position).sub(active.position).length(); - if (distance <= .25) return false; - ray.set(active.position, heading.multiplyScalar(1 / distance)); - ray.far = distance - .25; - return !ray.intersectObjects(activeScan, false).length; - }); - if (opening || !keepDirection) { - const nearest = neighbours.reduce((best, station) => !best - || station.position.distanceToSquared(active.position) < best.position.distanceToSquared(active.position) - ? station : best, null); - if (nearest) { - heading.copy(nearest.position).sub(active.position); - yaw = Math.atan2(heading.y, heading.x); - pitch = THREE.MathUtils.clamp(Math.atan2(heading.z, Math.hypot(heading.x, heading.y)), -1.55, 1.55); - } else { - yaw = sphere.rotation.z; - pitch = 0; - } - camera.fov = 72; - } status.textContent = ''; canvas.style.visibility = 'visible'; draw(); - canvas.focus(); + if (focusCanvas) canvas.focus(); }, undefined, () => { URL.revokeObjectURL(url); error(); diff --git a/src/IOViewer/Viewer/src/ui/sectionsPanel.js b/src/IOViewer/Viewer/src/ui/sectionsPanel.js index ce07ab0..b9f442a 100644 --- a/src/IOViewer/Viewer/src/ui/sectionsPanel.js +++ b/src/IOViewer/Viewer/src/ui/sectionsPanel.js @@ -68,7 +68,7 @@ function planeRow(sections, i) { * The «Сечения» panel and the section tools: toolbar `plane` / `box` / `resetSections`, context menu * «Бокс сечения по объекту» / «Сбросить сечения». Tools and panel stay off for a model with no geometry. */ -export function mountSections({ root, shell, toolbar, contextMenu, sections, selection, canFill }) { +export function mountSections({ root, shell, toolbar, contextMenu, sections, selection, canFill, hasMeshes = true }) { let axis = 'z'; // axis for new planes, chosen in the panel const addPlane = () => { if (sections.addPlane(axis) !== null) return; @@ -108,7 +108,7 @@ export function mountSections({ root, shell, toolbar, contextMenu, sections, sel boxBlock.append(boxMode.element, yaw, fit); const gizmo = checkbox(t('sections.showGizmo'), (on) => sections.setGizmoVisible(on)); const fill = checkbox(t('sections.fill'), (on) => sections.setFill(on)); - if (!canFill) fill.element.title = t('sections.fillUnavailable'); + if (!canFill) fill.element.title = t(hasMeshes ? 'sections.fillUnavailable' : 'sections.fillNeedsMeshes'); let rows = []; const update = () => { diff --git a/src/IOViewer/Viewer/styles/viewer.css b/src/IOViewer/Viewer/styles/viewer.css index 166bf34..35731d4 100644 --- a/src/IOViewer/Viewer/styles/viewer.css +++ b/src/IOViewer/Viewer/styles/viewer.css @@ -214,7 +214,7 @@ input:focus-visible { cursor: pointer; } -.scan-map-controls button[aria-pressed='true'] { +.scan-map-controls button[aria-pressed='true'], .scan-photo-intensity[aria-pressed='true'] { color: #72bfff; } diff --git a/src/IOViewer/Viewer/test/e2e/global-setup.js b/src/IOViewer/Viewer/test/e2e/global-setup.js index 57d04b6..40f88ff 100644 --- a/src/IOViewer/Viewer/test/e2e/global-setup.js +++ b/src/IOViewer/Viewer/test/e2e/global-setup.js @@ -91,6 +91,32 @@ export default function globalSetup() { exportHtml(snapPath, 'measure-snap'); const results = path.join(viewerDir, 'test-results'); + const cloud = { + Kind: 'ioviewer', Format: 2, + Scene: { + Kind: 'ioscene', Format: 1, Title: 'Point tools', + Models: [{ Id: 1, Key: 'fixture', Name: 'Fixture' }], + Elements: ['Scan', 'Second scan'].map((Name, i) => ({ Id: i + 1, Name, ModelId: 1 })), + Geometries: [ + { Id: 1, Topology: 2, Vertices: [-2, 0, 0, 0, 0, 0, 2, 0, 0], Indices: [] }, + { Id: 2, Topology: 2, Vertices: [0, 0, -1], Indices: [] }, + ], + Instances: [1, 2].map((id) => ({ ElementId: id, GeometryId: id })), + }, + PointColors: { 1: Buffer.from([0, 180, 0, 0, 180, 0, 0, 180, 0]).toString('base64') }, + }; + const cloudPath = path.join(results, 'point-tools.json'); + writeFileSync(cloudPath, JSON.stringify(cloud)); + exportHtml(cloudPath, 'point-tools'); + cloud.Scene.Elements.push({ Id: 3, Name: 'Occluder', ModelId: 1 }); + cloud.Scene.Geometries.push({ + Id: 3, Topology: 0, Vertices: [-0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0, 0.5, 0.5], Indices: [0, 1, 2], + }); + cloud.Scene.Instances.push({ ElementId: 3, GeometryId: 3 }); + const mixedPath = path.join(results, 'mixed-point-tools.json'); + writeFileSync(mixedPath, JSON.stringify(cloud)); + exportHtml(mixedPath, 'mixed-point-tools'); + const sources = ['Architecture', 'Services'].map((name) => { const doc = largeModel(2); doc.Title = name; diff --git a/src/IOViewer/Viewer/test/e2e/point-tools.spec.js b/src/IOViewer/Viewer/test/e2e/point-tools.spec.js new file mode 100644 index 0000000..652c2a5 --- /dev/null +++ b/src/IOViewer/Viewer/test/e2e/point-tools.spec.js @@ -0,0 +1,111 @@ +import { test, expect } from '@playwright/test'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { viewerDir } from './global-setup.js'; + +const tool = (page, id) => page.locator(`[data-tool="${id}"]`); +const pick = (page, at) => page.evaluate(([x, y]) => window.__ioviewer.picker.pick(x, y)?.element ?? null, at); + +async function open(page, name, fallback = false) { + const errors = []; + page.on('pageerror', (error) => errors.push(error.message)); + page.on('console', (message) => { if (message.type() === 'error') errors.push(message.text()); }); + if (fallback) await page.addInitScript(() => { window.IOVIEWER_TEST = { pickFloat: false }; }); + await page.goto(pathToFileURL(path.join(viewerDir, 'test-results', `${name}.html`)).href); + await page.evaluate(() => window.__ioviewer.ready); + const pixels = await page.evaluate(() => { + const { controls, points } = window.__ioviewer; + controls.setProjection('orthographic'); + const center = points.position(0, 1, controls.target.clone()); + controls.restoreViewCamera({ + position: [center.x, center.y, center.z + 8], target: center.toArray(), up: [0, 1, 0], + }); + const { camera } = controls; + camera.updateMatrixWorld(); + const canvas = document.getElementById('ioviewer-canvas').getBoundingClientRect(); + return [0, 1, 2].map((i) => { + const p = points.position(0, i, center.clone()).project(camera); + return [canvas.left + (p.x + 1) * canvas.width / 2, canvas.top + (1 - p.y) * canvas.height / 2]; + }); + }); + return { pixels, errors }; +} + +test('cloud selection, context actions and display settings use the same scan', async ({ page }) => { + const { pixels: [left, middle], errors } = await open(page, 'point-tools'); + const firstMaterial = () => page.evaluate(() => { + const { color, vertexColors, opacity } = window.__ioviewer.points.root.children[0].material; + return { color: color.getHexString(), vertexColors, opacity }; + }); + expect(await pick(page, middle)).toBe(0); + await page.mouse.click(...left); + expect(await page.evaluate(() => [...window.__ioviewer.selection.values()])).toEqual([0]); + expect(await firstMaterial()).toEqual({ color: 'f59e0b', vertexColors: false, opacity: 1 }); + await page.mouse.click(...left, { button: 'right' }); + await page.getByRole('menuitem', { name: /^Скрыть(?: |$)/ }).click(); + expect(await pick(page, middle)).toBe(1); + await page.keyboard.press('Shift+h'); + expect(await pick(page, middle)).toBe(0); + await page.keyboard.press('Escape'); + + await tool(page, 'displayMode').click(); + await expect(page.getByRole('menuitemradio', { name: 'Каркас' })).toBeDisabled(); + await page.getByRole('menuitemradio', { name: 'Белый' }).click(); + expect(await firstMaterial()).toEqual({ color: 'ebebed', vertexColors: false, opacity: 1 }); + await tool(page, 'displayMode').click(); + await page.getByRole('menuitemradio', { name: 'Материалы' }).click(); + await tool(page, 'opacity').click(); + await page.getByRole('slider', { name: 'Непрозрачность' }).fill('45'); + expect(await firstMaterial()).toEqual({ color: 'ffffff', vertexColors: true, opacity: 0.45 }); + + await page.keyboard.press('Escape'); + await tool(page, 'box').click(); + await expect(page.getByRole('checkbox', { name: 'Заливка срезов' })).toBeDisabled(); + expect(errors).toEqual([]); +}); + +for (const fallback of [false, true]) { + test(`mixed point measurement and clipping (${fallback ? 'RGBA8' : 'default'})`, async ({ page }) => { + const { pixels: [left, middle, right], errors } = await open(page, 'mixed-point-tools', fallback); + expect(await pick(page, middle)).toBe(2); + const near = [left[0] + 5, left[1]]; + expect(await pick(page, near)).toBeNull(); + await tool(page, 'distance').click(); + const canvas = page.locator('#ioviewer-canvas'); + await canvas.dispatchEvent('pointermove', { clientX: near[0], clientY: near[1], pointerType: 'mouse' }); + await expect(page.locator('.ioviewer-measure-preview')).toHaveAttribute('data-kind', 'vertex'); + expect(await pick(page, near)).toBeNull(); // the nearby snap must not change ordinary picking + await page.mouse.click(...near); + await page.mouse.click(...right); + const { distance, exact } = await page.evaluate(() => { + const { measure, points } = window.__ioviewer; + return { + distance: measure.distance, + exact: measure.points.every((point, i) => point.distanceTo(points.position(0, 2 * i, point.clone())) < 1e-5), + }; + }); + expect(distance).toBeCloseTo(4, 5); + expect(exact).toBe(true); + await tool(page, 'distance').click(); + + await page.evaluate(() => { + const { scene, sections } = window.__ioviewer; + const box = scene.elementBox(0); + box.min.x -= 0.25; + box.max.x = box.min.x + 1; + box.min.y -= 0.5; + box.max.y += 0.5; + box.min.z -= 0.5; + box.max.z += 0.25; + sections.setGizmoVisible(false); + sections.setBox(box, 0.2); + }); + expect(await pick(page, left)).toBe(0); + expect(await pick(page, middle)).toBeNull(); + await page.evaluate(() => window.__ioviewer.sections.setBoxMode('cutInside')); + expect(await pick(page, left)).toBeNull(); + expect(await pick(page, middle)).toBe(2); + expect(await pick(page, right)).toBe(0); + expect(errors).toEqual([]); + }); +} diff --git a/src/IOViewer/Viewer/test/unit/pointScene.test.js b/src/IOViewer/Viewer/test/unit/pointScene.test.js index dd84526..c8cef50 100644 --- a/src/IOViewer/Viewer/test/unit/pointScene.test.js +++ b/src/IOViewer/Viewer/test/unit/pointScene.test.js @@ -117,3 +117,18 @@ test('RGB and station image views accept bytes and reject a bad length or elemen rgb.n = 5; assert.throws(() => parseModelMeta(JSON.stringify(meta)), ModelDataError); }); + +test('point intensity bytes follow the positions independently of the RGB material', () => { + const { data, meta } = fixture(); + const values = new Uint8Array([0, 143]); + const descriptor = { t: 'u8', o: 0, n: values.length }; + meta.geometries[0].intensities = descriptor; + const view = data.view; + data.view = (v) => v === descriptor ? values : view(v); + parseModelMeta(JSON.stringify(meta)); + const attribute = new PointScene(data).root.children[0].geometry.getAttribute('intensity'); + assert.equal(attribute.getX(0), 0); + assert.equal(attribute.getX(1), 143 / 255); + descriptor.n = 3; + assert.throws(() => parseModelMeta(JSON.stringify(meta)), ModelDataError); +}); diff --git a/src/IOViewer/Viewer/test/unit/scanMap.test.js b/src/IOViewer/Viewer/test/unit/scanMap.test.js index b98aeaa..139466a 100644 --- a/src/IOViewer/Viewer/test/unit/scanMap.test.js +++ b/src/IOViewer/Viewer/test/unit/scanMap.test.js @@ -85,6 +85,13 @@ test('flat scans, a continuous ramp and a lone high station do not produce autom assert.deepEqual(detectScanLevels(z, -1, 6), []); }); +test('an isolated stair stop does not join two supported levels with uneven station heights', () => { + const levels = detectScanLevels([-1.9, -1.2, -.5, .2, 1, 2.4, 3.5, 3.8, 4.3], -3, 8); + assert.deepEqual(levels, [{ min: -3, max: 2.25 }, { min: 2.25, max: 8 }]); + assert.equal(levelContains(levels[0], 1), true); + assert.equal(levelContains(levels[1], 3.5), true); +}); + test('map wheel zoom keeps the world position under the cursor fixed', () => { const view = { x: 10, y: 30, side: 40, zoom: 1 }; const x = .2, y = -.3; diff --git a/tests/IOViewer.Tests/PointPayloadTests.cs b/tests/IOViewer.Tests/PointPayloadTests.cs index 9de7dc3..e083aa2 100644 --- a/tests/IOViewer.Tests/PointPayloadTests.cs +++ b/tests/IOViewer.Tests/PointPayloadTests.cs @@ -46,22 +46,37 @@ public void Point_Rgb_And_Panorama_Roundtrip_And_Use_The_Viewer_Binary_Block() { byte[] colors = [255, 0, 0, 0, 128, 0, 0, 0, 255]; byte[] image = [0xff, 0xd8, 0xff, 0xd9]; + byte[] intensityImage = [0xff, 0xd8, 0x6c, 0xff, 0xd9]; var source = new ViewerDocument(Cloud()) { PointColors = new() { [1] = colors }, - Panoramas = [new ViewerPanorama(1, new Vector3d(0.5, 0.5, 1), image) { Name = "Camera 3" }], + PointIntensities = new() { [1] = [85, 0, 210] }, + Panoramas = [new ViewerPanorama(1, new Vector3d(0.5, 0.5, 1), image) + { Name = "Camera 3", IntensityJpeg = intensityImage }], }; using var json = new MemoryStream(Encoding.UTF8.GetBytes(JsonViewerExporter.ExportToString(source))); var view = ViewerHtml.Export(JsonViewerImporter.Load(json)); var rgb = view.Geometries[0].GetProperty("colors"); Assert.Equal(colors, view.Bin.AsSpan(rgb.GetProperty("o").GetInt32(), rgb.GetProperty("n").GetInt32()).ToArray()); + var signals = view.Geometries[0].GetProperty("intensities"); + Assert.Equal(new byte[] { 85, 0, 210 }, + view.Bin.AsSpan(signals.GetProperty("o").GetInt32(), signals.GetProperty("n").GetInt32()).ToArray()); var panorama = view.Meta.GetProperty("panoramas")[0]; Assert.Equal(0, panorama.GetProperty("element").GetInt32()); Assert.Equal("Camera 3", panorama.GetProperty("name").GetString()); Assert.Equal([0.0, 0.0, 1.0], panorama.GetProperty("position").EnumerateArray().Select(x => x.GetDouble())); var jpeg = panorama.GetProperty("image"); Assert.Equal(image, view.Bin.AsSpan(jpeg.GetProperty("o").GetInt32(), jpeg.GetProperty("n").GetInt32()).ToArray()); + var intensity = panorama.GetProperty("intensity"); + Assert.Equal(intensityImage, view.Bin.AsSpan(intensity.GetProperty("o").GetInt32(), intensity.GetProperty("n").GetInt32()).ToArray()); + } + + [Fact] + public void Point_Intensity_Length_Must_Match_Vertex_Count() + { + var doc = new ViewerDocument(Cloud()) { PointIntensities = new() { [1] = [24, 125] } }; + Assert.Throws(() => ViewerHtml.Export(doc)); } [Fact] @@ -104,6 +119,33 @@ void WriteFace(int size, SKColor color) } } + [Fact] + public void Leica_Jpeg_Xr_Cube_Skips_Face_Trailers_And_Rejects_A_Truncated_Face() + { + using var cube = new MemoryStream(); + using var writer = new BinaryWriter(cube); + writer.Write("CUBE"u8); + for (byte face = 0; face < 6; face++) + { + writer.Write(new byte[] { 0x49, 0x49, 0xbc, 1 }); + writer.Write(8u); + writer.Write((ushort)2); + writer.Write((ushort)0xbcc0); + writer.Write((ushort)4); + writer.Write(1u); + writer.Write(34u); + writer.Write((ushort)0xbcc1); + writer.Write((ushort)4); + writer.Write(1u); + writer.Write(3u); + writer.Write(new byte[] { 0x18, face, 0x38 }); + if (face != 5) writer.Write(new byte[] { 1, 2, 3, 4 }); + } + byte[][] faces = ScanPhotographs.ReadCube(cube.ToArray()); + Assert.Equal(new byte[] { 0, 1, 2, 3, 4, 5 }, faces.Select(image => image[35])); + Assert.Throws(() => ScanPhotographs.ReadCube(cube.ToArray().AsSpan()[..^1])); + } + [Fact] public void Leica_Panorama_Places_Opposite_Faces_And_Orients_The_Poles() { @@ -127,16 +169,23 @@ public void Leica_Panorama_Places_Opposite_Faces_And_Orients_The_Poles() using var panorama = SKBitmap.Decode(ScanPhotographs.ProjectLeicaCube(faces, System.Numerics.Quaternion.Identity)); int equator = panorama.Height / 2; - AssertColor(colors[0], panorama.Width / 2, equator); - AssertColor(colors[1], 0, equator); - AssertColor(colors[2], panorama.Width * 3 / 4, equator); - AssertColor(colors[3], panorama.Width / 4, equator); - AssertColor(colors[4], panorama.Width / 4, panorama.Height / 8); - AssertColor(colors[5], panorama.Width / 4, panorama.Height * 7 / 8); - AssertColor(SKColors.White, panorama.Width * 3 / 4, panorama.Height / 8); - AssertColor(SKColors.White, panorama.Width * 3 / 4, panorama.Height * 7 / 8); - - void AssertColor(SKColor expected, int x, int y) + AssertColor(panorama, colors[0], panorama.Width * 3 / 4, equator); + AssertColor(panorama, colors[1], panorama.Width / 4, equator); + AssertColor(panorama, colors[2], 0, equator); + AssertColor(panorama, colors[3], panorama.Width / 2, equator); + AssertColor(panorama, colors[4], panorama.Width / 2, panorama.Height / 8); + AssertColor(panorama, colors[5], panorama.Width / 2, panorama.Height * 7 / 8); + AssertColor(panorama, SKColors.White, 0, panorama.Height / 8); + AssertColor(panorama, SKColors.White, 0, panorama.Height * 7 / 8); + + // Rotate around a different axis to check that the station pose is applied after the cube basis. + var tilt = System.Numerics.Quaternion.CreateFromAxisAngle(System.Numerics.Vector3.UnitX, MathF.PI / 2); + using var tilted = SKBitmap.Decode(ScanPhotographs.ProjectLeicaCube(faces, tilt)); + AssertColor(tilted, colors[0], tilted.Width / 2, tilted.Height / 8); + AssertColor(tilted, colors[1], tilted.Width / 2, tilted.Height * 7 / 8); + AssertColor(tilted, colors[3], tilted.Width / 2, equator); + + static void AssertColor(SKBitmap panorama, SKColor expected, int x, int y) { SKColor actual = panorama.GetPixel(x, y); Assert.InRange(Math.Abs(actual.Red - expected.Red), 0, 8);